Test Failed
Pull Request — master (#2551)
by Devin
04:51
created
includes/admin/payments/view-payment-details.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17
-if ( ! current_user_can( 'view_give_payments' ) ) {
17
+if ( ! current_user_can('view_give_payments')) {
18 18
 	wp_die(
19
-		__( 'Sorry, you are not allowed to access this page.', 'give' ), __( 'Error', 'give' ), array(
19
+		__('Sorry, you are not allowed to access this page.', 'give'), __('Error', 'give'), array(
20 20
 			'response' => 403,
21 21
 		)
22 22
 	);
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
  * @since 1.0
29 29
  * @return void
30 30
  */
31
-if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
32
-	wp_die( esc_html__( 'Donation ID not supplied. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
31
+if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
32
+	wp_die(esc_html__('Donation ID not supplied. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
33 33
 }
34 34
 
35 35
 // Setup the variables
36
-$payment_id = absint( $_GET['id'] );
37
-$payment    = new Give_Payment( $payment_id );
36
+$payment_id = absint($_GET['id']);
37
+$payment    = new Give_Payment($payment_id);
38 38
 
39 39
 // Sanity check... fail if donation ID is invalid
40 40
 $payment_exists = $payment->ID;
41
-if ( empty( $payment_exists ) ) {
42
-	wp_die( esc_html__( 'The specified ID does not belong to a donation. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
41
+if (empty($payment_exists)) {
42
+	wp_die(esc_html__('The specified ID does not belong to a donation. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
43 43
 }
44 44
 
45 45
 $number         = $payment->number;
46 46
 $payment_meta   = $payment->get_meta();
47
-$transaction_id = esc_attr( $payment->transaction_id );
47
+$transaction_id = esc_attr($payment->transaction_id);
48 48
 $user_id        = $payment->user_id;
49 49
 $donor_id       = $payment->customer_id;
50
-$payment_date   = strtotime( $payment->date );
51
-$user_info      = give_get_payment_meta_user_info( $payment_id );
50
+$payment_date   = strtotime($payment->date);
51
+$user_info      = give_get_payment_meta_user_info($payment_id);
52 52
 $address        = $payment->address;
53 53
 $currency_code  = $payment->currency;
54 54
 $gateway        = $payment->gateway;
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	<?php
62 62
 		printf(
63 63
 			/* translators: %s: donation number */
64
-			esc_html__( 'Donation %s', 'give' ),
64
+			esc_html__('Donation %s', 'give'),
65 65
 			$number
66 66
 		);
67
-		if ( $payment_mode == 'test' ) {
68
-			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '" data-tooltip-my-position="center left" data-tooltip-target-position="center right">' . esc_html__( 'Test Donation', 'give' ) . '</span>';
67
+		if ($payment_mode == 'test') {
68
+			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'" data-tooltip-my-position="center left" data-tooltip-target-position="center right">'.esc_html__('Test Donation', 'give').'</span>';
69 69
 		}
70 70
 		?>
71 71
 		</h1>
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param int $payment_id Payment id.
80 80
 	 */
81
-	do_action( 'give_view_order_details_before', $payment_id );
81
+	do_action('give_view_order_details_before', $payment_id);
82 82
 	?>
83 83
 
84 84
 	<hr class="wp-header-end">
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		 *
93 93
 		 * @param int $payment_id Payment id.
94 94
 		 */
95
-		do_action( 'give_view_order_details_form_top', $payment_id );
95
+		do_action('give_view_order_details_form_top', $payment_id);
96 96
 		?>
97 97
 		<div id="poststuff">
98 98
 			<div id="give-dashboard-widgets-wrap">
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 							 *
109 109
 							 * @param int $payment_id Payment id.
110 110
 							 */
111
-							do_action( 'give_view_order_details_sidebar_before', $payment_id );
111
+							do_action('give_view_order_details_sidebar_before', $payment_id);
112 112
 							?>
113 113
 
114 114
 							<div id="give-order-update" class="postbox give-order-data">
115 115
 
116
-								<h3 class="hndle"><?php esc_html_e( 'Update Donation', 'give' ); ?></h3>
116
+								<h3 class="hndle"><?php esc_html_e('Update Donation', 'give'); ?></h3>
117 117
 
118 118
 								<div class="inside">
119 119
 									<div class="give-admin-box">
@@ -126,33 +126,33 @@  discard block
 block discarded – undo
126 126
 										 *
127 127
 										 * @param int $payment_id Payment id.
128 128
 										 */
129
-										do_action( 'give_view_order_details_totals_before', $payment_id );
129
+										do_action('give_view_order_details_totals_before', $payment_id);
130 130
 										?>
131 131
 
132 132
 										<div class="give-admin-box-inside">
133 133
 											<p>
134
-												<label for="give-payment-status" class="strong"><?php esc_html_e( 'Status:', 'give' ); ?></label>&nbsp;
134
+												<label for="give-payment-status" class="strong"><?php esc_html_e('Status:', 'give'); ?></label>&nbsp;
135 135
 												<select id="give-payment-status" name="give-payment-status" class="medium-text">
136
-													<?php foreach ( give_get_payment_statuses() as $key => $status ) : ?>
137
-														<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php echo esc_html( $status ); ?></option>
136
+													<?php foreach (give_get_payment_statuses() as $key => $status) : ?>
137
+														<option value="<?php echo esc_attr($key); ?>"<?php selected($payment->status, $key, true); ?>><?php echo esc_html($status); ?></option>
138 138
 													<?php endforeach; ?>
139 139
 												</select>
140
-												<span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span>
140
+												<span class="give-donation-status status-<?php echo sanitize_title($payment->status); ?>"><span class="give-donation-status-icon"></span></span>
141 141
 											</p>
142 142
 										</div>
143 143
 
144 144
 										<div class="give-admin-box-inside">
145 145
 											<p>
146
-												<label for="give-payment-date" class="strong"><?php esc_html_e( 'Date:', 'give' ); ?></label>&nbsp;
147
-												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr( date( 'm/d/Y', $payment_date ) ); ?>" class="medium-text give_datepicker"/>
146
+												<label for="give-payment-date" class="strong"><?php esc_html_e('Date:', 'give'); ?></label>&nbsp;
147
+												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr(date('m/d/Y', $payment_date)); ?>" class="medium-text give_datepicker"/>
148 148
 											</p>
149 149
 										</div>
150 150
 
151 151
 										<div class="give-admin-box-inside">
152 152
 											<p>
153
-												<label for="give-payment-time-hour" class="strong"><?php esc_html_e( 'Time:', 'give' ); ?></label>&nbsp;
154
-												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
155
-												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/>
153
+												<label for="give-payment-time-hour" class="strong"><?php esc_html_e('Time:', 'give'); ?></label>&nbsp;
154
+												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr(date_i18n('H', $payment_date)); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
155
+												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr(date('i', $payment_date)); ?>" class="small-text give-payment-time-min"/>
156 156
 											</p>
157 157
 										</div>
158 158
 
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 										 *
167 167
 										 * @param int $payment_id Payment id.
168 168
 										 */
169
-										do_action( 'give_view_order_details_update_inner', $payment_id );
169
+										do_action('give_view_order_details_update_inner', $payment_id);
170 170
 										?>
171 171
 
172 172
 										<div class="give-order-payment give-admin-box-inside">
173 173
 											<p>
174
-												<label for="give-payment-total" class="strong"><?php esc_html_e( 'Total Donation:', 'give' ); ?></label>&nbsp;
175
-												<?php echo give_currency_symbol( $payment->currency ); ?>
176
-												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr( give_format_decimal( give_donation_amount( $payment_id ), false, false ) ); ?>"/>
174
+												<label for="give-payment-total" class="strong"><?php esc_html_e('Total Donation:', 'give'); ?></label>&nbsp;
175
+												<?php echo give_currency_symbol($payment->currency); ?>
176
+												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr(give_format_decimal(give_donation_amount($payment_id), false, false)); ?>"/>
177 177
 											</p>
178 178
 										</div>
179 179
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 										 *
186 186
 										 * @param int $payment_id Payment id.
187 187
 										 */
188
-										do_action( 'give_view_order_details_totals_after', $payment_id );
188
+										do_action('give_view_order_details_totals_after', $payment_id);
189 189
 										?>
190 190
 
191 191
 									</div>
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 									 *
204 204
 									 * @param int $payment_id Payment id.
205 205
 									 */
206
-									do_action( 'give_view_order_details_update_before', $payment_id );
206
+									do_action('give_view_order_details_update_before', $payment_id);
207 207
 									?>
208 208
 
209 209
 									<div id="major-publishing-actions">
210 210
 										<div id="publishing-action">
211
-											<input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Donation', 'give' ); ?>"/>
211
+											<input type="submit" class="button button-primary right" value="<?php esc_attr_e('Save Donation', 'give'); ?>"/>
212 212
 											<?php
213
-											if ( give_is_payment_complete( $payment_id ) ) {
213
+											if (give_is_payment_complete($payment_id)) {
214 214
 												echo sprintf(
215 215
 													'<a href="%1$s" id="give-resend-receipt" class="button-secondary right">%2$s</a>',
216 216
 													esc_url(
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 															)
222 222
 														)
223 223
 													),
224
-													__( 'Resend Receipt', 'give' )
224
+													__('Resend Receipt', 'give')
225 225
 												);
226 226
 											}
227 227
 											?>
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 									 *
238 238
 									 * @param int $payment_id Payment id.
239 239
 									 */
240
-									do_action( 'give_view_order_details_update_after', $payment_id );
240
+									do_action('give_view_order_details_update_after', $payment_id);
241 241
 									?>
242 242
 
243 243
 								</div>
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 							<div id="give-order-details" class="postbox give-order-data">
250 250
 
251
-								<h3 class="hndle"><?php esc_html_e( 'Donation Meta', 'give' ); ?></h3>
251
+								<h3 class="hndle"><?php esc_html_e('Donation Meta', 'give'); ?></h3>
252 252
 
253 253
 								<div class="inside">
254 254
 									<div class="give-admin-box">
@@ -261,45 +261,45 @@  discard block
 block discarded – undo
261 261
 										 *
262 262
 										 * @param int $payment_id Payment id.
263 263
 										 */
264
-										do_action( 'give_view_order_details_payment_meta_before', $payment_id );
264
+										do_action('give_view_order_details_payment_meta_before', $payment_id);
265 265
 
266
-										$gateway = give_get_payment_gateway( $payment_id );
267
-										if ( $gateway ) :
266
+										$gateway = give_get_payment_gateway($payment_id);
267
+										if ($gateway) :
268 268
 										?>
269 269
 											<div class="give-order-gateway give-admin-box-inside">
270 270
 												<p>
271
-													<strong><?php esc_html_e( 'Gateway:', 'give' ); ?></strong>&nbsp;
272
-													<?php echo give_get_gateway_admin_label( $gateway ); ?>
271
+													<strong><?php esc_html_e('Gateway:', 'give'); ?></strong>&nbsp;
272
+													<?php echo give_get_gateway_admin_label($gateway); ?>
273 273
 												</p>
274 274
 											</div>
275 275
 										<?php endif; ?>
276 276
 
277 277
 										<div class="give-order-payment-key give-admin-box-inside">
278 278
 											<p>
279
-												<strong><?php esc_html_e( 'Key:', 'give' ); ?></strong>&nbsp;
280
-												<?php echo give_get_payment_key( $payment_id ); ?>
279
+												<strong><?php esc_html_e('Key:', 'give'); ?></strong>&nbsp;
280
+												<?php echo give_get_payment_key($payment_id); ?>
281 281
 											</p>
282 282
 										</div>
283 283
 
284 284
 										<div class="give-order-ip give-admin-box-inside">
285 285
 											<p>
286
-												<strong><?php esc_html_e( 'IP:', 'give' ); ?></strong>&nbsp;
287
-												<?php echo esc_html( give_get_payment_user_ip( $payment_id ) ); ?>
286
+												<strong><?php esc_html_e('IP:', 'give'); ?></strong>&nbsp;
287
+												<?php echo esc_html(give_get_payment_user_ip($payment_id)); ?>
288 288
 											</p>
289 289
 										</div>
290 290
 
291
-										<?php if ( $transaction_id ) : ?>
291
+										<?php if ($transaction_id) : ?>
292 292
 											<div class="give-order-tx-id give-admin-box-inside">
293 293
 												<p>
294
-													<strong><?php esc_html_e( 'Donation ID:', 'give' ); ?></strong>&nbsp;
295
-													<?php echo apply_filters( "give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id ); ?>
294
+													<strong><?php esc_html_e('Donation ID:', 'give'); ?></strong>&nbsp;
295
+													<?php echo apply_filters("give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id); ?>
296 296
 												</p>
297 297
 											</div>
298 298
 										<?php endif; ?>
299 299
 
300 300
 										<div class="give-admin-box-inside">
301
-											<p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?>
302
-												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e( 'View all donations for this donor &raquo;', 'give' ); ?></a>
301
+											<p><?php $purchase_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint(give_get_payment_donor_id($payment_id))); ?>
302
+												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e('View all donations for this donor &raquo;', 'give'); ?></a>
303 303
 											</p>
304 304
 										</div>
305 305
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 										 *
312 312
 										 * @param int $payment_id Payment id.
313 313
 										 */
314
-										do_action( 'give_view_order_details_payment_meta_after', $payment_id );
314
+										do_action('give_view_order_details_payment_meta_after', $payment_id);
315 315
 										?>
316 316
 
317 317
 									</div>
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 							 *
332 332
 							 * @param int $payment_id Payment id.
333 333
 							 */
334
-							do_action( 'give_view_order_details_sidebar_after', $payment_id );
334
+							do_action('give_view_order_details_sidebar_after', $payment_id);
335 335
 							?>
336 336
 
337 337
 						</div>
@@ -351,31 +351,31 @@  discard block
 block discarded – undo
351 351
 							 *
352 352
 							 * @param int $payment_id Payment id.
353 353
 							 */
354
-							do_action( 'give_view_order_details_main_before', $payment_id );
354
+							do_action('give_view_order_details_main_before', $payment_id);
355 355
 							?>
356 356
 
357 357
 							<?php $column_count = 'columns-3'; ?>
358 358
 							<div id="give-donation-overview" class="postbox <?php echo $column_count; ?>">
359
-								<h3 class="hndle"><?php esc_html_e( 'Donation Information', 'give' ); ?></h3>
359
+								<h3 class="hndle"><?php esc_html_e('Donation Information', 'give'); ?></h3>
360 360
 
361 361
 								<div class="inside">
362 362
 
363 363
 									<div class="column-container">
364 364
 										<div class="column">
365 365
 											<p>
366
-												<strong><?php esc_html_e( 'Donation Form ID:', 'give' ); ?></strong><br>
366
+												<strong><?php esc_html_e('Donation Form ID:', 'give'); ?></strong><br>
367 367
 												<?php
368
-												if ( $payment_meta['form_id'] ) :
368
+												if ($payment_meta['form_id']) :
369 369
 													printf(
370 370
 														'<a href="%1$s">#%2$s</a>',
371
-														admin_url( 'post.php?action=edit&post=' . $payment_meta['form_id'] ),
371
+														admin_url('post.php?action=edit&post='.$payment_meta['form_id']),
372 372
 														$payment_meta['form_id']
373 373
 													);
374 374
 												endif;
375 375
 												?>
376 376
 											</p>
377 377
 											<p>
378
-												<strong><?php esc_html_e( 'Donation Form Title:', 'give' ); ?></strong><br>
378
+												<strong><?php esc_html_e('Donation Form Title:', 'give'); ?></strong><br>
379 379
 												<?php
380 380
 												echo Give()->html->forms_dropdown(
381 381
 													array(
@@ -391,21 +391,21 @@  discard block
 block discarded – undo
391 391
 										</div>
392 392
 										<div class="column">
393 393
 											<p>
394
-												<strong><?php esc_html_e( 'Donation Date:', 'give' ); ?></strong><br>
395
-												<?php echo date_i18n( give_date_format(), $payment_date ); ?>
394
+												<strong><?php esc_html_e('Donation Date:', 'give'); ?></strong><br>
395
+												<?php echo date_i18n(give_date_format(), $payment_date); ?>
396 396
 											</p>
397 397
 											<p>
398
-												<strong><?php esc_html_e( 'Donation Level:', 'give' ); ?></strong><br>
398
+												<strong><?php esc_html_e('Donation Level:', 'give'); ?></strong><br>
399 399
 												<span class="give-donation-level">
400 400
 													<?php
401
-													$var_prices = give_has_variable_prices( $payment_meta['form_id'] );
402
-													if ( empty( $var_prices ) ) {
403
-														esc_html_e( 'n/a', 'give' );
401
+													$var_prices = give_has_variable_prices($payment_meta['form_id']);
402
+													if (empty($var_prices)) {
403
+														esc_html_e('n/a', 'give');
404 404
 													} else {
405 405
 														$prices_atts = array();
406
-														if ( $variable_prices = give_get_variable_prices( $payment_meta['form_id'] ) ) {
407
-															foreach ( $variable_prices as $variable_price ) {
408
-																$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
406
+														if ($variable_prices = give_get_variable_prices($payment_meta['form_id'])) {
407
+															foreach ($variable_prices as $variable_price) {
408
+																$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
409 409
 															}
410 410
 														}
411 411
 														// Variable price dropdown options.
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 															'name'             => 'give-variable-price',
415 415
 															'chosen'           => true,
416 416
 															'show_option_all'  => '',
417
-															'show_option_none' => ( '' === get_post_meta( $payment_id, '_give_payment_price_id', true ) ? __( 'None', 'give' ) : '' ),
418
-															'select_atts'      => 'data-prices=' . esc_attr( wp_json_encode( $prices_atts ) ),
417
+															'show_option_none' => ('' === get_post_meta($payment_id, '_give_payment_price_id', true) ? __('None', 'give') : ''),
418
+															'select_atts'      => 'data-prices='.esc_attr(wp_json_encode($prices_atts)),
419 419
 															'selected'         => $payment_meta['price_id'],
420 420
 														);
421 421
 														// Render variable prices select tag html.
422
-														give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
422
+														give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
423 423
 													}
424 424
 													?>
425 425
 												</span>
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 										</div>
428 428
 										<div class="column">
429 429
 											<p>
430
-												<strong><?php esc_html_e( 'Total Donation:', 'give' ); ?></strong><br>
431
-												<?php echo give_donation_amount( $payment, true ); ?>
430
+												<strong><?php esc_html_e('Total Donation:', 'give'); ?></strong><br>
431
+												<?php echo give_donation_amount($payment, true); ?>
432 432
 											</p>
433 433
 											<p>
434 434
 												<?php
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 												 *
442 442
 												 * @param int $payment_id Payment id.
443 443
 												 */
444
-												do_action( 'give_donation_details_thead_before', $payment_id );
444
+												do_action('give_donation_details_thead_before', $payment_id);
445 445
 
446 446
 
447 447
 												/**
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 												 *
454 454
 												 * @param int $payment_id Payment id.
455 455
 												 */
456
-												do_action( 'give_donation_details_thead_after', $payment_id );
456
+												do_action('give_donation_details_thead_after', $payment_id);
457 457
 
458 458
 												/**
459 459
 												 * Fires in order details page, in the donation-information metabox, before the body elements.
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 												 *
465 465
 												 * @param int $payment_id Payment id.
466 466
 												 */
467
-												do_action( 'give_donation_details_tbody_before', $payment_id );
467
+												do_action('give_donation_details_tbody_before', $payment_id);
468 468
 
469 469
 												/**
470 470
 												 * Fires in order details page, in the donation-information metabox, after the body elements.
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 												 *
476 476
 												 * @param int $payment_id Payment id.
477 477
 												 */
478
-												do_action( 'give_donation_details_tbody_after', $payment_id );
478
+												do_action('give_donation_details_tbody_after', $payment_id);
479 479
 												?>
480 480
 											</p>
481 481
 										</div>
@@ -495,58 +495,58 @@  discard block
 block discarded – undo
495 495
 							 *
496 496
 							 * @param int $payment_id Payment id.
497 497
 							 */
498
-							do_action( 'give_view_order_details_files_after', $payment_id );
498
+							do_action('give_view_order_details_files_after', $payment_id);
499 499
 							?>
500 500
 
501 501
 							<div id="give-donor-details" class="postbox">
502
-								<h3 class="hndle"><?php esc_html_e( 'Donor Details', 'give' ); ?></h3>
502
+								<h3 class="hndle"><?php esc_html_e('Donor Details', 'give'); ?></h3>
503 503
 
504 504
 								<div class="inside">
505 505
 
506
-									<?php $donor = new Give_Donor( $donor_id ); ?>
506
+									<?php $donor = new Give_Donor($donor_id); ?>
507 507
 
508 508
 									<div class="column-container donor-info">
509 509
 										<div class="column">
510 510
 											<p>
511
-												<strong><?php esc_html_e( 'Donor ID:', 'give' ); ?></strong><br>
511
+												<strong><?php esc_html_e('Donor ID:', 'give'); ?></strong><br>
512 512
 												<?php
513
-												if ( ! empty( $donor->id ) ) {
513
+												if ( ! empty($donor->id)) {
514 514
 													printf(
515 515
 														'<a href="%1$s">#%2$s</a>',
516
-														admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ),
516
+														admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id),
517 517
 														$donor->id
518 518
 													);
519 519
 												}
520 520
 												?>
521 521
 											</p>
522 522
 											<p>
523
-												<strong><?php esc_html_e( 'Donor Since:', 'give' ); ?></strong><br>
524
-												<?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ); ?>
523
+												<strong><?php esc_html_e('Donor Since:', 'give'); ?></strong><br>
524
+												<?php echo date_i18n(give_date_format(), strtotime($donor->date_created)); ?>
525 525
 											</p>
526 526
 										</div>
527 527
 										<div class="column">
528 528
 											<p>
529
-												<strong><?php esc_html_e( 'Donor Name:', 'give' ); ?></strong><br>
529
+												<strong><?php esc_html_e('Donor Name:', 'give'); ?></strong><br>
530 530
 												<?php
531
-												$donor_billing_name = give_get_donor_name_by( $payment_id, 'donation' );
532
-												$donor_name         = give_get_donor_name_by( $donor_id, 'donor' );
531
+												$donor_billing_name = give_get_donor_name_by($payment_id, 'donation');
532
+												$donor_name         = give_get_donor_name_by($donor_id, 'donor');
533 533
 
534 534
 												// Check whether the donor name and WP_User name is same or not.
535
-												if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
536
-													echo $donor_billing_name . ' (<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>)';
535
+												if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
536
+													echo $donor_billing_name.' (<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>)';
537 537
 												} else {
538 538
 													echo $donor_name;
539 539
 												}
540 540
 												?>
541 541
 											</p>
542 542
 											<p>
543
-												<strong><?php esc_html_e( 'Donor Email:', 'give' ); ?></strong><br>
543
+												<strong><?php esc_html_e('Donor Email:', 'give'); ?></strong><br>
544 544
 												<?php echo $donor->email; ?>
545 545
 											</p>
546 546
 										</div>
547 547
 										<div class="column">
548 548
 											<p>
549
-												<strong><?php esc_html_e( 'Change Donor:', 'give' ); ?></strong><br>
549
+												<strong><?php esc_html_e('Change Donor:', 'give'); ?></strong><br>
550 550
 												<?php
551 551
 												echo Give()->html->donor_dropdown(
552 552
 													array(
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 												?>
558 558
 											</p>
559 559
 											<p>
560
-												<a href="#new" class="give-payment-new-donor"><?php esc_html_e( 'Create New Donor', 'give' ); ?></a>
560
+												<a href="#new" class="give-payment-new-donor"><?php esc_html_e('Create New Donor', 'give'); ?></a>
561 561
 											</p>
562 562
 										</div>
563 563
 									</div>
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 									<div class="column-container new-donor" style="display: none">
566 566
 										<div class="column">
567 567
 											<p>
568
-												<label for="give-new-donor-name"><?php esc_html_e( 'New Donor Name:', 'give' ); ?></label>
568
+												<label for="give-new-donor-name"><?php esc_html_e('New Donor Name:', 'give'); ?></label>
569 569
 												<input id="give-new-donor-name" type="text" name="give-new-donor-name" value="" class="medium-text"/>
570 570
 											</p>
571 571
 										</div>
572 572
 										<div class="column">
573 573
 											<p>
574
-												<label for="give-new-donor-email"><?php esc_html_e( 'New Donor Email:', 'give' ); ?></label>
574
+												<label for="give-new-donor-email"><?php esc_html_e('New Donor Email:', 'give'); ?></label>
575 575
 												<input id="give-new-donor-email" type="email" name="give-new-donor-email" value="" class="medium-text"/>
576 576
 											</p>
577 577
 										</div>
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 											<p>
580 580
 												<input type="hidden" name="give-current-donor" value="<?php echo $donor->id; ?>"/>
581 581
 												<input type="hidden" id="give-new-donor" name="give-new-donor" value="0"/>
582
-												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
582
+												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php esc_html_e('Cancel', 'give'); ?></a>
583 583
 												<br>
584
-												<em><?php esc_html_e( 'Click "Save Donation" to create new donor.', 'give' ); ?></em>
584
+												<em><?php esc_html_e('Click "Save Donation" to create new donor.', 'give'); ?></em>
585 585
 											</p>
586 586
 										</div>
587 587
 									</div>
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 									 * @param array $payment_meta Payment meta.
598 598
 									 * @param array $user_info    User information.
599 599
 									 */
600
-									do_action( 'give_payment_personal_details_list', $payment_meta, $user_info );
600
+									do_action('give_payment_personal_details_list', $payment_meta, $user_info);
601 601
 
602 602
 									/**
603 603
 									 * Fires on the donation details page, in the donor-details metabox.
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 									 *
607 607
 									 * @param int $payment_id Payment id.
608 608
 									 */
609
-									do_action( 'give_payment_view_details', $payment_id );
609
+									do_action('give_payment_view_details', $payment_id);
610 610
 									?>
611 611
 
612 612
 								</div>
@@ -622,11 +622,11 @@  discard block
 block discarded – undo
622 622
 							 *
623 623
 							 * @param int $payment_id Payment id.
624 624
 							 */
625
-							do_action( 'give_view_order_details_billing_before', $payment_id );
625
+							do_action('give_view_order_details_billing_before', $payment_id);
626 626
 							?>
627 627
 
628 628
 							<div id="give-billing-details" class="postbox">
629
-								<h3 class="hndle"><?php esc_html_e( 'Billing Address', 'give' ); ?></h3>
629
+								<h3 class="hndle"><?php esc_html_e('Billing Address', 'give'); ?></h3>
630 630
 
631 631
 								<div class="inside">
632 632
 
@@ -636,9 +636,9 @@  discard block
 block discarded – undo
636 636
 											<div class="data column-container">
637 637
 
638 638
 												<?php
639
-												$address['country'] = ( ! empty( $address['country'] ) ? $address['country'] : give_get_country() );
639
+												$address['country'] = ( ! empty($address['country']) ? $address['country'] : give_get_country());
640 640
 
641
-												$address['state'] = ( ! empty( $address['state'] ) ? $address['state'] : '' );
641
+												$address['state'] = ( ! empty($address['state']) ? $address['state'] : '');
642 642
 
643 643
 												// Get the country list that does not have any states init.
644 644
 												$no_states_country = give_no_states_country_list();
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 
647 647
 												<div class="row">
648 648
 													<div id="give-order-address-country-wrap">
649
-														<label class="order-data-address-line"><?php esc_html_e( 'Country:', 'give' ); ?></label>
649
+														<label class="order-data-address-line"><?php esc_html_e('Country:', 'give'); ?></label>
650 650
 														<?php
651 651
 														echo Give()->html->select(
652 652
 															array(
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
 																'show_option_all'  => false,
657 657
 																'show_option_none' => false,
658 658
 																'chosen'           => true,
659
-																'placeholder'      => esc_attr__( 'Select a country', 'give' ),
660
-																'data'             => array( 'search-type' => 'no_ajax' ),
659
+																'placeholder'      => esc_attr__('Select a country', 'give'),
660
+																'data'             => array('search-type' => 'no_ajax'),
661 661
 															)
662 662
 														);
663 663
 														?>
@@ -666,35 +666,35 @@  discard block
 block discarded – undo
666 666
 
667 667
 												<div class="row">
668 668
 													<div class="give-wrap-address-line1">
669
-														<label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e( 'Address 1:', 'give' ); ?></label>
670
-														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr( $address['line1'] ); ?>" class="medium-text"/>
669
+														<label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e('Address 1:', 'give'); ?></label>
670
+														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr($address['line1']); ?>" class="medium-text"/>
671 671
 													</div>
672 672
 												</div>
673 673
 
674 674
 												<div class="row">
675 675
 													<div class="give-wrap-address-line2">
676
-														<label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e( 'Address 2:', 'give' ); ?></label>
677
-														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr( $address['line2'] ); ?>" class="medium-text"/>
676
+														<label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e('Address 2:', 'give'); ?></label>
677
+														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr($address['line2']); ?>" class="medium-text"/>
678 678
 													</div>
679 679
 												</div>
680 680
 
681 681
 												<div class="row">
682 682
 													<div class="give-wrap-address-city">
683
-														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></label>
684
-														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr( $address['city'] ); ?>" class="medium-text"/>
683
+														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e('City:', 'give'); ?></label>
684
+														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr($address['city']); ?>" class="medium-text"/>
685 685
 													</div>
686 686
 												</div>
687 687
 
688 688
 												<?php
689
-												$state_exists = ( ! empty( $address['country'] ) && array_key_exists( $address['country'], $no_states_country ) ? true : false );
689
+												$state_exists = ( ! empty($address['country']) && array_key_exists($address['country'], $no_states_country) ? true : false);
690 690
 												?>
691 691
 												<div class="row">
692
-													<div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-state">
693
-														<div id="give-order-address-state-wrap" class="<?php echo( ! empty( $state_exists ) ? 'give-hidden' : '' ); ?>">
694
-															<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label>
692
+													<div class="<?php echo( ! empty($state_exists) ? 'column-full' : 'column'); ?> give-column give-column-state">
693
+														<div id="give-order-address-state-wrap" class="<?php echo( ! empty($state_exists) ? 'give-hidden' : ''); ?>">
694
+															<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e('State / Province / County:', 'give'); ?></label>
695 695
 															<?php
696
-															$states = give_get_states( $address['country'] );
697
-															if ( ! empty( $states ) ) {
696
+															$states = give_get_states($address['country']);
697
+															if ( ! empty($states)) {
698 698
 																echo Give()->html->select(
699 699
 																	array(
700 700
 																		'options'          => $states,
@@ -703,23 +703,23 @@  discard block
 block discarded – undo
703 703
 																		'show_option_all'  => false,
704 704
 																		'show_option_none' => false,
705 705
 																		'chosen'           => true,
706
-																		'placeholder'      => esc_attr__( 'Select a state', 'give' ),
707
-																		'data'             => array( 'search-type' => 'no_ajax' ),
706
+																		'placeholder'      => esc_attr__('Select a state', 'give'),
707
+																		'data'             => array('search-type' => 'no_ajax'),
708 708
 																	)
709 709
 																);
710 710
 															} else {
711 711
 																?>
712
-																<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/>
712
+																<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr($address['state']); ?>" class="medium-text"/>
713 713
 																<?php
714 714
 															}
715 715
 															?>
716 716
 														</div>
717 717
 													</div>
718 718
 
719
-													<div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-zip">
719
+													<div class="<?php echo( ! empty($state_exists) ? 'column-full' : 'column'); ?> give-column give-column-zip">
720 720
 														<div class="give-wrap-address-zip">
721
-															<label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label>
722
-															<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr( $address['zip'] ); ?>" class="medium-text"/>
721
+															<label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label>
722
+															<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr($address['zip']); ?>" class="medium-text"/>
723 723
 														</div>
724 724
 													</div>
725 725
 												</div>
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 									 *
739 739
 									 * @param int $payment_id Payment id.
740 740
 									 */
741
-									do_action( 'give_payment_billing_details', $payment_id );
741
+									do_action('give_payment_billing_details', $payment_id);
742 742
 									?>
743 743
 
744 744
 								</div>
@@ -754,33 +754,33 @@  discard block
 block discarded – undo
754 754
 							 *
755 755
 							 * @param int $payment_id Payment id.
756 756
 							 */
757
-							do_action( 'give_view_order_details_billing_after', $payment_id );
757
+							do_action('give_view_order_details_billing_after', $payment_id);
758 758
 							?>
759 759
 
760 760
 							<div id="give-payment-notes" class="postbox">
761
-								<h3 class="hndle"><?php esc_html_e( 'Donation Notes', 'give' ); ?></h3>
761
+								<h3 class="hndle"><?php esc_html_e('Donation Notes', 'give'); ?></h3>
762 762
 
763 763
 								<div class="inside">
764 764
 									<div id="give-payment-notes-inner">
765 765
 										<?php
766
-										$notes = give_get_payment_notes( $payment_id );
767
-										if ( ! empty( $notes ) ) {
766
+										$notes = give_get_payment_notes($payment_id);
767
+										if ( ! empty($notes)) {
768 768
 											$no_notes_display = ' style="display:none;"';
769
-											foreach ( $notes as $note ) :
769
+											foreach ($notes as $note) :
770 770
 
771
-												echo give_get_payment_note_html( $note, $payment_id );
771
+												echo give_get_payment_note_html($note, $payment_id);
772 772
 
773 773
 											endforeach;
774 774
 										} else {
775 775
 											$no_notes_display = '';
776 776
 										}
777
-										echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html__( 'No donation notes.', 'give' ) . '</p>';
777
+										echo '<p class="give-no-payment-notes"'.$no_notes_display.'>'.esc_html__('No donation notes.', 'give').'</p>';
778 778
 										?>
779 779
 									</div>
780 780
 									<textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea>
781 781
 
782 782
 									<div class="give-clearfix">
783
-										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php esc_html_e( 'Add Note', 'give' ); ?></button>
783
+										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint($payment_id); ?>"><?php esc_html_e('Add Note', 'give'); ?></button>
784 784
 									</div>
785 785
 
786 786
 								</div>
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 							 *
797 797
 							 * @param int $payment_id Payment id.
798 798
 							 */
799
-							do_action( 'give_view_order_details_main_after', $payment_id );
799
+							do_action('give_view_order_details_main_after', $payment_id);
800 800
 							?>
801 801
 
802 802
 						</div>
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
 		 *
819 819
 		 * @param int $payment_id Payment id.
820 820
 		 */
821
-		do_action( 'give_view_order_details_form_bottom', $payment_id );
821
+		do_action('give_view_order_details_form_bottom', $payment_id);
822 822
 
823
-		wp_nonce_field( 'give_update_payment_details_nonce' );
823
+		wp_nonce_field('give_update_payment_details_nonce');
824 824
 		?>
825
-		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr( $payment_id ); ?>"/>
825
+		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr($payment_id); ?>"/>
826 826
 		<input type="hidden" name="give_action" value="update_payment_details"/>
827 827
 	</form>
828 828
 	<?php
@@ -833,6 +833,6 @@  discard block
 block discarded – undo
833 833
 	 *
834 834
 	 * @param int $payment_id Payment id.
835 835
 	 */
836
-	do_action( 'give_view_order_details_after', $payment_id );
836
+	do_action('give_view_order_details_after', $payment_id);
837 837
 	?>
838 838
 </div><!-- /.wrap -->
Please login to merge, or discard this patch.
includes/admin/admin-actions.php 1 patch
Spacing   +191 added lines, -192 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
  * @since 1.8
21 21
  */
22 22
 function give_load_wp_editor() {
23
-	if ( ! isset( $_POST['wp_editor'] ) ) {
23
+	if ( ! isset($_POST['wp_editor'])) {
24 24
 		die();
25 25
 	}
26 26
 
27
-	$wp_editor                     = json_decode( base64_decode( $_POST['wp_editor'] ), true );
27
+	$wp_editor                     = json_decode(base64_decode($_POST['wp_editor']), true);
28 28
 	$wp_editor[2]['textarea_name'] = $_POST['textarea_name'];
29 29
 
30
-	wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] );
30
+	wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]);
31 31
 
32 32
 	die();
33 33
 }
34 34
 
35
-add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' );
35
+add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor');
36 36
 
37 37
 
38 38
 /**
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 	);
53 53
 
54 54
 	// Get current page.
55
-	$current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : '';
55
+	$current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : '';
56 56
 
57 57
 	// Bailout.
58 58
 	if (
59
-		empty( $current_page )
60
-		|| empty( $_GET['_wp_http_referer'] )
61
-		|| ! in_array( $current_page, $give_pages )
59
+		empty($current_page)
60
+		|| empty($_GET['_wp_http_referer'])
61
+		|| ! in_array($current_page, $give_pages)
62 62
 	) {
63 63
 		return false;
64 64
 	}
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @since 1.8
70 70
 	 */
71
-	$redirect = apply_filters( "give_validate_{$current_page}", true );
71
+	$redirect = apply_filters("give_validate_{$current_page}", true);
72 72
 
73
-	if ( $redirect ) {
73
+	if ($redirect) {
74 74
 		// Redirect.
75 75
 		wp_redirect(
76 76
 			remove_query_arg(
77
-				array( '_wp_http_referer', '_wpnonce' ),
78
-				wp_unslash( $_SERVER['REQUEST_URI'] )
77
+				array('_wp_http_referer', '_wpnonce'),
78
+				wp_unslash($_SERVER['REQUEST_URI'])
79 79
 			)
80 80
 		);
81 81
 		exit;
82 82
 	}
83 83
 }
84 84
 
85
-add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' );
85
+add_action('admin_init', 'give_redirect_to_clean_url_admin_pages');
86 86
 
87 87
 
88 88
 /**
@@ -96,25 +96,25 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function give_hide_outdated_php_notice() {
98 98
 
99
-	if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) {
99
+	if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) {
100 100
 		give_die();
101 101
 	}
102 102
 
103 103
 	// Transient key name.
104 104
 	$transient_key = "_give_hide_outdated_php_notices_shortly";
105 105
 
106
-	if ( Give_Cache::get( $transient_key, true ) ) {
106
+	if (Give_Cache::get($transient_key, true)) {
107 107
 		return;
108 108
 	}
109 109
 
110 110
 	// Hide notice for 24 hours.
111
-	Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true );
111
+	Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true);
112 112
 
113 113
 	give_die();
114 114
 
115 115
 }
116 116
 
117
-add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' );
117
+add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice');
118 118
 
119 119
 /**
120 120
  * Register admin notices.
@@ -123,27 +123,27 @@  discard block
 block discarded – undo
123 123
  */
124 124
 function _give_register_admin_notices() {
125 125
 	// Bailout.
126
-	if ( ! is_admin() ) {
126
+	if ( ! is_admin()) {
127 127
 		return;
128 128
 	}
129 129
 
130 130
 	// Bulk action notices.
131 131
 	if (
132
-		isset( $_GET['action'] ) &&
133
-		! empty( $_GET['action'] )
132
+		isset($_GET['action']) &&
133
+		! empty($_GET['action'])
134 134
 	) {
135 135
 
136 136
 		// Add payment bulk notice.
137 137
 		if (
138
-			current_user_can( 'edit_give_payments' ) &&
139
-			isset( $_GET['payment'] ) &&
140
-			! empty( $_GET['payment'] )
138
+			current_user_can('edit_give_payments') &&
139
+			isset($_GET['payment']) &&
140
+			! empty($_GET['payment'])
141 141
 		) {
142
-			$payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0;
142
+			$payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0;
143 143
 
144
-			switch ( $_GET['action'] ) {
144
+			switch ($_GET['action']) {
145 145
 				case 'delete':
146
-					Give()->notices->register_notice( array(
146
+					Give()->notices->register_notice(array(
147 147
 						'id'          => 'bulk_action_delete',
148 148
 						'type'        => 'updated',
149 149
 						'description' => sprintf(
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 							),
156 156
 							$payment_count ),
157 157
 						'show'        => true,
158
-					) );
158
+					));
159 159
 
160 160
 					break;
161 161
 
162 162
 				case 'resend-receipt':
163
-					Give()->notices->register_notice( array(
163
+					Give()->notices->register_notice(array(
164 164
 						'id'          => 'bulk_action_resend_receipt',
165 165
 						'type'        => 'updated',
166 166
 						'description' => sprintf(
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 							$payment_count
174 174
 						),
175 175
 						'show'        => true,
176
-					) );
176
+					));
177 177
 					break;
178 178
 
179 179
 				case 'set-status-publish' :
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				case 'set-status-cancelled' :
186 186
 				case 'set-status-abandoned' :
187 187
 				case 'set-status-preapproval' :
188
-					Give()->notices->register_notice( array(
188
+					Give()->notices->register_notice(array(
189 189
 						'id'          => 'bulk_action_status_change',
190 190
 						'type'        => 'updated',
191 191
 						'description' => _n(
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 							'give'
196 196
 						),
197 197
 						'show'        => true,
198
-					) );
198
+					));
199 199
 					break;
200 200
 			}
201 201
 
@@ -203,244 +203,244 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 
205 205
 	// Add give message notices.
206
-	if ( ! empty( $_GET['give-message'] ) ) {
206
+	if ( ! empty($_GET['give-message'])) {
207 207
 		// Donation reports errors.
208
-		if ( current_user_can( 'view_give_reports' ) ) {
209
-			switch ( $_GET['give-message'] ) {
208
+		if (current_user_can('view_give_reports')) {
209
+			switch ($_GET['give-message']) {
210 210
 				case 'donation_deleted' :
211
-					Give()->notices->register_notice( array(
211
+					Give()->notices->register_notice(array(
212 212
 						'id'          => 'give-donation-deleted',
213 213
 						'type'        => 'updated',
214
-						'description' => __( 'The donation has been deleted.', 'give' ),
214
+						'description' => __('The donation has been deleted.', 'give'),
215 215
 						'show'        => true,
216
-					) );
216
+					));
217 217
 					break;
218 218
 				case 'email_sent' :
219
-					Give()->notices->register_notice( array(
219
+					Give()->notices->register_notice(array(
220 220
 						'id'          => 'give-payment-sent',
221 221
 						'type'        => 'updated',
222
-						'description' => __( 'The donation receipt has been resent.', 'give' ),
222
+						'description' => __('The donation receipt has been resent.', 'give'),
223 223
 						'show'        => true,
224
-					) );
224
+					));
225 225
 					break;
226 226
 				case 'refreshed-reports' :
227
-					Give()->notices->register_notice( array(
227
+					Give()->notices->register_notice(array(
228 228
 						'id'          => 'give-refreshed-reports',
229 229
 						'type'        => 'updated',
230
-						'description' => __( 'The reports cache has been cleared.', 'give' ),
230
+						'description' => __('The reports cache has been cleared.', 'give'),
231 231
 						'show'        => true,
232
-					) );
232
+					));
233 233
 					break;
234 234
 				case 'donation-note-deleted' :
235
-					Give()->notices->register_notice( array(
235
+					Give()->notices->register_notice(array(
236 236
 						'id'          => 'give-donation-note-deleted',
237 237
 						'type'        => 'updated',
238
-						'description' => __( 'The donation note has been deleted.', 'give' ),
238
+						'description' => __('The donation note has been deleted.', 'give'),
239 239
 						'show'        => true,
240
-					) );
240
+					));
241 241
 					break;
242 242
 			}
243 243
 		}
244 244
 
245 245
 		// Give settings notices and errors.
246
-		if ( current_user_can( 'manage_give_settings' ) ) {
247
-			switch ( $_GET['give-message'] ) {
246
+		if (current_user_can('manage_give_settings')) {
247
+			switch ($_GET['give-message']) {
248 248
 				case 'settings-imported' :
249
-					Give()->notices->register_notice( array(
249
+					Give()->notices->register_notice(array(
250 250
 						'id'          => 'give-settings-imported',
251 251
 						'type'        => 'updated',
252
-						'description' => __( 'The settings have been imported.', 'give' ),
252
+						'description' => __('The settings have been imported.', 'give'),
253 253
 						'show'        => true,
254
-					) );
254
+					));
255 255
 					break;
256 256
 				case 'api-key-generated' :
257
-					Give()->notices->register_notice( array(
257
+					Give()->notices->register_notice(array(
258 258
 						'id'          => 'give-api-key-generated',
259 259
 						'type'        => 'updated',
260
-						'description' => __( 'API keys have been generated.', 'give' ),
260
+						'description' => __('API keys have been generated.', 'give'),
261 261
 						'show'        => true,
262
-					) );
262
+					));
263 263
 					break;
264 264
 				case 'api-key-exists' :
265
-					Give()->notices->register_notice( array(
265
+					Give()->notices->register_notice(array(
266 266
 						'id'          => 'give-api-key-exists',
267 267
 						'type'        => 'updated',
268
-						'description' => __( 'The specified user already has API keys.', 'give' ),
268
+						'description' => __('The specified user already has API keys.', 'give'),
269 269
 						'show'        => true,
270
-					) );
270
+					));
271 271
 					break;
272 272
 				case 'api-key-regenerated' :
273
-					Give()->notices->register_notice( array(
273
+					Give()->notices->register_notice(array(
274 274
 						'id'          => 'give-api-key-regenerated',
275 275
 						'type'        => 'updated',
276
-						'description' => __( 'API keys have been regenerated.', 'give' ),
276
+						'description' => __('API keys have been regenerated.', 'give'),
277 277
 						'show'        => true,
278
-					) );
278
+					));
279 279
 					break;
280 280
 				case 'api-key-revoked' :
281
-					Give()->notices->register_notice( array(
281
+					Give()->notices->register_notice(array(
282 282
 						'id'          => 'give-api-key-revoked',
283 283
 						'type'        => 'updated',
284
-						'description' => __( 'API keys have been revoked.', 'give' ),
284
+						'description' => __('API keys have been revoked.', 'give'),
285 285
 						'show'        => true,
286
-					) );
286
+					));
287 287
 					break;
288 288
 				case 'sent-test-email' :
289
-					Give()->notices->register_notice( array(
289
+					Give()->notices->register_notice(array(
290 290
 						'id'          => 'give-sent-test-email',
291 291
 						'type'        => 'updated',
292
-						'description' => __( 'The test email has been sent.', 'give' ),
292
+						'description' => __('The test email has been sent.', 'give'),
293 293
 						'show'        => true,
294
-					) );
294
+					));
295 295
 					break;
296 296
 				case 'matched-success-failure-page':
297
-					Give()->notices->register_notice( array(
297
+					Give()->notices->register_notice(array(
298 298
 						'id'          => 'give-matched-success-failure-page',
299 299
 						'type'        => 'updated',
300
-						'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ),
300
+						'description' => __('You cannot set the success and failed pages to the same page', 'give'),
301 301
 						'show'        => true,
302
-					) );
302
+					));
303 303
 					break;
304 304
 			}
305 305
 		}
306 306
 		// Payments errors.
307
-		if ( current_user_can( 'edit_give_payments' ) ) {
308
-			switch ( $_GET['give-message'] ) {
307
+		if (current_user_can('edit_give_payments')) {
308
+			switch ($_GET['give-message']) {
309 309
 				case 'note-added' :
310
-					Give()->notices->register_notice( array(
310
+					Give()->notices->register_notice(array(
311 311
 						'id'          => 'give-note-added',
312 312
 						'type'        => 'updated',
313
-						'description' => __( 'The donation note has been added.', 'give' ),
313
+						'description' => __('The donation note has been added.', 'give'),
314 314
 						'show'        => true,
315
-					) );
315
+					));
316 316
 					break;
317 317
 				case 'payment-updated' :
318
-					Give()->notices->register_notice( array(
318
+					Give()->notices->register_notice(array(
319 319
 						'id'          => 'give-payment-updated',
320 320
 						'type'        => 'updated',
321
-						'description' => __( 'The donation has been updated.', 'give' ),
321
+						'description' => __('The donation has been updated.', 'give'),
322 322
 						'show'        => true,
323
-					) );
323
+					));
324 324
 					break;
325 325
 			}
326 326
 		}
327 327
 
328 328
 		// Donor Notices.
329
-		if ( current_user_can( 'edit_give_payments' ) ) {
330
-			switch ( $_GET['give-message'] ) {
329
+		if (current_user_can('edit_give_payments')) {
330
+			switch ($_GET['give-message']) {
331 331
 				case 'donor-deleted' :
332
-					Give()->notices->register_notice( array(
332
+					Give()->notices->register_notice(array(
333 333
 						'id'          => 'give-donor-deleted',
334 334
 						'type'        => 'updated',
335
-						'description' => __( 'The selected donor(s) has been deleted.', 'give' ),
335
+						'description' => __('The selected donor(s) has been deleted.', 'give'),
336 336
 						'show'        => true,
337
-					) );
337
+					));
338 338
 					break;
339 339
 
340 340
 				case 'donor-donations-deleted' :
341
-					Give()->notices->register_notice( array(
341
+					Give()->notices->register_notice(array(
342 342
 						'id'          => 'give-donor-donations-deleted',
343 343
 						'type'        => 'updated',
344
-						'description' => __( 'The selected donor(s) and its associated donations has been deleted.', 'give' ),
344
+						'description' => __('The selected donor(s) and its associated donations has been deleted.', 'give'),
345 345
 						'show'        => true,
346
-					) );
346
+					));
347 347
 					break;
348 348
 
349 349
 				case 'confirm-delete-donor' :
350
-					Give()->notices->register_notice( array(
350
+					Give()->notices->register_notice(array(
351 351
 						'id'          => 'give-confirm-delete-donor',
352 352
 						'type'        => 'updated',
353
-						'description' => __( 'You must confirm to delete the selected donor(s).', 'give' ),
353
+						'description' => __('You must confirm to delete the selected donor(s).', 'give'),
354 354
 						'show'        => true,
355
-					) );
355
+					));
356 356
 					break;
357 357
 
358 358
 				case 'invalid-donor-id' :
359
-					Give()->notices->register_notice( array(
359
+					Give()->notices->register_notice(array(
360 360
 						'id'          => 'give-invalid-donor-id',
361 361
 						'type'        => 'updated',
362
-						'description' => __( 'Invalid Donor ID.', 'give' ),
362
+						'description' => __('Invalid Donor ID.', 'give'),
363 363
 						'show'        => true,
364
-					) );
364
+					));
365 365
 					break;
366 366
 
367 367
 				case 'donor-delete-failed' :
368
-					Give()->notices->register_notice( array(
368
+					Give()->notices->register_notice(array(
369 369
 						'id'          => 'give-donor-delete-failed',
370 370
 						'type'        => 'error',
371
-						'description' => __( 'Unable to delete selected donor(s).', 'give' ),
371
+						'description' => __('Unable to delete selected donor(s).', 'give'),
372 372
 						'show'        => true,
373
-					) );
373
+					));
374 374
 					break;
375 375
 
376 376
 				case 'email-added' :
377
-					Give()->notices->register_notice( array(
377
+					Give()->notices->register_notice(array(
378 378
 						'id'          => 'give-donor-email-added',
379 379
 						'type'        => 'updated',
380
-						'description' => __( 'Donor email added.', 'give' ),
380
+						'description' => __('Donor email added.', 'give'),
381 381
 						'show'        => true,
382
-					) );
382
+					));
383 383
 					break;
384 384
 
385 385
 				case 'email-removed' :
386
-					Give()->notices->register_notice( array(
386
+					Give()->notices->register_notice(array(
387 387
 						'id'          => 'give-donor-email-removed',
388 388
 						'type'        => 'updated',
389
-						'description' => __( 'Donor email removed.', 'give' ),
389
+						'description' => __('Donor email removed.', 'give'),
390 390
 						'show'        => true,
391
-					) );
391
+					));
392 392
 					break;
393 393
 
394 394
 				case 'email-remove-failed' :
395
-					Give()->notices->register_notice( array(
395
+					Give()->notices->register_notice(array(
396 396
 						'id'          => 'give-donor-email-remove-failed',
397 397
 						'type'        => 'updated',
398
-						'description' => __( 'Failed to remove donor email.', 'give' ),
398
+						'description' => __('Failed to remove donor email.', 'give'),
399 399
 						'show'        => true,
400
-					) );
400
+					));
401 401
 					break;
402 402
 
403 403
 				case 'primary-email-updated' :
404
-					Give()->notices->register_notice( array(
404
+					Give()->notices->register_notice(array(
405 405
 						'id'          => 'give-donor-primary-email-updated',
406 406
 						'type'        => 'updated',
407
-						'description' => __( 'Primary email updated for donor.', 'give' ),
407
+						'description' => __('Primary email updated for donor.', 'give'),
408 408
 						'show'        => true,
409
-					) );
409
+					));
410 410
 					break;
411 411
 
412 412
 				case 'primary-email-failed' :
413
-					Give()->notices->register_notice( array(
413
+					Give()->notices->register_notice(array(
414 414
 						'id'          => 'give-donor-primary-email-failed',
415 415
 						'type'        => 'updated',
416
-						'description' => __( 'Failed to set primary email.', 'give' ),
416
+						'description' => __('Failed to set primary email.', 'give'),
417 417
 						'show'        => true,
418
-					) );
418
+					));
419 419
 					break;
420 420
 
421 421
 				case 'reconnect-user' :
422
-					Give()->notices->register_notice( array(
422
+					Give()->notices->register_notice(array(
423 423
 						'id'          => 'give-donor-reconnect-user',
424 424
 						'type'        => 'updated',
425
-						'description' => __( 'User has been successfully connected with Donor.', 'give' ),
425
+						'description' => __('User has been successfully connected with Donor.', 'give'),
426 426
 						'show'        => true,
427
-					) );
427
+					));
428 428
 					break;
429 429
 
430 430
 				case 'profile-updated' :
431
-					Give()->notices->register_notice( array(
431
+					Give()->notices->register_notice(array(
432 432
 						'id'          => 'give-donor-profile-updated',
433 433
 						'type'        => 'updated',
434
-						'description' => __( 'Donor information updated successfully.', 'give' ),
434
+						'description' => __('Donor information updated successfully.', 'give'),
435 435
 						'show'        => true,
436
-					) );
436
+					));
437 437
 					break;
438 438
 			}
439 439
 		}
440 440
 	}
441 441
 }
442 442
 
443
-add_action( 'admin_notices', '_give_register_admin_notices', - 1 );
443
+add_action('admin_notices', '_give_register_admin_notices', - 1);
444 444
 
445 445
 
446 446
 /**
@@ -450,31 +450,30 @@  discard block
 block discarded – undo
450 450
  *
451 451
  * @return bool
452 452
  */
453
-function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) {
454
-	$is_test_mode = ! empty( $_POST['test_mode'] ) ?
455
-		give_is_setting_enabled( $_POST['test_mode'] ) :
456
-		give_is_test_mode();
453
+function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) {
454
+	$is_test_mode = ! empty($_POST['test_mode']) ?
455
+		give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode();
457 456
 
458 457
 	if (
459
-		! current_user_can( 'view_give_reports' ) ||
458
+		! current_user_can('view_give_reports') ||
460 459
 		! $is_test_mode
461 460
 	) {
462 461
 		return false;
463 462
 	}
464 463
 
465 464
 	// Add the main site admin menu item.
466
-	$wp_admin_bar->add_menu( array(
465
+	$wp_admin_bar->add_menu(array(
467 466
 		'id'     => 'give-test-notice',
468
-		'href'   => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ),
467
+		'href'   => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'),
469 468
 		'parent' => 'top-secondary',
470
-		'title'  => __( 'Give Test Mode Active', 'give' ),
471
-		'meta'   => array( 'class' => 'give-test-mode-active' ),
472
-	) );
469
+		'title'  => __('Give Test Mode Active', 'give'),
470
+		'meta'   => array('class' => 'give-test-mode-active'),
471
+	));
473 472
 
474 473
 	return true;
475 474
 }
476 475
 
477
-add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 );
476
+add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1);
478 477
 
479 478
 /**
480 479
  * Add Link to Import page in from donation archive and donation single page
@@ -483,12 +482,12 @@  discard block
 block discarded – undo
483 482
  */
484 483
 function give_import_page_link_callback() {
485 484
 	?>
486
-	<a href="<?php echo esc_url( give_import_page_url() ); ?>"
487
-	   class="page-import-action page-title-action"><?php _e( 'Import Donations', 'give' ); ?></a>
485
+	<a href="<?php echo esc_url(give_import_page_url()); ?>"
486
+	   class="page-import-action page-title-action"><?php _e('Import Donations', 'give'); ?></a>
488 487
 
489 488
 	<?php
490 489
 	// Check if view donation single page only.
491
-	if ( ! empty( $_REQUEST['view'] ) && 'view-payment-details' === (string) give_clean( $_REQUEST['view'] ) && 'give-payment-history' === give_clean( $_REQUEST['page'] ) ) {
490
+	if ( ! empty($_REQUEST['view']) && 'view-payment-details' === (string) give_clean($_REQUEST['view']) && 'give-payment-history' === give_clean($_REQUEST['page'])) {
492 491
 		?>
493 492
 		<style type="text/css">
494 493
 			.wrap #transaction-details-heading {
@@ -499,7 +498,7 @@  discard block
 block discarded – undo
499 498
 	}
500 499
 }
501 500
 
502
-add_action( 'give_payments_page_top', 'give_import_page_link_callback', 11 );
501
+add_action('give_payments_page_top', 'give_import_page_link_callback', 11);
503 502
 
504 503
 /**
505 504
  * Load donation import ajax callback
@@ -511,9 +510,9 @@  discard block
 block discarded – undo
511 510
  */
512 511
 function give_donation_import_callback() {
513 512
 	$import_setting = array();
514
-	$fields         = isset( $_POST['fields'] ) ? $_POST['fields'] : null;
513
+	$fields         = isset($_POST['fields']) ? $_POST['fields'] : null;
515 514
 
516
-	parse_str( $fields );
515
+	parse_str($fields);
517 516
 
518 517
 	$import_setting['create_user'] = $create_user;
519 518
 	$import_setting['mode']        = $mode;
@@ -522,57 +521,57 @@  discard block
 block discarded – undo
522 521
 	$import_setting['delete_csv']  = $delete_csv;
523 522
 
524 523
 	// Parent key id.
525
-	$main_key = maybe_unserialize( $main_key );
526
-
527
-	$current    = absint( $_REQUEST['current'] );
528
-	$total_ajax = absint( $_REQUEST['total_ajax'] );
529
-	$start      = absint( $_REQUEST['start'] );
530
-	$end        = absint( $_REQUEST['end'] );
531
-	$next       = absint( $_REQUEST['next'] );
532
-	$total      = absint( $_REQUEST['total'] );
533
-	$per_page   = absint( $_REQUEST['per_page'] );
534
-	if ( empty( $delimiter ) ) {
524
+	$main_key = maybe_unserialize($main_key);
525
+
526
+	$current    = absint($_REQUEST['current']);
527
+	$total_ajax = absint($_REQUEST['total_ajax']);
528
+	$start      = absint($_REQUEST['start']);
529
+	$end        = absint($_REQUEST['end']);
530
+	$next       = absint($_REQUEST['next']);
531
+	$total      = absint($_REQUEST['total']);
532
+	$per_page   = absint($_REQUEST['per_page']);
533
+	if (empty($delimiter)) {
535 534
 		$delimiter = ',';
536 535
 	}
537 536
 
538 537
 	// Processing done here.
539
-	$raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter );
540
-	$raw_key  = maybe_unserialize( $mapto );
538
+	$raw_data = give_get_donation_data_from_csv($csv, $start, $end, $delimiter);
539
+	$raw_key  = maybe_unserialize($mapto);
541 540
 
542 541
 	// Prevent normal emails.
543
-	remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );
544
-	remove_action( 'give_insert_user', 'give_new_user_notification', 10 );
545
-	remove_action( 'give_insert_payment', 'give_payment_save_page_data' );
546
-
547
-	$current_key  = $start;
548
-	foreach ( $raw_data as $row_data ) {
549
-		$import_setting['donation_key']  = $current_key;
550
-		give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting );
542
+	remove_action('give_complete_donation', 'give_trigger_donation_receipt', 999);
543
+	remove_action('give_insert_user', 'give_new_user_notification', 10);
544
+	remove_action('give_insert_payment', 'give_payment_save_page_data');
545
+
546
+	$current_key = $start;
547
+	foreach ($raw_data as $row_data) {
548
+		$import_setting['donation_key'] = $current_key;
549
+		give_save_import_donation_to_db($raw_key, $row_data, $main_key, $import_setting);
551 550
 		$current_key++;
552 551
 	}
553 552
 
554 553
 	// Check if function exists or not.
555
-	if ( function_exists( 'give_payment_save_page_data' ) ) {
556
-		add_action( 'give_insert_payment', 'give_payment_save_page_data' );
554
+	if (function_exists('give_payment_save_page_data')) {
555
+		add_action('give_insert_payment', 'give_payment_save_page_data');
557 556
 	}
558
-	add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
559
-	add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );
557
+	add_action('give_insert_user', 'give_new_user_notification', 10, 2);
558
+	add_action('give_complete_donation', 'give_trigger_donation_receipt', 999);
560 559
 
561
-	if ( $next == false ) {
560
+	if ($next == false) {
562 561
 		$json_data = array(
563 562
 			'success' => true,
564
-			'message' => __( 'All donation uploaded successfully!', 'give' ),
563
+			'message' => __('All donation uploaded successfully!', 'give'),
565 564
 		);
566 565
 	} else {
567 566
 		$index_start = $start;
568 567
 		$index_end   = $end;
569 568
 		$last        = false;
570 569
 		$next        = true;
571
-		if ( $next ) {
570
+		if ($next) {
572 571
 			$index_start = $index_start + $per_page;
573
-			$index_end   = $per_page + ( $index_start - 1 );
572
+			$index_end   = $per_page + ($index_start - 1);
574 573
 		}
575
-		if ( $index_end >= $total ) {
574
+		if ($index_end >= $total) {
576 575
 			$index_end = $total;
577 576
 			$last      = true;
578 577
 		}
@@ -586,27 +585,27 @@  discard block
 block discarded – undo
586 585
 		);
587 586
 	}
588 587
 
589
-	$url              = give_import_page_url( array(
588
+	$url = give_import_page_url(array(
590 589
 		'step'          => '4',
591 590
 		'importer-type' => 'import_donations',
592 591
 		'csv'           => $csv,
593 592
 		'total'         => $total,
594 593
 		'delete_csv'    => $import_setting['delete_csv'],
595
-		'success'       => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ),
596
-	) );
594
+		'success'       => (isset($json_data['success']) ? $json_data['success'] : ''),
595
+	));
597 596
 	$json_data['url'] = $url;
598 597
 
599
-	$current ++;
598
+	$current++;
600 599
 	$json_data['current'] = $current;
601 600
 
602
-	$percentage              = ( 100 / ( $total_ajax + 1 ) ) * $current;
601
+	$percentage              = (100 / ($total_ajax + 1)) * $current;
603 602
 	$json_data['percentage'] = $percentage;
604 603
 	
605
-	$json_data = apply_filters( 'give_import_ajax_responces', $json_data, $fields );
606
-	wp_die( json_encode( $json_data ) );
604
+	$json_data = apply_filters('give_import_ajax_responces', $json_data, $fields);
605
+	wp_die(json_encode($json_data));
607 606
 }
608 607
 
609
-add_action( 'wp_ajax_give_donation_import', 'give_donation_import_callback' );
608
+add_action('wp_ajax_give_donation_import', 'give_donation_import_callback');
610 609
 
611 610
 /**
612 611
  * Load core settings import ajax callback
@@ -618,8 +617,8 @@  discard block
 block discarded – undo
618 617
  */
619 618
 
620 619
 function give_core_settings_import_callback() {
621
-	$fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null;
622
-	parse_str( $fields, $fields );
620
+	$fields = isset($_POST['fields']) ? $_POST['fields'] : null;
621
+	parse_str($fields, $fields);
623 622
 
624 623
 	$json_data['success'] = false;
625 624
 
@@ -634,22 +633,22 @@  discard block
 block discarded – undo
634 633
 	 *
635 634
 	 * @return array $fields
636 635
 	 */
637
-	$fields = (array) apply_filters( 'give_import_core_settings_fields', $fields );
636
+	$fields = (array) apply_filters('give_import_core_settings_fields', $fields);
638 637
 
639
-	$file_name = ( ! empty( $fields['file_name'] ) ? give_clean( $fields['file_name'] ) : false );
638
+	$file_name = ( ! empty($fields['file_name']) ? give_clean($fields['file_name']) : false);
640 639
 
641
-	if ( ! empty( $file_name ) ) {
642
-		$type = ( ! empty( $fields['type'] ) ? give_clean( $fields['type'] ) : 'merge' );
640
+	if ( ! empty($file_name)) {
641
+		$type = ( ! empty($fields['type']) ? give_clean($fields['type']) : 'merge');
643 642
 
644 643
 		// Get the json data from the file and then alter it in array format
645
-		$json_string   = give_get_core_settings_json( $file_name );
646
-		$json_to_array = json_decode( $json_string, true );
644
+		$json_string   = give_get_core_settings_json($file_name);
645
+		$json_to_array = json_decode($json_string, true);
647 646
 
648 647
 		// get the current settign from the options table.
649
-		$host_give_options = get_option( 'give_settings', array() );
648
+		$host_give_options = get_option('give_settings', array());
650 649
 
651 650
 		// Save old settins for backup.
652
-		update_option( 'give_settings_old', $host_give_options );
651
+		update_option('give_settings_old', $host_give_options);
653 652
 
654 653
 		/**
655 654
 		 * Filter to Modify Core Settings that are being going to get import in options table as give settings.
@@ -665,9 +664,9 @@  discard block
 block discarded – undo
665 664
 		 *
666 665
 		 * @return array $json_to_array Setting that are being going to get imported
667 666
 		 */
668
-		$json_to_array = (array) apply_filters( 'give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields );
667
+		$json_to_array = (array) apply_filters('give_import_core_settings_data', $json_to_array, $type, $host_give_options, $fields);
669 668
 
670
-		update_option( 'give_settings', $json_to_array );
669
+		update_option('give_settings', $json_to_array);
671 670
 
672 671
 		$json_data['success'] = true;
673 672
 	}
@@ -683,16 +682,16 @@  discard block
 block discarded – undo
683 682
 	 *
684 683
 	 * @return array $url
685 684
 	 */
686
-	$json_data['url'] = give_import_page_url( (array) apply_filters( 'give_import_core_settings_success_url', array(
687
-		'step'          => ( empty( $json_data['success'] ) ? '1' : '3' ),
685
+	$json_data['url'] = give_import_page_url((array) apply_filters('give_import_core_settings_success_url', array(
686
+		'step'          => (empty($json_data['success']) ? '1' : '3'),
688 687
 		'importer-type' => 'import_core_setting',
689
-		'success'       => ( empty( $json_data['success'] ) ? '0' : '1' ),
690
-	) ) );
688
+		'success'       => (empty($json_data['success']) ? '0' : '1'),
689
+	)));
691 690
 
692
-	wp_send_json( $json_data );
691
+	wp_send_json($json_data);
693 692
 }
694 693
 
695
-add_action( 'wp_ajax_give_core_settings_import', 'give_core_settings_import_callback' );
694
+add_action('wp_ajax_give_core_settings_import', 'give_core_settings_import_callback');
696 695
 
697 696
 /**
698 697
  * Initializes blank slate content if a list table is empty.
@@ -704,7 +703,7 @@  discard block
 block discarded – undo
704 703
 	$blank_slate->init();
705 704
 }
706 705
 
707
-add_action( 'current_screen', 'give_blank_slate' );
706
+add_action('current_screen', 'give_blank_slate');
708 707
 
709 708
 /**
710 709
  * Get Array of WP User Roles.
@@ -717,8 +716,8 @@  discard block
 block discarded – undo
717 716
 	$user_roles = array();
718 717
 
719 718
 	// Loop through User Roles.
720
-	foreach ( get_editable_roles() as $role_name => $role_info ):
721
-		$user_roles[ $role_name ] = $role_info['name'];
719
+	foreach (get_editable_roles() as $role_name => $role_info):
720
+		$user_roles[$role_name] = $role_info['name'];
722 721
 	endforeach;
723 722
 
724 723
 	return $user_roles;
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +50 added lines, -50 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
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105 105
 		// Bailout.
106
-		if ( empty( $row_id ) ) {
106
+		if (empty($row_id)) {
107 107
 			return null;
108 108
 		}
109 109
 
110
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
110
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
111 111
 	}
112 112
 
113 113
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return object
123 123
 	 */
124
-	public function get_by( $column, $row_id ) {
124
+	public function get_by($column, $row_id) {
125 125
 		/* @var WPDB $wpdb */
126 126
 		global $wpdb;
127 127
 
128 128
 		// Bailout.
129
-		if ( empty( $column ) || empty( $row_id ) ) {
129
+		if (empty($column) || empty($row_id)) {
130 130
 			return null;
131 131
 		}
132 132
 
133
-		$column = esc_sql( $column );
133
+		$column = esc_sql($column);
134 134
 
135
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
135
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string      Column value.
148 148
 	 */
149
-	public function get_column( $column, $row_id ) {
149
+	public function get_column($column, $row_id) {
150 150
 		/* @var WPDB $wpdb */
151 151
 		global $wpdb;
152 152
 
153 153
 		// Bailout.
154
-		if ( empty( $column ) || empty( $row_id ) ) {
154
+		if (empty($column) || empty($row_id)) {
155 155
 			return null;
156 156
 		}
157 157
 
158
-		$column = esc_sql( $column );
158
+		$column = esc_sql($column);
159 159
 
160
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
160
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
      *
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_column_by( $column, $column_where, $column_value ) {
175
+	public function get_column_by($column, $column_where, $column_value) {
176 176
         /* @var WPDB $wpdb */
177 177
         global $wpdb;
178 178
 
179 179
 		// Bailout.
180
-		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
180
+		if (empty($column) || empty($column_where) || empty($column_value)) {
181 181
 			return null;
182 182
 		}
183 183
 
184
-		$column_where = esc_sql( $column_where );
185
-		$column       = esc_sql( $column );
186
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
184
+		$column_where = esc_sql($column_where);
185
+		$column       = esc_sql($column);
186
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
187 187
 	}
188 188
 
189 189
 	/**
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
      *
198 198
 	 * @return int
199 199
 	 */
200
-	public function insert( $data, $type = '' ) {
200
+	public function insert($data, $type = '') {
201 201
         /* @var WPDB $wpdb */
202 202
         global $wpdb;
203 203
 
204 204
 		// Set default values.
205
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
205
+		$data = wp_parse_args($data, $this->get_column_defaults());
206 206
 
207 207
 		/**
208 208
 		 * Fires before inserting data to the database.
@@ -211,22 +211,22 @@  discard block
 block discarded – undo
211 211
 		 *
212 212
 		 * @param array $data
213 213
 		 */
214
-		do_action( "give_pre_insert_{$type}", $data );
214
+		do_action("give_pre_insert_{$type}", $data);
215 215
 
216 216
 		// Initialise column format array
217 217
 		$column_formats = $this->get_columns();
218 218
 
219 219
 		// Force fields to lower case
220
-		$data = array_change_key_case( $data );
220
+		$data = array_change_key_case($data);
221 221
 
222 222
 		// White list columns
223
-		$data = array_intersect_key( $data, $column_formats );
223
+		$data = array_intersect_key($data, $column_formats);
224 224
 
225 225
 		// Reorder $column_formats to match the order of columns given in $data
226
-		$data_keys      = array_keys( $data );
227
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
226
+		$data_keys      = array_keys($data);
227
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
228 228
 
229
-		$wpdb->insert( $this->table_name, $data, $column_formats );
229
+		$wpdb->insert($this->table_name, $data, $column_formats);
230 230
 
231 231
 		/**
232 232
 		 * Fires after inserting data to the database.
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 * @param int   $insert_id
237 237
 		 * @param array $data
238 238
 		 */
239
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
239
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
240 240
 
241 241
 		return $wpdb->insert_id;
242 242
 	}
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
      *
254 254
 	 * @return bool
255 255
 	 */
256
-	public function update( $row_id, $data = array(), $where = '' ) {
256
+	public function update($row_id, $data = array(), $where = '') {
257 257
         /* @var WPDB $wpdb */
258 258
         global $wpdb;
259 259
 
260 260
 		// Row ID must be positive integer
261
-		$row_id = absint( $row_id );
261
+		$row_id = absint($row_id);
262 262
 
263
-		if ( empty( $row_id ) ) {
263
+		if (empty($row_id)) {
264 264
 			return false;
265 265
 		}
266 266
 
267
-		if ( empty( $where ) ) {
267
+		if (empty($where)) {
268 268
 			$where = $this->primary_key;
269 269
 		}
270 270
 
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 		$column_formats = $this->get_columns();
273 273
 
274 274
 		// Force fields to lower case
275
-		$data = array_change_key_case( $data );
275
+		$data = array_change_key_case($data);
276 276
 
277 277
 		// White list columns
278
-		$data = array_intersect_key( $data, $column_formats );
278
+		$data = array_intersect_key($data, $column_formats);
279 279
 
280 280
 		// Reorder $column_formats to match the order of columns given in $data
281
-		$data_keys      = array_keys( $data );
282
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
281
+		$data_keys      = array_keys($data);
282
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
283 283
 
284
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
284
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
285 285
 			return false;
286 286
 		}
287 287
 
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
      *
299 299
 	 * @return bool
300 300
 	 */
301
-	public function delete( $row_id = 0 ) {
301
+	public function delete($row_id = 0) {
302 302
         /* @var WPDB $wpdb */
303 303
         global $wpdb;
304 304
 
305 305
 		// Row ID must be positive integer
306
-		$row_id = absint( $row_id );
306
+		$row_id = absint($row_id);
307 307
 
308
-		if ( empty( $row_id ) ) {
308
+		if (empty($row_id)) {
309 309
 			return false;
310 310
 		}
311 311
 
312
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
312
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
313 313
 			return false;
314 314
 		}
315 315
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
      *
327 327
 	 * @return bool          If the table name exists.
328 328
 	 */
329
-	public function table_exists( $table ) {
329
+	public function table_exists($table) {
330 330
         /* @var WPDB $wpdb */
331 331
 		global $wpdb;
332 332
 
333
-		$table = sanitize_text_field( $table );
333
+		$table = sanitize_text_field($table);
334 334
 
335
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
335
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
336 336
 	}
337 337
 
338 338
 	/**
@@ -346,16 +346,16 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @return bool
348 348
 	 */
349
-	public function does_column_exist( $column_name ) {
349
+	public function does_column_exist($column_name) {
350 350
 
351 351
 		global $wpdb;
352 352
 
353
-		$column = $wpdb->get_results( $wpdb->prepare(
353
+		$column = $wpdb->get_results($wpdb->prepare(
354 354
 			"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ",
355 355
 			DB_NAME, $this->table_name, $column_name
356
-		) );
356
+		));
357 357
 
358
-		if ( ! empty( $column ) || get_option( 'give_version' ) ) {
358
+		if ( ! empty($column) || get_option('give_version')) {
359 359
 			return true;
360 360
 		}
361 361
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
372 372
 	 */
373 373
 	public function installed() {
374
-		return $this->table_exists( $this->table_name );
374
+		return $this->table_exists($this->table_name);
375 375
 	}
376 376
 
377 377
 	/**
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 * @access public
382 382
 	 */
383 383
 	public function register_table() {
384
-		$current_version = get_option( $this->table_name . '_db_version' );
385
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
384
+		$current_version = get_option($this->table_name.'_db_version');
385
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
386 386
 			$this->create_table();
387 387
 		}
388 388
 	}
@@ -393,5 +393,5 @@  discard block
 block discarded – undo
393 393
 	 * @since  1.8.9
394 394
 	 * @access public
395 395
 	 */
396
-	public function create_table(){}
396
+	public function create_table() {}
397 397
 }
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +126 added lines, -126 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
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed.
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( 'on' === $airplane->check_status() ) {
40
+			if ('on' === $airplane->check_status()) {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
48
+	if (Give_Cache::get('_give_ajax_works', true)) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
87
+	if ($works) {
88
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -196,41 +196,41 @@  discard block
 block discarded – undo
196 196
 	$show_field     = true;
197 197
 	$states_require = true;
198 198
 	// Get the Country code from the $_POST.
199
-	$country = sanitize_text_field( $_POST['country'] );
199
+	$country = sanitize_text_field($_POST['country']);
200 200
 
201 201
 	// Get the field name from the $_POST.
202
-	$field_name = sanitize_text_field( $_POST['field_name'] );
202
+	$field_name = sanitize_text_field($_POST['field_name']);
203 203
 
204
-	$label        = __( 'State', 'give' );
204
+	$label        = __('State', 'give');
205 205
 	$states_label = give_get_states_label();
206 206
 
207 207
 	$default_state = '';
208
-	if ( $country === give_get_country() ) {
208
+	if ($country === give_get_country()) {
209 209
 		$default_state = give_get_state();
210 210
 	}
211 211
 
212 212
 	// Check if $country code exists in the array key for states label.
213
-	if ( array_key_exists( $country, $states_label ) ) {
214
-		$label = $states_label[ $country ];
213
+	if (array_key_exists($country, $states_label)) {
214
+		$label = $states_label[$country];
215 215
 	}
216 216
 
217
-	if ( empty( $country ) ) {
217
+	if (empty($country)) {
218 218
 		$country = give_get_country();
219 219
 	}
220 220
 
221
-	$states = give_get_states( $country );
222
-	if ( ! empty( $states ) ) {
223
-		$args         = array(
221
+	$states = give_get_states($country);
222
+	if ( ! empty($states)) {
223
+		$args = array(
224 224
 			'name'             => $field_name,
225 225
 			'id'               => $field_name,
226
-			'class'            => $field_name . '  give-select',
226
+			'class'            => $field_name.'  give-select',
227 227
 			'options'          => $states,
228 228
 			'show_option_all'  => false,
229 229
 			'show_option_none' => false,
230 230
 			'placeholder'      => $label,
231 231
 			'selected'         => $default_state,
232 232
 		);
233
-		$data         = Give()->html->select( $args );
233
+		$data         = Give()->html->select($args);
234 234
 		$states_found = true;
235 235
 	} else {
236 236
 		$data = 'nostates';
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		$no_states_country = give_no_states_country_list();
240 240
 
241 241
 		// Check if $country code exists in the array key.
242
-		if ( array_key_exists( $country, $no_states_country ) ) {
242
+		if (array_key_exists($country, $no_states_country)) {
243 243
 			$show_field = false;
244 244
 		}
245 245
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$states_not_required_country_list = give_states_not_required_country_list();
248 248
 
249 249
 		// Check if $country code exists in the array key.
250
-		if ( array_key_exists( $country, $states_not_required_country_list ) ) {
250
+		if (array_key_exists($country, $states_not_required_country_list)) {
251 251
 			$states_require = false;
252 252
 		}
253 253
 	}
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 		'data'           => $data,
261 261
 		'default_state'  => $default_state,
262 262
 	);
263
-	wp_send_json( $response );
263
+	wp_send_json($response);
264 264
 }
265 265
 
266
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
267
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
266
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
267
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
268 268
 
269 269
 /**
270 270
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -276,19 +276,19 @@  discard block
 block discarded – undo
276 276
 function give_ajax_form_search() {
277 277
 	global $wpdb;
278 278
 
279
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
280
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
279
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
280
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
281 281
 
282 282
 	$results = array();
283
-	if ( current_user_can( 'edit_give_forms' ) ) {
284
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
283
+	if (current_user_can('edit_give_forms')) {
284
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
285 285
 	} else {
286
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
286
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
287 287
 	}
288 288
 
289
-	if ( $items ) {
289
+	if ($items) {
290 290
 
291
-		foreach ( $items as $item ) {
291
+		foreach ($items as $item) {
292 292
 
293 293
 			$results[] = array(
294 294
 				'id'   => $item->ID,
@@ -299,18 +299,18 @@  discard block
 block discarded – undo
299 299
 
300 300
 		$items[] = array(
301 301
 			'id'   => 0,
302
-			'name' => __( 'No forms found.', 'give' ),
302
+			'name' => __('No forms found.', 'give'),
303 303
 		);
304 304
 
305 305
 	}
306 306
 
307
-	echo json_encode( $results );
307
+	echo json_encode($results);
308 308
 
309 309
 	give_die();
310 310
 }
311 311
 
312
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
313
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
312
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
313
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
314 314
 
315 315
 /**
316 316
  * Search the donors database via Ajax
@@ -322,38 +322,38 @@  discard block
 block discarded – undo
322 322
 function give_ajax_donor_search() {
323 323
 	global $wpdb;
324 324
 
325
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
325
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
326 326
 	$results = array();
327
-	if ( ! current_user_can( 'view_give_reports' ) ) {
327
+	if ( ! current_user_can('view_give_reports')) {
328 328
 		$donors = array();
329 329
 	} else {
330
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
330
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
331 331
 	}
332 332
 
333
-	if ( $donors ) {
333
+	if ($donors) {
334 334
 
335
-		foreach ( $donors as $donor ) {
335
+		foreach ($donors as $donor) {
336 336
 
337 337
 			$results[] = array(
338 338
 				'id'   => $donor->id,
339
-				'name' => $donor->name . ' (' . $donor->email . ')',
339
+				'name' => $donor->name.' ('.$donor->email.')',
340 340
 			);
341 341
 		}
342 342
 	} else {
343 343
 
344 344
 		$donors[] = array(
345 345
 			'id'   => 0,
346
-			'name' => __( 'No donors found.', 'give' ),
346
+			'name' => __('No donors found.', 'give'),
347 347
 		);
348 348
 
349 349
 	}
350 350
 
351
-	echo json_encode( $results );
351
+	echo json_encode($results);
352 352
 
353 353
 	give_die();
354 354
 }
355 355
 
356
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
356
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
357 357
 
358 358
 
359 359
 /**
@@ -365,39 +365,39 @@  discard block
 block discarded – undo
365 365
  */
366 366
 function give_ajax_search_users() {
367 367
 
368
-	if ( current_user_can( 'manage_give_settings' ) ) {
368
+	if (current_user_can('manage_give_settings')) {
369 369
 
370
-		$search = esc_sql( sanitize_text_field( $_GET['s'] ) );
370
+		$search = esc_sql(sanitize_text_field($_GET['s']));
371 371
 
372 372
 		$get_users_args = array(
373 373
 			'number' => 9999,
374
-			'search' => $search . '*',
374
+			'search' => $search.'*',
375 375
 		);
376 376
 
377
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
377
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
378 378
 
379
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
379
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
380 380
 		$results     = array();
381 381
 
382
-		if ( $found_users ) {
382
+		if ($found_users) {
383 383
 
384
-			foreach ( $found_users as $user ) {
384
+			foreach ($found_users as $user) {
385 385
 
386 386
 				$results[] = array(
387 387
 					'id'   => $user->ID,
388
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
388
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
389 389
 				);
390 390
 			}
391 391
 		} else {
392 392
 
393 393
 			$results[] = array(
394 394
 				'id'   => 0,
395
-				'name' => __( 'No users found.', 'give' ),
395
+				'name' => __('No users found.', 'give'),
396 396
 			);
397 397
 
398 398
 		}
399 399
 
400
-		echo json_encode( $results );
400
+		echo json_encode($results);
401 401
 
402 402
 	}// End if().
403 403
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 
406 406
 }
407 407
 
408
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
408
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
409 409
 
410 410
 
411 411
 /**
@@ -417,32 +417,32 @@  discard block
 block discarded – undo
417 417
  */
418 418
 function give_check_for_form_price_variations() {
419 419
 
420
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
421
-		die( '-1' );
420
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
421
+		die('-1');
422 422
 	}
423 423
 
424
-	$form_id = intval( $_POST['form_id'] );
425
-	$form    = get_post( $form_id );
424
+	$form_id = intval($_POST['form_id']);
425
+	$form    = get_post($form_id);
426 426
 
427
-	if ( 'give_forms' != $form->post_type ) {
428
-		die( '-2' );
427
+	if ('give_forms' != $form->post_type) {
428
+		die('-2');
429 429
 	}
430 430
 
431
-	if ( give_has_variable_prices( $form_id ) ) {
432
-		$variable_prices = give_get_variable_prices( $form_id );
431
+	if (give_has_variable_prices($form_id)) {
432
+		$variable_prices = give_get_variable_prices($form_id);
433 433
 
434
-		if ( $variable_prices ) {
434
+		if ($variable_prices) {
435 435
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
436 436
 
437
-			if ( isset( $_POST['all_prices'] ) ) {
438
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
437
+			if (isset($_POST['all_prices'])) {
438
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
439 439
 			}
440 440
 
441
-			foreach ( $variable_prices as $key => $price ) {
441
+			foreach ($variable_prices as $key => $price) {
442 442
 
443
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) );
443
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)));
444 444
 
445
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
445
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
446 446
 			}
447 447
 			$ajax_response .= '</select>';
448 448
 			echo $ajax_response;
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	give_die();
453 453
 }
454 454
 
455
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
455
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
456 456
 
457 457
 
458 458
 /**
@@ -463,28 +463,28 @@  discard block
 block discarded – undo
463 463
  * @return void
464 464
  */
465 465
 function give_check_for_form_price_variations_html() {
466
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
466
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
467 467
 		wp_die();
468 468
 	}
469 469
 
470
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false;
471
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false;
472
-	if ( empty( $form_id ) || empty( $payment_id ) ) {
470
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false;
471
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false;
472
+	if (empty($form_id) || empty($payment_id)) {
473 473
 		wp_die();
474 474
 	}
475 475
 
476
-	$form = get_post( $form_id );
477
-	if ( ! empty( $form->post_type ) && 'give_forms' != $form->post_type ) {
476
+	$form = get_post($form_id);
477
+	if ( ! empty($form->post_type) && 'give_forms' != $form->post_type) {
478 478
 		wp_die();
479 479
 	}
480 480
 
481
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
482
-		esc_html_e( 'n/a', 'give' );
481
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
482
+		esc_html_e('n/a', 'give');
483 483
 	} else {
484 484
 		$prices_atts = array();
485
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
486
-			foreach ( $variable_prices as $variable_price ) {
487
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
485
+		if ($variable_prices = give_get_variable_prices($form_id)) {
486
+			foreach ($variable_prices as $variable_price) {
487
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
488 488
 			}
489 489
 		}
490 490
 
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 			'chosen'           => true,
496 496
 			'show_option_all'  => '',
497 497
 			'show_option_none' => '',
498
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
498
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
499 499
 		);
500 500
 
501
-		if ( $payment_id ) {
501
+		if ($payment_id) {
502 502
 			// Payment object.
503
-			$payment = new Give_Payment( $payment_id );
503
+			$payment = new Give_Payment($payment_id);
504 504
 
505 505
 			// Payment meta.
506 506
 			$payment_meta                               = $payment->get_meta();
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 		}
509 509
 
510 510
 		// Render variable prices select tag html.
511
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
511
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
512 512
 	}
513 513
 
514 514
 	give_die();
515 515
 }
516 516
 
517
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
517
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
518 518
 
519 519
 /**
520 520
  * Send Confirmation Email For Complete Donation History Access.
@@ -526,24 +526,24 @@  discard block
 block discarded – undo
526 526
 function give_confirm_email_for_donation_access() {
527 527
 
528 528
 	// Verify Security using Nonce.
529
-	if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) {
529
+	if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) {
530 530
 		return false;
531 531
 	}
532 532
 
533 533
 	// Bail Out, if email is empty.
534
-	if ( empty( $_POST['email'] ) ) {
534
+	if (empty($_POST['email'])) {
535 535
 		return false;
536 536
 	}
537 537
 
538
-	$donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) );
539
-	if ( Give()->email_access->can_send_email( $donor->id ) ) {
538
+	$donor = Give()->donors->get_donor_by('email', give_clean($_POST['email']));
539
+	if (Give()->email_access->can_send_email($donor->id)) {
540 540
 		$return     = array();
541
-		$email_sent = Give()->email_access->send_email( $donor->id, $donor->email );
541
+		$email_sent = Give()->email_access->send_email($donor->id, $donor->email);
542 542
 
543
-		if ( ! $email_sent ) {
543
+		if ( ! $email_sent) {
544 544
 			$return['status']  = 'error';
545 545
 			$return['message'] = Give()->notices->print_frontend_notice(
546
-				__( 'Unable to send email. Please try again.', 'give' ),
546
+				__('Unable to send email. Please try again.', 'give'),
547 547
 				false,
548 548
 				'error'
549 549
 			);
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 
552 552
 		$return['status']  = 'success';
553 553
 		$return['message'] = Give()->notices->print_frontend_notice(
554
-			__( 'Please check your email and click on the link to access your complete donation history.', 'give' ),
554
+			__('Please check your email and click on the link to access your complete donation history.', 'give'),
555 555
 			false,
556 556
 			'success'
557 557
 		);
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
 		$return['status']  = 'error';
563 563
 		$return['message'] = Give()->notices->print_frontend_notice(
564 564
 			sprintf(
565
-				__( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
566
-				sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
565
+				__('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'),
566
+				sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value)
567 567
 			),
568 568
 			false,
569 569
 			'error'
570 570
 		);
571 571
 	}
572 572
 
573
-	echo json_encode( $return );
573
+	echo json_encode($return);
574 574
 	give_die();
575 575
 }
576 576
 
577
-add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' );
578 577
\ No newline at end of file
578
+add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access');
579 579
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
39
-		add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 );
40
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39
+		add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1);
40
+		add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10);
41 41
 	}
42 42
 
43 43
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return void
52 52
 	 */
53 53
 	public function add_roles() {
54
-		add_role( 'give_manager', __( 'Give Manager', 'give' ), array(
54
+		add_role('give_manager', __('Give Manager', 'give'), array(
55 55
 			'read'                   => true,
56 56
 			'edit_posts'             => true,
57 57
 			'delete_posts'           => true,
@@ -80,25 +80,25 @@  discard block
 block discarded – undo
80 80
 			'publish_posts'          => true,
81 81
 			'read_private_pages'     => true,
82 82
 			'read_private_posts'     => true,
83
-		) );
83
+		));
84 84
 
85
-		add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array(
85
+		add_role('give_accountant', __('Give Accountant', 'give'), array(
86 86
 			'read'         => true,
87 87
 			'edit_posts'   => false,
88 88
 			'delete_posts' => false,
89
-		) );
89
+		));
90 90
 
91
-		add_role( 'give_worker', __( 'Give Worker', 'give' ), array(
91
+		add_role('give_worker', __('Give Worker', 'give'), array(
92 92
 			'read'         => true,
93 93
 			'edit_posts'   => true,
94 94
 			'edit_pages'   => true,
95 95
 			'upload_files' => true,
96 96
 			'delete_posts' => false,
97
-		) );
97
+		));
98 98
 
99
-		add_role( 'give_donor', __( 'Give Donor', 'give' ), array(
99
+		add_role('give_donor', __('Give Donor', 'give'), array(
100 100
 			'read' => true,
101
-		) );
101
+		));
102 102
 
103 103
 	}
104 104
 
@@ -117,53 +117,53 @@  discard block
 block discarded – undo
117 117
 	public function add_caps() {
118 118
 		global $wp_roles;
119 119
 
120
-		if ( class_exists( 'WP_Roles' ) ) {
121
-			if ( ! isset( $wp_roles ) ) {
120
+		if (class_exists('WP_Roles')) {
121
+			if ( ! isset($wp_roles)) {
122 122
 				$wp_roles = new WP_Roles();
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( is_object( $wp_roles ) ) {
127
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
128
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
129
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
126
+		if (is_object($wp_roles)) {
127
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
128
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
129
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
130
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
131 131
 
132
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
133
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
134
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
135
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
136
-			$wp_roles->add_cap( 'administrator', 'view_give_payments' );
132
+			$wp_roles->add_cap('administrator', 'view_give_reports');
133
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
134
+			$wp_roles->add_cap('administrator', 'export_give_reports');
135
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
136
+			$wp_roles->add_cap('administrator', 'view_give_payments');
137 137
 
138 138
 			// Add the main post type capabilities.
139 139
 			$capabilities = $this->get_core_caps();
140
-			foreach ( $capabilities as $cap_group ) {
141
-				foreach ( $cap_group as $cap ) {
142
-					$wp_roles->add_cap( 'administrator', $cap );
143
-					$wp_roles->add_cap( 'give_manager', $cap );
140
+			foreach ($capabilities as $cap_group) {
141
+				foreach ($cap_group as $cap) {
142
+					$wp_roles->add_cap('administrator', $cap);
143
+					$wp_roles->add_cap('give_manager', $cap);
144 144
 				}
145 145
 			}
146 146
 
147 147
 			// Add Capabilities to Give Workers User Role.
148
-			$wp_roles->add_cap( 'give_worker', 'edit_give_payments' );
149
-			$wp_roles->add_cap( 'give_worker', 'delete_give_forms' );
150
-			$wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' );
151
-			$wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' );
152
-			$wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' );
153
-			$wp_roles->add_cap( 'give_worker', 'edit_give_forms' );
154
-			$wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' );
155
-			$wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' );
156
-			$wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' );
157
-			$wp_roles->add_cap( 'give_worker', 'publish_give_forms' );
158
-			$wp_roles->add_cap( 'give_worker', 'read_private_give_forms' );
148
+			$wp_roles->add_cap('give_worker', 'edit_give_payments');
149
+			$wp_roles->add_cap('give_worker', 'delete_give_forms');
150
+			$wp_roles->add_cap('give_worker', 'delete_others_give_forms');
151
+			$wp_roles->add_cap('give_worker', 'delete_private_give_forms');
152
+			$wp_roles->add_cap('give_worker', 'delete_published_give_forms');
153
+			$wp_roles->add_cap('give_worker', 'edit_give_forms');
154
+			$wp_roles->add_cap('give_worker', 'edit_others_give_forms');
155
+			$wp_roles->add_cap('give_worker', 'edit_private_give_forms');
156
+			$wp_roles->add_cap('give_worker', 'edit_published_give_forms');
157
+			$wp_roles->add_cap('give_worker', 'publish_give_forms');
158
+			$wp_roles->add_cap('give_worker', 'read_private_give_forms');
159 159
 
160 160
 			// Add Capabilities to Give Accountant User Role.
161
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
162
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
163
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
164
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
165
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
166
-			$wp_roles->add_cap( 'give_accountant', 'view_give_payments' );
161
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
162
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
163
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
164
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
165
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
166
+			$wp_roles->add_cap('give_accountant', 'view_give_payments');
167 167
 
168 168
 		}
169 169
 	}
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	public function get_core_caps() {
182 182
 		$capabilities = array();
183 183
 
184
-		$capability_types = array( 'give_form', 'give_payment' );
184
+		$capability_types = array('give_form', 'give_payment');
185 185
 
186
-		foreach ( $capability_types as $capability_type ) {
187
-			$capabilities[ $capability_type ] = array(
186
+		foreach ($capability_types as $capability_type) {
187
+			$capabilities[$capability_type] = array(
188 188
 				// Post type.
189 189
 				"edit_{$capability_type}",
190 190
 				"read_{$capability_type}",
@@ -230,22 +230,22 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return array  $caps    Meta capabilities.
232 232
 	 */
233
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
233
+	public function meta_caps($caps, $cap, $user_id, $args) {
234 234
 
235
-		switch ( $cap ) {
235
+		switch ($cap) {
236 236
 
237 237
 			case 'view_give_form_stats' :
238 238
 
239
-				if ( empty( $args[0] ) ) {
239
+				if (empty($args[0])) {
240 240
 					break;
241 241
 				}
242 242
 
243
-				$form = get_post( $args[0] );
244
-				if ( empty( $form ) ) {
243
+				$form = get_post($args[0]);
244
+				if (empty($form)) {
245 245
 					break;
246 246
 				}
247 247
 
248
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
248
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
249 249
 					$caps = array();
250 250
 				}
251 251
 
@@ -272,57 +272,57 @@  discard block
 block discarded – undo
272 272
 
273 273
 		global $wp_roles;
274 274
 
275
-		if ( class_exists( 'WP_Roles' ) ) {
276
-			if ( ! isset( $wp_roles ) ) {
275
+		if (class_exists('WP_Roles')) {
276
+			if ( ! isset($wp_roles)) {
277 277
 				$wp_roles = new WP_Roles();
278 278
 			}
279 279
 		}
280 280
 
281
-		if ( is_object( $wp_roles ) ) {
281
+		if (is_object($wp_roles)) {
282 282
 			// Give Manager Capabilities.
283
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
284
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
285
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
286
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
283
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
284
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
285
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
286
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
287 287
 
288 288
 			// Site Administrator Capabilities.
289
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
290
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
291
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
292
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
293
-			$wp_roles->remove_cap( 'administrator', 'view_give_payments' );
289
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
290
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
291
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
292
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
293
+			$wp_roles->remove_cap('administrator', 'view_give_payments');
294 294
 
295 295
 			// Remove the Main Post Type Capabilities.
296 296
 			$capabilities = $this->get_core_caps();
297 297
 
298
-			foreach ( $capabilities as $cap_group ) {
299
-				foreach ( $cap_group as $cap ) {
300
-					$wp_roles->remove_cap( 'give_manager', $cap );
301
-					$wp_roles->remove_cap( 'administrator', $cap );
298
+			foreach ($capabilities as $cap_group) {
299
+				foreach ($cap_group as $cap) {
300
+					$wp_roles->remove_cap('give_manager', $cap);
301
+					$wp_roles->remove_cap('administrator', $cap);
302 302
 
303 303
 				}
304 304
 			}
305 305
 
306 306
 			// Remove capabilities from the Give Worker role.
307
-			$wp_roles->remove_cap( 'give_worker', 'edit_give_payments' );
308
-			$wp_roles->remove_cap( 'give_worker', 'delete_give_forms' );
309
-			$wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' );
310
-			$wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' );
311
-			$wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' );
312
-			$wp_roles->remove_cap( 'give_worker', 'edit_give_forms' );
313
-			$wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' );
314
-			$wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' );
315
-			$wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' );
316
-			$wp_roles->remove_cap( 'give_worker', 'publish_give_forms' );
317
-			$wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' );
307
+			$wp_roles->remove_cap('give_worker', 'edit_give_payments');
308
+			$wp_roles->remove_cap('give_worker', 'delete_give_forms');
309
+			$wp_roles->remove_cap('give_worker', 'delete_others_give_forms');
310
+			$wp_roles->remove_cap('give_worker', 'delete_private_give_forms');
311
+			$wp_roles->remove_cap('give_worker', 'delete_published_give_forms');
312
+			$wp_roles->remove_cap('give_worker', 'edit_give_forms');
313
+			$wp_roles->remove_cap('give_worker', 'edit_others_give_forms');
314
+			$wp_roles->remove_cap('give_worker', 'edit_private_give_forms');
315
+			$wp_roles->remove_cap('give_worker', 'edit_published_give_forms');
316
+			$wp_roles->remove_cap('give_worker', 'publish_give_forms');
317
+			$wp_roles->remove_cap('give_worker', 'read_private_give_forms');
318 318
 
319 319
 			// Remove Capabilities from Give Accountant User Role.
320
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
321
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
322
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
323
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
324
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' );
325
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_payments' );
320
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
321
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
322
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
323
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
324
+			$wp_roles->remove_cap('give_accountant', 'edit_give_payments');
325
+			$wp_roles->remove_cap('give_accountant', 'view_give_payments');
326 326
 
327 327
 		}
328 328
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		$current_user = wp_get_current_user();
346 346
 
347 347
 		// If user with "Give Accountant" user role is logged-in .
348
-		if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) {
348
+		if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) {
349 349
 
350 350
 			// Return false, means no prevention.
351 351
 			return false;
Please login to merge, or discard this patch.
includes/donors/class-give-donors-query.php 1 patch
Spacing   +49 added lines, -50 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
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
87 87
 	 */
88
-	public function __construct( $args = array() ) {
88
+	public function __construct($args = array()) {
89 89
 		$defaults = array(
90 90
 			'number'     => 20,
91 91
 			'offset'     => 0,
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			// 'form'       => array(),
104 104
 		);
105 105
 
106
-		$this->args = wp_parse_args( $args, $defaults );
106
+		$this->args = wp_parse_args($args, $defaults);
107 107
 		$this->table_name      = Give()->donors->table_name;
108 108
 		$this->meta_table_name = Give()->donor_meta->table_name;
109 109
 		$this->meta_type       = Give()->donor_meta->meta_type;
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 		 *
146 146
 		 * @param Give_Donors_Query $this Donors query object.
147 147
 		 */
148
-		do_action( 'give_pre_get_donors', $this );
148
+		do_action('give_pre_get_donors', $this);
149 149
 
150
-		if ( empty( $this->args['count'] ) ) {
151
-			$this->donors = $wpdb->get_results( $this->get_sql() );
150
+		if (empty($this->args['count'])) {
151
+			$this->donors = $wpdb->get_results($this->get_sql());
152 152
 		} else {
153
-			$this->donors = $wpdb->get_var( $this->get_sql() );
153
+			$this->donors = $wpdb->get_var($this->get_sql());
154 154
 		}
155 155
 
156 156
 		/**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 *
161 161
 		 * @param Give_Donors_Query $this Donors query object.
162 162
 		 */
163
-		do_action( 'give_post_get_donors', $this );
163
+		do_action('give_post_get_donors', $this);
164 164
 
165 165
 		return $this->donors;
166 166
 	}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	public function get_sql() {
178 178
 		global $wpdb;
179 179
 
180
-		if ( $this->args['number'] < 1 ) {
180
+		if ($this->args['number'] < 1) {
181 181
 			$this->args['number'] = 999999999999;
182 182
 		}
183 183
 
@@ -185,22 +185,22 @@  discard block
 block discarded – undo
185 185
 
186 186
 
187 187
 		// Set offset.
188
-		if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) {
189
-			$this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 );
188
+		if (empty($this->args['offset']) && (0 < $this->args['paged'])) {
189
+			$this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1);
190 190
 		}
191 191
 
192 192
 		// Set fields.
193 193
 		$fields = "{$this->table_name}.*";
194
-		if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
195
-			if ( is_string( $this->args['fields'] ) ) {
194
+		if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) {
195
+			if (is_string($this->args['fields'])) {
196 196
 				$fields = "{$this->table_name}.{$this->args['fields']}";
197
-			} else if ( is_array( $this->args['fields'] ) ) {
198
-				$fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] );
197
+			} else if (is_array($this->args['fields'])) {
198
+				$fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']);
199 199
 			}
200 200
 		}
201 201
 
202 202
 		// Set count.
203
-		if ( ! empty( $this->args['count'] ) ) {
203
+		if ( ! empty($this->args['count'])) {
204 204
 			$fields = "COUNT({$this->table_name}.id)";
205 205
 		}
206 206
 
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 
209 209
 		$sql = $wpdb->prepare(
210 210
 			"SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;",
211
-			absint( $this->args['offset'] ),
212
-			absint( $this->args['number'] )
211
+			absint($this->args['offset']),
212
+			absint($this->args['number'])
213 213
 		);
214 214
 
215 215
 		// $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
216 216
 		// WordPress consider LIKE condition as placeholder if start with s,f, or d.
217
-		$sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql );
217
+		$sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql);
218 218
 
219 219
 		return $sql;
220 220
 	}
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
 		$where = '';
233 233
 
234 234
 		// Get sql query for meta.
235
-		if ( ! empty( $this->args['meta_query'] ) ) {
236
-			$meta_query_object = new WP_Meta_Query( $this->args['meta_query'] );
235
+		if ( ! empty($this->args['meta_query'])) {
236
+			$meta_query_object = new WP_Meta_Query($this->args['meta_query']);
237 237
 			$meta_query        = $meta_query_object->get_sql(
238 238
 				$this->meta_type,
239 239
 				$this->table_name,
240 240
 				'id'
241 241
 			);
242 242
 
243
-			$where = implode( '', $meta_query );
243
+			$where = implode('', $meta_query);
244 244
 		}
245 245
 
246 246
 		$where .= 'WHERE 1=1 ';
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$where .= $this->get_where_user();
251 251
 		$where .= $this->get_where_date();
252 252
 
253
-		return trim( $where );
253
+		return trim($where);
254 254
 		
255 255
 	}
256 256
 
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
 
269 269
 		$where = '';
270 270
 
271
-		if ( ! empty( $this->args['email'] ) ) {
271
+		if ( ! empty($this->args['email'])) {
272 272
 
273
-			if ( is_array( $this->args['email'] ) ) {
273
+			if (is_array($this->args['email'])) {
274 274
 
275
-				$emails_count       = count( $this->args['email'] );
276
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
277
-				$emails             = implode( ', ', $emails_placeholder );
275
+				$emails_count       = count($this->args['email']);
276
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
277
+				$emails             = implode(', ', $emails_placeholder);
278 278
 
279
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] );
279
+				$where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']);
280 280
 			} else {
281
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] );
281
+				$where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']);
282 282
 			}
283 283
 		}
284 284
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 		$where = '';
299 299
 
300 300
 		// Specific donors.
301
-		if ( ! empty( $this->args['donor'] ) ) {
302
-			if ( ! is_array( $this->args['donor'] ) ) {
303
-				$this->args['donor'] = explode( ',', $this->args['donor'] );
301
+		if ( ! empty($this->args['donor'])) {
302
+			if ( ! is_array($this->args['donor'])) {
303
+				$this->args['donor'] = explode(',', $this->args['donor']);
304 304
 			}
305
-			$donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) );
305
+			$donor_ids = implode(',', array_map('intval', $this->args['donor']));
306 306
 
307 307
 			$where .= "AND {$this->table_name}.id IN( {$donor_ids} )";
308 308
 		}
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 		$where = '';
324 324
 
325 325
 		// Donors created for a specific date or in a date range
326
-		if ( ! empty( $this->args['date_query'] ) ) {
326
+		if ( ! empty($this->args['date_query'])) {
327 327
 			$date_query_object = new WP_Date_Query(
328
-				is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ),
328
+				is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']),
329 329
 				"{$this->table_name}.date_created"
330 330
 			);
331 331
 
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 		$where = '';
361 361
 
362 362
 		// Donors created for a specific date or in a date range
363
-		if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) {
364
-			$search_parts = explode( ':', $this->args['s'] );
363
+		if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) {
364
+			$search_parts = explode(':', $this->args['s']);
365 365
 
366
-			if ( ! empty( $search_parts[0] ) ) {
367
-				switch ( $search_parts[0] ) {
366
+			if ( ! empty($search_parts[0])) {
367
+				switch ($search_parts[0]) {
368 368
 					case 'name':
369 369
 						$where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'";
370 370
 						break;
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 		$where = '';
393 393
 
394 394
 		// Donors create for specific wp user.
395
-		if ( ! empty( $this->args['user'] ) ) {
396
-			if ( ! is_array( $this->args['user'] ) ) {
397
-				$this->args['user'] = explode( ',', $this->args['user'] );
395
+		if ( ! empty($this->args['user'])) {
396
+			if ( ! is_array($this->args['user'])) {
397
+				$this->args['user'] = explode(',', $this->args['user']);
398 398
 			}
399
-			$user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) );
399
+			$user_ids = implode(',', array_map('intval', $this->args['user']));
400 400
 
401 401
 			$where .= "AND {$this->table_name}.user_id IN( {$user_ids} )";
402 402
 		}
@@ -415,14 +415,13 @@  discard block
 block discarded – undo
415 415
 	private function get_order_query() {
416 416
 		$table_columns = Give()->donors->get_columns();
417 417
 
418
-		$this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ?
419
-			'id' :
420
-			$this->args['orderby'];
418
+		$this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ?
419
+			'id' : $this->args['orderby'];
421 420
 
422
-		$this->args['orderby'] = esc_sql( $this->args['orderby'] );
423
-		$this->args['order']   = esc_sql( $this->args['order'] );
421
+		$this->args['orderby'] = esc_sql($this->args['orderby']);
422
+		$this->args['order']   = esc_sql($this->args['order']);
424 423
 
425
-		switch ( $table_columns[ $this->args['orderby'] ] ) {
424
+		switch ($table_columns[$this->args['orderby']]) {
426 425
 			case '%d':
427 426
 			case '%f':
428 427
 				$query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0";
Please login to merge, or discard this patch.
includes/class-give-donor.php 1 patch
Spacing   +172 added lines, -172 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
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = Give()->donors;
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
415
+			if ($update_stats) {
416
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_donation_amount( $payment_id );
501
+				$payment_amount = give_donation_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 *
799 799
 	 * @return string|float
800 800
 	 */
801
-	public function get_total_donation_amount( $args = array() ) {
801
+	public function get_total_donation_amount($args = array()) {
802 802
 
803 803
 		/**
804 804
 		 * Filter total donation amount.
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		 * @param integer      $donor_id       Donor ID.
810 810
 		 * @param array        $args           Pass additional data.
811 811
 		 */
812
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
812
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
813 813
 	}
814 814
 
815 815
 	/**
@@ -822,22 +822,22 @@  discard block
 block discarded – undo
822 822
 	 *
823 823
 	 * @return string|boolean The new note if added successfully, false otherwise.
824 824
 	 */
825
-	public function add_note( $note = '' ) {
825
+	public function add_note($note = '') {
826 826
 
827
-		$note = trim( $note );
828
-		if ( empty( $note ) ) {
827
+		$note = trim($note);
828
+		if (empty($note)) {
829 829
 			return false;
830 830
 		}
831 831
 
832 832
 		$notes = $this->get_raw_notes();
833 833
 
834
-		if ( empty( $notes ) ) {
834
+		if (empty($notes)) {
835 835
 			$notes = '';
836 836
 		}
837 837
 
838
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
839
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
840
-		$notes       .= "\n\n" . $new_note;
838
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
839
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
840
+		$notes .= "\n\n".$new_note;
841 841
 
842 842
 		/**
843 843
 		 * Fires before donor note is added.
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 		 * @param string $new_note New note to add.
848 848
 		 * @param int $donor_id Donor id.
849 849
 		 */
850
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
850
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
851 851
 
852
-		$updated = $this->update( array( 'notes' => $notes ) );
852
+		$updated = $this->update(array('notes' => $notes));
853 853
 
854
-		if ( $updated ) {
854
+		if ($updated) {
855 855
 			$this->notes = $this->get_notes();
856 856
 		}
857 857
 
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 		 * @param string $new_note New note added.
865 865
 		 * @param int $donor_id Donor id.
866 866
 		 */
867
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
867
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
868 868
 
869 869
 		// Return the formatted note, so we can test, as well as update any displays
870 870
 		return $new_note;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 */
882 882
 	private function get_raw_notes() {
883 883
 
884
-		$all_notes = $this->db->get_column( 'notes', $this->id );
884
+		$all_notes = $this->db->get_column('notes', $this->id);
885 885
 
886 886
 		return $all_notes;
887 887
 
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 *
899 899
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
900 900
 	 */
901
-	public function get_meta( $meta_key = '', $single = true ) {
902
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
901
+	public function get_meta($meta_key = '', $single = true) {
902
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
903 903
 	}
904 904
 
905 905
 	/**
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 	 *
915 915
 	 * @return bool               False for failure. True for success.
916 916
 	 */
917
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
918
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
917
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
918
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
919 919
 	}
920 920
 
921 921
 	/**
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 *
931 931
 	 * @return bool               False on failure, true if success.
932 932
 	 */
933
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
934
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
933
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
934
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
935 935
 	}
936 936
 
937 937
 	/**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return bool               False for failure. True for success.
947 947
 	 */
948
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
949
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
948
+	public function delete_meta($meta_key = '', $meta_value = '') {
949
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
950 950
 	}
951 951
 
952 952
 	/**
@@ -959,51 +959,51 @@  discard block
 block discarded – undo
959 959
 	 *
960 960
 	 * @return array       The sanitized data, based off column defaults.
961 961
 	 */
962
-	private function sanitize_columns( $data ) {
962
+	private function sanitize_columns($data) {
963 963
 
964 964
 		$columns        = $this->db->get_columns();
965 965
 		$default_values = $this->db->get_column_defaults();
966 966
 
967
-		foreach ( $columns as $key => $type ) {
967
+		foreach ($columns as $key => $type) {
968 968
 
969 969
 			// Only sanitize data that we were provided
970
-			if ( ! array_key_exists( $key, $data ) ) {
970
+			if ( ! array_key_exists($key, $data)) {
971 971
 				continue;
972 972
 			}
973 973
 
974
-			switch ( $type ) {
974
+			switch ($type) {
975 975
 
976 976
 				case '%s':
977
-					if ( 'email' == $key ) {
978
-						$data[ $key ] = sanitize_email( $data[ $key ] );
979
-					} elseif ( 'notes' == $key ) {
980
-						$data[ $key ] = strip_tags( $data[ $key ] );
977
+					if ('email' == $key) {
978
+						$data[$key] = sanitize_email($data[$key]);
979
+					} elseif ('notes' == $key) {
980
+						$data[$key] = strip_tags($data[$key]);
981 981
 					} else {
982
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
982
+						$data[$key] = sanitize_text_field($data[$key]);
983 983
 					}
984 984
 					break;
985 985
 
986 986
 				case '%d':
987
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
988
-						$data[ $key ] = $default_values[ $key ];
987
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
988
+						$data[$key] = $default_values[$key];
989 989
 					} else {
990
-						$data[ $key ] = absint( $data[ $key ] );
990
+						$data[$key] = absint($data[$key]);
991 991
 					}
992 992
 					break;
993 993
 
994 994
 				case '%f':
995 995
 					// Convert what was given to a float
996
-					$value = floatval( $data[ $key ] );
996
+					$value = floatval($data[$key]);
997 997
 
998
-					if ( ! is_float( $value ) ) {
999
-						$data[ $key ] = $default_values[ $key ];
998
+					if ( ! is_float($value)) {
999
+						$data[$key] = $default_values[$key];
1000 1000
 					} else {
1001
-						$data[ $key ] = $value;
1001
+						$data[$key] = $value;
1002 1002
 					}
1003 1003
 					break;
1004 1004
 
1005 1005
 				default:
1006
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1006
+					$data[$key] = sanitize_text_field($data[$key]);
1007 1007
 					break;
1008 1008
 
1009 1009
 			}
@@ -1023,33 +1023,33 @@  discard block
 block discarded – undo
1023 1023
 	 *
1024 1024
 	 * @return bool            If the email was added successfully
1025 1025
 	 */
1026
-	public function add_email( $email = '', $primary = false ) {
1027
-		if ( ! is_email( $email ) ) {
1026
+	public function add_email($email = '', $primary = false) {
1027
+		if ( ! is_email($email)) {
1028 1028
 			return false;
1029 1029
 		}
1030
-		$existing = new Give_Donor( $email );
1030
+		$existing = new Give_Donor($email);
1031 1031
 
1032
-		if ( $existing->id > 0 ) {
1032
+		if ($existing->id > 0) {
1033 1033
 			// Email address already belongs to another donor
1034 1034
 			return false;
1035 1035
 		}
1036 1036
 
1037
-		if ( email_exists( $email ) ) {
1038
-			$user = get_user_by( 'email', $email );
1039
-			if ( $user->ID != $this->user_id ) {
1037
+		if (email_exists($email)) {
1038
+			$user = get_user_by('email', $email);
1039
+			if ($user->ID != $this->user_id) {
1040 1040
 				return false;
1041 1041
 			}
1042 1042
 		}
1043 1043
 
1044
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1044
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1045 1045
 
1046 1046
 		// Add is used to ensure duplicate emails are not added
1047
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1047
+		$ret = (bool) $this->add_meta('additional_email', $email);
1048 1048
 
1049
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1049
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1050 1050
 
1051
-		if ( $ret && true === $primary ) {
1052
-			$this->set_primary_email( $email );
1051
+		if ($ret && true === $primary) {
1052
+			$this->set_primary_email($email);
1053 1053
 		}
1054 1054
 
1055 1055
 		return $ret;
@@ -1065,16 +1065,16 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @return bool          If the email was removed successfully.
1067 1067
 	 */
1068
-	public function remove_email( $email = '' ) {
1069
-		if ( ! is_email( $email ) ) {
1068
+	public function remove_email($email = '') {
1069
+		if ( ! is_email($email)) {
1070 1070
 			return false;
1071 1071
 		}
1072 1072
 
1073
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1073
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1074 1074
 
1075
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1075
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1076 1076
 
1077
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1077
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1078 1078
 
1079 1079
 		return $ret;
1080 1080
 	}
@@ -1091,16 +1091,16 @@  discard block
 block discarded – undo
1091 1091
 	 *
1092 1092
 	 * @return bool                      If the email was set as primary successfully.
1093 1093
 	 */
1094
-	public function set_primary_email( $new_primary_email = '' ) {
1095
-		if ( ! is_email( $new_primary_email ) ) {
1094
+	public function set_primary_email($new_primary_email = '') {
1095
+		if ( ! is_email($new_primary_email)) {
1096 1096
 			return false;
1097 1097
 		}
1098 1098
 
1099
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1099
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1100 1100
 
1101
-		$existing = new Give_Donor( $new_primary_email );
1101
+		$existing = new Give_Donor($new_primary_email);
1102 1102
 
1103
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1103
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1104 1104
 			// This email belongs to another donor.
1105 1105
 			return false;
1106 1106
 		}
@@ -1108,21 +1108,21 @@  discard block
 block discarded – undo
1108 1108
 		$old_email = $this->email;
1109 1109
 
1110 1110
 		// Update donor record with new email.
1111
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1111
+		$update = $this->update(array('email' => $new_primary_email));
1112 1112
 
1113 1113
 		// Remove new primary from list of additional emails.
1114
-		$remove = $this->remove_email( $new_primary_email );
1114
+		$remove = $this->remove_email($new_primary_email);
1115 1115
 
1116 1116
 		// Add old email to additional emails list.
1117
-		$add = $this->add_email( $old_email );
1117
+		$add = $this->add_email($old_email);
1118 1118
 
1119 1119
 		$ret = $update && $remove && $add;
1120 1120
 
1121
-		if ( $ret ) {
1121
+		if ($ret) {
1122 1122
 			$this->email = $new_primary_email;
1123 1123
 		}
1124 1124
 
1125
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1125
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1126 1126
 
1127 1127
 		return $ret;
1128 1128
 	}
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
 	give_setup_post_types();
62 62
 
63 63
 	// Add Upgraded From Option.
64
-	$current_version = get_option( 'give_version' );
65
-	if ( $current_version ) {
66
-		update_option( 'give_version_upgraded_from', $current_version );
64
+	$current_version = get_option('give_version');
65
+	if ($current_version) {
66
+		update_option('give_version_upgraded_from', $current_version);
67 67
 	}
68 68
 
69 69
 	// Setup some default options.
70 70
 	$options = array();
71 71
 
72 72
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
73
-	if ( empty( $current_version ) ) {
74
-		$options = array_merge( $options, give_get_default_settings() );
73
+	if (empty($current_version)) {
74
+		$options = array_merge($options, give_get_default_settings());
75 75
 	}
76 76
 
77 77
 	// Populate the default values.
78
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
78
+	update_option('give_settings', array_merge($give_options, $options));
79 79
 
80 80
 	/**
81 81
 	 * Run plugin upgrades.
82 82
 	 *
83 83
 	 * @since 1.8
84 84
 	 */
85
-	do_action( 'give_upgrades' );
85
+	do_action('give_upgrades');
86 86
 
87
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
88
-		update_option( 'give_version', GIVE_VERSION );
87
+	if (GIVE_VERSION !== get_option('give_version')) {
88
+		update_option('give_version', GIVE_VERSION);
89 89
 	}
90 90
 
91 91
 	// Create Give roles.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	// Set api version, end point and refresh permalink.
97 97
 	$api = new Give_API();
98 98
 	$api->add_endpoint();
99
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
99
+	update_option('give_default_api_version', 'v'.$api->get_version());
100 100
 
101 101
 	flush_rewrite_rules();
102 102
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	$give_sessions->use_php_sessions();
106 106
 
107 107
 	// Add a temporary option to note that Give pages have been created.
108
-	Give_Cache::set( '_give_installed', $options, 30, true );
108
+	Give_Cache::set('_give_installed', $options, 30, true);
109 109
 
110
-	if ( ! $current_version ) {
110
+	if ( ! $current_version) {
111 111
 
112
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
112
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
113 113
 
114 114
 		// When new upgrade routines are added, mark them as complete on fresh install.
115 115
 		$upgrade_routines = array(
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 			'v1818_give_worker_role_cleanup'
130 130
 		);
131 131
 
132
-		foreach ( $upgrade_routines as $upgrade ) {
133
-			give_set_upgrade_complete( $upgrade );
132
+		foreach ($upgrade_routines as $upgrade) {
133
+			give_set_upgrade_complete($upgrade);
134 134
 		}
135 135
 	}
136 136
 
137 137
 	// Bail if activating from network, or bulk.
138
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
138
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
139 139
 		return;
140 140
 	}
141 141
 
142 142
 	// Add the transient to redirect.
143
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
143
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
144 144
 }
145 145
 
146 146
 /**
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
  * @param  int $site_id The Site ID.
158 158
  * @param  array $meta Blog Meta.
159 159
  */
160
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
160
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
161 161
 
162
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
162
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
163 163
 
164
-		switch_to_blog( $blog_id );
164
+		switch_to_blog($blog_id);
165 165
 		give_install();
166 166
 		restore_current_blog();
167 167
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 }
171 171
 
172
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
172
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
173 173
 
174 174
 
175 175
 /**
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @return array          The tables to drop.
184 184
  */
185
-function give_wpmu_drop_tables( $tables, $blog_id ) {
185
+function give_wpmu_drop_tables($tables, $blog_id) {
186 186
 
187
-	switch_to_blog( $blog_id );
187
+	switch_to_blog($blog_id);
188 188
 	$donors_db     = new Give_DB_Donors();
189 189
 	$donor_meta_db = new Give_DB_Donor_Meta();
190 190
 
191
-	if ( $donors_db->installed() ) {
191
+	if ($donors_db->installed()) {
192 192
 		$tables[] = $donors_db->table_name;
193 193
 		$tables[] = $donor_meta_db->table_name;
194 194
 	}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
 }
200 200
 
201
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
201
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
202 202
 
203 203
 /**
204 204
  * Post-installation
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function give_after_install() {
212 212
 
213
-	if ( ! is_admin() ) {
213
+	if ( ! is_admin()) {
214 214
 		return;
215 215
 	}
216 216
 
217
-	$give_options     = Give_Cache::get( '_give_installed', true );
218
-	$give_table_check = get_option( '_give_table_check', false );
217
+	$give_options     = Give_Cache::get('_give_installed', true);
218
+	$give_table_check = get_option('_give_table_check', false);
219 219
 
220
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
220
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
221 221
 
222
-		if ( ! @Give()->donor_meta->installed() ) {
222
+		if ( ! @Give()->donor_meta->installed()) {
223 223
 
224 224
 			// Create the donor meta database.
225 225
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 		}
229 229
 
230
-		if ( ! @Give()->donors->installed() ) {
230
+		if ( ! @Give()->donors->installed()) {
231 231
 			// Create the donor database.
232 232
 			// (this ensures it creates it on multisite instances where it is network activated).
233 233
 			@Give()->donors->create_table();
@@ -239,22 +239,22 @@  discard block
 block discarded – undo
239 239
 			 *
240 240
 			 * @param array $give_options Give plugin options.
241 241
 			 */
242
-			do_action( 'give_after_install', $give_options );
242
+			do_action('give_after_install', $give_options);
243 243
 		}
244 244
 
245
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
245
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
246 246
 
247 247
 	}
248 248
 
249 249
 	// Delete the transient
250
-	if ( false !== $give_options ) {
251
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
250
+	if (false !== $give_options) {
251
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
252 252
 	}
253 253
 
254 254
 
255 255
 }
256 256
 
257
-add_action( 'admin_init', 'give_after_install' );
257
+add_action('admin_init', 'give_after_install');
258 258
 
259 259
 
260 260
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 
270 270
 	global $wp_roles;
271 271
 
272
-	if ( ! is_object( $wp_roles ) ) {
272
+	if ( ! is_object($wp_roles)) {
273 273
 		return;
274 274
 	}
275 275
 
276
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
276
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
277 277
 
278 278
 		// Create Give plugin roles
279 279
 		$roles = new Give_Roles();
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 }
286 286
 
287
-add_action( 'admin_init', 'give_install_roles_on_network' );
287
+add_action('admin_init', 'give_install_roles_on_network');
288 288
 
289 289
 /**
290 290
  * Default core setting values.
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 		'uninstall_on_delete'                         => 'disabled',
323 323
 		'the_content_filter'                          => 'enabled',
324 324
 		'scripts_footer'                              => 'disabled',
325
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
325
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
326 326
 		'agreement_text'                              => give_get_default_agreement_text(),
327 327
 
328 328
 		// Paypal IPN verification.
329 329
 		'paypal_verification'                         => 'enabled',
330 330
 
331 331
 		// Default is manual gateway.
332
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
332
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
333 333
 		'default_gateway'                             => 'manual',
334 334
 
335 335
 		// Offline gateway setup.
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function give_get_default_agreement_text() {
359 359
 
360
-	$org_name = get_bloginfo( 'name' );
360
+	$org_name = get_bloginfo('name');
361 361
 
362 362
 	$agreement = sprintf(
363 363
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 		$org_name
372 372
 	);
373 373
 
374
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
374
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
375 375
 }
376 376
 
377 377
 
@@ -380,22 +380,22 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @since 1.8.11
382 382
  */
383
-function give_create_pages(){
383
+function give_create_pages() {
384 384
 
385 385
 	// Bailout if pages already created.
386
-	if( get_option( 'give_install_pages_created') ) {
386
+	if (get_option('give_install_pages_created')) {
387 387
 		return false;
388 388
 	}
389 389
 
390 390
 	$options = array();
391 391
 
392 392
 	// Checks if the Success Page option exists AND that the page exists.
393
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
393
+	if ( ! get_post(give_get_option('success_page'))) {
394 394
 
395 395
 		// Donation Confirmation (Success) Page
396 396
 		$success = wp_insert_post(
397 397
 			array(
398
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
398
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
399 399
 				'post_content'   => '[give_receipt]',
400 400
 				'post_status'    => 'publish',
401 401
 				'post_author'    => 1,
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	// Checks if the Failure Page option exists AND that the page exists.
412
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
412
+	if ( ! get_post(give_get_option('failure_page'))) {
413 413
 
414 414
 		// Failed Donation Page
415 415
 		$failed = wp_insert_post(
416 416
 			array(
417
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
418
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
417
+				'post_title'     => esc_html__('Donation Failed', 'give'),
418
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
419 419
 				'post_status'    => 'publish',
420 420
 				'post_author'    => 1,
421 421
 				'post_type'      => 'page',
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 	}
428 428
 
429 429
 	// Checks if the History Page option exists AND that the page exists.
430
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
430
+	if ( ! get_post(give_get_option('history_page'))) {
431 431
 		// Donation History Page
432 432
 		$history = wp_insert_post(
433 433
 			array(
434
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
434
+				'post_title'     => esc_html__('Donation History', 'give'),
435 435
 				'post_content'   => '[donation_history]',
436 436
 				'post_status'    => 'publish',
437 437
 				'post_author'    => 1,
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 		$options['history_page'] = $history;
444 444
 	}
445 445
 
446
-	if( ! empty( $options ) ) {
447
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
446
+	if ( ! empty($options)) {
447
+		update_option('give_settings', array_merge(give_get_settings(), $options));
448 448
 	}
449 449
 
450
-	add_option( 'give_install_pages_created', 1, '', 'no' );
450
+	add_option('give_install_pages_created', 1, '', 'no');
451 451
 }
452
-add_action( 'admin_init', 'give_create_pages', -1 );
452
+add_action('admin_init', 'give_create_pages', -1);
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function give_is_test_mode() {
25 25
 
26
-	$ret = give_is_setting_enabled( give_get_option( 'test_mode' ) );
26
+	$ret = give_is_setting_enabled(give_get_option('test_mode'));
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 
40 40
 	global $wp;
41 41
 
42
-	if ( get_option( 'permalink_structure' ) ) {
43
-		$base = trailingslashit( home_url( $wp->request ) );
42
+	if (get_option('permalink_structure')) {
43
+		$base = trailingslashit(home_url($wp->request));
44 44
 	} else {
45
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
46
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
45
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
46
+		$base = remove_query_arg(array('post_type', 'name'), $base);
47 47
 	}
48 48
 
49 49
 	$scheme      = is_ssl() ? 'https' : 'http';
50
-	$current_uri = set_url_scheme( $base, $scheme );
50
+	$current_uri = set_url_scheme($base, $scheme);
51 51
 
52
-	if ( is_front_page() ) {
53
-		$current_uri = home_url( '/' );
52
+	if (is_front_page()) {
53
+		$current_uri = home_url('/');
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param string $current_uri
62 62
 	 */
63
-	return apply_filters( 'give_get_current_page_url', $current_uri );
63
+	return apply_filters('give_get_current_page_url', $current_uri);
64 64
 
65 65
 }
66 66
 
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	$gateways = give_get_enabled_payment_gateways();
84 84
 
85
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
85
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
86 86
 		$ret = true;
87
-	} elseif ( count( $gateways ) == 1 ) {
87
+	} elseif (count($gateways) == 1) {
88 88
 		$ret = false;
89
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
89
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
90 90
 		$ret = false;
91 91
 	}
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param bool $ret
99 99
 	 */
100
-	return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret );
100
+	return (bool) apply_filters('give_is_cc_verify_enabled', $ret);
101 101
 }
102 102
 
103 103
 /**
@@ -109,26 +109,26 @@  discard block
 block discarded – undo
109 109
 function give_get_timezone_id() {
110 110
 
111 111
 	// if site timezone string exists, return it.
112
-	if ( $timezone = get_option( 'timezone_string' ) ) {
112
+	if ($timezone = get_option('timezone_string')) {
113 113
 		return $timezone;
114 114
 	}
115 115
 
116 116
 	// get UTC offset, if it isn't set return UTC.
117
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
117
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
118 118
 		return 'UTC';
119 119
 	}
120 120
 
121 121
 	// attempt to guess the timezone string from the UTC offset.
122
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
122
+	$timezone = timezone_name_from_abbr('', $utc_offset);
123 123
 
124 124
 	// last try, guess timezone string manually.
125
-	if ( $timezone === false ) {
125
+	if ($timezone === false) {
126 126
 
127
-		$is_dst = date( 'I' );
127
+		$is_dst = date('I');
128 128
 
129
-		foreach ( timezone_abbreviations_list() as $abbr ) {
130
-			foreach ( $abbr as $city ) {
131
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
129
+		foreach (timezone_abbreviations_list() as $abbr) {
130
+			foreach ($abbr as $city) {
131
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
132 132
 					return $city['timezone_id'];
133 133
 				}
134 134
 			}
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 
153 153
 	$ip = '127.0.0.1';
154 154
 
155
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
155
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
156 156
 		// check ip from share internet
157 157
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
158
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
158
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
159 159
 		// to check ip is pass from proxy
160 160
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
161
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
161
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
162 162
 		$ip = $_SERVER['REMOTE_ADDR'];
163 163
 	}
164 164
 
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 */
170
-	$ip = apply_filters( 'give_get_ip', $ip );
170
+	$ip = apply_filters('give_get_ip', $ip);
171 171
 
172 172
 	// Filter empty values.
173
-	if( false !== strpos( $ip, ',' ) ) {
174
-		$ip = give_clean( explode( ',', $ip ) );
175
-		$ip = array_filter( $ip );
176
-		$ip = implode( ',', $ip );
177
-	} else{
178
-		$ip = give_clean( $ip );
173
+	if (false !== strpos($ip, ',')) {
174
+		$ip = give_clean(explode(',', $ip));
175
+		$ip = array_filter($ip);
176
+		$ip = implode(',', $ip);
177
+	} else {
178
+		$ip = give_clean($ip);
179 179
 	}
180 180
 
181 181
 	return $ip;
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @uses  Give()->session->set()
195 195
  */
196
-function give_set_purchase_session( $purchase_data = array() ) {
197
-	Give()->session->set( 'give_purchase', $purchase_data );
198
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
196
+function give_set_purchase_session($purchase_data = array()) {
197
+	Give()->session->set('give_purchase', $purchase_data);
198
+	Give()->session->set('give_email', $purchase_data['user_email']);
199 199
 }
200 200
 
201 201
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  * @return mixed array | false
210 210
  */
211 211
 function give_get_purchase_session() {
212
-	return Give()->session->get( 'give_purchase' );
212
+	return Give()->session->get('give_purchase');
213 213
 }
214 214
 
215 215
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  * @return array|string
221 221
  */
222 222
 function give_get_receipt_session() {
223
-	return Give()->session->get( 'receipt_access' );
223
+	return Give()->session->get('receipt_access');
224 224
 }
225 225
 
226 226
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return array|string
232 232
  */
233 233
 function give_get_history_session() {
234
-	return (bool) Give()->session->get( 'history_access' );
234
+	return (bool) Give()->session->get('history_access');
235 235
 }
236 236
 
237 237
 /**
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
  *
244 244
  * @return string By default, the name of the form. Then the price level text if any is found.
245 245
  */
246
-function give_payment_gateway_item_title( $payment_data ) {
246
+function give_payment_gateway_item_title($payment_data) {
247 247
 
248
-	$form_id   = intval( $payment_data['post_data']['give-form-id'] );
249
-	$item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : '';
250
-	$price_id  = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
248
+	$form_id   = intval($payment_data['post_data']['give-form-id']);
249
+	$item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : '';
250
+	$price_id  = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
251 251
 
252 252
 
253 253
 	// Verify has variable prices.
254
-	if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) {
254
+	if (give_has_variable_prices($form_id) && ! empty($price_id)) {
255 255
 
256
-		$item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false );
256
+		$item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false);
257 257
 
258 258
 		/**
259 259
 		 * Output donation level text if:
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 		 */
264 264
 		if (
265 265
 			'custom' !== $price_id
266
-			&& ! empty( $item_price_level_text )
266
+			&& ! empty($item_price_level_text)
267 267
 		) {
268 268
 			// Matches a donation level - append level text.
269
-			$item_name .= ' - ' . $item_price_level_text;
269
+			$item_name .= ' - '.$item_price_level_text;
270 270
 		}
271 271
 	}
272 272
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return string
283 283
 	 */
284
-	return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data );
284
+	return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data);
285 285
 }
286 286
 
287 287
 /**
@@ -297,36 +297,36 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return string
299 299
  */
300
-function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) {
301
-	$form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : '';
300
+function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) {
301
+	$form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : '';
302 302
 
303 303
 	// Form title.
304
-	$summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) );
304
+	$summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give')));
305 305
 
306 306
 	// Form multilevel if applicable.
307
-	if ( isset( $donation_data['post_data']['give-price-id'] ) ) {
308
-		$summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] );
307
+	if (isset($donation_data['post_data']['give-price-id'])) {
308
+		$summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']);
309 309
 	}
310 310
 
311 311
 	// Add Donor's name + email if requested.
312
-	if ( $name_and_email ) {
312
+	if ($name_and_email) {
313 313
 
314 314
 		// First name
315
-		if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) {
316
-			$summary .= ' - ' . $donation_data['user_info']['first_name'];
315
+		if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) {
316
+			$summary .= ' - '.$donation_data['user_info']['first_name'];
317 317
 		}
318 318
 
319
-		if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) {
320
-			$summary .= ' ' . $donation_data['user_info']['last_name'];
319
+		if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) {
320
+			$summary .= ' '.$donation_data['user_info']['last_name'];
321 321
 		}
322 322
 
323
-		$summary .= ' (' . $donation_data['user_email'] . ')';
323
+		$summary .= ' ('.$donation_data['user_email'].')';
324 324
 	}
325 325
 
326 326
 	// Cut the length
327
-	$summary = substr( $summary, 0, $length );
327
+	$summary = substr($summary, 0, $length);
328 328
 
329
-	return apply_filters( 'give_payment_gateway_donation_summary', $summary );
329
+	return apply_filters('give_payment_gateway_donation_summary', $summary);
330 330
 }
331 331
 
332 332
 
@@ -341,31 +341,31 @@  discard block
 block discarded – undo
341 341
 function give_get_host() {
342 342
 	$host = false;
343 343
 
344
-	if ( defined( 'WPE_APIKEY' ) ) {
344
+	if (defined('WPE_APIKEY')) {
345 345
 		$host = 'WP Engine';
346
-	} elseif ( defined( 'PAGELYBIN' ) ) {
346
+	} elseif (defined('PAGELYBIN')) {
347 347
 		$host = 'Pagely';
348
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
348
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
349 349
 		$host = 'ICDSoft';
350
-	} elseif ( DB_HOST == 'mysqlv5' ) {
350
+	} elseif (DB_HOST == 'mysqlv5') {
351 351
 		$host = 'NetworkSolutions';
352
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
352
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
353 353
 		$host = 'iPage';
354
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
354
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
355 355
 		$host = 'IPower';
356
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
356
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
357 357
 		$host = 'MediaTemple Grid';
358
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
358
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
359 359
 		$host = 'pair Networks';
360
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
360
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
361 361
 		$host = 'Rackspace Cloud';
362
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
362
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
363 363
 		$host = 'SysFix.eu Power Hosting';
364
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
364
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
365 365
 		$host = 'Flywheel';
366 366
 	} else {
367 367
 		// Adding a general fallback for data gathering
368
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
368
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
369 369
 	}
370 370
 
371 371
 	return $host;
@@ -381,67 +381,67 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return bool true if host matches, false if not
383 383
  */
384
-function give_is_host( $host = false ) {
384
+function give_is_host($host = false) {
385 385
 
386 386
 	$return = false;
387 387
 
388
-	if ( $host ) {
389
-		$host = str_replace( ' ', '', strtolower( $host ) );
388
+	if ($host) {
389
+		$host = str_replace(' ', '', strtolower($host));
390 390
 
391
-		switch ( $host ) {
391
+		switch ($host) {
392 392
 			case 'wpengine':
393
-				if ( defined( 'WPE_APIKEY' ) ) {
393
+				if (defined('WPE_APIKEY')) {
394 394
 					$return = true;
395 395
 				}
396 396
 				break;
397 397
 			case 'pagely':
398
-				if ( defined( 'PAGELYBIN' ) ) {
398
+				if (defined('PAGELYBIN')) {
399 399
 					$return = true;
400 400
 				}
401 401
 				break;
402 402
 			case 'icdsoft':
403
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
403
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
404 404
 					$return = true;
405 405
 				}
406 406
 				break;
407 407
 			case 'networksolutions':
408
-				if ( DB_HOST == 'mysqlv5' ) {
408
+				if (DB_HOST == 'mysqlv5') {
409 409
 					$return = true;
410 410
 				}
411 411
 				break;
412 412
 			case 'ipage':
413
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
413
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
414 414
 					$return = true;
415 415
 				}
416 416
 				break;
417 417
 			case 'ipower':
418
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
418
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
419 419
 					$return = true;
420 420
 				}
421 421
 				break;
422 422
 			case 'mediatemplegrid':
423
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
423
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
424 424
 					$return = true;
425 425
 				}
426 426
 				break;
427 427
 			case 'pairnetworks':
428
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
428
+				if (strpos(DB_HOST, '.pair.com') !== false) {
429 429
 					$return = true;
430 430
 				}
431 431
 				break;
432 432
 			case 'rackspacecloud':
433
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
433
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
434 434
 					$return = true;
435 435
 				}
436 436
 				break;
437 437
 			case 'sysfix.eu':
438 438
 			case 'sysfix.eupowerhosting':
439
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
439
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
440 440
 					$return = true;
441 441
 				}
442 442
 				break;
443 443
 			case 'flywheel':
444
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
444
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
445 445
 					$return = true;
446 446
 				}
447 447
 				break;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
  * @param string $replacement Optional. The function that should have been called.
475 475
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
476 476
  */
477
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
477
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
478 478
 
479 479
 	/**
480 480
 	 * Fires while give deprecated function call occurs.
@@ -487,19 +487,19 @@  discard block
 block discarded – undo
487 487
 	 * @param string $replacement Optional. The function that should have been called.
488 488
 	 * @param string $version     The plugin version that deprecated the function.
489 489
 	 */
490
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
490
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
491 491
 
492
-	$show_errors = current_user_can( 'manage_options' );
492
+	$show_errors = current_user_can('manage_options');
493 493
 
494 494
 	// Allow plugin to filter the output error trigger.
495
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
496
-		if ( ! is_null( $replacement ) ) {
497
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
498
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
495
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
496
+		if ( ! is_null($replacement)) {
497
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
498
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
499 499
 			// Alternatively we could dump this to a file.
500 500
 		} else {
501
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
502
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
501
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
502
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
503 503
 			// Alternatively we could dump this to a file.
504 504
 		}
505 505
 	}
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
  * @return string $post_id
514 514
  */
515 515
 function give_get_admin_post_id() {
516
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
517
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
516
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
517
+	if ( ! $post_id && isset($_POST['post_id'])) {
518 518
 		$post_id = $_POST['post_id'];
519 519
 	}
520 520
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
  * @return string Arg separator output
529 529
  */
530 530
 function give_get_php_arg_separator_output() {
531
-	return ini_get( 'arg_separator.output' );
531
+	return ini_get('arg_separator.output');
532 532
 }
533 533
 
534 534
 
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return string Short month name
545 545
  */
546
-function give_month_num_to_name( $n ) {
547
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
546
+function give_month_num_to_name($n) {
547
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
548 548
 
549
-	return date_i18n( 'M', $timestamp );
549
+	return date_i18n('M', $timestamp);
550 550
 }
551 551
 
552 552
 
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
  *
560 560
  * @return bool Whether or not function is disabled.
561 561
  */
562
-function give_is_func_disabled( $function ) {
563
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
562
+function give_is_func_disabled($function) {
563
+	$disabled = explode(',', ini_get('disable_functions'));
564 564
 
565
-	return in_array( $function, $disabled );
565
+	return in_array($function, $disabled);
566 566
 }
567 567
 
568 568
 /**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 function give_get_newsletter() {
574 574
 	?>
575 575
 
576
-	<p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p>
576
+	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p>
577 577
 
578 578
 	<div class="give-newsletter-form-wrap">
579 579
 
@@ -581,33 +581,33 @@  discard block
 block discarded – undo
581 581
 		      method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
582 582
 		      target="_blank" novalidate>
583 583
 			<div class="give-newsletter-confirmation">
584
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
584
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
585 585
 			</div>
586 586
 
587 587
 			<table class="form-table give-newsletter-form">
588 588
 				<tr valign="middle">
589 589
 					<td>
590 590
 						<label for="mce-EMAIL"
591
-						       class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
591
+						       class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
592 592
 						<input type="email" name="EMAIL" id="mce-EMAIL"
593
-						       placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
593
+						       placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
594 594
 						       class="required email" value="">
595 595
 					</td>
596 596
 					<td>
597 597
 						<label for="mce-FNAME"
598
-						       class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
598
+						       class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
599 599
 						<input type="text" name="FNAME" id="mce-FNAME"
600
-						       placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
600
+						       placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
601 601
 					</td>
602 602
 					<td>
603 603
 						<label for="mce-LNAME"
604
-						       class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
604
+						       class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
605 605
 						<input type="text" name="LNAME" id="mce-LNAME"
606
-						       placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
606
+						       placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
607 607
 					</td>
608 608
 					<td>
609 609
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
610
-						       value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
610
+						       value="<?php esc_attr_e('Subscribe', 'give'); ?>">
611 611
 					</td>
612 612
 				</tr>
613 613
 			</table>
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
  *
661 661
  * @return string
662 662
  */
663
-function give_svg_icons( $icon ) {
663
+function give_svg_icons($icon) {
664 664
 
665 665
 	// Store your SVGs in an associative array
666 666
 	$svgs = array(
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	);
673 673
 
674 674
 	// Return the chosen icon's SVG string
675
-	return $svgs[ $icon ];
675
+	return $svgs[$icon];
676 676
 }
677 677
 
678 678
 /**
@@ -684,15 +684,15 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return mixed
686 686
  */
687
-function modify_nav_menu_meta_box_object( $post_type ) {
688
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
689
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
687
+function modify_nav_menu_meta_box_object($post_type) {
688
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
689
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
690 690
 	}
691 691
 
692 692
 	return $post_type;
693 693
 }
694 694
 
695
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
695
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
696 696
 
697 697
 /**
698 698
  * Show Donation Forms Post Type in Appearance > Menus by default on fresh install.
@@ -711,35 +711,35 @@  discard block
 block discarded – undo
711 711
 	// Proceed, if current screen is navigation menus.
712 712
 	if (
713 713
 		'nav-menus' === $screen->id &&
714
-		give_is_setting_enabled( give_get_option( 'forms_singular' ) ) &&
715
-		! get_user_option( 'give_is_donation_forms_menu_updated' )
714
+		give_is_setting_enabled(give_get_option('forms_singular')) &&
715
+		! get_user_option('give_is_donation_forms_menu_updated')
716 716
 	) {
717 717
 
718 718
 		// Return false, if it fails to retrieve hidden meta box list and is not admin.
719 719
 		if (
720 720
 			! is_admin() ||
721
-			( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) )
721
+			( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus'))
722 722
 		) {
723 723
 			return false;
724 724
 		}
725 725
 
726 726
 		// Return false, In case, we don't find 'Donation Form' in hidden meta box list.
727
-		if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) {
727
+		if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) {
728 728
 			return false;
729 729
 		}
730 730
 
731 731
 		// Exclude 'Donation Form' value from hidden meta box's list.
732
-		$hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) );
732
+		$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms'));
733 733
 
734 734
 		// Get current user ID.
735 735
 		$user = wp_get_current_user();
736 736
 
737
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
738
-		update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true );
737
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
738
+		update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true);
739 739
 	}
740 740
 }
741 741
 
742
-add_action( 'current_screen', 'give_donation_metabox_menu' );
742
+add_action('current_screen', 'give_donation_metabox_menu');
743 743
 
744 744
 /**
745 745
  * Array_column backup usage
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  * @license    https://opensource.org/licenses/MIT MIT
753 753
  */
754 754
 
755
-if ( ! function_exists( 'array_column' ) ) {
755
+if ( ! function_exists('array_column')) {
756 756
 	/**
757 757
 	 * Returns the values from a single column of the input array, identified by
758 758
 	 * the $columnKey.
@@ -771,53 +771,53 @@  discard block
 block discarded – undo
771 771
 	 *
772 772
 	 * @return array
773 773
 	 */
774
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
774
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
775 775
 		// Using func_get_args() in order to check for proper number of
776 776
 		// parameters and trigger errors exactly as the built-in array_column()
777 777
 		// does in PHP 5.5.
778 778
 		$argc   = func_num_args();
779 779
 		$params = func_get_args();
780 780
 
781
-		if ( $argc < 2 ) {
782
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
781
+		if ($argc < 2) {
782
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
783 783
 
784 784
 			return null;
785 785
 		}
786 786
 
787
-		if ( ! is_array( $params[0] ) ) {
788
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
787
+		if ( ! is_array($params[0])) {
788
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
789 789
 
790 790
 			return null;
791 791
 		}
792 792
 
793
-		if ( ! is_int( $params[1] )
794
-		     && ! is_float( $params[1] )
795
-		     && ! is_string( $params[1] )
793
+		if ( ! is_int($params[1])
794
+		     && ! is_float($params[1])
795
+		     && ! is_string($params[1])
796 796
 		     && $params[1] !== null
797
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
797
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
798 798
 		) {
799
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
799
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
800 800
 
801 801
 			return false;
802 802
 		}
803 803
 
804
-		if ( isset( $params[2] )
805
-		     && ! is_int( $params[2] )
806
-		     && ! is_float( $params[2] )
807
-		     && ! is_string( $params[2] )
808
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
804
+		if (isset($params[2])
805
+		     && ! is_int($params[2])
806
+		     && ! is_float($params[2])
807
+		     && ! is_string($params[2])
808
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
809 809
 		) {
810
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
810
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
811 811
 
812 812
 			return false;
813 813
 		}
814 814
 
815 815
 		$paramsInput     = $params[0];
816
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
816
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
817 817
 
818 818
 		$paramsIndexKey = null;
819
-		if ( isset( $params[2] ) ) {
820
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
819
+		if (isset($params[2])) {
820
+			if (is_float($params[2]) || is_int($params[2])) {
821 821
 				$paramsIndexKey = (int) $params[2];
822 822
 			} else {
823 823
 				$paramsIndexKey = (string) $params[2];
@@ -826,26 +826,26 @@  discard block
 block discarded – undo
826 826
 
827 827
 		$resultArray = array();
828 828
 
829
-		foreach ( $paramsInput as $row ) {
829
+		foreach ($paramsInput as $row) {
830 830
 			$key    = $value = null;
831 831
 			$keySet = $valueSet = false;
832 832
 
833
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
833
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
834 834
 				$keySet = true;
835
-				$key    = (string) $row[ $paramsIndexKey ];
835
+				$key    = (string) $row[$paramsIndexKey];
836 836
 			}
837 837
 
838
-			if ( $paramsColumnKey === null ) {
838
+			if ($paramsColumnKey === null) {
839 839
 				$valueSet = true;
840 840
 				$value    = $row;
841
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
841
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
842 842
 				$valueSet = true;
843
-				$value    = $row[ $paramsColumnKey ];
843
+				$value    = $row[$paramsColumnKey];
844 844
 			}
845 845
 
846
-			if ( $valueSet ) {
847
-				if ( $keySet ) {
848
-					$resultArray[ $key ] = $value;
846
+			if ($valueSet) {
847
+				if ($keySet) {
848
+					$resultArray[$key] = $value;
849 849
 				} else {
850 850
 					$resultArray[] = $value;
851 851
 				}
@@ -865,54 +865,54 @@  discard block
 block discarded – undo
865 865
  *
866 866
  * @return bool Whether the receipt is visible or not.
867 867
  */
868
-function give_can_view_receipt( $payment_key = '' ) {
868
+function give_can_view_receipt($payment_key = '') {
869 869
 
870 870
 	$return = false;
871 871
 
872
-	if ( empty( $payment_key ) ) {
872
+	if (empty($payment_key)) {
873 873
 		return $return;
874 874
 	}
875 875
 
876 876
 	global $give_receipt_args;
877 877
 
878
-	$give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key );
878
+	$give_receipt_args['id'] = give_get_donation_id_by_key($payment_key);
879 879
 
880
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
880
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
881 881
 
882
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
882
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
883 883
 
884
-	if ( is_user_logged_in() ) {
885
-		if ( $user_id === (int) get_current_user_id() ) {
884
+	if (is_user_logged_in()) {
885
+		if ($user_id === (int) get_current_user_id()) {
886 886
 			$return = true;
887
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
887
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
888 888
 			$return = true;
889
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
889
+		} elseif (current_user_can('view_give_sensitive_data')) {
890 890
 			$return = true;
891 891
 		}
892 892
 	}
893 893
 
894 894
 	// Check whether it is purchase session?
895 895
 	$purchase_session = give_get_purchase_session();
896
-	if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) {
897
-		if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) {
896
+	if ( ! empty($purchase_session) && ! is_user_logged_in()) {
897
+		if ($purchase_session['purchase_key'] === $payment_meta['key']) {
898 898
 			$return = true;
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Check whether it is receipt access session?
903 903
 	$receipt_session = give_get_receipt_session();
904
-	if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) {
905
-		if ( $receipt_session === $payment_meta['key'] ) {
904
+	if ( ! empty($receipt_session) && ! is_user_logged_in()) {
905
+		if ($receipt_session === $payment_meta['key']) {
906 906
 			$return = true;
907 907
 		}
908 908
 	}
909 909
 
910 910
 	// Check whether it is history access session?
911
-	if ( true === give_get_history_session() ) {
911
+	if (true === give_get_history_session()) {
912 912
 		$return = true;
913 913
 	}
914 914
 
915
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
915
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
916 916
 
917 917
 }
918 918
 
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
  *
922 922
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
923 923
  */
924
-if ( ! function_exists( 'cal_days_in_month' ) ) {
924
+if ( ! function_exists('cal_days_in_month')) {
925 925
 	/**
926 926
 	 * cal_days_in_month
927 927
 	 *
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	 *
932 932
 	 * @return bool|string
933 933
 	 */
934
-	function cal_days_in_month( $calendar, $month, $year ) {
935
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
934
+	function cal_days_in_month($calendar, $month, $year) {
935
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
936 936
 	}
937 937
 }
938 938
 
@@ -951,42 +951,42 @@  discard block
 block discarded – undo
951 951
  */
952 952
 function give_get_plugins() {
953 953
 	$plugins             = get_plugins();
954
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
954
+	$active_plugin_paths = (array) get_option('active_plugins', array());
955 955
 
956
-	if ( is_multisite() ) {
957
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
958
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
956
+	if (is_multisite()) {
957
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
958
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
959 959
 	}
960 960
 
961
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
961
+	foreach ($plugins as $plugin_path => $plugin_data) {
962 962
 		// Is plugin active?
963
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
964
-			$plugins[ $plugin_path ]['Status'] = 'active';
963
+		if (in_array($plugin_path, $active_plugin_paths)) {
964
+			$plugins[$plugin_path]['Status'] = 'active';
965 965
 		} else {
966
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
966
+			$plugins[$plugin_path]['Status'] = 'inactive';
967 967
 		}
968 968
 
969
-		$dirname = strtolower( dirname( $plugin_path ) );
969
+		$dirname = strtolower(dirname($plugin_path));
970 970
 
971 971
 		// Is plugin a Give add-on by WordImpress?
972
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
972
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
973 973
 			// Plugin is a Give-addon.
974
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
974
+			$plugins[$plugin_path]['Type'] = 'add-on';
975 975
 
976 976
 			// Get license info from database.
977
-			$plugin_name    = str_replace( 'Give - ', '', $plugin_data['Name'] );
978
-			$db_option      = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active';
979
-			$license_active = get_option( $db_option );
977
+			$plugin_name    = str_replace('Give - ', '', $plugin_data['Name']);
978
+			$db_option      = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active';
979
+			$license_active = get_option($db_option);
980 980
 
981 981
 			// Does a valid license exist?
982
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
983
-				$plugins[ $plugin_path ]['License'] = true;
982
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
983
+				$plugins[$plugin_path]['License'] = true;
984 984
 			} else {
985
-				$plugins[ $plugin_path ]['License'] = false;
985
+				$plugins[$plugin_path]['License'] = false;
986 986
 			}
987 987
 		} else {
988 988
 			// Plugin is not a Give add-on.
989
-			$plugins[ $plugin_path ]['Type'] = 'other';
989
+			$plugins[$plugin_path]['Type'] = 'other';
990 990
 		}
991 991
 	}
992 992
 
@@ -1003,16 +1003,16 @@  discard block
 block discarded – undo
1003 1003
  *
1004 1004
  * @return bool
1005 1005
  */
1006
-function give_is_terms_enabled( $form_id ) {
1007
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
1006
+function give_is_terms_enabled($form_id) {
1007
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
1008 1008
 
1009 1009
 	if (
1010
-		give_is_setting_enabled( $form_option, 'global' )
1011
-		&& give_is_setting_enabled( give_get_option( 'terms' ) )
1010
+		give_is_setting_enabled($form_option, 'global')
1011
+		&& give_is_setting_enabled(give_get_option('terms'))
1012 1012
 	) {
1013 1013
 		return true;
1014 1014
 
1015
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
1015
+	} elseif (give_is_setting_enabled($form_option)) {
1016 1016
 		return true;
1017 1017
 
1018 1018
 	} else {
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
  *
1038 1038
  * @return WP_Error|bool
1039 1039
  */
1040
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1040
+function give_delete_donation_stats($date_range = '', $args = array()) {
1041 1041
 
1042 1042
 	// Delete all cache.
1043
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1043
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1044 1044
 
1045 1045
 	/**
1046 1046
 	 * Fire the action when donation stats delete.
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 	 * @param string|array $date_range
1051 1051
 	 * @param array        $args
1052 1052
 	 */
1053
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1053
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1054 1054
 
1055 1055
 	return $status;
1056 1056
 }
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
  *
1069 1069
  * @return mixed
1070 1070
  */
1071
-function give_get_meta( $id, $meta_key, $single = false, $default = false ) {
1071
+function give_get_meta($id, $meta_key, $single = false, $default = false) {
1072 1072
 	/**
1073 1073
 	 * Filter the meta value
1074 1074
 	 *
@@ -1076,14 +1076,14 @@  discard block
 block discarded – undo
1076 1076
 	 */
1077 1077
 	$meta_value = apply_filters(
1078 1078
 		'give_get_meta',
1079
-		get_post_meta( $id, $meta_key, $single ),
1079
+		get_post_meta($id, $meta_key, $single),
1080 1080
 		$id,
1081 1081
 		$meta_key,
1082 1082
 		$default
1083 1083
 	);
1084 1084
 
1085 1085
 	if (
1086
-		( empty( $meta_key ) || empty( $meta_value ) )
1086
+		(empty($meta_key) || empty($meta_value))
1087 1087
 		&& $default
1088 1088
 	) {
1089 1089
 		$meta_value = $default;
@@ -1104,15 +1104,15 @@  discard block
 block discarded – undo
1104 1104
  *
1105 1105
  * @return mixed
1106 1106
  */
1107
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1108
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1107
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1108
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1109 1109
 
1110 1110
 	/**
1111 1111
 	 * Filter the meta value update status
1112 1112
 	 *
1113 1113
 	 * @since 1.8.8
1114 1114
 	 */
1115
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1115
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1116 1116
 }
1117 1117
 
1118 1118
 /**
@@ -1126,15 +1126,15 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return mixed
1128 1128
  */
1129
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1130
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1129
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1130
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1131 1131
 
1132 1132
 	/**
1133 1133
 	 * Filter the meta value delete status
1134 1134
 	 *
1135 1135
 	 * @since 1.8.8
1136 1136
 	 */
1137
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1137
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1138 1138
 }
1139 1139
 
1140 1140
 /**
@@ -1146,15 +1146,15 @@  discard block
 block discarded – undo
1146 1146
  *
1147 1147
  * @return bool                   If the action has been added to the completed actions array
1148 1148
  */
1149
-function give_has_upgrade_completed( $upgrade_action = '' ) {
1149
+function give_has_upgrade_completed($upgrade_action = '') {
1150 1150
 
1151
-	if ( empty( $upgrade_action ) ) {
1151
+	if (empty($upgrade_action)) {
1152 1152
 		return false;
1153 1153
 	}
1154 1154
 
1155 1155
 	$completed_upgrades = give_get_completed_upgrades();
1156 1156
 
1157
-	return in_array( $upgrade_action, $completed_upgrades );
1157
+	return in_array($upgrade_action, $completed_upgrades);
1158 1158
 
1159 1159
 }
1160 1160
 
@@ -1166,8 +1166,8 @@  discard block
 block discarded – undo
1166 1166
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
1167 1167
  */
1168 1168
 function give_maybe_resume_upgrade() {
1169
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
1170
-	if ( empty( $doing_upgrade ) ) {
1169
+	$doing_upgrade = get_option('give_doing_upgrade', false);
1170
+	if (empty($doing_upgrade)) {
1171 1171
 		return false;
1172 1172
 	}
1173 1173
 
@@ -1183,9 +1183,9 @@  discard block
 block discarded – undo
1183 1183
  *
1184 1184
  * @return bool                   If the function was successfully added
1185 1185
  */
1186
-function give_set_upgrade_complete( $upgrade_action = '' ) {
1186
+function give_set_upgrade_complete($upgrade_action = '') {
1187 1187
 
1188
-	if ( empty( $upgrade_action ) ) {
1188
+	if (empty($upgrade_action)) {
1189 1189
 		return false;
1190 1190
 	}
1191 1191
 
@@ -1193,16 +1193,16 @@  discard block
 block discarded – undo
1193 1193
 	$completed_upgrades[] = $upgrade_action;
1194 1194
 
1195 1195
 	// Remove any blanks, and only show uniques.
1196
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
1196
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
1197 1197
 
1198 1198
 	/**
1199 1199
 	 * Fire the action when any upgrade set to complete.
1200 1200
 	 *
1201 1201
 	 * @since 1.8.12
1202 1202
 	 */
1203
-	do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades );
1203
+	do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades);
1204 1204
 
1205
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
1205
+	return update_option('give_completed_upgrades', $completed_upgrades);
1206 1206
 }
1207 1207
 
1208 1208
 /**
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
  * @return array The array of completed upgrades
1213 1213
  */
1214 1214
 function give_get_completed_upgrades() {
1215
-	return (array) get_option( 'give_completed_upgrades' );
1215
+	return (array) get_option('give_completed_upgrades');
1216 1216
 }
1217 1217
 
1218 1218
 /**
@@ -1222,21 +1222,21 @@  discard block
 block discarded – undo
1222 1222
  *
1223 1223
  * @param \WP_Query
1224 1224
  */
1225
-function give_remove_pages_from_search( $query ) {
1226
-	if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
1227
-		$transaction_failed = give_get_option( 'failure_page', 0 );
1228
-		$success_page       = give_get_option( 'success_page', 0 );
1225
+function give_remove_pages_from_search($query) {
1226
+	if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) {
1227
+		$transaction_failed = give_get_option('failure_page', 0);
1228
+		$success_page       = give_get_option('success_page', 0);
1229 1229
 		$args               = apply_filters(
1230 1230
 			'give_remove_pages_from_search', array(
1231 1231
 			$transaction_failed,
1232 1232
 			$success_page,
1233 1233
 		), $query
1234 1234
 		);
1235
-		$query->set( 'post__not_in', $args );
1235
+		$query->set('post__not_in', $args);
1236 1236
 	}
1237 1237
 }
1238 1238
 
1239
-add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 );
1239
+add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1);
1240 1240
 
1241 1241
 /**
1242 1242
  * Inserts a new key/value before a key in the array.
@@ -1252,14 +1252,14 @@  discard block
 block discarded – undo
1252 1252
  *
1253 1253
  * @see   array_insert_before()
1254 1254
  */
1255
-function give_array_insert_before( $key, array &$array, $new_key, $new_value ) {
1256
-	if ( array_key_exists( $key, $array ) ) {
1255
+function give_array_insert_before($key, array &$array, $new_key, $new_value) {
1256
+	if (array_key_exists($key, $array)) {
1257 1257
 		$new = array();
1258
-		foreach ( $array as $k => $value ) {
1259
-			if ( $k === $key ) {
1260
-				$new[ $new_key ] = $new_value;
1258
+		foreach ($array as $k => $value) {
1259
+			if ($k === $key) {
1260
+				$new[$new_key] = $new_value;
1261 1261
 			}
1262
-			$new[ $k ] = $value;
1262
+			$new[$k] = $value;
1263 1263
 		}
1264 1264
 
1265 1265
 		return $new;
@@ -1282,13 +1282,13 @@  discard block
 block discarded – undo
1282 1282
  *
1283 1283
  * @see   array_insert_before()
1284 1284
  */
1285
-function give_array_insert_after( $key, array &$array, $new_key, $new_value ) {
1286
-	if ( array_key_exists( $key, $array ) ) {
1285
+function give_array_insert_after($key, array &$array, $new_key, $new_value) {
1286
+	if (array_key_exists($key, $array)) {
1287 1287
 		$new = array();
1288
-		foreach ( $array as $k => $value ) {
1289
-			$new[ $k ] = $value;
1290
-			if ( $k === $key ) {
1291
-				$new[ $new_key ] = $new_value;
1288
+		foreach ($array as $k => $value) {
1289
+			$new[$k] = $value;
1290
+			if ($k === $key) {
1291
+				$new[$new_key] = $new_value;
1292 1292
 			}
1293 1293
 		}
1294 1294
 
@@ -1315,21 +1315,21 @@  discard block
 block discarded – undo
1315 1315
  *               corresponding to `$index_key`. If `$index_key` is null, array keys from the original
1316 1316
  *               `$list` will be preserved in the results.
1317 1317
  */
1318
-function give_list_pluck( $list, $field, $index_key = null ) {
1318
+function give_list_pluck($list, $field, $index_key = null) {
1319 1319
 
1320
-	if ( ! $index_key ) {
1320
+	if ( ! $index_key) {
1321 1321
 		/**
1322 1322
 		 * This is simple. Could at some point wrap array_column()
1323 1323
 		 * if we knew we had an array of arrays.
1324 1324
 		 */
1325
-		foreach ( $list as $key => $value ) {
1326
-			if ( is_object( $value ) ) {
1327
-				if ( isset( $value->$field ) ) {
1328
-					$list[ $key ] = $value->$field;
1325
+		foreach ($list as $key => $value) {
1326
+			if (is_object($value)) {
1327
+				if (isset($value->$field)) {
1328
+					$list[$key] = $value->$field;
1329 1329
 				}
1330 1330
 			} else {
1331
-				if ( isset( $value[ $field ] ) ) {
1332
-					$list[ $key ] = $value[ $field ];
1331
+				if (isset($value[$field])) {
1332
+					$list[$key] = $value[$field];
1333 1333
 				}
1334 1334
 			}
1335 1335
 		}
@@ -1342,18 +1342,18 @@  discard block
 block discarded – undo
1342 1342
 	 * to the end of the stack. This is how array_column() behaves.
1343 1343
 	 */
1344 1344
 	$newlist = array();
1345
-	foreach ( $list as $value ) {
1346
-		if ( is_object( $value ) ) {
1347
-			if ( isset( $value->$index_key ) ) {
1348
-				$newlist[ $value->$index_key ] = $value->$field;
1345
+	foreach ($list as $value) {
1346
+		if (is_object($value)) {
1347
+			if (isset($value->$index_key)) {
1348
+				$newlist[$value->$index_key] = $value->$field;
1349 1349
 			} else {
1350 1350
 				$newlist[] = $value->$field;
1351 1351
 			}
1352 1352
 		} else {
1353
-			if ( isset( $value[ $index_key ] ) ) {
1354
-				$newlist[ $value[ $index_key ] ] = $value[ $field ];
1353
+			if (isset($value[$index_key])) {
1354
+				$newlist[$value[$index_key]] = $value[$field];
1355 1355
 			} else {
1356
-				$newlist[] = $value[ $field ];
1356
+				$newlist[] = $value[$field];
1357 1357
 			}
1358 1358
 		}
1359 1359
 	}
@@ -1376,8 +1376,8 @@  discard block
 block discarded – undo
1376 1376
  *
1377 1377
  * @return int|false Meta ID on success, false on failure.
1378 1378
  */
1379
-function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) {
1380
-	return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique );
1379
+function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) {
1380
+	return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique);
1381 1381
 }
1382 1382
 
1383 1383
 /**
@@ -1395,8 +1395,8 @@  discard block
 block discarded – undo
1395 1395
  *
1396 1396
  * @return bool True on success, false on failure.
1397 1397
  */
1398
-function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) {
1399
-	return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value );
1398
+function delete_donor_meta($donor_id, $meta_key, $meta_value = '') {
1399
+	return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value);
1400 1400
 }
1401 1401
 
1402 1402
 /**
@@ -1411,8 +1411,8 @@  discard block
 block discarded – undo
1411 1411
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1412 1412
  *  is true.
1413 1413
  */
1414
-function get_donor_meta( $donor_id, $key = '', $single = false ) {
1415
-	return get_metadata( 'give_customer', $donor_id, $key, $single );
1414
+function get_donor_meta($donor_id, $key = '', $single = false) {
1415
+	return get_metadata('give_customer', $donor_id, $key, $single);
1416 1416
 }
1417 1417
 
1418 1418
 /**
@@ -1429,8 +1429,8 @@  discard block
 block discarded – undo
1429 1429
  *
1430 1430
  * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
1431 1431
  */
1432
-function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) {
1433
-	return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value );
1432
+function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') {
1433
+	return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value);
1434 1434
 }
1435 1435
 
1436 1436
 /*
@@ -1440,15 +1440,15 @@  discard block
 block discarded – undo
1440 1440
  *
1441 1441
  * @param int $form_id Form id of which recalculation needs to be done.
1442 1442
  */
1443
-function give_recount_form_income_donation( $form_id = false ) {
1443
+function give_recount_form_income_donation($form_id = false) {
1444 1444
 	// Check if form id is not empty.
1445
-	if ( ! empty( $form_id ) ) {
1445
+	if ( ! empty($form_id)) {
1446 1446
 		/**
1447 1447
 		 * Filter to modify payment status.
1448 1448
 		 *
1449 1449
 		 * @since 1.8.13
1450 1450
 		 */
1451
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
1451
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
1452 1452
 
1453 1453
 		/**
1454 1454
 		 * Filter to modify args of payment query before recalculating the form total
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 			'give_recount_form_stats_args', array(
1460 1460
 				'give_forms'     => $form_id,
1461 1461
 				'status'         => $accepted_statuses,
1462
-				'posts_per_page' => - 1,
1462
+				'posts_per_page' => -1,
1463 1463
 				'fields'         => 'ids',
1464 1464
 			)
1465 1465
 		);
@@ -1469,28 +1469,28 @@  discard block
 block discarded – undo
1469 1469
 			'earnings' => 0,
1470 1470
 		);
1471 1471
 
1472
-		$payments = new Give_Payments_Query( $args );
1472
+		$payments = new Give_Payments_Query($args);
1473 1473
 		$payments = $payments->get_payments();
1474 1474
 
1475
-		if ( $payments ) {
1476
-			foreach ( $payments as $payment ) {
1475
+		if ($payments) {
1476
+			foreach ($payments as $payment) {
1477 1477
 				// Ensure acceptible status only
1478
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
1478
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
1479 1479
 					continue;
1480 1480
 				}
1481 1481
 
1482 1482
 				// Ensure only payments for this form are counted
1483
-				if ( $payment->form_id != $form_id ) {
1483
+				if ($payment->form_id != $form_id) {
1484 1484
 					continue;
1485 1485
 				}
1486 1486
 
1487
-				$totals['sales'] ++;
1487
+				$totals['sales']++;
1488 1488
 				$totals['earnings'] += $payment->total;
1489 1489
 
1490 1490
 			}
1491 1491
 		}
1492
-		give_update_meta( $form_id, '_give_form_sales', $totals['sales'] );
1493
-		give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
1492
+		give_update_meta($form_id, '_give_form_sales', $totals['sales']);
1493
+		give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
1494 1494
 	}// End if().
1495 1495
 }
1496 1496
 
@@ -1503,18 +1503,18 @@  discard block
 block discarded – undo
1503 1503
  *
1504 1504
  * @return string
1505 1505
  */
1506
-function give_get_attribute_str( $attributes ) {
1506
+function give_get_attribute_str($attributes) {
1507 1507
 	$attribute_str = '';
1508 1508
 
1509
-	if ( empty( $attributes ) ) {
1509
+	if (empty($attributes)) {
1510 1510
 		return $attribute_str;
1511 1511
 	}
1512 1512
 
1513
-	foreach ( $attributes as $tag => $value ) {
1513
+	foreach ($attributes as $tag => $value) {
1514 1514
 		$attribute_str .= " {$tag}=\"{$value}\"";
1515 1515
 	}
1516 1516
 
1517
-	return trim( $attribute_str );
1517
+	return trim($attribute_str);
1518 1518
 }
1519 1519
 
1520 1520
 /**
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 function give_get_wp_upload_dir() {
1528 1528
 	$wp_upload_dir = wp_upload_dir();
1529 1529
 
1530
-	return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false );
1530
+	return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false);
1531 1531
 }
1532 1532
 
1533 1533
 /**
@@ -1539,15 +1539,15 @@  discard block
 block discarded – undo
1539 1539
  *
1540 1540
  * @return string/bool $file_contents File content
1541 1541
  */
1542
-function give_get_core_settings_json( $file_name ) {
1542
+function give_get_core_settings_json($file_name) {
1543 1543
 	$upload_dir = give_get_wp_upload_dir();
1544
-	$file_path  = $upload_dir . '/' . $file_name;
1544
+	$file_path  = $upload_dir.'/'.$file_name;
1545 1545
 
1546
-	if ( is_wp_error( $file_path ) || empty( $file_path ) ) {
1547
-		Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) );
1546
+	if (is_wp_error($file_path) || empty($file_path)) {
1547
+		Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give'));
1548 1548
 	}
1549 1549
 
1550
-	$file_contents = file_get_contents( $file_path );
1550
+	$file_contents = file_get_contents($file_path);
1551 1551
 
1552 1552
 	return $file_contents;
1553 1553
 }
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
  * @return int $country The two letter country code for the site's base country
1561 1561
  */
1562 1562
 function give_get_limit_display_donations() {
1563
-	return give_get_option( 'limit_display_donations', 1 );
1563
+	return give_get_option('limit_display_donations', 1);
1564 1564
 }
1565 1565
 
1566 1566
 /**
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
  * @since 1.8.17
1570 1570
  */
1571 1571
 function give_donation_history_table_end() {
1572
-	$email = Give()->session->get( 'give_email' );
1572
+	$email = Give()->session->get('give_email');
1573 1573
 	?>
1574 1574
 	<tfoot>
1575 1575
 	<tr>
@@ -1578,16 +1578,16 @@  discard block
 block discarded – undo
1578 1578
 				<div class="give-security-column give-security-description-wrap">
1579 1579
 					<?php
1580 1580
 					echo sprintf(
1581
-						__( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ),
1581
+						__('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'),
1582 1582
 						$email
1583 1583
 					);
1584 1584
 					?>
1585 1585
 				</div>
1586 1586
 				<div class="give-security-column give-security-button-wrap">
1587 1587
 					<a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn" class="give-confirm-email-btn give-btn">
1588
-						<?php _e( 'Confirm Email', 'give' ); ?>
1588
+						<?php _e('Confirm Email', 'give'); ?>
1589 1589
 					</a>
1590
-					<span><?php _e( 'Email Sent!', 'give' ); ?></span>
1590
+					<span><?php _e('Email Sent!', 'give'); ?></span>
1591 1591
 				</div>
1592 1592
 			</div>
1593 1593
 		</td>
@@ -1607,10 +1607,10 @@  discard block
 block discarded – undo
1607 1607
  *
1608 1608
  * @return void
1609 1609
  */
1610
-function give_doing_it_wrong( $function, $message, $version ) {
1611
-	$message .= "\nBacktrace:" . wp_debug_backtrace_summary();
1610
+function give_doing_it_wrong($function, $message, $version) {
1611
+	$message .= "\nBacktrace:".wp_debug_backtrace_summary();
1612 1612
 
1613
-	_doing_it_wrong( $function, $message , $version );
1613
+	_doing_it_wrong($function, $message, $version);
1614 1614
 }
1615 1615
 
1616 1616
 
@@ -1619,10 +1619,10 @@  discard block
 block discarded – undo
1619 1619
  *
1620 1620
  * @since 1.8.18
1621 1621
  */
1622
-function give_ignore_user_abort(){
1623
-	ignore_user_abort( true );
1622
+function give_ignore_user_abort() {
1623
+	ignore_user_abort(true);
1624 1624
 
1625
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
1626
-		set_time_limit( 0 );
1625
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
1626
+		set_time_limit(0);
1627 1627
 	}
1628 1628
 }
1629 1629
\ No newline at end of file
Please login to merge, or discard this patch.