Test Failed
Push — master ( 1d3b59...426730 )
by Devin
01:16
created
includes/payments/actions.php 1 patch
Spacing   +106 added lines, -110 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221
-		foreach ( $payments as $payment ) {
222
-			$gateway = give_get_payment_gateway( $payment );
221
+		foreach ($payments as $payment) {
222
+			$gateway = give_get_payment_gateway($payment);
223 223
 
224 224
 			// Skip payment gateways.
225
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
225
+			if (in_array($gateway, $skip_payment_gateways)) {
226 226
 				continue;
227 227
 			}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 }
234 234
 
235
-Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' );
235
+Give_Cron::add_weekly_event('give_mark_abandoned_donations');
236 236
 
237 237
 
238 238
 /**
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return void
246 246
  */
247
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
247
+function give_refresh_thismonth_stat_transients($payment_ID) {
248 248
 	// Monthly stats.
249
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
249
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
250 250
 
251 251
 	// @todo: Refresh only range related stat cache
252 252
 	give_delete_donation_stats();
253 253
 }
254 254
 
255
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
255
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
256 256
 
257 257
 
258 258
 /**
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return array
270 270
  */
271
-function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) {
271
+function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) {
272 272
 	// Bailout.
273 273
 	if (
274
-		'give_payment' !== get_post_type( $object_id ) ||
274
+		'give_payment' !== get_post_type($object_id) ||
275 275
 		'_give_payment_meta' !== $meta_key ||
276
-		! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' )
276
+		! give_has_upgrade_completed('v20_upgrades_payment_metadata')
277 277
 	) {
278 278
 		return $check;
279 279
 	}
@@ -281,73 +281,69 @@  discard block
 block discarded – undo
281 281
 	$cache_key = "_give_payment_meta_{$object_id}";
282 282
 
283 283
 	// Get already calculate payment meta from cache.
284
-	$payment_meta = Give_Cache::get_db_query( $cache_key );
284
+	$payment_meta = Give_Cache::get_db_query($cache_key);
285 285
 
286
-	if ( is_null( $payment_meta ) ) {
286
+	if (is_null($payment_meta)) {
287 287
 		// Remove filter.
288
-		remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 );
288
+		remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999);
289 289
 
290
-		$donation = new Give_Payment( $object_id );
290
+		$donation = new Give_Payment($object_id);
291 291
 
292 292
 		// Get all payment meta.
293
-		$payment_meta = give_get_meta( $object_id );
293
+		$payment_meta = give_get_meta($object_id);
294 294
 
295 295
 		// Set default value to array.
296
-		if ( empty( $payment_meta ) ) {
296
+		if (empty($payment_meta)) {
297 297
 			return $check;
298 298
 		}
299 299
 
300 300
 		// Convert all meta key value to string instead of array
301
-		array_walk( $payment_meta, function ( &$meta, $key ) {
302
-			$meta = current( $meta );
301
+		array_walk($payment_meta, function(&$meta, $key) {
302
+			$meta = current($meta);
303 303
 		} );
304 304
 
305 305
 		/**
306 306
 		 * Add backward compatibility to old meta keys.
307 307
 		 */
308 308
 		// Donation key.
309
-		$payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : '';
309
+		$payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : '';
310 310
 
311 311
 		// Donation form.
312
-		$payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : '';
312
+		$payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : '';
313 313
 
314 314
 		// Donor email.
315
-		$payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : '';
316
-		$payment_meta['email'] = ! empty( $payment_meta['email'] ) ?
317
-			$payment_meta['email'] :
318
-			Give()->donors->get_column( 'email', $donation->donor_id );
315
+		$payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : '';
316
+		$payment_meta['email'] = ! empty($payment_meta['email']) ?
317
+			$payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id);
319 318
 
320 319
 		// Form id.
321
-		$payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : '';
320
+		$payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : '';
322 321
 
323 322
 		// Price id.
324
-		$payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : '';
323
+		$payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : '';
325 324
 
326 325
 		// Date.
327
-		$payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : '';
328
-		$payment_meta['date'] = ! empty( $payment_meta['date'] ) ?
329
-			$payment_meta['date'] :
330
-			get_post_field( 'post_date', $object_id );
326
+		$payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : '';
327
+		$payment_meta['date'] = ! empty($payment_meta['date']) ?
328
+			$payment_meta['date'] : get_post_field('post_date', $object_id);
331 329
 
332 330
 
333 331
 		// Currency.
334
-		$payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : '';
332
+		$payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : '';
335 333
 
336 334
 		// Decode donor data.
337
-		$donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0;
338
-		$donor    = new Give_Donor( $donor_id );
335
+		$donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0;
336
+		$donor    = new Give_Donor($donor_id);
339 337
 
340 338
 		// Donor first name.
341
-		$donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : '';
342
-		$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
343
-			$donor_data['first_name'] :
344
-			$donor->get_first_name();
339
+		$donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : '';
340
+		$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
341
+			$donor_data['first_name'] : $donor->get_first_name();
345 342
 
346 343
 		// Donor last name.
347
-		$donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : '';
348
-		$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
349
-			$donor_data['last_name'] :
350
-			$donor->get_last_name();
344
+		$donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : '';
345
+		$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
346
+			$donor_data['last_name'] : $donor->get_last_name();
351 347
 
352 348
 		// Donor email.
353 349
 		$donor_data['email'] = $payment_meta['email'];
@@ -358,63 +354,63 @@  discard block
 block discarded – undo
358 354
 		$donor_data['address'] = false;
359 355
 
360 356
 		// Address1.
361
-		$address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : '';
362
-		if ( $address1 ) {
357
+		$address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : '';
358
+		if ($address1) {
363 359
 			$donor_data['address']['line1'] = $address1;
364 360
 		}
365 361
 
366 362
 		// Address2.
367
-		$address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : '';
368
-		if ( $address2 ) {
363
+		$address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : '';
364
+		if ($address2) {
369 365
 			$donor_data['address']['line2'] = $address2;
370 366
 		}
371 367
 
372 368
 		// City.
373
-		$city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : '';
374
-		if ( $city ) {
369
+		$city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : '';
370
+		if ($city) {
375 371
 			$donor_data['address']['city'] = $city;
376 372
 		}
377 373
 
378 374
 		// Zip.
379
-		$zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : '';
380
-		if ( $zip ) {
375
+		$zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : '';
376
+		if ($zip) {
381 377
 			$donor_data['address']['zip'] = $zip;
382 378
 		}
383 379
 
384 380
 		// State.
385
-		$state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : '';
386
-		if ( $state ) {
381
+		$state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : '';
382
+		if ($state) {
387 383
 			$donor_data['address']['state'] = $state;
388 384
 		}
389 385
 
390 386
 		// Country.
391
-		$country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : '';
392
-		if ( $country ) {
387
+		$country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : '';
388
+		if ($country) {
393 389
 			$donor_data['address']['country'] = $country;
394 390
 		}
395 391
 
396 392
 		$payment_meta['user_info'] = $donor_data;
397 393
 
398 394
 		// Add filter
399
-		add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
395
+		add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
400 396
 
401 397
 		// Set custom meta key into payment meta.
402
-		if ( ! empty( $payment_meta['_give_payment_meta'] ) ) {
403
-			$payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta );
398
+		if ( ! empty($payment_meta['_give_payment_meta'])) {
399
+			$payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta);
404 400
 		}
405 401
 
406 402
 		// Set cache.
407
-		Give_Cache::set_db_query( $cache_key, $payment_meta );
403
+		Give_Cache::set_db_query($cache_key, $payment_meta);
408 404
 	}
409 405
 
410
-	if ( $single ) {
406
+	if ($single) {
411 407
 		/**
412 408
 		 * Filter the payment meta
413 409
 		 * Add custom meta key to payment meta
414 410
 		 *
415 411
 		 * @since 2.0
416 412
 		 */
417
-		$new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key );
413
+		$new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key);
418 414
 
419 415
 		$payment_meta = $new_payment_meta;
420 416
 	}
@@ -422,7 +418,7 @@  discard block
 block discarded – undo
422 418
 	return $payment_meta;
423 419
 }
424 420
 
425
-add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
421
+add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
426 422
 
427 423
 /**
428 424
  * Add meta in payment that store page id and page url.
@@ -434,19 +430,19 @@  discard block
 block discarded – undo
434 430
  *
435 431
  * @param int $payment_id Payment id for which the meta value should be updated.
436 432
  */
437
-function give_payment_save_page_data( $payment_id ) {
438
-	$page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false );
433
+function give_payment_save_page_data($payment_id) {
434
+	$page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false);
439 435
 
440 436
 	// Check $page_url is not empty.
441
-	if ( $page_url ) {
442
-		update_post_meta( $payment_id, '_give_current_url', $page_url );
443
-		$page_id = url_to_postid( $page_url );
437
+	if ($page_url) {
438
+		update_post_meta($payment_id, '_give_current_url', $page_url);
439
+		$page_id = url_to_postid($page_url);
444 440
 		// Check $page_id is not empty.
445
-		if ( $page_id ) {
446
-			update_post_meta( $payment_id, '_give_current_page_id', $page_id );
441
+		if ($page_id) {
442
+			update_post_meta($payment_id, '_give_current_page_id', $page_id);
447 443
 		}
448 444
 	}
449 445
 }
450 446
 
451 447
 // Fire when payment is save.
452
-add_action( 'give_insert_payment', 'give_payment_save_page_data' );
453 448
\ No newline at end of file
449
+add_action('give_insert_payment', 'give_payment_save_page_data');
454 450
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-db-payment-meta.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta';
53
+		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return bool
116 116
 	 */
117
-	protected function is_valid_post_type( $ID ) {
117
+	protected function is_valid_post_type($ID) {
118 118
 		return $ID && true;
119 119
 	}
120 120
 }
Please login to merge, or discard this patch.
includes/class-give-background-updater.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @category Class
12 12
  * @author   WordImpress
13 13
  */
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	 * and data exists in the queue.
55 55
 	 */
56 56
 	public function handle_cron_healthcheck() {
57
-		if ( $this->is_process_running() || $this->is_paused_process()  ) {
57
+		if ($this->is_process_running() || $this->is_paused_process()) {
58 58
 			// Background process already running.
59 59
 			return;
60 60
 		}
61 61
 
62
-		if ( $this->is_queue_empty() ) {
62
+		if ($this->is_queue_empty()) {
63 63
 			// No data to process.
64 64
 			$this->clear_scheduled_event();
65 65
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * Schedule fallback event.
74 74
 	 */
75 75
 	protected function schedule_event() {
76
-		if ( ! wp_next_scheduled( $this->cron_hook_identifier ) && ! $this->is_paused_process() ) {
77
-			wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier );
76
+		if ( ! wp_next_scheduled($this->cron_hook_identifier) && ! $this->is_paused_process()) {
77
+			wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier);
78 78
 		}
79 79
 	}
80 80
 
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return mixed
92 92
 	 */
93
-	protected function task( $update ) {
93
+	protected function task($update) {
94 94
 		// Pause upgrade immediately if admin pausing upgrades.
95
-		if( $this->is_paused_process() ) {
95
+		if ($this->is_paused_process()) {
96 96
 			wp_die();
97 97
 		}
98 98
 
99
-		if ( empty( $update ) ) {
99
+		if (empty($update)) {
100 100
 			return false;
101 101
 		}
102 102
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 				'update_info' => $update,
111 111
 				'step'        => 1,
112 112
 				'update'      => 1,
113
-				'heading'     => sprintf( 'Update %s of {update_count}', 1 ),
113
+				'heading'     => sprintf('Update %s of {update_count}', 1),
114 114
 				'percentage'  => $give_updates->percentage,
115 115
 			)
116 116
 		);
@@ -118,22 +118,22 @@  discard block
 block discarded – undo
118 118
 		// Continuously skip update if previous update does not complete yet.
119 119
 		if (
120 120
 			$resume_update['update_info']['id'] !== $update['id'] &&
121
-			! give_has_upgrade_completed( $resume_update['update_info']['id'] )
121
+			! give_has_upgrade_completed($resume_update['update_info']['id'])
122 122
 		) {
123 123
 			return $update;
124 124
 		}
125 125
 
126 126
 		// Set params.
127 127
 		$resume_update['update_info'] = $update;
128
-		$give_updates->step           = absint( $resume_update['step'] );
129
-		$give_updates->update         = absint( $resume_update['update'] );
130
-		$is_parent_update_completed   = $give_updates->is_parent_updates_completed( $update );
128
+		$give_updates->step           = absint($resume_update['step']);
129
+		$give_updates->update         = absint($resume_update['update']);
130
+		$is_parent_update_completed   = $give_updates->is_parent_updates_completed($update);
131 131
 
132 132
 
133 133
 		// Skip update if dependency update does not complete yet.
134
-		if ( empty( $is_parent_update_completed ) ) {
134
+		if (empty($is_parent_update_completed)) {
135 135
 			// @todo: set error when you have only one update with invalid dependency
136
-			if ( ! is_null( $is_parent_update_completed ) ) {
136
+			if ( ! is_null($is_parent_update_completed)) {
137 137
 				return $update;
138 138
 			}
139 139
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		Give_Cache::disable();
145 145
 
146 146
 		// Run update.
147
-		if ( is_array( $update['callback'] ) ) {
147
+		if (is_array($update['callback'])) {
148 148
 			$update['callback'][0]->$update['callback'][1]();
149 149
 		} else {
150 150
 			$update['callback']();
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 		// Set update info.
154 154
 		$doing_upgrade_args = array(
155 155
 			'update_info'      => $update,
156
-			'step'             => ++ $give_updates->step,
156
+			'step'             => ++$give_updates->step,
157 157
 			'update'           => $give_updates->update,
158
-			'heading'          => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ),
158
+			'heading'          => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')),
159 159
 			'percentage'       => $give_updates->percentage,
160 160
 			'total_percentage' => $give_updates->get_db_update_processing_percentage(),
161 161
 		);
162 162
 
163 163
 		// Cache upgrade.
164
-		update_option( 'give_doing_upgrade', $doing_upgrade_args );
164
+		update_option('give_doing_upgrade', $doing_upgrade_args);
165 165
 
166 166
 		// Enable cache.
167 167
 		Give_Cache::enable();
168 168
 
169 169
 		// Check if current update completed or not.
170
-		if ( give_has_upgrade_completed( $update['id'] ) ) {
170
+		if (give_has_upgrade_completed($update['id'])) {
171 171
 			return false;
172 172
 		}
173 173
 
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
 	 * performed, or, call parent::complete().
182 182
 	 */
183 183
 	protected function complete() {
184
-		if( $this->is_paused_process() ) {
184
+		if ($this->is_paused_process()) {
185 185
 			return false;
186 186
 		}
187 187
 
188 188
 		parent::complete();
189 189
 
190
-		delete_option( 'give_db_update_count' );
191
-		delete_option( 'give_doing_upgrade' );
192
-		add_option( 'give_show_db_upgrade_complete_notice', 1, '', 'no' );
190
+		delete_option('give_db_update_count');
191
+		delete_option('give_doing_upgrade');
192
+		add_option('give_show_db_upgrade_complete_notice', 1, '', 'no');
193 193
 
194 194
 		// Flush cache.
195 195
 		Give_Cache::get_instance()->flush_cache();
196 196
 
197
-		if( $cache_keys = Give_Cache::get_options_like('') ) {
198
-			Give_Cache::delete( $cache_keys );
197
+		if ($cache_keys = Give_Cache::get_options_like('')) {
198
+			Give_Cache::delete($cache_keys);
199 199
 		}
200 200
 	}
201 201
 
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
 	 * @return int
206 206
 	 */
207 207
 	protected function get_memory_limit() {
208
-		if ( function_exists( 'ini_get' ) ) {
209
-			$memory_limit = ini_get( 'memory_limit' );
208
+		if (function_exists('ini_get')) {
209
+			$memory_limit = ini_get('memory_limit');
210 210
 		} else {
211 211
 			// Sensible default.
212 212
 			$memory_limit = '128M';
213 213
 		}
214 214
 
215
-		if ( ! $memory_limit || '-1' === $memory_limit ) {
215
+		if ( ! $memory_limit || '-1' === $memory_limit) {
216 216
 			// Unlimited, set to 32GB.
217 217
 			$memory_limit = '32000M';
218 218
 		}
219 219
 
220
-		return intval( $memory_limit ) * 1024 * 1024;
220
+		return intval($memory_limit) * 1024 * 1024;
221 221
 	}
222 222
 
223 223
 	/**
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		// Don't lock up other requests while processing
231 231
 		session_write_close();
232 232
 
233
-		if ( $this->is_process_running() || $this->is_paused_process() ) {
233
+		if ($this->is_process_running() || $this->is_paused_process()) {
234 234
 			// Background process already running.
235 235
 			wp_die();
236 236
 		}
237 237
 
238
-		if ( $this->is_queue_empty() ) {
238
+		if ($this->is_queue_empty()) {
239 239
 			// No data to process.
240 240
 			wp_die();
241 241
 		}
242 242
 
243
-		check_ajax_referer( $this->identifier, 'nonce' );
243
+		check_ajax_referer($this->identifier, 'nonce');
244 244
 
245 245
 		$this->handle();
246 246
 
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 	 * @access public
256 256
 	 * @return bool
257 257
 	 */
258
-	public function is_paused_process(){
258
+	public function is_paused_process() {
259 259
 		// Not using get_option because i am facing some caching releated issue.
260 260
 		global $wpdb;
261 261
 
262
-		$options = $wpdb->get_results( "SELECT * FROM $wpdb->options WHERE option_name='give_paused_batches' LIMIT 1" );
262
+		$options = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name='give_paused_batches' LIMIT 1");
263 263
 
264
-		return ! empty( $options );
264
+		return ! empty($options);
265 265
 	}
266 266
 
267 267
 
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly.
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	 * @param callable $func        Hook to run when email tag is found
57 57
 	 * @param string   $context     Email tag category
58 58
 	 */
59
-	public function add( $tag, $description, $func, $context = '' ) {
60
-		if ( is_callable( $func ) ) {
61
-			$this->tags[ $tag ] = array(
59
+	public function add($tag, $description, $func, $context = '') {
60
+		if (is_callable($func)) {
61
+			$this->tags[$tag] = array(
62 62
 				'tag'         => $tag,
63 63
 				'description' => $description,
64 64
 				'func'        => $func,
65
-				'context'     => give_check_variable( $context, 'empty', 'general' ),
65
+				'context'     => give_check_variable($context, 'empty', 'general'),
66 66
 			);
67 67
 		}
68 68
 	}
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param string $tag Email tag to remove hook from
76 76
 	 */
77
-	public function remove( $tag ) {
78
-		unset( $this->tags[ $tag ] );
77
+	public function remove($tag) {
78
+		unset($this->tags[$tag]);
79 79
 	}
80 80
 
81 81
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return bool
89 89
 	 */
90
-	public function email_tag_exists( $tag ) {
91
-		return array_key_exists( $tag, $this->tags );
90
+	public function email_tag_exists($tag) {
91
+		return array_key_exists($tag, $this->tags);
92 92
 	}
93 93
 
94 94
 	/**
@@ -102,23 +102,23 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array
104 104
 	 */
105
-	public function get_tags( $context_type = 'all', $field = '' ) {
105
+	public function get_tags($context_type = 'all', $field = '') {
106 106
 		$tags = $this->tags;
107 107
 
108
-		if ( 'all' !== $context_type ) {
108
+		if ('all' !== $context_type) {
109 109
 			$tags = array();
110 110
 
111
-			foreach ( $this->tags as $tag ) {
112
-				if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) {
111
+			foreach ($this->tags as $tag) {
112
+				if (empty($tag['context']) || $context_type !== $tag['context']) {
113 113
 					continue;
114 114
 				}
115 115
 
116
-				$tags[ $tag['tag'] ] = $tag;
116
+				$tags[$tag['tag']] = $tag;
117 117
 			}
118 118
 		}
119 119
 
120
-		if ( ! empty( $tags ) && ! empty( $field ) ) {
121
-			$tags = wp_list_pluck( $tags, $field );
120
+		if ( ! empty($tags) && ! empty($field)) {
121
+			$tags = wp_list_pluck($tags, $field);
122 122
 		}
123 123
 
124 124
 		return $tags;
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return string Content with email tags filtered out.
138 138
 	 */
139
-	public function do_tags( $content, $tag_args ) {
139
+	public function do_tags($content, $tag_args) {
140 140
 
141 141
 		// Check if there is at least one tag added.
142
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
142
+		if (empty($this->tags) || ! is_array($this->tags)) {
143 143
 			return $content;
144 144
 		}
145 145
 
146 146
 		$this->tag_args = $tag_args;
147 147
 
148
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
148
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
149 149
 
150 150
 		$this->tag_args = null;
151 151
 
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return mixed
163 163
 	 */
164
-	public function do_tag( $m ) {
164
+	public function do_tag($m) {
165 165
 
166 166
 		// Get tag
167 167
 		$tag = $m[1];
168 168
 
169 169
 		// Return tag if tag not set
170
-		if ( ! $this->email_tag_exists( $tag ) ) {
170
+		if ( ! $this->email_tag_exists($tag)) {
171 171
 			return $m[0];
172 172
 		}
173 173
 
174
-		return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag );
174
+		return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag);
175 175
 	}
176 176
 
177 177
 }
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
  * @param callable $func        Hook to run when email tag is found
187 187
  * @param string   $context     Email tag category
188 188
  */
189
-function give_add_email_tag( $tag, $description, $func, $context = '' ) {
190
-	Give()->email_tags->add( $tag, $description, $func, $context );
189
+function give_add_email_tag($tag, $description, $func, $context = '') {
190
+	Give()->email_tags->add($tag, $description, $func, $context);
191 191
 }
192 192
 
193 193
 /**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
  *
198 198
  * @param string $tag Email tag to remove hook from
199 199
  */
200
-function give_remove_email_tag( $tag ) {
201
-	Give()->email_tags->remove( $tag );
200
+function give_remove_email_tag($tag) {
201
+	Give()->email_tags->remove($tag);
202 202
 }
203 203
 
204 204
 /**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return bool
212 212
  */
213
-function give_email_tag_exists( $tag ) {
214
-	return Give()->email_tags->email_tag_exists( $tag );
213
+function give_email_tag_exists($tag) {
214
+	return Give()->email_tags->email_tag_exists($tag);
215 215
 }
216 216
 
217 217
 /**
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	$email_tags = give_get_email_tags();
239 239
 
240 240
 	ob_start();
241
-	if ( count( $email_tags ) > 0 ) : ?>
241
+	if (count($email_tags) > 0) : ?>
242 242
 		<div class="give-email-tags-wrap">
243
-			<?php foreach ( $email_tags as $email_tag ) : ?>
243
+			<?php foreach ($email_tags as $email_tag) : ?>
244 244
 				<span class="give_<?php echo $email_tag['tag']; ?>_tag">
245 245
 					<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
246 246
 				</span>
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @return string Content with email tags filtered out.
266 266
  */
267
-function give_do_email_tags( $content, $tag_args ) {
267
+function give_do_email_tags($content, $tag_args) {
268 268
 	// Backward compatibility < 2.0
269
-	if ( ! is_array( $tag_args ) ) {
270
-		$tag_args = array( 'payment_id' => $tag_args );
269
+	if ( ! is_array($tag_args)) {
270
+		$tag_args = array('payment_id' => $tag_args);
271 271
 	}
272 272
 
273 273
 	// Replace all tags
274
-	$content = Give()->email_tags->do_tags( $content, $tag_args );
274
+	$content = Give()->email_tags->do_tags($content, $tag_args);
275 275
 
276 276
 	/**
277 277
 	 * Filter the filtered content text.
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @since 1.0
280 280
 	 * @since 2.0 $payment_meta, $payment_id removed and $tag_args added.
281 281
 	 */
282
-	$content = apply_filters( 'give_email_template_tags', $content, $tag_args );
282
+	$content = apply_filters('give_email_template_tags', $content, $tag_args);
283 283
 
284 284
 	// Return content
285 285
 	return $content;
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @since 1.0
300 300
 	 */
301
-	do_action( 'give_add_email_tags' );
301
+	do_action('give_add_email_tags');
302 302
 }
303 303
 
304
-add_action( 'init', 'give_load_email_tags', - 999 );
304
+add_action('init', 'give_load_email_tags', - 999);
305 305
 
306 306
 
307 307
 /**
@@ -316,67 +316,67 @@  discard block
 block discarded – undo
316 316
 		/*	Donation Payment */
317 317
 		array(
318 318
 			'tag'         => 'donation',
319
-			'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ),
319
+			'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'),
320 320
 			'function'    => 'give_email_tag_donation',
321 321
 			'context'     => 'donation',
322 322
 		),
323 323
 		array(
324 324
 			'tag'         => 'amount',
325
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
325
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
326 326
 			'function'    => 'give_email_tag_amount',
327 327
 			'context'     => 'donation',
328 328
 		),
329 329
 		array(
330 330
 			'tag'         => 'price',
331
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
331
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
332 332
 			'function'    => 'give_email_tag_price',
333 333
 			'context'     => 'donation',
334 334
 		),
335 335
 		array(
336 336
 			'tag'         => 'billing_address',
337
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
337
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
338 338
 			'function'    => 'give_email_tag_billing_address',
339 339
 			'context'     => 'donation',
340 340
 		),
341 341
 		array(
342 342
 			'tag'         => 'date',
343
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
343
+			'description' => esc_html__('The date of the donation.', 'give'),
344 344
 			'function'    => 'give_email_tag_date',
345 345
 			'context'     => 'donation',
346 346
 		),
347 347
 		array(
348 348
 			'tag'         => 'payment_id',
349
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
349
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
350 350
 			'function'    => 'give_email_tag_payment_id',
351 351
 			'context'     => 'donation',
352 352
 		),
353 353
 		array(
354 354
 			'tag'         => 'payment_method',
355
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
355
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
356 356
 			'function'    => 'give_email_tag_payment_method',
357 357
 			'context'     => 'donation',
358 358
 		),
359 359
 		array(
360 360
 			'tag'         => 'payment_total',
361
-			'description' => esc_html__( 'The payment total for this donation.', 'give' ),
361
+			'description' => esc_html__('The payment total for this donation.', 'give'),
362 362
 			'function'    => 'give_email_tag_payment_total',
363 363
 			'context'     => 'donation',
364 364
 		),
365 365
 		array(
366 366
 			'tag'         => 'receipt_id',
367
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
367
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
368 368
 			'function'    => 'give_email_tag_receipt_id',
369 369
 			'context'     => 'donation',
370 370
 		),
371 371
 		array(
372 372
 			'tag'         => 'receipt_link',
373
-			'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ),
373
+			'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'),
374 374
 			'function'    => 'give_email_tag_receipt_link',
375 375
 			'context'     => 'donation',
376 376
 		),
377 377
 		array(
378 378
 			'tag'         => 'receipt_link_url',
379
-			'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ),
379
+			'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'),
380 380
 			'function'    => 'give_email_tag_receipt_link_url',
381 381
 			'context'     => 'donation',
382 382
 		),
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		/* Donation Form */
385 385
 		array(
386 386
 			'tag'         => 'form_title',
387
-			'description' => esc_html__( 'The donation form name.', 'give' ),
387
+			'description' => esc_html__('The donation form name.', 'give'),
388 388
 			'function'    => 'give_email_tag_form_title',
389 389
 			'context'     => 'form',
390 390
 		),
@@ -392,31 +392,31 @@  discard block
 block discarded – undo
392 392
 		/* Donor */
393 393
 		array(
394 394
 			'tag'         => 'name',
395
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
395
+			'description' => esc_html__('The donor\'s first name.', 'give'),
396 396
 			'function'    => 'give_email_tag_first_name',
397 397
 			'context'     => 'donor',
398 398
 		),
399 399
 		array(
400 400
 			'tag'         => 'fullname',
401
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
401
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
402 402
 			'function'    => 'give_email_tag_fullname',
403 403
 			'context'     => 'donor',
404 404
 		),
405 405
 		array(
406 406
 			'tag'         => 'username',
407
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
407
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
408 408
 			'function'    => 'give_email_tag_username',
409 409
 			'context'     => 'donor',
410 410
 		),
411 411
 		array(
412 412
 			'tag'         => 'user_email',
413
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
413
+			'description' => esc_html__('The donor\'s email address.', 'give'),
414 414
 			'function'    => 'give_email_tag_user_email',
415 415
 			'context'     => 'donor',
416 416
 		),
417 417
 		array(
418 418
 			'tag'         => 'email_access_link',
419
-			'description' => esc_html__( 'The donor\'s email access link.', 'give' ),
419
+			'description' => esc_html__('The donor\'s email access link.', 'give'),
420 420
 			'function'    => 'give_email_tag_email_access_link',
421 421
 			'context'     => 'donor',
422 422
 		),
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 		/* General */
425 425
 		array(
426 426
 			'tag'         => 'sitename',
427
-			'description' => esc_html__( 'The name of your site.', 'give' ),
427
+			'description' => esc_html__('The name of your site.', 'give'),
428 428
 			'function'    => 'give_email_tag_sitename',
429 429
 			'context'     => 'general',
430 430
 		),
431 431
 
432 432
 		array(
433 433
 			'tag'         => 'reset_password_link',
434
-			'description' => esc_html__( 'The reset password link for user.', 'give' ),
434
+			'description' => esc_html__('The reset password link for user.', 'give'),
435 435
 			'function'    => 'give_email_tag_reset_password_link',
436 436
 			'context'     => 'general',
437 437
 		),
@@ -439,21 +439,21 @@  discard block
 block discarded – undo
439 439
 	);
440 440
 
441 441
 	// Apply give_email_tags filter
442
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
442
+	$email_tags = apply_filters('give_email_tags', $email_tags);
443 443
 
444 444
 	// Add email tags
445
-	foreach ( $email_tags as $email_tag ) {
445
+	foreach ($email_tags as $email_tag) {
446 446
 		give_add_email_tag(
447 447
 			$email_tag['tag'],
448 448
 			$email_tag['description'],
449 449
 			$email_tag['function'],
450
-			( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' )
450
+			( ! empty($email_tag['context']) ? $email_tag['context'] : '')
451 451
 		);
452 452
 	}
453 453
 
454 454
 }
455 455
 
456
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
456
+add_action('give_add_email_tags', 'give_setup_email_tags');
457 457
 
458 458
 
459 459
 /**
@@ -465,26 +465,26 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string $firstname
467 467
  */
468
-function give_email_tag_first_name( $tag_args ) {
468
+function give_email_tag_first_name($tag_args) {
469 469
 	$user_info = array();
470 470
 	$firstname = '';
471 471
 
472 472
 	// Backward compatibility.
473
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
473
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
474 474
 
475
-	switch ( true ) {
476
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
477
-			$payment = new Give_Payment( $tag_args['payment_id'] );
475
+	switch (true) {
476
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
477
+			$payment = new Give_Payment($tag_args['payment_id']);
478 478
 
479 479
 			// Get firstname.
480
-			if ( ! empty( $payment->user_info ) ) {
481
-				$email_names = give_get_email_names( $payment->user_info );
480
+			if ( ! empty($payment->user_info)) {
481
+				$email_names = give_get_email_names($payment->user_info);
482 482
 				$firstname   = $email_names['name'];
483 483
 			}
484 484
 			break;
485 485
 
486
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
487
-			$donor = new Give_Donor( $tag_args['user_id'], true );
486
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
487
+			$donor = new Give_Donor($tag_args['user_id'], true);
488 488
 			$firstname = $donor->get_first_name();
489 489
 			break;
490 490
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 		 *
494 494
 		 * @since 2.0
495 495
 		 */
496
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
497
-			$donor = new Give_Donor( $tag_args['donor_id'] );
496
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
497
+			$donor = new Give_Donor($tag_args['donor_id']);
498 498
 			$firstname = $donor->get_first_name();
499 499
 			break;
500 500
 	}
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 * @param string $firstname
508 508
 	 * @param array  $tag_args
509 509
 	 */
510
-	$firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args );
510
+	$firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args);
511 511
 
512 512
 	return $firstname;
513 513
 }
@@ -521,26 +521,26 @@  discard block
 block discarded – undo
521 521
  *
522 522
  * @return string $fullname
523 523
  */
524
-function give_email_tag_fullname( $tag_args ) {
524
+function give_email_tag_fullname($tag_args) {
525 525
 	$fullname = '';
526 526
 
527 527
 	// Backward compatibility.
528
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
528
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
529 529
 
530
-	switch ( true ) {
531
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
532
-			$payment = new Give_Payment( $tag_args['payment_id'] );
530
+	switch (true) {
531
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
532
+			$payment = new Give_Payment($tag_args['payment_id']);
533 533
 
534 534
 			// Get fullname.
535
-			if ( ! empty( $payment->user_info ) ) {
536
-				$email_names = give_get_email_names( $payment->user_info );
535
+			if ( ! empty($payment->user_info)) {
536
+				$email_names = give_get_email_names($payment->user_info);
537 537
 				$fullname    = $email_names['fullname'];
538 538
 			}
539 539
 			break;
540 540
 
541
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
542
-			$donor = new Give_Donor( $tag_args['user_id'], true );
543
-			$fullname  = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" );
541
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
542
+			$donor = new Give_Donor($tag_args['user_id'], true);
543
+			$fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}");
544 544
 			break;
545 545
 
546 546
 		/**
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 		 *
549 549
 		 * @since 2.0
550 550
 		 */
551
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
552
-			$donor = new Give_Donor( $tag_args['donor_id'] );
551
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
552
+			$donor = new Give_Donor($tag_args['donor_id']);
553 553
 			$fullname = $donor->name;
554 554
 			break;
555 555
 	}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 * @param string $fullname
563 563
 	 * @param array  $tag_args
564 564
 	 */
565
-	$fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args );
565
+	$fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args);
566 566
 
567 567
 	return $fullname;
568 568
 }
@@ -576,25 +576,25 @@  discard block
 block discarded – undo
576 576
  *
577 577
  * @return string username.
578 578
  */
579
-function give_email_tag_username( $tag_args ) {
579
+function give_email_tag_username($tag_args) {
580 580
 	$username = '';
581 581
 
582 582
 	// Backward compatibility.
583
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
583
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
584 584
 
585
-	switch ( true ) {
586
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
587
-			$payment = new Give_Payment( $tag_args['payment_id'] );
585
+	switch (true) {
586
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
587
+			$payment = new Give_Payment($tag_args['payment_id']);
588 588
 
589 589
 			// Get username.
590
-			if ( ! empty( $payment->user_info ) ) {
591
-				$email_names = give_get_email_names( $payment->user_info );
590
+			if ( ! empty($payment->user_info)) {
591
+				$email_names = give_get_email_names($payment->user_info);
592 592
 				$username    = $email_names['username'];
593 593
 			}
594 594
 			break;
595 595
 
596
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
597
-			$user_info = get_user_by( 'id', $tag_args['user_id'] );
596
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
597
+			$user_info = get_user_by('id', $tag_args['user_id']);
598 598
 			$username  = $user_info->user_login;
599 599
 			break;
600 600
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 		 *
604 604
 		 * @since 2.0
605 605
 		 */
606
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
607
-			$donor = new Give_Donor( $tag_args['donor_id'] );
608
-			if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) {
609
-				$user_info = get_user_by( 'id', $donor->user_id );
606
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
607
+			$donor = new Give_Donor($tag_args['donor_id']);
608
+			if ( ! empty($donor->id) && ! empty($donor->user_id)) {
609
+				$user_info = get_user_by('id', $donor->user_id);
610 610
 				$username  = $user_info->user_login;
611 611
 			}
612 612
 			break;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @param string $username
621 621
 	 * @param array  $tag_args
622 622
 	 */
623
-	$username = apply_filters( 'give_email_tag_username', $username, $tag_args );
623
+	$username = apply_filters('give_email_tag_username', $username, $tag_args);
624 624
 
625 625
 	return $username;
626 626
 }
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
  *
635 635
  * @return string user_email
636 636
  */
637
-function give_email_tag_user_email( $tag_args ) {
637
+function give_email_tag_user_email($tag_args) {
638 638
 	$email = '';
639 639
 
640 640
 	// Backward compatibility.
641
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
641
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
642 642
 
643
-	switch ( true ) {
644
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
645
-			$payment = new Give_Payment( $tag_args['payment_id'] );
643
+	switch (true) {
644
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
645
+			$payment = new Give_Payment($tag_args['payment_id']);
646 646
 			$email   = $payment->email;
647 647
 			break;
648 648
 
649
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
650
-			$user_info = get_user_by( 'id', $tag_args['user_id'] );
649
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
650
+			$user_info = get_user_by('id', $tag_args['user_id']);
651 651
 			$email     = $user_info->user_email;
652 652
 			break;
653 653
 
@@ -656,9 +656,9 @@  discard block
 block discarded – undo
656 656
 		 *
657 657
 		 * @since 2.0
658 658
 		 */
659
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
660
-			$donor = new Give_Donor( $tag_args['donor_id'] );
661
-			$email     = $donor->email;
659
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
660
+			$donor = new Give_Donor($tag_args['donor_id']);
661
+			$email = $donor->email;
662 662
 			break;
663 663
 	}
664 664
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	 * @param string $email
671 671
 	 * @param array  $tag_args
672 672
 	 */
673
-	$email = apply_filters( 'give_email_tag_user_email', $email, $tag_args );
673
+	$email = apply_filters('give_email_tag_user_email', $email, $tag_args);
674 674
 
675 675
 	return $email;
676 676
 }
@@ -684,22 +684,22 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return string billing_address
686 686
  */
687
-function give_email_tag_billing_address( $tag_args ) {
687
+function give_email_tag_billing_address($tag_args) {
688 688
 	$address = '';
689 689
 
690 690
 	// Backward compatibility.
691
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
691
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
692 692
 
693
-	switch ( true ) {
694
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
695
-			$donation   = new Give_Payment( $tag_args['payment_id'] );
696
-			$address = $donation->address['line1'] . "\n";
693
+	switch (true) {
694
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
695
+			$donation = new Give_Payment($tag_args['payment_id']);
696
+			$address = $donation->address['line1']."\n";
697 697
 
698
-			if ( ! empty( $donation->address['line2'] ) ) {
699
-				$address .= $donation->address['line2'] . "\n";
698
+			if ( ! empty($donation->address['line2'])) {
699
+				$address .= $donation->address['line2']."\n";
700 700
 			}
701 701
 
702
-			$address .= $donation->address['city'] . ' ' . $donation->address['zip'] . ' ' . $donation->address['state'] . "\n";
702
+			$address .= $donation->address['city'].' '.$donation->address['zip'].' '.$donation->address['state']."\n";
703 703
 			$address .= $donation->address['country'];
704 704
 			break;
705 705
 	}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	 * @param string $address
713 713
 	 * @param array  $tag_args
714 714
 	 */
715
-	$address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args );
715
+	$address = apply_filters('give_email_tag_billing_address', $address, $tag_args);
716 716
 
717 717
 	return $address;
718 718
 }
@@ -726,16 +726,16 @@  discard block
 block discarded – undo
726 726
  *
727 727
  * @return string date
728 728
  */
729
-function give_email_tag_date( $tag_args ) {
729
+function give_email_tag_date($tag_args) {
730 730
 	$date = '';
731 731
 
732 732
 	// Backward compatibility.
733
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
733
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
734 734
 
735
-	switch ( true ) {
736
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
737
-			$payment = new Give_Payment( $tag_args['payment_id'] );
738
-			$date    = date_i18n( give_date_format(), strtotime( $payment->date ) );
735
+	switch (true) {
736
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
737
+			$payment = new Give_Payment($tag_args['payment_id']);
738
+			$date    = date_i18n(give_date_format(), strtotime($payment->date));
739 739
 			break;
740 740
 	}
741 741
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 * @param string $date
748 748
 	 * @param array  $tag_args
749 749
 	 */
750
-	$date = apply_filters( 'give_email_tag_date', $date, $tag_args );
750
+	$date = apply_filters('give_email_tag_date', $date, $tag_args);
751 751
 
752 752
 	return $date;
753 753
 }
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
  *
762 762
  * @return string amount
763 763
  */
764
-function give_email_tag_amount( $tag_args ) {
764
+function give_email_tag_amount($tag_args) {
765 765
 	$amount = '';
766 766
 
767 767
 	// Backward compatibility.
768
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
768
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
769 769
 
770
-	switch ( true ) {
771
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
772
-			$payment     = new Give_Payment( $tag_args['payment_id'] );
773
-			$give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) );
774
-			$amount      = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' );
770
+	switch (true) {
771
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
772
+			$payment     = new Give_Payment($tag_args['payment_id']);
773
+			$give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency));
774
+			$amount      = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8');
775 775
 			break;
776 776
 	}
777 777
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @param string $amount
784 784
 	 * @param array  $tag_args
785 785
 	 */
786
-	$amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args );
786
+	$amount = apply_filters('give_email_tag_amount', $amount, $tag_args);
787 787
 
788 788
 	return $amount;
789 789
 }
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
  *
798 798
  * @return string price
799 799
  */
800
-function give_email_tag_price( $tag_args ) {
801
-	return give_email_tag_amount( $tag_args );
800
+function give_email_tag_price($tag_args) {
801
+	return give_email_tag_amount($tag_args);
802 802
 }
803 803
 
804 804
 /**
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return int payment_id
812 812
  */
813
-function give_email_tag_payment_id( $tag_args ) {
813
+function give_email_tag_payment_id($tag_args) {
814 814
 	$payment_id = '';
815 815
 
816 816
 	// Backward compatibility.
817
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
817
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
818 818
 
819
-	switch ( true ) {
820
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
821
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
819
+	switch (true) {
820
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
821
+			$payment    = new Give_Payment($tag_args['payment_id']);
822 822
 			$payment_id = $payment->number;
823 823
 			break;
824 824
 	}
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 	 * @param string $payment_id
832 832
 	 * @param array  $tag_args
833 833
 	 */
834
-	return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args );
834
+	return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args);
835 835
 }
836 836
 
837 837
 /**
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
  *
844 844
  * @return string receipt_id
845 845
  */
846
-function give_email_tag_receipt_id( $tag_args ) {
846
+function give_email_tag_receipt_id($tag_args) {
847 847
 	$receipt_id = '';
848 848
 
849 849
 	// Backward compatibility.
850
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
850
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
851 851
 
852
-	switch ( true ) {
853
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
854
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
852
+	switch (true) {
853
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
854
+			$payment    = new Give_Payment($tag_args['payment_id']);
855 855
 			$receipt_id = $payment->key;
856 856
 			break;
857 857
 	}
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 * @param string $receipt_id
865 865
 	 * @param array  $tag_args
866 866
 	 */
867
-	return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args );
867
+	return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args);
868 868
 }
869 869
 
870 870
 /**
@@ -876,23 +876,23 @@  discard block
 block discarded – undo
876 876
  *
877 877
  * @return string $form_title
878 878
  */
879
-function give_email_tag_donation( $tag_args ) {
879
+function give_email_tag_donation($tag_args) {
880 880
 	$donation_form_title = '';
881 881
 
882 882
 	// Backward compatibility.
883
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
883
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
884 884
 
885
-	switch ( true ) {
886
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
887
-			$payment             = new Give_Payment( $tag_args['payment_id'] );
888
-			$level_title         = give_has_variable_prices( $payment->form_id );
885
+	switch (true) {
886
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
887
+			$payment             = new Give_Payment($tag_args['payment_id']);
888
+			$level_title         = give_has_variable_prices($payment->form_id);
889 889
 			$separator           = $level_title ? '-' : '';
890
-			$donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title(
890
+			$donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title(
891 891
 				$payment,
892 892
 				array(
893 893
 					'separator' => $separator,
894 894
 				)
895
-			), 'empty', '' ) );
895
+			), 'empty', ''));
896 896
 			break;
897 897
 	}
898 898
 
@@ -920,17 +920,17 @@  discard block
 block discarded – undo
920 920
  *
921 921
  * @return string $form_title
922 922
  */
923
-function give_email_tag_form_title( $tag_args ) {
923
+function give_email_tag_form_title($tag_args) {
924 924
 	$donation_form_title = '';
925 925
 
926 926
 	// Backward compatibility.
927
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
927
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
928 928
 
929
-	switch ( true ) {
930
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
931
-			$payment             = new Give_Payment( $tag_args['payment_id'] );
929
+	switch (true) {
930
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
931
+			$payment             = new Give_Payment($tag_args['payment_id']);
932 932
 			$payment_meta        = $payment->payment_meta;
933
-			$donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) );
933
+			$donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title'));
934 934
 			break;
935 935
 	}
936 936
 
@@ -958,19 +958,19 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return string gateway
960 960
  */
961
-function give_email_tag_payment_method( $tag_args ) {
961
+function give_email_tag_payment_method($tag_args) {
962 962
 	$payment_method = '';
963 963
 
964 964
 	// Backward compatibility.
965
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
965
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
966 966
 
967 967
 	// Backward compatibility.
968
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
968
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
969 969
 
970
-	switch ( true ) {
971
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
972
-			$payment        = new Give_Payment( $tag_args['payment_id'] );
973
-			$payment_method = give_get_gateway_checkout_label( $payment->gateway );
970
+	switch (true) {
971
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
972
+			$payment        = new Give_Payment($tag_args['payment_id']);
973
+			$payment_method = give_get_gateway_checkout_label($payment->gateway);
974 974
 			break;
975 975
 	}
976 976
 
@@ -1001,16 +1001,16 @@  discard block
 block discarded – undo
1001 1001
  *
1002 1002
  * @return string
1003 1003
  */
1004
-function give_email_tag_payment_total( $tag_args ) {
1004
+function give_email_tag_payment_total($tag_args) {
1005 1005
 	$payment_total = '';
1006 1006
 
1007 1007
 	// Backward compatibility.
1008
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1008
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1009 1009
 
1010
-	switch ( true ) {
1011
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
1012
-			$payment       = new Give_Payment( $tag_args['payment_id'] );
1013
-			$payment_total = give_currency_filter( $payment->total );
1010
+	switch (true) {
1011
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
1012
+			$payment       = new Give_Payment($tag_args['payment_id']);
1013
+			$payment_total = give_currency_filter($payment->total);
1014 1014
 			break;
1015 1015
 	}
1016 1016
 
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
  *
1039 1039
  * @return string
1040 1040
  */
1041
-function give_email_tag_sitename( $tag_args = array() ) {
1042
-	$sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1041
+function give_email_tag_sitename($tag_args = array()) {
1042
+	$sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
1043 1043
 
1044 1044
 	// Backward compatibility.
1045
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1045
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1046 1046
 
1047 1047
 	/**
1048 1048
 	 * Filter the {sitename} email template tag output.
@@ -1068,26 +1068,26 @@  discard block
 block discarded – undo
1068 1068
  *
1069 1069
  * @return string receipt_link
1070 1070
  */
1071
-function give_email_tag_receipt_link( $tag_args ) {
1071
+function give_email_tag_receipt_link($tag_args) {
1072 1072
 	// Backward compatibility.
1073
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1073
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1074 1074
 
1075
-	$receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) );
1075
+	$receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id'));
1076 1076
 
1077 1077
 	// Bailout.
1078
-	if ( give_get_option( 'email_template' ) === 'none' ) {
1078
+	if (give_get_option('email_template') === 'none') {
1079 1079
 		return $receipt_url;
1080 1080
 	}
1081 1081
 
1082 1082
 
1083
-	$receipt_url = esc_url( add_query_arg( array(
1084
-		'payment_key' => give_get_payment_key( $tag_args['payment_id'] ),
1085
-	), give_get_history_page_uri() ) );
1083
+	$receipt_url = esc_url(add_query_arg(array(
1084
+		'payment_key' => give_get_payment_key($tag_args['payment_id']),
1085
+	), give_get_history_page_uri()));
1086 1086
 
1087
-	$formatted   = sprintf(
1087
+	$formatted = sprintf(
1088 1088
 		'<a href="%1$s">%2$s</a>',
1089 1089
 		$receipt_url,
1090
-		__( 'View it in your browser &raquo;', 'give' )
1090
+		__('View it in your browser &raquo;', 'give')
1091 1091
 	);
1092 1092
 
1093 1093
 	/**
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
  *
1117 1117
  * @return string receipt_url
1118 1118
  */
1119
-function give_email_tag_receipt_link_url( $tag_args ) {
1119
+function give_email_tag_receipt_link_url($tag_args) {
1120 1120
 	// Backward compatibility.
1121
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1121
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1122 1122
 
1123
-	$receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) );
1123
+	$receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id'));
1124 1124
 
1125 1125
 	/**
1126 1126
 	 * Filter the {receipt_link_url} email template tag output.
@@ -1147,13 +1147,13 @@  discard block
 block discarded – undo
1147 1147
  *
1148 1148
  * @return string
1149 1149
  */
1150
-function give_get_receipt_url( $payment_id ) {
1150
+function give_get_receipt_url($payment_id) {
1151 1151
 	$receipt_url = '';
1152 1152
 
1153
-	if ( $payment_id ) {
1154
-		$receipt_url = esc_url( add_query_arg( array(
1155
-			'payment_key' => give_get_payment_key( $payment_id ),
1156
-		), give_get_history_page_uri() ) );
1153
+	if ($payment_id) {
1154
+		$receipt_url = esc_url(add_query_arg(array(
1155
+			'payment_key' => give_get_payment_key($payment_id),
1156
+		), give_get_history_page_uri()));
1157 1157
 	}
1158 1158
 
1159 1159
 	return $receipt_url;
@@ -1169,22 +1169,22 @@  discard block
 block discarded – undo
1169 1169
  *
1170 1170
  * @return string
1171 1171
  */
1172
-function give_email_tag_email_access_link( $tag_args ) {
1172
+function give_email_tag_email_access_link($tag_args) {
1173 1173
 	$donor_id          = 0;
1174 1174
 	$donor             = array();
1175 1175
 	$email_access_link = '';
1176 1176
 
1177 1177
 	// Backward compatibility.
1178
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1178
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1179 1179
 
1180
-	switch ( true ) {
1181
-		case ! empty( $tag_args['donor_id'] ):
1180
+	switch (true) {
1181
+		case ! empty($tag_args['donor_id']):
1182 1182
 			$donor_id = $tag_args['donor_id'];
1183
-			$donor    = Give()->donors->get_by( 'id', $tag_args['donor_id'] );
1183
+			$donor    = Give()->donors->get_by('id', $tag_args['donor_id']);
1184 1184
 			break;
1185 1185
 
1186
-		case ! empty( $tag_args['user_id'] ):
1187
-			$donor    = Give()->donors->get_by( 'user_id', $tag_args['user_id'] );
1186
+		case ! empty($tag_args['user_id']):
1187
+			$donor    = Give()->donors->get_by('user_id', $tag_args['user_id']);
1188 1188
 			$donor_id = $donor->id;
1189 1189
 			break;
1190 1190
 
@@ -1193,11 +1193,11 @@  discard block
 block discarded – undo
1193 1193
 	}
1194 1194
 
1195 1195
 	// Set email access link if donor exist.
1196
-	if ( $donor_id ) {
1197
-		$verify_key = wp_generate_password( 20, false );
1196
+	if ($donor_id) {
1197
+		$verify_key = wp_generate_password(20, false);
1198 1198
 
1199 1199
 		// Generate a new verify key
1200
-		Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key );
1200
+		Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key);
1201 1201
 
1202 1202
 		$access_url = add_query_arg(
1203 1203
 			array(
@@ -1207,28 +1207,28 @@  discard block
 block discarded – undo
1207 1207
 		);
1208 1208
 
1209 1209
 		// Add Payment Key to email access url, if it exists.
1210
-		if ( ! empty( $_GET['payment_key'] ) ) {
1210
+		if ( ! empty($_GET['payment_key'])) {
1211 1211
 			$access_url = add_query_arg(
1212 1212
 				array(
1213
-					'payment_key' => give_clean( $_GET['payment_key'] ),
1213
+					'payment_key' => give_clean($_GET['payment_key']),
1214 1214
 				),
1215 1215
 				$access_url
1216 1216
 			);
1217 1217
 		}
1218 1218
 
1219
-		if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) {
1219
+		if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) {
1220 1220
 			$email_access_link = sprintf(
1221 1221
 				'<a href="%1$s" target="_blank">%2$s</a>',
1222
-				esc_url( $access_url ),
1223
-				__( 'View your donation history &raquo;', 'give' )
1222
+				esc_url($access_url),
1223
+				__('View your donation history &raquo;', 'give')
1224 1224
 			);
1225 1225
 
1226 1226
 		} else {
1227 1227
 
1228 1228
 			$email_access_link = sprintf(
1229 1229
 				'%1$s: %2$s',
1230
-				__( 'View your donation history', 'give' ),
1231
-				esc_url( $access_url )
1230
+				__('View your donation history', 'give'),
1231
+				esc_url($access_url)
1232 1232
 			);
1233 1233
 		}
1234 1234
 	}
@@ -1260,23 +1260,23 @@  discard block
 block discarded – undo
1260 1260
  *
1261 1261
  * @return array
1262 1262
  */
1263
-function __give_20_bc_str_type_email_tag_param( $tag_args ) {
1264
-	if ( ! is_array( $tag_args ) ) {
1265
-		switch ( true ) {
1266
-			case ( 'give_payment' === get_post_type( $tag_args ) ):
1267
-				$tag_args = array( 'payment_id' => $tag_args );
1263
+function __give_20_bc_str_type_email_tag_param($tag_args) {
1264
+	if ( ! is_array($tag_args)) {
1265
+		switch (true) {
1266
+			case ('give_payment' === get_post_type($tag_args)):
1267
+				$tag_args = array('payment_id' => $tag_args);
1268 1268
 				break;
1269 1269
 
1270
-			case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ):
1271
-				$tag_args = array( 'user_id' => $tag_args );
1270
+			case ( ! is_wp_error(get_user_by('id', $tag_args))):
1271
+				$tag_args = array('user_id' => $tag_args);
1272 1272
 				break;
1273 1273
 
1274
-			case ( Give()->donors->get_by( 'id', $tag_args ) ):
1275
-				$tag_args = array( 'donor_id' => $tag_args );
1274
+			case (Give()->donors->get_by('id', $tag_args)):
1275
+				$tag_args = array('donor_id' => $tag_args);
1276 1276
 				break;
1277 1277
 
1278
-			case ( Give()->donors->get_by( 'user_id', $tag_args ) ):
1279
-				$tag_args = array( 'user_id' => $tag_args );
1278
+			case (Give()->donors->get_by('user_id', $tag_args)):
1279
+				$tag_args = array('user_id' => $tag_args);
1280 1280
 				break;
1281 1281
 		}
1282 1282
 	}
@@ -1294,39 +1294,39 @@  discard block
 block discarded – undo
1294 1294
  *
1295 1295
  * @return array
1296 1296
  */
1297
-function give_email_tag_reset_password_link( $tag_args, $payment_id ) {
1297
+function give_email_tag_reset_password_link($tag_args, $payment_id) {
1298 1298
 
1299 1299
 	$reset_password_url = '';
1300 1300
 
1301
-	switch ( true ) {
1302
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
1303
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
1301
+	switch (true) {
1302
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
1303
+			$payment    = new Give_Payment($tag_args['payment_id']);
1304 1304
 			$payment_id = $payment->number;
1305 1305
 			break;
1306 1306
 
1307
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
1308
-			$reset_password_url = give_get_reset_password_url( $tag_args['user_id'] );
1307
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
1308
+			$reset_password_url = give_get_reset_password_url($tag_args['user_id']);
1309 1309
 			break;
1310 1310
 
1311
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
1311
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
1312 1312
 			/* @var Give_Donor $donor */
1313
-			$donor = new Give_Donor( $tag_args['user_id'], true );
1314
-			$reset_password_url = give_get_reset_password_url( $donor->user_id );
1313
+			$donor = new Give_Donor($tag_args['user_id'], true);
1314
+			$reset_password_url = give_get_reset_password_url($donor->user_id);
1315 1315
 			break;
1316 1316
 	}
1317 1317
 
1318
-	if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) {
1318
+	if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) {
1319 1319
 		// Generate link, if Email content type is html.
1320 1320
 		$reset_password_link = sprintf(
1321 1321
 			'<a href="%1$s" target="_blank">%2$s</a>',
1322
-			esc_url( $reset_password_url ),
1323
-			__( 'Reset your password &raquo;', 'give' )
1322
+			esc_url($reset_password_url),
1323
+			__('Reset your password &raquo;', 'give')
1324 1324
 		);
1325
-	} else{
1325
+	} else {
1326 1326
 		$reset_password_link = sprintf(
1327 1327
 			'%1$s: %2$s',
1328
-			__( 'Reset your password', 'give' ),
1329
-			esc_url( $reset_password_url )
1328
+			__('Reset your password', 'give'),
1329
+			esc_url($reset_password_url)
1330 1330
 		);
1331 1331
 	}
1332 1332
 
@@ -1355,21 +1355,21 @@  discard block
 block discarded – undo
1355 1355
  *
1356 1356
  * @return mixed|string
1357 1357
  */
1358
-function give_get_reset_password_url( $user_id ) {
1358
+function give_get_reset_password_url($user_id) {
1359 1359
 	$reset_password_url = '';
1360 1360
 
1361 1361
 	// Proceed further only, if user_id exists.
1362
-	if ( $user_id ) {
1362
+	if ($user_id) {
1363 1363
 
1364 1364
 		// Get User Object Details.
1365
-		$user = get_user_by( 'ID', $user_id );
1365
+		$user = get_user_by('ID', $user_id);
1366 1366
 
1367 1367
 		// Prepare Reset Password URL.
1368
-		$reset_password_url = esc_url( add_query_arg( array(
1368
+		$reset_password_url = esc_url(add_query_arg(array(
1369 1369
 			'action' => 'rp',
1370
-			'key' => get_password_reset_key( $user ),
1370
+			'key' => get_password_reset_key($user),
1371 1371
 			'login' => $user->user_login,
1372
-		), wp_login_url() ) );
1372
+		), wp_login_url()));
1373 1373
 	}
1374 1374
 
1375 1375
 	return $reset_password_url;
Please login to merge, or discard this patch.
includes/class-give-db-donor-meta.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		/* @var WPDB $wpdb */
54 54
 		global $wpdb;
55 55
 
56
-		$wpdb->donormeta   = $this->table_name = $wpdb->prefix . 'give_donormeta';
56
+		$wpdb->donormeta   = $this->table_name = $wpdb->prefix.'give_donormeta';
57 57
 		$this->primary_key = 'meta_id';
58 58
 		$this->version     = '1.0';
59 59
 
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return  bool  False for failure. True for success.
92 92
 	 */
93
-	public function delete_all_meta( $donor_id = 0 ) {
93
+	public function delete_all_meta($donor_id = 0) {
94 94
 		global $wpdb;
95
-		$status = $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) );
95
+		$status = $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d'));
96 96
 
97
-		if( $status ) {
98
-			Give_Cache::delete_group( $donor_id, 'give-donors' );
97
+		if ($status) {
98
+			Give_Cache::delete_group($donor_id, 'give-donors');
99 99
 		}
100 100
 	}
101 101
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 		global $wpdb;
112 112
 
113 113
 		if (
114
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
115
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) )
114
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
115
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta"))
116 116
 		) {
117 117
 			$wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta";
118 118
 			$this->meta_type = 'customer';
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return bool
133 133
 	 */
134
-	protected function is_valid_post_type( $ID ) {
134
+	protected function is_valid_post_type($ID) {
135 135
 		return $ID && true;
136 136
 	}
137 137
 
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 1 patch
Spacing   +197 added lines, -203 removed lines patch added patch discarded remove patch
@@ -80,34 +80,34 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param array $args
82 82
 	 */
83
-	public function register( $args ) {
83
+	public function register($args) {
84 84
 		$args_default = array(
85 85
 			'id'       => '',
86 86
 			'version'  => '',
87 87
 			'callback' => '',
88 88
 		);
89 89
 
90
-		$args = wp_parse_args( $args, $args_default );
90
+		$args = wp_parse_args($args, $args_default);
91 91
 
92 92
 		// You can only register database upgrade.
93 93
 		$args['type'] = 'database';
94 94
 
95 95
 		// Bailout.
96 96
 		if (
97
-			empty( $args['id'] ) ||
98
-			empty( $args['version'] ) ||
99
-			empty( $args['callback'] ) ||
100
-			! is_callable( $args['callback'] )
97
+			empty($args['id']) ||
98
+			empty($args['version']) ||
99
+			empty($args['callback']) ||
100
+			! is_callable($args['callback'])
101 101
 		) {
102 102
 			return;
103 103
 		}
104 104
 
105 105
 		// Change depend param to array.
106
-		if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) {
107
-			$args['depend'] = array( $args['depend'] );
106
+		if (isset($args['depend']) && is_string($args['depend'])) {
107
+			$args['depend'] = array($args['depend']);
108 108
 		}
109 109
 
110
-		$this->updates[ $args['type'] ][] = $args;
110
+		$this->updates[$args['type']][] = $args;
111 111
 	}
112 112
 
113 113
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return static
119 119
 	 */
120 120
 	static function get_instance() {
121
-		if ( is_null( self::$instance ) ) {
121
+		if (is_null(self::$instance)) {
122 122
 			self::$instance = new self();
123 123
 		}
124 124
 
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
 		/**
137 137
 		 * Load file
138 138
 		 */
139
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php';
140
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
139
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php';
140
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
141 141
 
142 142
 		self::$background_updater = new Give_Background_Updater();
143 143
 
144 144
 		/**
145 145
 		 * Setup hooks.
146 146
 		 */
147
-		add_action( 'init', array( $this, '__register_upgrade' ), 9999 );
148
-		add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 );
149
-		add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) );
150
-		add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) );
151
-		add_action( 'admin_init', array( $this, '__redirect_admin' ) );
152
-		add_action( 'admin_init', array( $this, '__pause_db_update' ), -1 );
153
-		add_action( 'admin_init', array( $this, '__restart_db_update' ), -1 );
154
-		add_action( 'admin_notices', array( $this, '__show_notice' ) );
155
-		add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) );
147
+		add_action('init', array($this, '__register_upgrade'), 9999);
148
+		add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999);
149
+		add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info'));
150
+		add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating'));
151
+		add_action('admin_init', array($this, '__redirect_admin'));
152
+		add_action('admin_init', array($this, '__pause_db_update'), -1);
153
+		add_action('admin_init', array($this, '__restart_db_update'), -1);
154
+		add_action('admin_notices', array($this, '__show_notice'));
155
+		add_action('give_restart_db_upgrade', array($this, '__health_background_update'));
156 156
 
157
-		if ( is_admin() ) {
158
-			add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 );
159
-			add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 );
157
+		if (is_admin()) {
158
+			add_action('admin_init', array($this, '__change_donations_label'), 9999);
159
+			add_action('admin_menu', array($this, '__register_menu'), 9999);
160 160
 		}
161 161
 	}
162 162
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 		$addons         = give_get_plugins();
171 171
 		$plugin_updates = get_plugin_updates();
172 172
 
173
-		foreach ( $addons as $key => $info ) {
174
-			if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) {
173
+		foreach ($addons as $key => $info) {
174
+			if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) {
175 175
 				continue;
176 176
 			}
177 177
 
178
-			$this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] );
178
+			$this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]);
179 179
 		}
180 180
 	}
181 181
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @access public
188 188
 	 */
189 189
 	public function __register_upgrade() {
190
-		if ( ! is_admin() ) {
190
+		if ( ! is_admin()) {
191 191
 			return;
192 192
 		}
193 193
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		 *
197 197
 		 * @since 1.8.12
198 198
 		 */
199
-		do_action( 'give_register_updates', $this );
199
+		do_action('give_register_updates', $this);
200 200
 	}
201 201
 
202 202
 	/**
@@ -209,23 +209,22 @@  discard block
 block discarded – undo
209 209
 		global $menu;
210 210
 
211 211
 		// Bailout.
212
-		if ( empty( $menu ) || ! $this->get_total_update_count() ) {
212
+		if (empty($menu) || ! $this->get_total_update_count()) {
213 213
 			return;
214 214
 		}
215 215
 
216
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
216
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
217 217
 
218
-		foreach ( $menu as $index => $menu_item ) {
219
-			if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) {
218
+		foreach ($menu as $index => $menu_item) {
219
+			if ('edit.php?post_type=give_forms' !== $menu_item[2]) {
220 220
 				continue;
221 221
 			}
222 222
 
223
-			$menu[ $index ][0] = sprintf(
223
+			$menu[$index][0] = sprintf(
224 224
 				'%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>',
225
-				__( 'Donations', 'give' ),
225
+				__('Donations', 'give'),
226 226
 				$is_update ?
227
-					$this->get_db_update_processing_percentage() :
228
-					$this->get_total_update_count(),
227
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
229 228
 				$is_update ? '%' : ''
230 229
 			);
231 230
 
@@ -241,7 +240,7 @@  discard block
 block discarded – undo
241 240
 	 */
242 241
 	public function __register_menu() {
243 242
 		// Bailout.
244
-		if( ! give_test_ajax_works() ) {
243
+		if ( ! give_test_ajax_works()) {
245 244
 			return;
246 245
 		}
247 246
 
@@ -249,41 +248,40 @@  discard block
 block discarded – undo
249 248
 		$this->__register_plugin_addon_updates();
250 249
 
251 250
 		// Bailout.
252
-		if ( ! $this->get_total_update_count() ) {
251
+		if ( ! $this->get_total_update_count()) {
253 252
 			// Show complete update message if still on update setting page.
254
-			if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
253
+			if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
255 254
 				// Upgrades
256 255
 				add_submenu_page(
257 256
 					'edit.php?post_type=give_forms',
258
-					esc_html__( 'Give Updates Complete', 'give' ),
259
-					__( 'Updates', 'give' ),
257
+					esc_html__('Give Updates Complete', 'give'),
258
+					__('Updates', 'give'),
260 259
 					'manage_give_settings',
261 260
 					'give-updates',
262
-					array( $this, 'render_complete_page' )
261
+					array($this, 'render_complete_page')
263 262
 				);
264 263
 			}
265 264
 
266 265
 			return;
267 266
 		}
268 267
 
269
-		$is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() );
268
+		$is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process());
270 269
 
271 270
 		// Upgrades
272 271
 		add_submenu_page(
273 272
 			'edit.php?post_type=give_forms',
274
-			esc_html__( 'Give Updates', 'give' ),
273
+			esc_html__('Give Updates', 'give'),
275 274
 			sprintf(
276 275
 				'%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>',
277
-				__( 'Updates', 'give' ),
278
-				isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '',
276
+				__('Updates', 'give'),
277
+				isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '',
279 278
 				$is_update ?
280
-					$this->get_db_update_processing_percentage() :
281
-					$this->get_total_update_count(),
279
+					$this->get_db_update_processing_percentage() : $this->get_total_update_count(),
282 280
 				$is_update ? '%' : ''
283 281
 			),
284 282
 			'manage_give_settings',
285 283
 			'give-updates',
286
-			array( $this, 'render_page' )
284
+			array($this, 'render_page')
287 285
 		);
288 286
 	}
289 287
 
@@ -298,13 +296,13 @@  discard block
 block discarded – undo
298 296
 		// Show db upgrade completed notice.
299 297
 		if (
300 298
 			! wp_doing_ajax() &&
301
-			current_user_can( 'manage_give_settings' ) &&
302
-			get_option( 'give_show_db_upgrade_complete_notice' ) &&
303
-			! isset( $_GET['give-db-update-completed'] )
299
+			current_user_can('manage_give_settings') &&
300
+			get_option('give_show_db_upgrade_complete_notice') &&
301
+			! isset($_GET['give-db-update-completed'])
304 302
 		) {
305
-			delete_option( 'give_show_db_upgrade_complete_notice' );
303
+			delete_option('give_show_db_upgrade_complete_notice');
306 304
 
307
-			wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) );
305
+			wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed')));
308 306
 			exit();
309 307
 		}
310 308
 	}
@@ -322,9 +320,9 @@  discard block
 block discarded – undo
322 320
 		// Bailout.
323 321
 		if (
324 322
 			wp_doing_ajax() ||
325
-			! isset( $_GET['page'] ) ||
323
+			! isset($_GET['page']) ||
326 324
 			'give-updates' !== $_GET['page'] ||
327
-			! isset( $_GET['give-pause-db-upgrades'] ) ||
325
+			! isset($_GET['give-pause-db-upgrades']) ||
328 326
 			self::$background_updater->is_paused_process()
329 327
 		) {
330 328
 			return false;
@@ -332,20 +330,20 @@  discard block
 block discarded – undo
332 330
 
333 331
 		$batch = self::$background_updater->get_all_batch();
334 332
 
335
-		if ( ! empty( $batch ) ) {
336
-			update_option( 'give_paused_batches', $batch,  'no' );
337
-			delete_option( $batch->key );
338
-			delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
339
-			wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );
333
+		if ( ! empty($batch)) {
334
+			update_option('give_paused_batches', $batch, 'no');
335
+			delete_option($batch->key);
336
+			delete_site_transient(self::$background_updater->get_identifier().'_process_lock');
337
+			wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier());
340 338
 
341
-			Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' );
339
+			Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update');
342 340
 
343 341
 			/**
344 342
 			 * Fire action when pause db updates
345 343
 			 *
346 344
 			 * @since 2.0.1
347 345
 			 */
348
-			do_action( 'give_pause_db_upgrade', $this );
346
+			do_action('give_pause_db_upgrade', $this);
349 347
 		}
350 348
 
351 349
 		return true;
@@ -363,28 +361,28 @@  discard block
 block discarded – undo
363 361
 		// Bailout.
364 362
 		if (
365 363
 			wp_doing_ajax() ||
366
-			! isset( $_GET['page'] ) ||
364
+			! isset($_GET['page']) ||
367 365
 			'give-updates' !== $_GET['page'] ||
368
-			! isset( $_GET['give-restart-db-upgrades'] ) ||
366
+			! isset($_GET['give-restart-db-upgrades']) ||
369 367
 			! self::$background_updater->is_paused_process()
370 368
 		) {
371 369
 			return false;
372 370
 		}
373 371
 
374
-		$batch = get_option( 'give_paused_batches' );
372
+		$batch = get_option('give_paused_batches');
375 373
 
376
-		if ( ! empty( $batch ) ) {
377
-			update_option( $batch->key, $batch->data );
378
-			delete_option( 'give_paused_batches' );
374
+		if ( ! empty($batch)) {
375
+			update_option($batch->key, $batch->data);
376
+			delete_option('give_paused_batches');
379 377
 
380
-			Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' );
378
+			Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update');
381 379
 
382 380
 
383 381
 			/** Fire action when restart db updates
384 382
 			 *
385 383
 			 * @since 2.0.1
386 384
 			 */
387
-			do_action( 'give_restart_db_upgrade', $this );
385
+			do_action('give_restart_db_upgrade', $this);
388 386
 
389 387
 			self::$background_updater->dispatch();
390 388
 		}
@@ -400,77 +398,77 @@  discard block
 block discarded – undo
400 398
 	 *
401 399
 	 * @param Give_Updates $give_updates
402 400
 	 */
403
-	public function __health_background_update( $give_updates ) {
404
-		if( ! $this->is_doing_updates() ) {
401
+	public function __health_background_update($give_updates) {
402
+		if ( ! $this->is_doing_updates()) {
405 403
 			return;
406 404
 		}
407 405
 
408 406
 		$batch                = Give_Updates::$background_updater->get_all_batch();
409
-		$batch_data_count     = count( $batch->data );
410
-		$all_updates          = $give_updates->get_updates( 'database', 'all' );
411
-		$all_update_ids       = wp_list_pluck( $all_updates, 'id' );
412
-		$all_batch_update_ids = ! empty( $batch ) ? wp_list_pluck( $batch->data, 'id' ) : array();
407
+		$batch_data_count     = count($batch->data);
408
+		$all_updates          = $give_updates->get_updates('database', 'all');
409
+		$all_update_ids       = wp_list_pluck($all_updates, 'id');
410
+		$all_batch_update_ids = ! empty($batch) ? wp_list_pluck($batch->data, 'id') : array();
413 411
 		$log_data             = '';
414 412
 
415
-		if ( ! empty( $batch ) ) {
413
+		if ( ! empty($batch)) {
416 414
 
417
-			foreach ( $batch->data as $index => $update ) {
418
-				$log_data = print_r( $update, true ) . "\n";
415
+			foreach ($batch->data as $index => $update) {
416
+				$log_data = print_r($update, true)."\n";
419 417
 
420
-				if ( ! is_callable( $update['callback'] ) ) {
421
-					$log_data .= 'Removing missing callback update: ' . "{$update['id']}\n";
422
-					unset( $batch->data[ $index ] );
418
+				if ( ! is_callable($update['callback'])) {
419
+					$log_data .= 'Removing missing callback update: '."{$update['id']}\n";
420
+					unset($batch->data[$index]);
423 421
 				}
424 422
 
425
-				if ( ! empty( $update['depend'] ) ) {
423
+				if ( ! empty($update['depend'])) {
426 424
 
427
-					foreach ( $update['depend'] as $depend ) {
428
-						if ( give_has_upgrade_completed( $depend ) ) {
429
-							$log_data .= 'Completed update: ' . "{$depend}\n";
425
+					foreach ($update['depend'] as $depend) {
426
+						if (give_has_upgrade_completed($depend)) {
427
+							$log_data .= 'Completed update: '."{$depend}\n";
430 428
 							continue;
431 429
 						}
432 430
 
433
-						if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) {
434
-							$log_data .= 'Adding missing update: ' . "{$depend}\n";
435
-							array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] );
431
+						if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) {
432
+							$log_data .= 'Adding missing update: '."{$depend}\n";
433
+							array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]);
436 434
 						}
437 435
 					}
438 436
 				}
439 437
 			}
440 438
 		}
441 439
 
442
-		if( $new_updates = $this->get_updates( 'database', 'new' ) ){
443
-			$all_batch_update_ids = ! empty( $batch ) ? wp_list_pluck( $batch->data, 'id' ) : array();
440
+		if ($new_updates = $this->get_updates('database', 'new')) {
441
+			$all_batch_update_ids = ! empty($batch) ? wp_list_pluck($batch->data, 'id') : array();
444 442
 
445
-			foreach ( $new_updates as $index => $new_update ) {
446
-				if( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) {
447
-					unset( $new_updates[$index] );
443
+			foreach ($new_updates as $index => $new_update) {
444
+				if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) {
445
+					unset($new_updates[$index]);
448 446
 				}
449 447
 			}
450 448
 
451
-			if( ! empty( $new_updates ) ) {
452
-				$log_data .= 'Adding new update: ' . "\n";
453
-				$log_data .= print_r( $new_updates, true ) . "\n";
449
+			if ( ! empty($new_updates)) {
450
+				$log_data .= 'Adding new update: '."\n";
451
+				$log_data .= print_r($new_updates, true)."\n";
454 452
 
455
-				$batch->data = array_merge( $batch->data, $new_updates );
456
-				update_option( 'give_db_update_count',  ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) );
453
+				$batch->data = array_merge($batch->data, $new_updates);
454
+				update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates)));
457 455
 			}
458 456
 		}
459 457
 
460
-		if ( $batch_data_count !== count( $batch->data ) ) {
461
-			$log_data .= 'Updating batch' . "\n";
462
-			$log_data .= print_r( $batch, true );
458
+		if ($batch_data_count !== count($batch->data)) {
459
+			$log_data .= 'Updating batch'."\n";
460
+			$log_data .= print_r($batch, true);
463 461
 
464
-			update_option( $batch->key, $batch->data );
462
+			update_option($batch->key, $batch->data);
465 463
 
466 464
 			// Reset update info.
467
-			$doing_upgrade_args                     = get_option( 'give_doing_upgrade' );
465
+			$doing_upgrade_args                     = get_option('give_doing_upgrade');
468 466
 			// $doing_upgrade_args['update']           = $give_updates->update;
469
-			$doing_upgrade_args['heading']          = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) );
467
+			$doing_upgrade_args['heading']          = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count'));
470 468
 			$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage();
471
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
469
+			update_option('give_doing_upgrade', $doing_upgrade_args);
472 470
 
473
-			Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' );
471
+			Give()->logs->add('Update Health Check', $log_data, 0, 'update');
474 472
 		}
475 473
 	}
476 474
 
@@ -483,63 +481,63 @@  discard block
 block discarded – undo
483 481
 	 */
484 482
 	public function __show_notice() {
485 483
 		// Bailout.
486
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
484
+		if ( ! current_user_can('manage_give_settings')) {
487 485
 			return;
488 486
 		}
489 487
 
490 488
 		// Run DB updates.
491
-		if ( ! empty( $_GET['give-run-db-update'] ) ) {
489
+		if ( ! empty($_GET['give-run-db-update'])) {
492 490
 			$this->run_db_update();
493 491
 		}
494 492
 
495 493
 
496 494
 		// Bailout.
497
-		if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
495
+		if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
498 496
 			return;
499 497
 		}
500 498
 
501 499
 		// Show notice if upgrade paused.
502
-		if ( self::$background_updater->is_paused_process() ) {
500
+		if (self::$background_updater->is_paused_process()) {
503 501
 			ob_start();
504 502
 			?>
505 503
 			<p>
506
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
507
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?>
504
+				<strong><?php _e('Database Update', 'give'); ?></strong>
505
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?>
508 506
 			</p>
509 507
 			<p class="submit">
510
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn">
511
-					<?php _e( 'Restart the updater', 'give' ); ?>
508
+				<a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn">
509
+					<?php _e('Restart the updater', 'give'); ?>
512 510
 				</a>
513 511
 			</p>
514 512
 			<script type="text/javascript">
515 513
 				jQuery('.give-restart-updater-btn').click('click', function () {
516
-					return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line
514
+					return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line
517 515
 				});
518 516
 			</script>
519 517
 			<?php
520 518
 			$desc_html = ob_get_clean();
521 519
 
522 520
 
523
-			Give()->notices->register_notice( array(
521
+			Give()->notices->register_notice(array(
524 522
 				'id'          => 'give_upgrade_db',
525 523
 				'type'        => 'error',
526 524
 				'dismissible' => false,
527 525
 				'description' => $desc_html,
528
-			) );
526
+			));
529 527
 		}
530 528
 
531 529
 		// Bailout if doing upgrades.
532
-		if( $this->is_doing_updates() ) {
530
+		if ($this->is_doing_updates()) {
533 531
 			return;
534 532
 		}
535 533
 
536 534
 		// Show notice if ajax is not working.
537
-		if ( ! give_test_ajax_works() ) {
535
+		if ( ! give_test_ajax_works()) {
538 536
 			Give()->notices->register_notice(
539 537
 				array(
540 538
 					'id'          => 'give_db_upgrade_ajax_inaccessible',
541 539
 					'type'        => 'error',
542
-					'description' => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' &raquo;' ),
540
+					'description' => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' &raquo;'),
543 541
 					'show'        => true,
544 542
 				)
545 543
 			);
@@ -548,46 +546,46 @@  discard block
 block discarded – undo
548 546
 		}
549 547
 
550 548
 		// Show db upgrade completed notice.
551
-		if ( ! empty( $_GET['give-db-update-completed'] ) ) {
552
-			Give()->notices->register_notice( array(
549
+		if ( ! empty($_GET['give-db-update-completed'])) {
550
+			Give()->notices->register_notice(array(
553 551
 				'id'          => 'give_db_upgrade_completed',
554 552
 				'type'        => 'updated',
555
-				'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
553
+				'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
556 554
 				'show'        => true,
557
-			) );
555
+			));
558 556
 
559 557
 			// Start update.
560
-		} elseif ( ! empty( $_GET['give-run-db-update'] ) ) {
558
+		} elseif ( ! empty($_GET['give-run-db-update'])) {
561 559
 			$this->run_db_update();
562 560
 
563 561
 			// Show run the update notice.
564
-		} elseif ( $this->get_total_new_db_update_count() ) {
562
+		} elseif ($this->get_total_new_db_update_count()) {
565 563
 			ob_start();
566 564
 			?>
567 565
 			<p>
568
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
569
-				&nbsp;&#8211;&nbsp;<?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?>
566
+				<strong><?php _e('Database Update', 'give'); ?></strong>
567
+				&nbsp;&#8211;&nbsp;<?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?>
570 568
 			</p>
571 569
 			<p class="submit">
572
-				<a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now">
573
-					<?php _e( 'Run the updater', 'give' ); ?>
570
+				<a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now">
571
+					<?php _e('Run the updater', 'give'); ?>
574 572
 				</a>
575 573
 			</p>
576 574
 			<script type="text/javascript">
577 575
 				jQuery('.give-run-update-now').click('click', function () {
578
-					return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line
576
+					return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line
579 577
 				});
580 578
 			</script>
581 579
 			<?php
582 580
 			$desc_html = ob_get_clean();
583 581
 
584 582
 
585
-			Give()->notices->register_notice( array(
583
+			Give()->notices->register_notice(array(
586 584
 				'id'          => 'give_upgrade_db',
587 585
 				'type'        => 'updated',
588 586
 				'dismissible' => false,
589 587
 				'description' => $desc_html,
590
-			) );
588
+			));
591 589
 		}
592 590
 	}
593 591
 
@@ -598,7 +596,7 @@  discard block
 block discarded – undo
598 596
 	 * @access public
599 597
 	 */
600 598
 	public function render_complete_page() {
601
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
599
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
602 600
 	}
603 601
 
604 602
 	/**
@@ -608,7 +606,7 @@  discard block
 block discarded – undo
608 606
 	 * @access public
609 607
 	 */
610 608
 	public function render_page() {
611
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
609
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
612 610
 	}
613 611
 
614 612
 	/**
@@ -619,26 +617,26 @@  discard block
 block discarded – undo
619 617
 	 */
620 618
 	private function run_db_update() {
621 619
 		// Bailout.
622
-		if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) {
620
+		if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) {
623 621
 			return;
624 622
 		}
625 623
 
626
-		$updates = $this->get_updates( 'database', 'new' );
624
+		$updates = $this->get_updates('database', 'new');
627 625
 
628
-		foreach ( $updates as $update ) {
629
-			self::$background_updater->push_to_queue( $update );
626
+		foreach ($updates as $update) {
627
+			self::$background_updater->push_to_queue($update);
630 628
 		}
631 629
 
632
-		add_option( 'give_db_update_count', count( $updates ), '', 'no' );
630
+		add_option('give_db_update_count', count($updates), '', 'no');
633 631
 
634
-		add_option( 'give_doing_upgrade', array(
632
+		add_option('give_doing_upgrade', array(
635 633
 			'update_info' => $updates[0],
636 634
 			'step'        => 1,
637 635
 			'update'      => 1,
638
-			'heading'     => sprintf( 'Update %s of %s', 1, count( $updates ) ),
636
+			'heading'     => sprintf('Update %s of %s', 1, count($updates)),
639 637
 			'percentage'  => 0,
640 638
 			'total_percentage'  => 0,
641
-		), '', 'no' );
639
+		), '', 'no');
642 640
 
643 641
 		self::$background_updater->save()->dispatch();
644 642
 	}
@@ -652,11 +650,11 @@  discard block
 block discarded – undo
652 650
 	 */
653 651
 	public function __flush_resume_updates() {
654 652
 		//delete_option( 'give_doing_upgrade' );
655
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
653
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
656 654
 
657 655
 		// Reset counter.
658 656
 		$this->step = $this->percentage = 0;
659
-		++ $this->update;
657
+		++$this->update;
660 658
 	}
661 659
 
662 660
 
@@ -671,7 +669,7 @@  discard block
 block discarded – undo
671 669
 	public function __give_start_updating() {
672 670
 		// Check permission.
673 671
 		if (
674
-			! current_user_can( 'manage_give_settings' ) ||
672
+			! current_user_can('manage_give_settings') ||
675 673
 			$this->is_doing_updates()
676 674
 		) {
677 675
 			wp_send_json_error();
@@ -679,7 +677,7 @@  discard block
 block discarded – undo
679 677
 
680 678
 		// @todo: validate nonce
681 679
 		// @todo: set http method to post
682
-		if ( empty( $_POST['run_db_update'] ) ) {
680
+		if (empty($_POST['run_db_update'])) {
683 681
 			wp_send_json_error();
684 682
 		}
685 683
 
@@ -698,21 +696,21 @@  discard block
 block discarded – undo
698 696
 	 * @return string
699 697
 	 */
700 698
 	public function __give_db_updates_info() {
701
-		$update_info   = get_option( 'give_doing_upgrade' );
699
+		$update_info   = get_option('give_doing_upgrade');
702 700
 		$response_type = '';
703 701
 
704
-		if ( empty( $update_info ) ) {
705
-			$update_info   = array(
706
-				'message'    => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
707
-				'heading'    => __( 'Updates Completed.', 'give' ),
702
+		if (empty($update_info)) {
703
+			$update_info = array(
704
+				'message'    => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
705
+				'heading'    => __('Updates Completed.', 'give'),
708 706
 				'percentage' => 0,
709 707
 			);
710 708
 			$response_type = 'success';
711 709
 
712
-			delete_option( 'give_show_db_upgrade_complete_notice' );
710
+			delete_option('give_show_db_upgrade_complete_notice');
713 711
 		}
714 712
 
715
-		$this->send_ajax_response( $update_info, $response_type );
713
+		$this->send_ajax_response($update_info, $response_type);
716 714
 	}
717 715
 
718 716
 	/**
@@ -724,7 +722,7 @@  discard block
 block discarded – undo
724 722
 	 * @param        $data
725 723
 	 * @param string $type
726 724
 	 */
727
-	public function send_ajax_response( $data, $type = '' ) {
725
+	public function send_ajax_response($data, $type = '') {
728 726
 		$default = array(
729 727
 			'message'    => '',
730 728
 			'heading'    => '',
@@ -734,24 +732,24 @@  discard block
 block discarded – undo
734 732
 		);
735 733
 
736 734
 		// Set data.
737
-		$data = wp_parse_args( $data, $default );
735
+		$data = wp_parse_args($data, $default);
738 736
 
739 737
 		// Enable cache.
740 738
 		Give_Cache::enable();
741 739
 
742
-		switch ( $type ) {
740
+		switch ($type) {
743 741
 			case 'success':
744
-				wp_send_json_success( $data );
742
+				wp_send_json_success($data);
745 743
 				break;
746 744
 
747 745
 			case 'error':
748
-				wp_send_json_error( $data );
746
+				wp_send_json_error($data);
749 747
 				break;
750 748
 
751 749
 			default:
752
-				wp_send_json( array(
750
+				wp_send_json(array(
753 751
 					'data' => $data,
754
-				) );
752
+				));
755 753
 				break;
756 754
 		}
757 755
 	}
@@ -765,12 +763,12 @@  discard block
 block discarded – undo
765 763
 	 * @param $total
766 764
 	 * @param $current_total
767 765
 	 */
768
-	public function set_percentage( $total, $current_total ) {
766
+	public function set_percentage($total, $current_total) {
769 767
 		// Set percentage.
770
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
768
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
771 769
 
772 770
 		// Verify percentage.
773
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
771
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
774 772
 	}
775 773
 
776 774
 	/**
@@ -783,22 +781,22 @@  discard block
 block discarded – undo
783 781
 	 *
784 782
 	 * @return bool|null
785 783
 	 */
786
-	public function is_parent_updates_completed( $update ) {
784
+	public function is_parent_updates_completed($update) {
787 785
 		// Bailout.
788
-		if ( empty( $update['depend'] ) ) {
786
+		if (empty($update['depend'])) {
789 787
 			return true;
790 788
 		}
791 789
 
792 790
 		// Check if dependency is valid or not.
793
-		if ( ! $this->has_valid_dependency( $update ) ) {
791
+		if ( ! $this->has_valid_dependency($update)) {
794 792
 			return null;
795 793
 		}
796 794
 
797 795
 		$is_dependency_completed = true;
798 796
 
799
-		foreach ( $update['depend'] as $depend ) {
797
+		foreach ($update['depend'] as $depend) {
800 798
 
801
-			if ( ! give_has_upgrade_completed( $depend ) ) {
799
+			if ( ! give_has_upgrade_completed($depend)) {
802 800
 				$is_dependency_completed = false;
803 801
 				break;
804 802
 			}
@@ -815,7 +813,7 @@  discard block
 block discarded – undo
815 813
 	 * @return bool
816 814
 	 */
817 815
 	public function is_doing_updates() {
818
-		return (bool) get_option( 'give_doing_upgrade' );
816
+		return (bool) get_option('give_doing_upgrade');
819 817
 	}
820 818
 
821 819
 
@@ -829,7 +827,7 @@  discard block
 block discarded – undo
829 827
 	 *
830 828
 	 * @return bool
831 829
 	 */
832
-	public function has_valid_dependency( $update ) {
830
+	public function has_valid_dependency($update) {
833 831
 		$is_valid_dependency = true;
834 832
 		// $update_ids          = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' );
835 833
 		//
@@ -855,32 +853,32 @@  discard block
 block discarded – undo
855 853
 	 *
856 854
 	 * @return array
857 855
 	 */
858
-	public function get_updates( $update_type = '', $status = 'all' ) {
856
+	public function get_updates($update_type = '', $status = 'all') {
859 857
 		// return all updates.
860
-		if ( empty( $update_type ) ) {
858
+		if (empty($update_type)) {
861 859
 			return $this->updates;
862 860
 		}
863 861
 
864 862
 		// Get specific update.
865
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
863
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
866 864
 
867 865
 		// Bailout.
868
-		if ( empty( $updates ) ) {
866
+		if (empty($updates)) {
869 867
 			return $updates;
870 868
 		}
871 869
 
872
-		switch ( $status ) {
870
+		switch ($status) {
873 871
 			case 'new':
874 872
 				// Remove already completed updates.
875 873
 				$completed_updates = give_get_completed_upgrades();
876 874
 
877
-				if ( ! empty( $completed_updates ) ) {
878
-					foreach ( $updates as $index => $update ) {
879
-						if ( in_array( $update['id'], $completed_updates ) ) {
880
-							unset( $updates[ $index ] );
875
+				if ( ! empty($completed_updates)) {
876
+					foreach ($updates as $index => $update) {
877
+						if (in_array($update['id'], $completed_updates)) {
878
+							unset($updates[$index]);
881 879
 						}
882 880
 					}
883
-					$updates = array_values( $updates );
881
+					$updates = array_values($updates);
884 882
 				}
885 883
 
886 884
 				break;
@@ -897,7 +895,7 @@  discard block
 block discarded – undo
897 895
 	 * @return int
898 896
 	 */
899 897
 	public function get_total_plugin_update_count() {
900
-		return count( $this->get_updates( 'plugin' ) );
898
+		return count($this->get_updates('plugin'));
901 899
 	}
902 900
 
903 901
 	/**
@@ -912,7 +910,7 @@  discard block
 block discarded – undo
912 910
 		$db_update_count     = $this->get_pending_db_update_count();
913 911
 		$plugin_update_count = $this->get_total_plugin_update_count();
914 912
 
915
-		return ( $db_update_count + $plugin_update_count );
913
+		return ($db_update_count + $plugin_update_count);
916 914
 	}
917 915
 
918 916
 	/**
@@ -924,7 +922,7 @@  discard block
 block discarded – undo
924 922
 	 * @return int
925 923
 	 */
926 924
 	public function get_pending_db_update_count() {
927
-		return count( $this->get_updates( 'database', 'new' ) );
925
+		return count($this->get_updates('database', 'new'));
928 926
 	}
929 927
 
930 928
 	/**
@@ -936,7 +934,7 @@  discard block
 block discarded – undo
936 934
 	 * @return int
937 935
 	 */
938 936
 	public function get_total_db_update_count() {
939
-		return count( $this->get_updates( 'database', 'all' ) );
937
+		return count($this->get_updates('database', 'all'));
940 938
 	}
941 939
 
942 940
 	/**
@@ -949,8 +947,7 @@  discard block
 block discarded – undo
949 947
 	 */
950 948
 	public function get_total_new_db_update_count() {
951 949
 		return $this->is_doing_updates() ?
952
-			get_option( 'give_db_update_count' ) :
953
-			$this->get_pending_db_update_count();
950
+			get_option('give_db_update_count') : $this->get_pending_db_update_count();
954 951
 	}
955 952
 
956 953
 	/**
@@ -962,11 +959,10 @@  discard block
 block discarded – undo
962 959
 	 * @return int
963 960
 	 */
964 961
 	public function get_running_db_update() {
965
-		$current_update = get_option( 'give_doing_upgrade' );
962
+		$current_update = get_option('give_doing_upgrade');
966 963
 
967 964
 		return $this->is_doing_updates() ?
968
-			$current_update['update'] :
969
-			1;
965
+			$current_update['update'] : 1;
970 966
 	}
971 967
 
972 968
 	/**
@@ -978,23 +974,21 @@  discard block
 block discarded – undo
978 974
 	 */
979 975
 	public function get_db_update_processing_percentage() {
980 976
 		// Bailout.
981
-		if ( ! $this->get_total_new_db_update_count() ) {
977
+		if ( ! $this->get_total_new_db_update_count()) {
982 978
 			return 0;
983 979
 		}
984 980
 
985
-		$resume_update            = get_option( 'give_doing_upgrade' );
986
-		$update_count_percentages = ( ( $this->get_running_db_update() - 1 ) / $this->get_total_new_db_update_count() ) * 100;
987
-		$update_percentage_share  = ( 1 / $this->get_total_new_db_update_count() ) * 100;
988
-		$upgrade_percentage       = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 );
981
+		$resume_update            = get_option('give_doing_upgrade');
982
+		$update_count_percentages = (($this->get_running_db_update() - 1) / $this->get_total_new_db_update_count()) * 100;
983
+		$update_percentage_share  = (1 / $this->get_total_new_db_update_count()) * 100;
984
+		$upgrade_percentage       = (($resume_update['percentage'] * $update_percentage_share) / 100);
989 985
 
990 986
 		$final_percentage = $update_count_percentages + $upgrade_percentage;
991 987
 
992 988
 		return $this->is_doing_updates() ?
993
-			( absint( $final_percentage ) ?
994
-				absint( $final_percentage ) :
995
-				round( $final_percentage, 2 )
996
-			) :
997
-			0;
989
+			(absint($final_percentage) ?
990
+				absint($final_percentage) : round($final_percentage, 2)
991
+			) : 0;
998 992
 	}
999 993
 }
1000 994
 
Please login to merge, or discard this patch.