Completed
Push — master ( d8bbfb...b19d65 )
by Devin
05:28
created
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +97 added lines, -99 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Constructor.
75 75
 	 */
76
-	public function __construct( $_step = 1 ) {
77
-		parent::__construct( $_step );
76
+	public function __construct($_step = 1) {
77
+		parent::__construct($_step);
78 78
 
79 79
 		$this->is_writable = true;
80 80
 	}
@@ -89,108 +89,106 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function get_data() {
91 91
 
92
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
93
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
94
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
95
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
92
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
93
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
94
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
95
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
96 96
 
97
-		if ( false === $totals ) {
97
+		if (false === $totals) {
98 98
 			$totals = array();
99 99
 		}
100 100
 
101
-		if ( false === $payment_items ) {
101
+		if (false === $payment_items) {
102 102
 			$payment_items = array();
103 103
 		}
104 104
 
105
-		if ( false === $processed_payments ) {
105
+		if (false === $processed_payments) {
106 106
 			$processed_payments = array();
107 107
 		}
108 108
 
109
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
109
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
110 110
 
111
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
111
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
112 112
 
113
-		if ( empty( $payments ) ) {
114
-			$args = apply_filters( 'give_recount_form_stats_args', array(
113
+		if (empty($payments)) {
114
+			$args = apply_filters('give_recount_form_stats_args', array(
115 115
 				'give_forms' => $all_forms,
116 116
 				'number'     => $this->per_step,
117 117
 				'status'     => $accepted_statuses,
118 118
 				'paged'      => $this->step,
119 119
 				'output'     => 'give_payments',
120
-			) );
120
+			));
121 121
 
122
-			$payments_query = new Give_Payments_Query( $args );
122
+			$payments_query = new Give_Payments_Query($args);
123 123
 			$payments       = $payments_query->get_payments();
124 124
 		}
125 125
 
126
-		if ( ! empty( $payments ) ) {
126
+		if ( ! empty($payments)) {
127 127
 
128 128
 			//Loop through payments
129
-			foreach ( $payments as $payment ) {
129
+			foreach ($payments as $payment) {
130 130
 
131
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
132
-				$payment = new Give_Payment( $payment_id );
131
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
132
+				$payment = new Give_Payment($payment_id);
133 133
 
134 134
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
135
-				if ( in_array( $payment->ID, $processed_payments ) ) {
135
+				if (in_array($payment->ID, $processed_payments)) {
136 136
 					continue;
137 137
 				}
138 138
 
139 139
 				// Verify accepted status.
140
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
140
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
141 141
 					$processed_payments[] = $payment->ID;
142 142
 					continue;
143 143
 				}
144 144
 
145
-				$payment_item = $payment_items[ $payment->ID ];
145
+				$payment_item = $payment_items[$payment->ID];
146 146
 
147
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
147
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
148 148
 
149 149
 				// Must have a form ID.
150
-				if ( empty( $form_id ) ) {
150
+				if (empty($form_id)) {
151 151
 					continue;
152 152
 				}
153 153
 
154 154
 				// Form ID must be within $all_forms array to be validated.
155
-				if ( ! in_array( $form_id, $all_forms ) ) {
155
+				if ( ! in_array($form_id, $all_forms)) {
156 156
 					continue;
157 157
 				}
158 158
 
159 159
 				// Set Sales count
160
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
161
-					++ $totals[ $form_id ]['sales'] :
162
-					1;
160
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
161
+					++$totals[$form_id]['sales'] : 1;
163 162
 
164 163
 				// Set Total Earnings
165
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
166
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
167
-					$payment_item['price'];
164
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
165
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
168 166
 
169 167
 				$processed_payments[] = $payment->ID;
170 168
 			}
171 169
 
172 170
 			// Get the list of form ids which does not contain any payment record.
173
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
174
-			foreach ( $remaining_form_ids as $form_id ) {
171
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
172
+			foreach ($remaining_form_ids as $form_id) {
175 173
 				//If array key doesn't exist, create it
176
-				if ( ! array_key_exists( $form_id, $totals ) ) {
177
-					$totals[ $form_id ] = array(
174
+				if ( ! array_key_exists($form_id, $totals)) {
175
+					$totals[$form_id] = array(
178 176
 						'sales'    => (int) 0,
179 177
 						'earnings' => (float) 0,
180 178
 					);
181 179
 				}
182 180
 			}
183 181
 
184
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
185
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
182
+			$this->store_data('give_temp_processed_payments', $processed_payments);
183
+			$this->store_data('give_temp_recount_all_stats', $totals);
186 184
 
187 185
 			return true;
188 186
 		}
189 187
 
190 188
 
191
-		foreach ( $totals as $key => $stats ) {
192
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
193
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
189
+		foreach ($totals as $key => $stats) {
190
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
191
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
194 192
 		}
195 193
 
196 194
 		return false;
@@ -205,20 +203,20 @@  discard block
 block discarded – undo
205 203
 	 */
206 204
 	public function get_percentage_complete() {
207 205
 
208
-		$total = $this->get_stored_data( 'give_recount_all_total' );
206
+		$total = $this->get_stored_data('give_recount_all_total');
209 207
 
210
-		if ( false === $total ) {
208
+		if (false === $total) {
211 209
 			$this->pre_fetch();
212
-			$total = $this->get_stored_data( 'give_recount_all_total' );
210
+			$total = $this->get_stored_data('give_recount_all_total');
213 211
 		}
214 212
 
215 213
 		$percentage = 100;
216 214
 
217
-		if ( $total > 0 ) {
218
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
215
+		if ($total > 0) {
216
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
219 217
 		}
220 218
 
221
-		if ( $percentage > 100 ) {
219
+		if ($percentage > 100) {
222 220
 			$percentage = 100;
223 221
 		}
224 222
 
@@ -232,8 +230,8 @@  discard block
 block discarded – undo
232 230
 	 *
233 231
 	 * @param array $request The Form Data passed into the batch processing
234 232
 	 */
235
-	public function set_properties( $request ) {
236
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
233
+	public function set_properties($request) {
234
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
237 235
 	}
238 236
 
239 237
 	/**
@@ -244,25 +242,25 @@  discard block
 block discarded – undo
244 242
 	 */
245 243
 	public function process_step() {
246 244
 
247
-		if ( ! $this->can_export() ) {
248
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
245
+		if ( ! $this->can_export()) {
246
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
249 247
 		}
250 248
 
251 249
 		$had_data = $this->get_data();
252 250
 
253
-		if ( $had_data ) {
251
+		if ($had_data) {
254 252
 			$this->done = false;
255 253
 
256 254
 			return true;
257 255
 		} else {
258
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
259
-			$this->delete_data( 'give_recount_all_total' );
260
-			$this->delete_data( 'give_temp_recount_all_stats' );
261
-			$this->delete_data( 'give_temp_payment_items' );
262
-			$this->delete_data( 'give_temp_form_ids' );
263
-			$this->delete_data( 'give_temp_processed_payments' );
256
+			$this->delete_data('give_recount_total_'.$this->form_id);
257
+			$this->delete_data('give_recount_all_total');
258
+			$this->delete_data('give_temp_recount_all_stats');
259
+			$this->delete_data('give_temp_payment_items');
260
+			$this->delete_data('give_temp_form_ids');
261
+			$this->delete_data('give_temp_processed_payments');
264 262
 			$this->done    = true;
265
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
263
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
266 264
 
267 265
 			return false;
268 266
 		}
@@ -298,70 +296,70 @@  discard block
 block discarded – undo
298 296
 	 */
299 297
 	public function pre_fetch() {
300 298
 
301
-		if ( 1 == $this->step ) {
302
-			$this->delete_data( 'give_temp_recount_all_total' );
303
-			$this->delete_data( 'give_temp_recount_all_stats' );
304
-			$this->delete_data( 'give_temp_payment_items' );
305
-			$this->delete_data( 'give_temp_processed_payments' );
306
-			$this->delete_data( 'give_temp_all_payments_data' );
299
+		if (1 == $this->step) {
300
+			$this->delete_data('give_temp_recount_all_total');
301
+			$this->delete_data('give_temp_recount_all_stats');
302
+			$this->delete_data('give_temp_payment_items');
303
+			$this->delete_data('give_temp_processed_payments');
304
+			$this->delete_data('give_temp_all_payments_data');
307 305
 		}
308 306
 
309
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
310
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
307
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
308
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
311 309
 
312
-		if ( false === $total ) {
310
+		if (false === $total) {
313 311
 
314
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
312
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
315 313
 
316
-			if ( false === $payment_items ) {
314
+			if (false === $payment_items) {
317 315
 				$payment_items = array();
318
-				$this->store_data( 'give_temp_payment_items', $payment_items );
316
+				$this->store_data('give_temp_payment_items', $payment_items);
319 317
 			}
320 318
 
321 319
 			$args = array(
322 320
 				'post_status'    => 'publish',
323 321
 				'post_type'      => 'give_forms',
324
-				'posts_per_page' => - 1,
322
+				'posts_per_page' => -1,
325 323
 				'fields'         => 'ids',
326 324
 			);
327 325
 
328
-			$all_forms = get_posts( $args );
326
+			$all_forms = get_posts($args);
329 327
 
330
-			$this->store_data( 'give_temp_form_ids', $all_forms );
328
+			$this->store_data('give_temp_form_ids', $all_forms);
331 329
 
332
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
330
+			$args = apply_filters('give_recount_form_stats_total_args', array(
333 331
 				'give_forms' => $all_forms,
334 332
 				'number'     => $this->per_step,
335 333
 				'status'     => $accepted_statuses,
336 334
 				'page'       => $this->step,
337 335
 				'output'     => 'payments',
338
-			) );
336
+			));
339 337
 
340
-			$payments_query = new Give_Payments_Query( $args );
338
+			$payments_query = new Give_Payments_Query($args);
341 339
 			$payments       = $payments_query->get_payments();
342 340
 
343
-			$total = wp_count_posts( 'give_payment' )->publish;
341
+			$total = wp_count_posts('give_payment')->publish;
344 342
 
345
-			$this->store_data( 'give_temp_all_payments_data', $payments );
343
+			$this->store_data('give_temp_all_payments_data', $payments);
346 344
 
347
-			if ( $payments ) {
345
+			if ($payments) {
348 346
 
349
-				foreach ( $payments as $payment ) {
347
+				foreach ($payments as $payment) {
350 348
 
351 349
 					$form_id = $payment->form_id;
352 350
 
353 351
 					//If for some reason somehow the form_ID isn't set check payment meta
354
-					if ( empty( $payment->form_id ) ) {
352
+					if (empty($payment->form_id)) {
355 353
 						$payment_meta = $payment->get_meta();
356
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
354
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
357 355
 					}
358 356
 
359
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
357
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
360 358
 						continue;
361 359
 					}
362 360
 
363
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
364
-						$payment_items[ $payment->ID ] = array(
361
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
362
+						$payment_items[$payment->ID] = array(
365 363
 							'id'         => $form_id,
366 364
 							'payment_id' => $payment->ID,
367 365
 							'price'      => $payment->total,
@@ -369,8 +367,8 @@  discard block
 block discarded – undo
369 367
 					}
370 368
 				}
371 369
 			}
372
-			$this->store_data( 'give_temp_payment_items', $payment_items );
373
-			$this->store_data( 'give_recount_all_total', $total );
370
+			$this->store_data('give_temp_payment_items', $payment_items);
371
+			$this->store_data('give_recount_all_total', $total);
374 372
 		}
375 373
 
376 374
 	}
@@ -384,17 +382,17 @@  discard block
 block discarded – undo
384 382
 	 *
385 383
 	 * @return mixed       Returns the data from the database
386 384
 	 */
387
-	private function get_stored_data( $key ) {
385
+	private function get_stored_data($key) {
388 386
 		global $wpdb;
389
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
390
-		if ( empty( $value ) ) {
387
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
388
+		if (empty($value)) {
391 389
 			return false;
392 390
 		}
393 391
 
394
-		$maybe_json = json_decode( $value );
392
+		$maybe_json = json_decode($value);
395 393
 
396
-		if ( ! is_null( $maybe_json ) ) {
397
-			$value = json_decode( $value, true );
394
+		if ( ! is_null($maybe_json)) {
395
+			$value = json_decode($value, true);
398 396
 		}
399 397
 
400 398
 		return $value;
@@ -410,10 +408,10 @@  discard block
 block discarded – undo
410 408
 	 *
411 409
 	 * @return void
412 410
 	 */
413
-	private function store_data( $key, $value ) {
411
+	private function store_data($key, $value) {
414 412
 		global $wpdb;
415 413
 
416
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
414
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
417 415
 
418 416
 		$data = array(
419 417
 			'option_name'  => $key,
@@ -427,7 +425,7 @@  discard block
 block discarded – undo
427 425
 			'%s',
428 426
 		);
429 427
 
430
-		$wpdb->replace( $wpdb->options, $data, $formats );
428
+		$wpdb->replace($wpdb->options, $data, $formats);
431 429
 	}
432 430
 
433 431
 	/**
@@ -439,9 +437,9 @@  discard block
 block discarded – undo
439 437
 	 *
440 438
 	 * @return void
441 439
 	 */
442
-	private function delete_data( $key ) {
440
+	private function delete_data($key) {
443 441
 		global $wpdb;
444
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
442
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
445 443
 	}
446 444
 
447 445
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_data() {
64 64
 
65
-		$donor    = new Give_Donor( $this->customer_id );
66
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
65
+		$donor    = new Give_Donor($this->customer_id);
66
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
67 67
 
68
-		$offset     = ( $this->step - 1 ) * $this->per_step;
69
-		$step_items = array_slice( $payments, $offset, $this->per_step );
68
+		$offset     = ($this->step - 1) * $this->per_step;
69
+		$step_items = array_slice($payments, $offset, $this->per_step);
70 70
 
71
-		if ( count( $step_items ) > 0 ) {
72
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
71
+		if (count($step_items) > 0) {
72
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
73 73
 			$step_total    = 0;
74 74
 
75
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
75
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
76 76
 
77
-			foreach ( $step_items as $payment ) {
78
-				$payment = get_post( $payment->ID );
77
+			foreach ($step_items as $payment) {
78
+				$payment = get_post($payment->ID);
79 79
 
80
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
80
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
81 81
 
82
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
82
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
83 83
 					$missing_payments[] = $payment->ID;
84
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
84
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
85 85
 
86 86
 					continue;
87 87
 				}
88 88
 
89 89
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
90
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
90
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
91 91
 
92
-				if ( true === $should_process_payment ) {
92
+				if (true === $should_process_payment) {
93 93
 
94 94
 					$found_payment_ids[] = $payment->ID;
95 95
 
96
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
97
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
98
-						$step_total     += $payment_amount;
96
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
97
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
98
+						$step_total += $payment_amount;
99 99
 					}
100 100
 
101 101
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			}
104 104
 
105 105
 			$updated_total = $pending_total + $step_total;
106
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
107
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
106
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
107
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
108 108
 
109 109
 			return true;
110 110
 		}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function get_percentage_complete() {
123 123
 
124
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
125
-		$total    = count( $payments );
124
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
125
+		$total    = count($payments);
126 126
 
127 127
 		$percentage = 100;
128 128
 
129
-		if ( $total > 0 ) {
130
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
129
+		if ($total > 0) {
130
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
131 131
 		}
132 132
 
133
-		if ( $percentage > 100 ) {
133
+		if ($percentage > 100) {
134 134
 			$percentage = 100;
135 135
 		}
136 136
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param array $request The Form Data passed into the batch processing
146 146
 	 */
147
-	public function set_properties( $request ) {
148
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
147
+	public function set_properties($request) {
148
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function process_step() {
158 158
 
159
-		if ( ! $this->can_export() ) {
160
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
159
+		if ( ! $this->can_export()) {
160
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
161 161
 		}
162 162
 
163 163
 		$had_data = $this->get_data();
164 164
 
165
-		if ( $had_data ) {
165
+		if ($had_data) {
166 166
 			$this->done = false;
167 167
 
168 168
 			return true;
169 169
 		} else {
170
-			$donor       = new Give_Donor( $this->customer_id );
171
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
172
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
170
+			$donor       = new Give_Donor($this->customer_id);
171
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
172
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
173 173
 
174
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
174
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
175 175
 
176 176
 			// Find non-existing payments (deleted) and total up the donation count
177 177
 			$purchase_count = 0;
178
-			foreach ( $payment_ids as $key => $payment_id ) {
179
-				if ( in_array( $payment_id, $removed_payments ) ) {
180
-					unset( $payment_ids[ $key ] );
178
+			foreach ($payment_ids as $key => $payment_id) {
179
+				if (in_array($payment_id, $removed_payments)) {
180
+					unset($payment_ids[$key]);
181 181
 					continue;
182 182
 				}
183 183
 
184
-				$payment = get_post( $payment_id );
185
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
186
-					$purchase_count ++;
184
+				$payment = get_post($payment_id);
185
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
186
+					$purchase_count++;
187 187
 				}
188 188
 			}
189 189
 
190
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
190
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
191 191
 
192
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
193
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
194
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
195
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
192
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
193
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
194
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
195
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
196 196
 
197
-			$payment_ids = implode( ',', $payment_ids );
198
-			$donor->update( array(
197
+			$payment_ids = implode(',', $payment_ids);
198
+			$donor->update(array(
199 199
 				'payment_ids'    => $payment_ids,
200 200
 				'purchase_count' => $purchase_count,
201 201
 				'purchase_value' => $pending_total,
202
-			) );
202
+			));
203 203
 
204 204
 			$this->done    = true;
205
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
205
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
206 206
 
207 207
 			return false;
208 208
 		}
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function pre_fetch() {
238
-		if ( $this->step === 1 ) {
239
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
238
+		if ($this->step === 1) {
239
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
240 240
 
241 241
 			// Before we start, let's zero out the customer's data
242
-			$donor = new Give_Donor( $this->customer_id );
243
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
242
+			$donor = new Give_Donor($this->customer_id);
243
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
244 244
 
245
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
245
+			$attached_payment_ids = explode(',', $donor->payment_ids);
246 246
 
247 247
 			$attached_args = array(
248 248
 				'post__in' => $attached_payment_ids,
249
-				'number'   => - 1,
249
+				'number'   => -1,
250 250
 				'status'   => $allowed_payment_status,
251 251
 			);
252 252
 
253
-			$attached_payments = give_get_payments( $attached_args );
253
+			$attached_payments = give_get_payments($attached_args);
254 254
 
255 255
 			$unattached_args = array(
256 256
 				'post__not_in' => $attached_payment_ids,
257
-				'number'       => - 1,
257
+				'number'       => -1,
258 258
 				'status'       => $allowed_payment_status,
259 259
 				'meta_query'   => array(
260 260
 					array(
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 				),
265 265
 			);
266 266
 
267
-			$unattached_payments = give_get_payments( $unattached_args );
267
+			$unattached_payments = give_get_payments($unattached_args);
268 268
 
269
-			$payments = array_merge( $attached_payments, $unattached_payments );
269
+			$payments = array_merge($attached_payments, $unattached_payments);
270 270
 
271
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
271
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
272 272
 		}
273 273
 	}
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return mixed       Returns the data from the database
283 283
 	 */
284
-	private function get_stored_data( $key ) {
284
+	private function get_stored_data($key) {
285 285
 		global $wpdb;
286
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
286
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
287 287
 
288
-		if ( empty( $value ) ) {
288
+		if (empty($value)) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$maybe_json = json_decode( $value );
293
-		if ( ! is_null( $maybe_json ) ) {
294
-			$value = json_decode( $value, true );
292
+		$maybe_json = json_decode($value);
293
+		if ( ! is_null($maybe_json)) {
294
+			$value = json_decode($value, true);
295 295
 		}
296 296
 
297 297
 		return $value;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @return void
309 309
 	 */
310
-	private function store_data( $key, $value ) {
310
+	private function store_data($key, $value) {
311 311
 		global $wpdb;
312 312
 
313
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
313
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
314 314
 
315 315
 		$data = array(
316 316
 			'option_name'  => $key,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'%s',
325 325
 		);
326 326
 
327
-		$wpdb->replace( $wpdb->options, $data, $formats );
327
+		$wpdb->replace($wpdb->options, $data, $formats);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return void
338 338
 	 */
339
-	private function delete_data( $key ) {
339
+	private function delete_data($key) {
340 340
 		global $wpdb;
341
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
341
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
342 342
 	}
343 343
 
344 344
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-reset-stats.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Constructor.
51 51
 	 */
52
-	public function __construct( $_step = 1 ) {
53
-		parent::__construct( $_step );
52
+	public function __construct($_step = 1) {
53
+		parent::__construct($_step);
54 54
 
55 55
 		$this->is_writable = true;
56 56
 	}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 	public function get_data() {
68 68
 		global $wpdb;
69 69
 
70
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
70
+		$items = $this->get_stored_data('give_temp_reset_ids');
71 71
 
72
-		if ( ! is_array( $items ) ) {
72
+		if ( ! is_array($items)) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$offset     = ( $this->step - 1 ) * $this->per_step;
77
-		$step_items = array_slice( $items, $offset, $this->per_step );
76
+		$offset     = ($this->step - 1) * $this->per_step;
77
+		$step_items = array_slice($items, $offset, $this->per_step);
78 78
 
79
-		if ( $step_items ) {
79
+		if ($step_items) {
80 80
 
81 81
 			$step_ids = array(
82 82
 				'customers' => array(),
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 				'other'     => array(),
85 85
 			);
86 86
 
87
-			foreach ( $step_items as $item ) {
87
+			foreach ($step_items as $item) {
88 88
 
89
-				switch ( $item['type'] ) {
89
+				switch ($item['type']) {
90 90
 					case 'customer':
91 91
 						$step_ids['customers'][] = $item['id'];
92 92
 						break;
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 						$step_ids['give_forms'][] = $item['id'];
95 95
 						break;
96 96
 					default:
97
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
98
-						$step_ids[ $item_type ][] = $item['id'];
97
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
98
+						$step_ids[$item_type][] = $item['id'];
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			$sql = array();
104
-			$meta_table = __give_v20_bc_table_details('form' );
104
+			$meta_table = __give_v20_bc_table_details('form');
105 105
 
106
-			foreach ( $step_ids as $type => $ids ) {
106
+			foreach ($step_ids as $type => $ids) {
107 107
 
108
-				if ( empty( $ids ) ) {
108
+				if (empty($ids)) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$ids = implode( ',', $ids );
112
+				$ids = implode(',', $ids);
113 113
 
114
-				switch ( $type ) {
114
+				switch ($type) {
115 115
 					case 'customers':
116 116
 						$sql[]           = "DELETE FROM $wpdb->donors WHERE id IN ($ids)";
117 117
 						$table_name      = $wpdb->donors;
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
 						break;
132 132
 				}
133 133
 
134
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
134
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
135 135
 					// Allows other types of custom post types to filter on their own post_type
136 136
 					// and add items to the query list, for the IDs found in their post type.
137
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
137
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
138 138
 				}
139 139
 			}
140 140
 
141
-			if ( ! empty( $sql ) ) {
142
-				foreach ( $sql as $query ) {
143
-					$wpdb->query( $query );
141
+			if ( ! empty($sql)) {
142
+				foreach ($sql as $query) {
143
+					$wpdb->query($query);
144 144
 				}
145 145
 			}
146 146
 
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_percentage_complete() {
162 162
 
163
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
164
-		$total = count( $items );
163
+		$items = $this->get_stored_data('give_temp_reset_ids');
164
+		$total = count($items);
165 165
 
166 166
 		$percentage = 100;
167 167
 
168
-		if ( $total > 0 ) {
169
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
168
+		if ($total > 0) {
169
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
170 170
 		}
171 171
 
172
-		if ( $percentage > 100 ) {
172
+		if ($percentage > 100) {
173 173
 			$percentage = 100;
174 174
 		}
175 175
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param array $request The Form Data passed into the batch processing.
185 185
 	 */
186
-	public function set_properties( $request ) {
186
+	public function set_properties($request) {
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function process_step() {
196 196
 
197
-		if ( ! $this->can_export() ) {
198
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
197
+		if ( ! $this->can_export()) {
198
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
199 199
 				'response' => 403,
200
-			) );
200
+			));
201 201
 		}
202 202
 
203 203
 		$had_data = $this->get_data();
204 204
 
205
-		if ( $had_data ) {
205
+		if ($had_data) {
206 206
 			$this->done = false;
207 207
 
208 208
 			return true;
209 209
 		} else {
210
-			update_option( 'give_earnings_total', 0 );
211
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
210
+			update_option('give_earnings_total', 0);
211
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
212 212
 
213
-			$this->delete_data( 'give_temp_reset_ids' );
213
+			$this->delete_data('give_temp_reset_ids');
214 214
 
215 215
 			// Reset the sequential order numbers
216
-			if ( give_get_option( 'enable_sequential' ) ) {
217
-				delete_option( 'give_last_payment_number' );
216
+			if (give_get_option('enable_sequential')) {
217
+				delete_option('give_last_payment_number');
218 218
 			}
219 219
 
220 220
 			$this->done    = true;
221
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
221
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
222 222
 
223 223
 			return false;
224 224
 		}
@@ -251,26 +251,26 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function pre_fetch() {
253 253
 
254
-		if ( $this->step == 1 ) {
255
-			$this->delete_data( 'give_temp_reset_ids' );
254
+		if ($this->step == 1) {
255
+			$this->delete_data('give_temp_reset_ids');
256 256
 		}
257 257
 
258
-		$items = get_option( 'give_temp_reset_ids', false );
258
+		$items = get_option('give_temp_reset_ids', false);
259 259
 
260
-		if ( false === $items ) {
260
+		if (false === $items) {
261 261
 			$items = array();
262 262
 
263
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
264
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
263
+			$give_types_for_reset = array('give_forms', 'give_payment');
264
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
265 265
 
266
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
266
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
267 267
 				'post_type'      => $give_types_for_reset,
268 268
 				'post_status'    => 'any',
269
-				'posts_per_page' => - 1,
270
-			) );
269
+				'posts_per_page' => -1,
270
+			));
271 271
 
272
-			$posts = get_posts( $args );
273
-			foreach ( $posts as $post ) {
272
+			$posts = get_posts($args);
273
+			foreach ($posts as $post) {
274 274
 				$items[] = array(
275 275
 					'id'   => (int) $post->ID,
276 276
 					'type' => $post->post_type,
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 			}
279 279
 
280 280
 			$donor_args = array(
281
-				'number' => - 1,
281
+				'number' => -1,
282 282
 			);
283
-			$donors     = Give()->donors->get_donors( $donor_args );
284
-			foreach ( $donors as $donor ) {
283
+			$donors     = Give()->donors->get_donors($donor_args);
284
+			foreach ($donors as $donor) {
285 285
 				$items[] = array(
286 286
 					'id'   => (int) $donor->id,
287 287
 					'type' => 'customer',
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 
291 291
 			// Allow filtering of items to remove with an unassociative array for each item
292 292
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
293
-			$items = apply_filters( 'give_reset_items', $items );
293
+			$items = apply_filters('give_reset_items', $items);
294 294
 
295
-			$this->store_data( 'give_temp_reset_ids', $items );
295
+			$this->store_data('give_temp_reset_ids', $items);
296 296
 		}// End if().
297 297
 
298 298
 	}
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @return mixed       Returns the data from the database.
308 308
 	 */
309
-	private function get_stored_data( $key ) {
309
+	private function get_stored_data($key) {
310 310
 		global $wpdb;
311
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
311
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
312 312
 
313
-		if ( empty( $value ) ) {
313
+		if (empty($value)) {
314 314
 			return false;
315 315
 		}
316 316
 
317
-		$maybe_json = json_decode( $value );
318
-		if ( ! is_null( $maybe_json ) ) {
319
-			$value = json_decode( $value, true );
317
+		$maybe_json = json_decode($value);
318
+		if ( ! is_null($maybe_json)) {
319
+			$value = json_decode($value, true);
320 320
 		}
321 321
 
322 322
 		return $value;
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return void
334 334
 	 */
335
-	private function store_data( $key, $value ) {
335
+	private function store_data($key, $value) {
336 336
 		global $wpdb;
337 337
 
338
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
338
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
339 339
 
340 340
 		$data = array(
341 341
 			'option_name'  => $key,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 			'%s',
350 350
 		);
351 351
 
352
-		$wpdb->replace( $wpdb->options, $data, $formats );
352
+		$wpdb->replace($wpdb->options, $data, $formats);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @return void
363 363
 	 */
364
-	private function delete_data( $key ) {
364
+	private function delete_data($key) {
365 365
 		global $wpdb;
366
-		$wpdb->delete( $wpdb->options, array(
366
+		$wpdb->delete($wpdb->options, array(
367 367
 			'option_name' => $key,
368
-		) );
368
+		));
369 369
 	}
370 370
 
371 371
 }
372 372
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +471 added lines, -471 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly.
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -25,70 +25,70 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_do_automatic_upgrades() {
27 27
 	$did_upgrade  = false;
28
-	$give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) );
28
+	$give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version'));
29 29
 
30
-	if ( ! $give_version ) {
30
+	if ( ! $give_version) {
31 31
 		// 1.0 is the first version to use this option so we must add it.
32 32
 		$give_version = '1.0';
33 33
 	}
34 34
 
35
-	switch ( true ) {
35
+	switch (true) {
36 36
 
37
-		case version_compare( $give_version, '1.6', '<' ) :
37
+		case version_compare($give_version, '1.6', '<') :
38 38
 			give_v16_upgrades();
39 39
 			$did_upgrade = true;
40 40
 
41
-		case version_compare( $give_version, '1.7', '<' ) :
41
+		case version_compare($give_version, '1.7', '<') :
42 42
 			give_v17_upgrades();
43 43
 			$did_upgrade = true;
44 44
 
45
-		case version_compare( $give_version, '1.8', '<' ) :
45
+		case version_compare($give_version, '1.8', '<') :
46 46
 			give_v18_upgrades();
47 47
 			$did_upgrade = true;
48 48
 
49
-		case version_compare( $give_version, '1.8.7', '<' ) :
49
+		case version_compare($give_version, '1.8.7', '<') :
50 50
 			give_v187_upgrades();
51 51
 			$did_upgrade = true;
52 52
 
53
-		case version_compare( $give_version, '1.8.8', '<' ) :
53
+		case version_compare($give_version, '1.8.8', '<') :
54 54
 			give_v188_upgrades();
55 55
 			$did_upgrade = true;
56 56
 
57
-		case version_compare( $give_version, '1.8.9', '<' ) :
57
+		case version_compare($give_version, '1.8.9', '<') :
58 58
 			give_v189_upgrades();
59 59
 			$did_upgrade = true;
60 60
 
61
-		case version_compare( $give_version, '1.8.12', '<' ) :
61
+		case version_compare($give_version, '1.8.12', '<') :
62 62
 			give_v1812_upgrades();
63 63
 			$did_upgrade = true;
64 64
 
65
-		case version_compare( $give_version, '1.8.13', '<' ) :
65
+		case version_compare($give_version, '1.8.13', '<') :
66 66
 			give_v1813_upgrades();
67 67
 			$did_upgrade = true;
68 68
 
69
-		case version_compare( $give_version, '1.8.17', '<' ) :
69
+		case version_compare($give_version, '1.8.17', '<') :
70 70
 			give_v1817_upgrades();
71 71
 			$did_upgrade = true;
72 72
 
73
-		case version_compare( $give_version, '1.8.18', '<' ) :
73
+		case version_compare($give_version, '1.8.18', '<') :
74 74
 			give_v1818_upgrades();
75 75
 			$did_upgrade = true;
76 76
 
77
-		case version_compare( $give_version, '2.0', '<' ) :
77
+		case version_compare($give_version, '2.0', '<') :
78 78
 			give_v20_upgrades();
79 79
 			$did_upgrade = true;
80 80
 
81
-		case version_compare( $give_version, '2.0.1', '<' ) :
81
+		case version_compare($give_version, '2.0.1', '<') :
82 82
 			// Do nothing on fresh install.
83
-			if( ! doing_action( 'give_upgrades' ) ) {
83
+			if ( ! doing_action('give_upgrades')) {
84 84
 				give_v201_create_tables();
85
-				Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() );
85
+				Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance());
86 86
 				Give_Updates::$background_updater->dispatch();
87 87
 			}
88 88
 
89 89
 			$did_upgrade = true;
90 90
 
91
-		case version_compare( $give_version, '2.0.2', '<' ) :
91
+		case version_compare($give_version, '2.0.2', '<') :
92 92
 			// Remove 2.0.1 update to rerun on 2.0.2
93 93
 			$completed_upgrades = give_get_completed_upgrades();
94 94
 			$v201_updates = array(
@@ -98,31 +98,31 @@  discard block
 block discarded – undo
98 98
 				'v201_logs_upgrades'
99 99
 			);
100 100
 
101
-			foreach ( $v201_updates as $v201_update ) {
102
-				if( in_array( $v201_update, $completed_upgrades ) ) {
103
-					unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades )] );
101
+			foreach ($v201_updates as $v201_update) {
102
+				if (in_array($v201_update, $completed_upgrades)) {
103
+					unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]);
104 104
 				}
105 105
 			}
106 106
 
107
-			update_option( 'give_completed_upgrades', $completed_upgrades );
107
+			update_option('give_completed_upgrades', $completed_upgrades);
108 108
 
109 109
 			// Do nothing on fresh install.
110
-			if( ! doing_action( 'give_upgrades' ) ) {
110
+			if ( ! doing_action('give_upgrades')) {
111 111
 				give_v201_create_tables();
112
-				Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() );
112
+				Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance());
113 113
 				Give_Updates::$background_updater->dispatch();
114 114
 			}
115 115
 
116 116
 			$did_upgrade = true;
117 117
 	}
118 118
 
119
-	if ( $did_upgrade ) {
120
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
119
+	if ($did_upgrade) {
120
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
121 121
 	}
122 122
 }
123 123
 
124
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
125
-add_action( 'give_upgrades', 'give_do_automatic_upgrades' );
124
+add_action('admin_init', 'give_do_automatic_upgrades');
125
+add_action('give_upgrades', 'give_do_automatic_upgrades');
126 126
 
127 127
 /**
128 128
  * Display Upgrade Notices.
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
  *
137 137
  * @return void
138 138
  */
139
-function give_show_upgrade_notices( $give_updates ) {
139
+function give_show_upgrade_notices($give_updates) {
140 140
 	// v1.3.2 Upgrades
141 141
 	$give_updates->register(
142 142
 		array(
@@ -202,32 +202,32 @@  discard block
 block discarded – undo
202 202
 	);
203 203
 
204 204
 	// v1.8.17 Upgrades for donations.
205
-	$give_updates->register( array(
205
+	$give_updates->register(array(
206 206
 		'id'       => 'v1817_update_donation_iranian_currency_code',
207 207
 		'version'  => '1.8.17',
208 208
 		'callback' => 'give_v1817_update_donation_iranian_currency_code',
209
-	) );
209
+	));
210 210
 
211 211
 	// v1.8.17 Upgrades for cleanup of user roles.
212
-	$give_updates->register( array(
212
+	$give_updates->register(array(
213 213
 		'id'       => 'v1817_cleanup_user_roles',
214 214
 		'version'  => '1.8.17',
215 215
 		'callback' => 'give_v1817_cleanup_user_roles',
216
-	) );
216
+	));
217 217
 
218 218
 	// v1.8.18 Upgrades for assigning custom amount to existing set donations.
219
-	$give_updates->register( array(
219
+	$give_updates->register(array(
220 220
 		'id'       => 'v1818_assign_custom_amount_set_donation',
221 221
 		'version'  => '1.8.18',
222 222
 		'callback' => 'give_v1818_assign_custom_amount_set_donation',
223
-	) );
223
+	));
224 224
 
225 225
 	// v1.8.18 Cleanup the Give Worker Role Caps.
226
-	$give_updates->register( array(
226
+	$give_updates->register(array(
227 227
 		'id'       => 'v1818_give_worker_role_cleanup',
228 228
 		'version'  => '1.8.18',
229 229
 		'callback' => 'give_v1818_give_worker_role_cleanup',
230
-	) );
230
+	));
231 231
 
232 232
 	// v2.0.0 Upgrades
233 233
 	$give_updates->register(
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			'id'       => 'v20_move_metadata_into_new_table',
282 282
 			'version'  => '2.0.0',
283 283
 			'callback' => 'give_v20_move_metadata_into_new_table_callback',
284
-			'depend'   => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ),
284
+			'depend'   => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'),
285 285
 		)
286 286
 	);
287 287
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			'id'       => 'v201_move_metadata_into_new_table',
328 328
 			'version'  => '2.0.1',
329 329
 			'callback' => 'give_v201_move_metadata_into_new_table_callback',
330
-			'depend'   => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ),
330
+			'depend'   => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'),
331 331
 		)
332 332
 	);
333 333
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	);
343 343
 }
344 344
 
345
-add_action( 'give_register_updates', 'give_show_upgrade_notices' );
345
+add_action('give_register_updates', 'give_show_upgrade_notices');
346 346
 
347 347
 /**
348 348
  * Triggers all upgrade functions
@@ -354,29 +354,29 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function give_trigger_upgrades() {
356 356
 
357
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
358
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
357
+	if ( ! current_user_can('manage_give_settings')) {
358
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
359 359
 			'response' => 403,
360
-		) );
360
+		));
361 361
 	}
362 362
 
363
-	$give_version = get_option( 'give_version' );
363
+	$give_version = get_option('give_version');
364 364
 
365
-	if ( ! $give_version ) {
365
+	if ( ! $give_version) {
366 366
 		// 1.0 is the first version to use this option so we must add it.
367 367
 		$give_version = '1.0';
368
-		add_option( 'give_version', $give_version );
368
+		add_option('give_version', $give_version);
369 369
 	}
370 370
 
371
-	update_option( 'give_version', GIVE_VERSION );
372
-	delete_option( 'give_doing_upgrade' );
371
+	update_option('give_version', GIVE_VERSION);
372
+	delete_option('give_doing_upgrade');
373 373
 
374
-	if ( DOING_AJAX ) {
375
-		die( 'complete' );
374
+	if (DOING_AJAX) {
375
+		die('complete');
376 376
 	} // End if().
377 377
 }
378 378
 
379
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
379
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
380 380
 
381 381
 
382 382
 /**
@@ -392,20 +392,20 @@  discard block
 block discarded – undo
392 392
 	/* @var Give_Updates $give_updates */
393 393
 	$give_updates = Give_Updates::get_instance();
394 394
 
395
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
396
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
395
+	if ( ! current_user_can('manage_give_settings')) {
396
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
397 397
 			'response' => 403,
398
-		) );
398
+		));
399 399
 	}
400 400
 
401 401
 	give_ignore_user_abort();
402 402
 
403 403
 	// UPDATE DB METAKEYS.
404 404
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
405
-	$query = $wpdb->query( $sql );
405
+	$query = $wpdb->query($sql);
406 406
 
407 407
 	$give_updates->percentage = 100;
408
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
408
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
409 409
 }
410 410
 
411 411
 
@@ -429,24 +429,24 @@  discard block
 block discarded – undo
429 429
 	$where  .= "AND ( p.post_status = 'abandoned' )";
430 430
 	$where  .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
431 431
 
432
-	$sql            = $select . $join . $where;
433
-	$found_payments = $wpdb->get_col( $sql );
432
+	$sql            = $select.$join.$where;
433
+	$found_payments = $wpdb->get_col($sql);
434 434
 
435
-	foreach ( $found_payments as $payment ) {
435
+	foreach ($found_payments as $payment) {
436 436
 
437 437
 		// Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves.
438
-		$modified_time = get_post_modified_time( 'U', false, $payment );
438
+		$modified_time = get_post_modified_time('U', false, $payment);
439 439
 
440 440
 		// 1450124863 =  12/10/2015 20:42:25.
441
-		if ( $modified_time >= 1450124863 ) {
441
+		if ($modified_time >= 1450124863) {
442 442
 
443
-			give_update_payment_status( $payment, 'pending' );
443
+			give_update_payment_status($payment, 'pending');
444 444
 
445 445
 		}
446 446
 	}
447 447
 
448 448
 	$give_updates->percentage = 100;
449
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
449
+	give_set_upgrade_complete('upgrade_give_offline_status');
450 450
 }
451 451
 
452 452
 
@@ -459,17 +459,17 @@  discard block
 block discarded – undo
459 459
  */
460 460
 function give_v152_cleanup_users() {
461 461
 
462
-	$give_version = get_option( 'give_version' );
462
+	$give_version = get_option('give_version');
463 463
 
464
-	if ( ! $give_version ) {
464
+	if ( ! $give_version) {
465 465
 		// 1.0 is the first version to use this option so we must add it.
466 466
 		$give_version = '1.0';
467 467
 	}
468 468
 
469
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
469
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
470 470
 
471 471
 	// v1.5.2 Upgrades
472
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
472
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
473 473
 
474 474
 		// Delete all caps with "ss".
475 475
 		// Also delete all unused "campaign" roles.
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 		);
517 517
 
518 518
 		global $wp_roles;
519
-		foreach ( $delete_caps as $cap ) {
520
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
521
-				$wp_roles->remove_cap( $role, $cap );
519
+		foreach ($delete_caps as $cap) {
520
+			foreach (array_keys($wp_roles->roles) as $role) {
521
+				$wp_roles->remove_cap($role, $cap);
522 522
 			}
523 523
 		}
524 524
 
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
 		$roles->add_caps();
529 529
 
530 530
 		// The Update Ran.
531
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
532
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
533
-		delete_option( 'give_doing_upgrade' );
531
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
532
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
533
+		delete_option('give_doing_upgrade');
534 534
 
535 535
 	}// End if().
536 536
 
537 537
 }
538 538
 
539
-add_action( 'admin_init', 'give_v152_cleanup_users' );
539
+add_action('admin_init', 'give_v152_cleanup_users');
540 540
 
541 541
 /**
542 542
  * 1.6 Upgrade routine to create the customer meta table.
@@ -579,53 +579,53 @@  discard block
 block discarded – undo
579 579
 
580 580
 	// Get addons license key.
581 581
 	$addons = array();
582
-	foreach ( $give_options as $key => $value ) {
583
-		if ( false !== strpos( $key, '_license_key' ) ) {
584
-			$addons[ $key ] = $value;
582
+	foreach ($give_options as $key => $value) {
583
+		if (false !== strpos($key, '_license_key')) {
584
+			$addons[$key] = $value;
585 585
 		}
586 586
 	}
587 587
 
588 588
 	// Bailout: We do not have any addon license data to upgrade.
589
-	if ( empty( $addons ) ) {
589
+	if (empty($addons)) {
590 590
 		return false;
591 591
 	}
592 592
 
593
-	foreach ( $addons as $key => $addon_license ) {
593
+	foreach ($addons as $key => $addon_license) {
594 594
 
595 595
 		// Get addon shortname.
596
-		$shortname = str_replace( '_license_key', '', $key );
596
+		$shortname = str_replace('_license_key', '', $key);
597 597
 
598 598
 		// Addon license option name.
599
-		$addon_license_option_name = $shortname . '_license_active';
599
+		$addon_license_option_name = $shortname.'_license_active';
600 600
 
601 601
 		// bailout if license is empty.
602
-		if ( empty( $addon_license ) ) {
603
-			delete_option( $addon_license_option_name );
602
+		if (empty($addon_license)) {
603
+			delete_option($addon_license_option_name);
604 604
 			continue;
605 605
 		}
606 606
 
607 607
 		// Get addon name.
608 608
 		$addon_name       = array();
609
-		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
610
-		foreach ( $addon_name_parts as $name_part ) {
609
+		$addon_name_parts = explode('_', str_replace('give_', '', $shortname));
610
+		foreach ($addon_name_parts as $name_part) {
611 611
 
612 612
 			// Fix addon name
613
-			switch ( $name_part ) {
613
+			switch ($name_part) {
614 614
 				case 'authorizenet' :
615 615
 					$name_part = 'authorize.net';
616 616
 					break;
617 617
 			}
618 618
 
619
-			$addon_name[] = ucfirst( $name_part );
619
+			$addon_name[] = ucfirst($name_part);
620 620
 		}
621 621
 
622
-		$addon_name = implode( ' ', $addon_name );
622
+		$addon_name = implode(' ', $addon_name);
623 623
 
624 624
 		// Data to send to the API.
625 625
 		$api_params = array(
626 626
 			'edd_action' => 'activate_license', // never change from "edd_" to "give_"!
627 627
 			'license'    => $addon_license,
628
-			'item_name'  => urlencode( $addon_name ),
628
+			'item_name'  => urlencode($addon_name),
629 629
 			'url'        => home_url(),
630 630
 		);
631 631
 
@@ -640,17 +640,17 @@  discard block
 block discarded – undo
640 640
 		);
641 641
 
642 642
 		// Make sure there are no errors.
643
-		if ( is_wp_error( $response ) ) {
644
-			delete_option( $addon_license_option_name );
643
+		if (is_wp_error($response)) {
644
+			delete_option($addon_license_option_name);
645 645
 			continue;
646 646
 		}
647 647
 
648 648
 		// Tell WordPress to look for updates.
649
-		set_site_transient( 'update_plugins', null );
649
+		set_site_transient('update_plugins', null);
650 650
 
651 651
 		// Decode license data.
652
-		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
653
-		update_option( $addon_license_option_name, $license_data );
652
+		$license_data = json_decode(wp_remote_retrieve_body($response));
653
+		update_option($addon_license_option_name, $license_data);
654 654
 	}// End foreach().
655 655
 }
656 656
 
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 	);
681 681
 
682 682
 	global $wp_roles;
683
-	foreach ( $delete_caps as $cap ) {
684
-		foreach ( array_keys( $wp_roles->roles ) as $role ) {
685
-			$wp_roles->remove_cap( $role, $cap );
683
+	foreach ($delete_caps as $cap) {
684
+		foreach (array_keys($wp_roles->roles) as $role) {
685
+			$wp_roles->remove_cap($role, $cap);
686 686
 		}
687 687
 	}
688 688
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 function give_v18_upgrades_core_setting() {
717 717
 	// Core settings which changes from checkbox to radio.
718 718
 	$core_setting_names = array_merge(
719
-		array_keys( give_v18_renamed_core_settings() ),
719
+		array_keys(give_v18_renamed_core_settings()),
720 720
 		array(
721 721
 			'uninstall_on_delete',
722 722
 			'scripts_footer',
@@ -728,48 +728,48 @@  discard block
 block discarded – undo
728 728
 	);
729 729
 
730 730
 	// Bailout: If not any setting define.
731
-	if ( $give_settings = get_option( 'give_settings' ) ) {
731
+	if ($give_settings = get_option('give_settings')) {
732 732
 
733 733
 		$setting_changed = false;
734 734
 
735 735
 		// Loop: check each setting field.
736
-		foreach ( $core_setting_names as $setting_name ) {
736
+		foreach ($core_setting_names as $setting_name) {
737 737
 			// New setting name.
738
-			$new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name );
738
+			$new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name);
739 739
 
740 740
 			// Continue: If setting already set.
741 741
 			if (
742
-				array_key_exists( $new_setting_name, $give_settings )
743
-				&& in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) )
742
+				array_key_exists($new_setting_name, $give_settings)
743
+				&& in_array($give_settings[$new_setting_name], array('enabled', 'disabled'))
744 744
 			) {
745 745
 				continue;
746 746
 			}
747 747
 
748 748
 			// Set checkbox value to radio value.
749
-			$give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' );
749
+			$give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled');
750 750
 
751 751
 			// @see https://github.com/WordImpress/Give/issues/1063.
752
-			if ( false !== strpos( $setting_name, 'disable_' ) ) {
752
+			if (false !== strpos($setting_name, 'disable_')) {
753 753
 
754
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' );
755
-			} elseif ( false !== strpos( $setting_name, 'enable_' ) ) {
754
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled');
755
+			} elseif (false !== strpos($setting_name, 'enable_')) {
756 756
 
757
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' );
757
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled');
758 758
 			}
759 759
 
760 760
 			// Tell bot to update core setting to db.
761
-			if ( ! $setting_changed ) {
761
+			if ( ! $setting_changed) {
762 762
 				$setting_changed = true;
763 763
 			}
764 764
 		}
765 765
 
766 766
 		// Update setting only if they changed.
767
-		if ( $setting_changed ) {
768
-			update_option( 'give_settings', $give_settings );
767
+		if ($setting_changed) {
768
+			update_option('give_settings', $give_settings);
769 769
 		}
770 770
 	}// End if().
771 771
 
772
-	give_set_upgrade_complete( 'v18_upgrades_core_setting' );
772
+	give_set_upgrade_complete('v18_upgrades_core_setting');
773 773
 }
774 774
 
775 775
 /**
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	$give_updates = Give_Updates::get_instance();
784 784
 
785 785
 	// form query
786
-	$forms = new WP_Query( array(
786
+	$forms = new WP_Query(array(
787 787
 			'paged'          => $give_updates->step,
788 788
 			'status'         => 'any',
789 789
 			'order'          => 'ASC',
@@ -792,41 +792,41 @@  discard block
 block discarded – undo
792 792
 		)
793 793
 	);
794 794
 
795
-	if ( $forms->have_posts() ) {
796
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) );
795
+	if ($forms->have_posts()) {
796
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20));
797 797
 
798
-		while ( $forms->have_posts() ) {
798
+		while ($forms->have_posts()) {
799 799
 			$forms->the_post();
800 800
 
801 801
 			// Form content.
802 802
 			// Note in version 1.8 display content setting split into display content and content placement setting.
803 803
 			// You can delete _give_content_option in future.
804
-			$show_content = give_get_meta( get_the_ID(), '_give_content_option', true );
805
-			if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) {
806
-				$field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' );
807
-				give_update_meta( get_the_ID(), '_give_display_content', $field_value );
804
+			$show_content = give_get_meta(get_the_ID(), '_give_content_option', true);
805
+			if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) {
806
+				$field_value = ('none' !== $show_content ? 'enabled' : 'disabled');
807
+				give_update_meta(get_the_ID(), '_give_display_content', $field_value);
808 808
 
809
-				$field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' );
810
-				give_update_meta( get_the_ID(), '_give_content_placement', $field_value );
809
+				$field_value = ('none' !== $show_content ? $show_content : 'give_pre_form');
810
+				give_update_meta(get_the_ID(), '_give_content_placement', $field_value);
811 811
 			}
812 812
 
813 813
 			// "Disable" Guest Donation. Checkbox.
814 814
 			// See: https://github.com/WordImpress/Give/issues/1470.
815
-			$guest_donation        = give_get_meta( get_the_ID(), '_give_logged_in_only', true );
816
-			$guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' );
817
-			give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval );
815
+			$guest_donation        = give_get_meta(get_the_ID(), '_give_logged_in_only', true);
816
+			$guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled');
817
+			give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval);
818 818
 
819 819
 			// Offline Donations.
820 820
 			// See: https://github.com/WordImpress/Give/issues/1579.
821
-			$offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true );
822
-			if ( 'no' === $offline_donation ) {
821
+			$offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true);
822
+			if ('no' === $offline_donation) {
823 823
 				$offline_donation_newval = 'global';
824
-			} elseif ( 'yes' === $offline_donation ) {
824
+			} elseif ('yes' === $offline_donation) {
825 825
 				$offline_donation_newval = 'enabled';
826 826
 			} else {
827 827
 				$offline_donation_newval = 'disabled';
828 828
 			}
829
-			give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval );
829
+			give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval);
830 830
 
831 831
 			// Convert yes/no setting field to enabled/disabled.
832 832
 			$form_radio_settings = array(
@@ -846,15 +846,15 @@  discard block
 block discarded – undo
846 846
 				'_give_offline_donation_enable_billing_fields_single',
847 847
 			);
848 848
 
849
-			foreach ( $form_radio_settings as $meta_key ) {
849
+			foreach ($form_radio_settings as $meta_key) {
850 850
 				// Get value.
851
-				$field_value = give_get_meta( get_the_ID(), $meta_key, true );
851
+				$field_value = give_get_meta(get_the_ID(), $meta_key, true);
852 852
 
853 853
 				// Convert meta value only if it is in yes/no/none.
854
-				if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) {
854
+				if (in_array($field_value, array('yes', 'on', 'no', 'none'))) {
855 855
 
856
-					$field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' );
857
-					give_update_meta( get_the_ID(), $meta_key, $field_value );
856
+					$field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled');
857
+					give_update_meta(get_the_ID(), $meta_key, $field_value);
858 858
 				}
859 859
 			}
860 860
 		}// End while().
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
 	} else {
865 865
 		// No more forms found, finish up.
866
-		give_set_upgrade_complete( 'v18_upgrades_form_metadata' );
866
+		give_set_upgrade_complete('v18_upgrades_form_metadata');
867 867
 	}
868 868
 }
869 869
 
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 				'%_transient_give_stats_%',
931 931
 				'give_cache%',
932 932
 				'%_transient_give_add_ons_feed%',
933
-				'%_transient__give_ajax_works' .
933
+				'%_transient__give_ajax_works'.
934 934
 				'%_transient_give_total_api_keys%',
935 935
 				'%_transient_give_i18n_give_promo_hide%',
936 936
 				'%_transient_give_contributors%',
@@ -957,24 +957,24 @@  discard block
 block discarded – undo
957 957
 		ARRAY_A
958 958
 	);
959 959
 
960
-	if ( ! empty( $user_apikey_options ) ) {
961
-		foreach ( $user_apikey_options as $user ) {
962
-			$cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] );
963
-			$cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] );
964
-			$cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] );
960
+	if ( ! empty($user_apikey_options)) {
961
+		foreach ($user_apikey_options as $user) {
962
+			$cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']);
963
+			$cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']);
964
+			$cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']);
965 965
 		}
966 966
 	}
967 967
 
968
-	if ( ! empty( $cached_options ) ) {
969
-		foreach ( $cached_options as $option ) {
970
-			switch ( true ) {
971
-				case ( false !== strpos( $option, 'transient' ) ):
972
-					$option = str_replace( '_transient_', '', $option );
973
-					delete_transient( $option );
968
+	if ( ! empty($cached_options)) {
969
+		foreach ($cached_options as $option) {
970
+			switch (true) {
971
+				case (false !== strpos($option, 'transient')):
972
+					$option = str_replace('_transient_', '', $option);
973
+					delete_transient($option);
974 974
 					break;
975 975
 
976 976
 				default:
977
-					delete_option( $option );
977
+					delete_option($option);
978 978
 			}
979 979
 		}
980 980
 	}
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	global $wp_roles;
993 993
 
994 994
 	// Get the role object.
995
-	$give_worker = get_role( 'give_worker' );
995
+	$give_worker = get_role('give_worker');
996 996
 
997 997
 	// A list of capabilities to add for give workers.
998 998
 	$caps_to_add = array(
@@ -1000,9 +1000,9 @@  discard block
 block discarded – undo
1000 1000
 		'edit_pages',
1001 1001
 	);
1002 1002
 
1003
-	foreach ( $caps_to_add as $cap ) {
1003
+	foreach ($caps_to_add as $cap) {
1004 1004
 		// Add the capability.
1005
-		$give_worker->add_cap( $cap );
1005
+		$give_worker->add_cap($cap);
1006 1006
 	}
1007 1007
 
1008 1008
 }
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 	$give_updates = Give_Updates::get_instance();
1020 1020
 
1021 1021
 	// form query.
1022
-	$donation_forms = new WP_Query( array(
1022
+	$donation_forms = new WP_Query(array(
1023 1023
 			'paged'          => $give_updates->step,
1024 1024
 			'status'         => 'any',
1025 1025
 			'order'          => 'ASC',
@@ -1028,10 +1028,10 @@  discard block
 block discarded – undo
1028 1028
 		)
1029 1029
 	);
1030 1030
 
1031
-	if ( $donation_forms->have_posts() ) {
1032
-		$give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) );
1031
+	if ($donation_forms->have_posts()) {
1032
+		$give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20));
1033 1033
 
1034
-		while ( $donation_forms->have_posts() ) {
1034
+		while ($donation_forms->have_posts()) {
1035 1035
 			$donation_forms->the_post();
1036 1036
 			$form_id = get_the_ID();
1037 1037
 
@@ -1039,41 +1039,41 @@  discard block
 block discarded – undo
1039 1039
 			update_post_meta(
1040 1040
 				$form_id,
1041 1041
 				'_give_set_price',
1042
-				give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) )
1042
+				give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true))
1043 1043
 			);
1044 1044
 
1045 1045
 			// Remove formatting from _give_custom_amount_minimum.
1046 1046
 			update_post_meta(
1047 1047
 				$form_id,
1048 1048
 				'_give_custom_amount_minimum',
1049
-				give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) )
1049
+				give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true))
1050 1050
 			);
1051 1051
 
1052 1052
 			// Bailout.
1053
-			if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) {
1053
+			if ('set' === get_post_meta($form_id, '_give_price_option', true)) {
1054 1054
 				continue;
1055 1055
 			}
1056 1056
 
1057
-			$donation_levels = get_post_meta( $form_id, '_give_donation_levels', true );
1057
+			$donation_levels = get_post_meta($form_id, '_give_donation_levels', true);
1058 1058
 
1059
-			if ( ! empty( $donation_levels ) ) {
1059
+			if ( ! empty($donation_levels)) {
1060 1060
 
1061
-				foreach ( $donation_levels as $index => $donation_level ) {
1062
-					if ( isset( $donation_level['_give_amount'] ) ) {
1063
-						$donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] );
1061
+				foreach ($donation_levels as $index => $donation_level) {
1062
+					if (isset($donation_level['_give_amount'])) {
1063
+						$donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']);
1064 1064
 					}
1065 1065
 				}
1066 1066
 
1067
-				update_post_meta( $form_id, '_give_donation_levels', $donation_levels );
1067
+				update_post_meta($form_id, '_give_donation_levels', $donation_levels);
1068 1068
 
1069
-				$donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' );
1069
+				$donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount');
1070 1070
 
1071
-				$min_amount = min( $donation_levels_amounts );
1072
-				$max_amount = max( $donation_levels_amounts );
1071
+				$min_amount = min($donation_levels_amounts);
1072
+				$max_amount = max($donation_levels_amounts);
1073 1073
 
1074 1074
 				// Set Minimum and Maximum amount for Multi Level Donation Forms
1075
-				give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 );
1076
-				give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 );
1075
+				give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0);
1076
+				give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0);
1077 1077
 			}
1078 1078
 
1079 1079
 		}
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 		wp_reset_postdata();
1083 1083
 	} else {
1084 1084
 		// The Update Ran.
1085
-		give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' );
1085
+		give_set_upgrade_complete('v189_upgrades_levels_post_meta');
1086 1086
 	}
1087 1087
 
1088 1088
 }
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
  */
1133 1133
 function give_v20_upgrades() {
1134 1134
 	// Update cache setting.
1135
-	give_update_option( 'cache', 'enabled' );
1135
+	give_update_option('cache', 'enabled');
1136 1136
 
1137 1137
 	// Upgrade email settings.
1138 1138
 	give_v20_upgrades_email_setting();
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 	$all_setting = give_get_settings();
1152 1152
 
1153 1153
 	// Bailout on fresh install.
1154
-	if ( empty( $all_setting ) ) {
1154
+	if (empty($all_setting)) {
1155 1155
 		return;
1156 1156
 	}
1157 1157
 
@@ -1170,19 +1170,19 @@  discard block
 block discarded – undo
1170 1170
 		'admin_notices'                 => 'new-donation_notification',
1171 1171
 	);
1172 1172
 
1173
-	foreach ( $settings as $old_setting => $new_setting ) {
1173
+	foreach ($settings as $old_setting => $new_setting) {
1174 1174
 		// Do not update already modified
1175
-		if ( ! is_array( $new_setting ) ) {
1176
-			if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) {
1175
+		if ( ! is_array($new_setting)) {
1176
+			if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) {
1177 1177
 				continue;
1178 1178
 			}
1179 1179
 		}
1180 1180
 
1181
-		switch ( $old_setting ) {
1181
+		switch ($old_setting) {
1182 1182
 			case 'admin_notices':
1183
-				$notification_status = give_get_option( $old_setting, 'enabled' );
1183
+				$notification_status = give_get_option($old_setting, 'enabled');
1184 1184
 
1185
-				give_update_option( $new_setting, $notification_status );
1185
+				give_update_option($new_setting, $notification_status);
1186 1186
 
1187 1187
 				// @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon.
1188 1188
 				// give_delete_option( $old_setting );
@@ -1193,19 +1193,19 @@  discard block
 block discarded – undo
1193 1193
 			case 'admin_notice_emails':
1194 1194
 				$recipients = give_get_admin_notice_emails();
1195 1195
 
1196
-				foreach ( $new_setting as $setting ) {
1196
+				foreach ($new_setting as $setting) {
1197 1197
 					// bailout if setting already exist.
1198
-					if ( array_key_exists( $setting, $all_setting ) ) {
1198
+					if (array_key_exists($setting, $all_setting)) {
1199 1199
 						continue;
1200 1200
 					}
1201 1201
 
1202
-					give_update_option( $setting, $recipients );
1202
+					give_update_option($setting, $recipients);
1203 1203
 				}
1204 1204
 				break;
1205 1205
 
1206 1206
 			default:
1207
-				give_update_option( $new_setting, give_get_option( $old_setting ) );
1208
-				give_delete_option( $old_setting );
1207
+				give_update_option($new_setting, give_get_option($old_setting));
1208
+				give_delete_option($old_setting);
1209 1209
 		}
1210 1210
 	}
1211 1211
 }
@@ -1222,22 +1222,22 @@  discard block
 block discarded – undo
1222 1222
 	$give_settings        = give_get_settings();
1223 1223
 	$give_setting_updated = false;
1224 1224
 
1225
-	if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) {
1225
+	if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) {
1226 1226
 		$give_settings['number_decimals']   = 0;
1227 1227
 		$give_settings['decimal_separator'] = '';
1228 1228
 		$give_setting_updated               = true;
1229 1229
 
1230
-	} elseif ( empty( $give_settings['decimal_separator'] ) ) {
1230
+	} elseif (empty($give_settings['decimal_separator'])) {
1231 1231
 		$give_settings['number_decimals'] = 0;
1232 1232
 		$give_setting_updated             = true;
1233 1233
 
1234
-	} elseif ( 6 < absint( $give_settings['number_decimals'] ) ) {
1234
+	} elseif (6 < absint($give_settings['number_decimals'])) {
1235 1235
 		$give_settings['number_decimals'] = 5;
1236 1236
 		$give_setting_updated             = true;
1237 1237
 	}
1238 1238
 
1239
-	if ( $give_setting_updated ) {
1240
-		update_option( 'give_settings', $give_settings );
1239
+	if ($give_setting_updated) {
1240
+		update_option('give_settings', $give_settings);
1241 1241
 	}
1242 1242
 }
1243 1243
 
@@ -1256,69 +1256,69 @@  discard block
 block discarded – undo
1256 1256
 	$give_updates = Give_Updates::get_instance();
1257 1257
 
1258 1258
 	// form query.
1259
-	$donation_forms = new WP_Query( array(
1259
+	$donation_forms = new WP_Query(array(
1260 1260
 			'paged'          => $give_updates->step,
1261 1261
 			'status'         => 'any',
1262 1262
 			'order'          => 'ASC',
1263
-			'post_type'      => array( 'give_forms', 'give_payment' ),
1263
+			'post_type'      => array('give_forms', 'give_payment'),
1264 1264
 			'posts_per_page' => 20,
1265 1265
 		)
1266 1266
 	);
1267
-	if ( $donation_forms->have_posts() ) {
1268
-		$give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) );
1267
+	if ($donation_forms->have_posts()) {
1268
+		$give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20));
1269 1269
 
1270
-		while ( $donation_forms->have_posts() ) {
1270
+		while ($donation_forms->have_posts()) {
1271 1271
 			$donation_forms->the_post();
1272 1272
 			global $post;
1273 1273
 
1274
-			$meta = get_post_meta( $post->ID );
1274
+			$meta = get_post_meta($post->ID);
1275 1275
 
1276
-			switch ( $post->post_type ) {
1276
+			switch ($post->post_type) {
1277 1277
 				case 'give_forms':
1278 1278
 					// _give_set_price.
1279
-					if ( ! empty( $meta['_give_set_price'][0] ) ) {
1280
-						update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) );
1279
+					if ( ! empty($meta['_give_set_price'][0])) {
1280
+						update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0]));
1281 1281
 					}
1282 1282
 
1283 1283
 					// _give_custom_amount_minimum.
1284
-					if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) {
1285
-						update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) );
1284
+					if ( ! empty($meta['_give_custom_amount_minimum'][0])) {
1285
+						update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0]));
1286 1286
 					}
1287 1287
 
1288 1288
 					// _give_levels_minimum_amount.
1289
-					if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) {
1290
-						update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) );
1289
+					if ( ! empty($meta['_give_levels_minimum_amount'][0])) {
1290
+						update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0]));
1291 1291
 					}
1292 1292
 
1293 1293
 					// _give_levels_maximum_amount.
1294
-					if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) {
1295
-						update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) );
1294
+					if ( ! empty($meta['_give_levels_maximum_amount'][0])) {
1295
+						update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0]));
1296 1296
 					}
1297 1297
 
1298 1298
 					// _give_set_goal.
1299
-					if ( ! empty( $meta['_give_set_goal'][0] ) ) {
1300
-						update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) );
1299
+					if ( ! empty($meta['_give_set_goal'][0])) {
1300
+						update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0]));
1301 1301
 					}
1302 1302
 
1303 1303
 					// _give_form_earnings.
1304
-					if ( ! empty( $meta['_give_form_earnings'][0] ) ) {
1305
-						update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) );
1304
+					if ( ! empty($meta['_give_form_earnings'][0])) {
1305
+						update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0]));
1306 1306
 					}
1307 1307
 
1308 1308
 					// _give_custom_amount_minimum.
1309
-					if ( ! empty( $meta['_give_donation_levels'][0] ) ) {
1310
-						$donation_levels = unserialize( $meta['_give_donation_levels'][0] );
1309
+					if ( ! empty($meta['_give_donation_levels'][0])) {
1310
+						$donation_levels = unserialize($meta['_give_donation_levels'][0]);
1311 1311
 
1312
-						foreach ( $donation_levels as $index => $level ) {
1313
-							if ( empty( $level['_give_amount'] ) ) {
1312
+						foreach ($donation_levels as $index => $level) {
1313
+							if (empty($level['_give_amount'])) {
1314 1314
 								continue;
1315 1315
 							}
1316 1316
 
1317
-							$donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] );
1317
+							$donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']);
1318 1318
 						}
1319 1319
 
1320 1320
 						$meta['_give_donation_levels'] = $donation_levels;
1321
-						update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] );
1321
+						update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']);
1322 1322
 					}
1323 1323
 
1324 1324
 
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
 				case 'give_payment':
1328 1328
 					// _give_payment_total.
1329
-					if ( ! empty( $meta['_give_payment_total'][0] ) ) {
1330
-						update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) );
1329
+					if ( ! empty($meta['_give_payment_total'][0])) {
1330
+						update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0]));
1331 1331
 					}
1332 1332
 
1333 1333
 					break;
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 		wp_reset_postdata();
1339 1339
 	} else {
1340 1340
 		// The Update Ran.
1341
-		give_set_upgrade_complete( 'v1812_update_amount_values' );
1341
+		give_set_upgrade_complete('v1812_update_amount_values');
1342 1342
 	}
1343 1343
 }
1344 1344
 
@@ -1358,22 +1358,22 @@  discard block
 block discarded – undo
1358 1358
 	$offset       = 1 === $give_updates->step ? 0 : $give_updates->step * 20;
1359 1359
 
1360 1360
 	// form query.
1361
-	$donors = Give()->donors->get_donors( array(
1361
+	$donors = Give()->donors->get_donors(array(
1362 1362
 			'number' => 20,
1363 1363
 			'offset' => $offset,
1364 1364
 		)
1365 1365
 	);
1366 1366
 
1367
-	if ( ! empty( $donors ) ) {
1368
-		$give_updates->set_percentage( Give()->donors->count(), $offset );
1367
+	if ( ! empty($donors)) {
1368
+		$give_updates->set_percentage(Give()->donors->count(), $offset);
1369 1369
 
1370 1370
 		/* @var Object $donor */
1371
-		foreach ( $donors as $donor ) {
1372
-			Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) );
1371
+		foreach ($donors as $donor) {
1372
+			Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value)));
1373 1373
 		}
1374 1374
 	} else {
1375 1375
 		// The Update Ran.
1376
-		give_set_upgrade_complete( 'v1812_update_donor_purchase_values' );
1376
+		give_set_upgrade_complete('v1812_update_donor_purchase_values');
1377 1377
 	}
1378 1378
 }
1379 1379
 
@@ -1388,25 +1388,25 @@  discard block
 block discarded – undo
1388 1388
 	$offset       = 1 === $give_updates->step ? 0 : $give_updates->step * 20;
1389 1389
 
1390 1390
 	// Fetch all the existing donors.
1391
-	$donors = Give()->donors->get_donors( array(
1391
+	$donors = Give()->donors->get_donors(array(
1392 1392
 			'number' => 20,
1393 1393
 			'offset' => $offset,
1394 1394
 		)
1395 1395
 	);
1396 1396
 
1397
-	if ( ! empty( $donors ) ) {
1398
-		$give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) );
1397
+	if ( ! empty($donors)) {
1398
+		$give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20));
1399 1399
 
1400 1400
 		/* @var Object $donor */
1401
-		foreach ( $donors as $donor ) {
1401
+		foreach ($donors as $donor) {
1402 1402
 			$user_id = $donor->user_id;
1403 1403
 
1404 1404
 			// Proceed, if donor is attached with user.
1405
-			if ( $user_id ) {
1406
-				$user = get_userdata( $user_id );
1405
+			if ($user_id) {
1406
+				$user = get_userdata($user_id);
1407 1407
 
1408 1408
 				// Update user role, if user has subscriber role.
1409
-				if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) {
1409
+				if (is_array($user->roles) && in_array('subscriber', $user->roles)) {
1410 1410
 					wp_update_user(
1411 1411
 						array(
1412 1412
 							'ID'   => $user_id,
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 		}
1419 1419
 	} else {
1420 1420
 		// The Update Ran.
1421
-		give_set_upgrade_complete( 'v1813_update_donor_user_roles' );
1421
+		give_set_upgrade_complete('v1813_update_donor_user_roles');
1422 1422
 	}
1423 1423
 }
1424 1424
 
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
  */
1431 1431
 function give_v1813_upgrades() {
1432 1432
 	// Update admin setting.
1433
-	give_update_option( 'donor_default_user_role', 'give_donor' );
1433
+	give_update_option('donor_default_user_role', 'give_donor');
1434 1434
 
1435 1435
 	// Update Give roles.
1436 1436
 	$roles = new Give_Roles();
@@ -1448,33 +1448,33 @@  discard block
 block discarded – undo
1448 1448
 	$give_updates = Give_Updates::get_instance();
1449 1449
 
1450 1450
 	// form query.
1451
-	$payments = new WP_Query( array(
1451
+	$payments = new WP_Query(array(
1452 1452
 			'paged'          => $give_updates->step,
1453 1453
 			'status'         => 'any',
1454 1454
 			'order'          => 'ASC',
1455
-			'post_type'      => array( 'give_payment' ),
1455
+			'post_type'      => array('give_payment'),
1456 1456
 			'posts_per_page' => 100,
1457 1457
 		)
1458 1458
 	);
1459 1459
 
1460
-	if ( $payments->have_posts() ) {
1461
-		$give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) );
1460
+	if ($payments->have_posts()) {
1461
+		$give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100));
1462 1462
 
1463
-		while ( $payments->have_posts() ) {
1463
+		while ($payments->have_posts()) {
1464 1464
 			$payments->the_post();
1465 1465
 
1466
-			$payment_meta = give_get_payment_meta( get_the_ID() );
1466
+			$payment_meta = give_get_payment_meta(get_the_ID());
1467 1467
 
1468
-			if ( 'RIAL' === $payment_meta['currency'] ) {
1468
+			if ('RIAL' === $payment_meta['currency']) {
1469 1469
 				$payment_meta['currency'] = 'IRR';
1470
-				give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta );
1470
+				give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta);
1471 1471
 			}
1472 1472
 
1473 1473
 		}
1474 1474
 
1475 1475
 	} else {
1476 1476
 		// The Update Ran.
1477
-		give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' );
1477
+		give_set_upgrade_complete('v1817_update_donation_iranian_currency_code');
1478 1478
 	}
1479 1479
 }
1480 1480
 
@@ -1487,9 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 function give_v1817_upgrades() {
1488 1488
 	$give_settings = give_get_settings();
1489 1489
 
1490
-	if ( 'RIAL' === $give_settings['currency'] ) {
1490
+	if ('RIAL' === $give_settings['currency']) {
1491 1491
 		$give_settings['currency'] = 'IRR';
1492
-		update_option( 'give_settings', $give_settings );
1492
+		update_option('give_settings', $give_settings);
1493 1493
 	}
1494 1494
 }
1495 1495
 
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 
1503 1503
 	global $wp_roles;
1504 1504
 
1505
-	if( ! ( $wp_roles instanceof  WP_Roles ) ) {
1505
+	if ( ! ($wp_roles instanceof  WP_Roles)) {
1506 1506
 		return;
1507 1507
 	}
1508 1508
 
@@ -1526,15 +1526,15 @@  discard block
 block discarded – undo
1526 1526
 		),
1527 1527
 	);
1528 1528
 
1529
-	foreach ( $add_caps as $role => $caps ) {
1530
-		foreach ( $caps as $cap ) {
1531
-			$wp_roles->add_cap( $role, $cap );
1529
+	foreach ($add_caps as $role => $caps) {
1530
+		foreach ($caps as $cap) {
1531
+			$wp_roles->add_cap($role, $cap);
1532 1532
 		}
1533 1533
 	}
1534 1534
 
1535
-	foreach ( $remove_caps as $role => $caps ) {
1536
-		foreach ( $caps as $cap ) {
1537
-			$wp_roles->remove_cap( $role, $cap );
1535
+	foreach ($remove_caps as $role => $caps) {
1536
+		foreach ($caps as $cap) {
1537
+			$wp_roles->remove_cap($role, $cap);
1538 1538
 		}
1539 1539
 	}
1540 1540
 
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 	$roles->add_roles();
1559 1559
 	$roles->add_caps();
1560 1560
 
1561
-	give_set_upgrade_complete( 'v1817_cleanup_user_roles' );
1561
+	give_set_upgrade_complete('v1817_cleanup_user_roles');
1562 1562
 }
1563 1563
 
1564 1564
 /**
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 function give_v1818_upgrades() {
1570 1570
 
1571 1571
 	// Remove email_access_installed from give_settings.
1572
-	give_delete_option( 'email_access_installed' );
1572
+	give_delete_option('email_access_installed');
1573 1573
 }
1574 1574
 
1575 1575
 /**
@@ -1580,25 +1580,25 @@  discard block
 block discarded – undo
1580 1580
 function give_v1818_assign_custom_amount_set_donation() {
1581 1581
 
1582 1582
 	/* @var Give_Updates $give_updates */
1583
-	$give_updates   = Give_Updates::get_instance();
1583
+	$give_updates = Give_Updates::get_instance();
1584 1584
 
1585
-	$donations = new WP_Query( array(
1585
+	$donations = new WP_Query(array(
1586 1586
 			'paged'          => $give_updates->step,
1587 1587
 			'status'         => 'any',
1588 1588
 			'order'          => 'ASC',
1589
-			'post_type'      => array( 'give_payment' ),
1589
+			'post_type'      => array('give_payment'),
1590 1590
 			'posts_per_page' => 100,
1591 1591
 		)
1592 1592
 	);
1593 1593
 
1594
-	if ( $donations->have_posts() ) {
1595
-		$give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 );
1594
+	if ($donations->have_posts()) {
1595
+		$give_updates->set_percentage($donations->found_posts, $give_updates->step * 100);
1596 1596
 
1597
-		while ( $donations->have_posts() ) {
1597
+		while ($donations->have_posts()) {
1598 1598
 			$donations->the_post();
1599 1599
 
1600
-			$form          = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) );
1601
-			$donation_meta = give_get_payment_meta( get_the_ID() );
1600
+			$form          = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true));
1601
+			$donation_meta = give_get_payment_meta(get_the_ID());
1602 1602
 
1603 1603
 			// Update Donation meta with price_id set as custom, only if it is:
1604 1604
 			// 1. Donation Type = Set Donation.
@@ -1607,19 +1607,19 @@  discard block
 block discarded – undo
1607 1607
 			if (
1608 1608
 				$form->ID &&
1609 1609
 				$form->is_set_type_donation_form() &&
1610
-				( 'custom' !== $donation_meta['price_id'] ) &&
1611
-				$form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) )
1610
+				('custom' !== $donation_meta['price_id']) &&
1611
+				$form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true))
1612 1612
 			) {
1613 1613
 				$donation_meta['price_id'] = 'custom';
1614
-				give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta );
1615
-				give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' );
1614
+				give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta);
1615
+				give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom');
1616 1616
 			}
1617 1617
 		}
1618 1618
 
1619 1619
 		wp_reset_postdata();
1620 1620
 	} else {
1621 1621
 		// Update Ran Successfully.
1622
-		give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' );
1622
+		give_set_upgrade_complete('v1818_assign_custom_amount_set_donation');
1623 1623
 	}
1624 1624
 }
1625 1625
 
@@ -1630,14 +1630,14 @@  discard block
 block discarded – undo
1630 1630
  *
1631 1631
  * @since 1.8.18
1632 1632
  */
1633
-function give_v1818_give_worker_role_cleanup(){
1633
+function give_v1818_give_worker_role_cleanup() {
1634 1634
 
1635 1635
 	/* @var Give_Updates $give_updates */
1636 1636
 	$give_updates = Give_Updates::get_instance();
1637 1637
 
1638 1638
 	global $wp_roles;
1639 1639
 
1640
-	if( ! ( $wp_roles instanceof  WP_Roles ) ) {
1640
+	if ( ! ($wp_roles instanceof  WP_Roles)) {
1641 1641
 		return;
1642 1642
 	}
1643 1643
 
@@ -1655,9 +1655,9 @@  discard block
 block discarded – undo
1655 1655
 		),
1656 1656
 	);
1657 1657
 
1658
-	foreach ( $remove_caps as $role => $caps ) {
1659
-		foreach( $caps as $cap ) {
1660
-			$wp_roles->remove_cap( $role, $cap );
1658
+	foreach ($remove_caps as $role => $caps) {
1659
+		foreach ($caps as $cap) {
1660
+			$wp_roles->remove_cap($role, $cap);
1661 1661
 		}
1662 1662
 	}
1663 1663
 
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
 	$roles->add_roles();
1669 1669
 	$roles->add_caps();
1670 1670
 
1671
-	give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' );
1671
+	give_set_upgrade_complete('v1818_give_worker_role_cleanup');
1672 1672
 }
1673 1673
 
1674 1674
 /**
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 	$give_updates = Give_Updates::get_instance();
1683 1683
 
1684 1684
 	// form query
1685
-	$forms = new WP_Query( array(
1685
+	$forms = new WP_Query(array(
1686 1686
 			'paged'          => $give_updates->step,
1687 1687
 			'status'         => 'any',
1688 1688
 			'order'          => 'ASC',
@@ -1691,22 +1691,22 @@  discard block
 block discarded – undo
1691 1691
 		)
1692 1692
 	);
1693 1693
 
1694
-	if ( $forms->have_posts() ) {
1695
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) );
1694
+	if ($forms->have_posts()) {
1695
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100));
1696 1696
 
1697
-		while ( $forms->have_posts() ) {
1697
+		while ($forms->have_posts()) {
1698 1698
 			$forms->the_post();
1699 1699
 			global $post;
1700 1700
 
1701 1701
 			// Update offline instruction email notification status.
1702
-			$offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true );
1703
-			$offline_instruction_notification_status = give_is_setting_enabled( $offline_instruction_notification_status, array(
1702
+			$offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true);
1703
+			$offline_instruction_notification_status = give_is_setting_enabled($offline_instruction_notification_status, array(
1704 1704
 				'enabled',
1705 1705
 				'global',
1706
-			) )
1706
+			))
1707 1707
 				? $offline_instruction_notification_status
1708 1708
 				: 'global';
1709
-			update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status );
1709
+			update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status);
1710 1710
 
1711 1711
 			// Update offline instruction email message.
1712 1712
 			update_post_meta(
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 		wp_reset_postdata();
1739 1739
 	} else {
1740 1740
 		// No more forms found, finish up.
1741
-		give_set_upgrade_complete( 'v20_upgrades_form_metadata' );
1741
+		give_set_upgrade_complete('v20_upgrades_form_metadata');
1742 1742
 	}
1743 1743
 }
1744 1744
 
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 	$give_updates = Give_Updates::get_instance();
1756 1756
 
1757 1757
 	// form query
1758
-	$forms = new WP_Query( array(
1758
+	$forms = new WP_Query(array(
1759 1759
 			'paged'          => $give_updates->step,
1760 1760
 			'status'         => 'any',
1761 1761
 			'order'          => 'ASC',
@@ -1764,19 +1764,19 @@  discard block
 block discarded – undo
1764 1764
 		)
1765 1765
 	);
1766 1766
 
1767
-	if ( $forms->have_posts() ) {
1768
-		$give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) );
1767
+	if ($forms->have_posts()) {
1768
+		$give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100));
1769 1769
 
1770
-		while ( $forms->have_posts() ) {
1770
+		while ($forms->have_posts()) {
1771 1771
 			$forms->the_post();
1772 1772
 			global $post;
1773 1773
 
1774 1774
 			// Split _give_payment_meta meta.
1775 1775
 			// @todo Remove _give_payment_meta after releases 2.0
1776
-			$payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true );
1776
+			$payment_meta = give_get_meta($post->ID, '_give_payment_meta', true);
1777 1777
 
1778
-			if ( ! empty( $payment_meta ) ) {
1779
-				_give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta );
1778
+			if ( ! empty($payment_meta)) {
1779
+				_give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta);
1780 1780
 			}
1781 1781
 
1782 1782
 			$deprecated_meta_keys = array(
@@ -1785,9 +1785,9 @@  discard block
 block discarded – undo
1785 1785
 				'_give_payment_user_ip'     => '_give_payment_donor_ip',
1786 1786
 			);
1787 1787
 
1788
-			foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) {
1788
+			foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) {
1789 1789
 				// Do not add new meta key if already exist.
1790
-				if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) {
1790
+				if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) {
1791 1791
 					continue;
1792 1792
 				}
1793 1793
 
@@ -1796,25 +1796,25 @@  discard block
 block discarded – undo
1796 1796
 					array(
1797 1797
 						'post_id' => $post->ID,
1798 1798
 						'meta_key' => $new_meta_key,
1799
-						'meta_value' => give_get_meta( $post->ID, $old_meta_key, true )
1799
+						'meta_value' => give_get_meta($post->ID, $old_meta_key, true)
1800 1800
 					)
1801 1801
 				);
1802 1802
 			}
1803 1803
 
1804 1804
 			// Bailout
1805
-			if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) {
1805
+			if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) {
1806 1806
 				/* @var Give_Donor $donor */
1807
-				$donor = new Give_Donor( $donor_id );
1807
+				$donor = new Give_Donor($donor_id);
1808 1808
 
1809
-				$address['line1']   = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' );
1810
-				$address['line2']   = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' );
1811
-				$address['city']    = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' );
1812
-				$address['state']   = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' );
1813
-				$address['zip']     = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' );
1814
-				$address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' );
1809
+				$address['line1']   = give_get_meta($post->ID, '_give_donor_billing_address1', true, '');
1810
+				$address['line2']   = give_get_meta($post->ID, '_give_donor_billing_address2', true, '');
1811
+				$address['city']    = give_get_meta($post->ID, '_give_donor_billing_city', true, '');
1812
+				$address['state']   = give_get_meta($post->ID, '_give_donor_billing_state', true, '');
1813
+				$address['zip']     = give_get_meta($post->ID, '_give_donor_billing_zip', true, '');
1814
+				$address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, '');
1815 1815
 
1816 1816
 				// Save address.
1817
-				$donor->add_address( 'billing[]', $address );
1817
+				$donor->add_address('billing[]', $address);
1818 1818
 			}
1819 1819
 
1820 1820
 		}// End while().
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
 		// $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) );
1826 1826
 
1827 1827
 		// No more forms found, finish up.
1828
-		give_set_upgrade_complete( 'v20_upgrades_payment_metadata' );
1828
+		give_set_upgrade_complete('v20_upgrades_payment_metadata');
1829 1829
 	}
1830 1830
 }
1831 1831
 
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 	$give_updates = Give_Updates::get_instance();
1842 1842
 
1843 1843
 	// form query
1844
-	$forms = new WP_Query( array(
1844
+	$forms = new WP_Query(array(
1845 1845
 			'paged'          => $give_updates->step,
1846 1846
 			'order'          => 'DESC',
1847 1847
 			'post_type'      => 'give_log',
@@ -1850,20 +1850,20 @@  discard block
 block discarded – undo
1850 1850
 		)
1851 1851
 	);
1852 1852
 
1853
-	if ( $forms->have_posts() ) {
1854
-		$give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 );
1853
+	if ($forms->have_posts()) {
1854
+		$give_updates->set_percentage($forms->found_posts, $give_updates->step * 100);
1855 1855
 
1856
-		while ( $forms->have_posts() ) {
1856
+		while ($forms->have_posts()) {
1857 1857
 			$forms->the_post();
1858 1858
 			global $post;
1859 1859
 
1860
-			if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) {
1860
+			if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) {
1861 1861
 				continue;
1862 1862
 			}
1863 1863
 
1864
-			$term      = get_the_terms( $post->ID, 'give_log_type' );
1865
-			$term      = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
1866
-			$term_name = ! empty( $term ) ? $term->slug : '';
1864
+			$term      = get_the_terms($post->ID, 'give_log_type');
1865
+			$term      = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
1866
+			$term_name = ! empty($term) ? $term->slug : '';
1867 1867
 
1868 1868
 			$log_data = array(
1869 1869
 				'ID'           => $post->ID,
@@ -1876,29 +1876,29 @@  discard block
 block discarded – undo
1876 1876
 			);
1877 1877
 			$log_meta = array();
1878 1878
 
1879
-			if ( $old_log_meta = get_post_meta( $post->ID ) ) {
1880
-				foreach ( $old_log_meta as $meta_key => $meta_value ) {
1881
-					switch ( $meta_key ) {
1879
+			if ($old_log_meta = get_post_meta($post->ID)) {
1880
+				foreach ($old_log_meta as $meta_key => $meta_value) {
1881
+					switch ($meta_key) {
1882 1882
 						case '_give_log_payment_id':
1883
-							$log_data['log_parent']        = current( $meta_value );
1883
+							$log_data['log_parent']        = current($meta_value);
1884 1884
 							$log_meta['_give_log_form_id'] = $post->post_parent;
1885 1885
 							break;
1886 1886
 
1887 1887
 						default:
1888
-							$log_meta[ $meta_key ] = current( $meta_value );
1888
+							$log_meta[$meta_key] = current($meta_value);
1889 1889
 					}
1890 1890
 				}
1891 1891
 			}
1892 1892
 
1893
-			if ( 'api_request' === $term_name ) {
1893
+			if ('api_request' === $term_name) {
1894 1894
 				$log_meta['_give_log_api_query'] = $post->post_excerpt;
1895 1895
 			}
1896 1896
 
1897
-			$wpdb->insert( "{$wpdb->prefix}give_logs", $log_data );
1897
+			$wpdb->insert("{$wpdb->prefix}give_logs", $log_data);
1898 1898
 
1899
-			if ( ! empty( $log_meta ) ) {
1900
-				foreach ( $log_meta as $meta_key => $meta_value ) {
1901
-					Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value );
1899
+			if ( ! empty($log_meta)) {
1900
+				foreach ($log_meta as $meta_key => $meta_value) {
1901
+					Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value);
1902 1902
 				}
1903 1903
 			}
1904 1904
 
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 		Give()->logs->delete_cache();
1941 1941
 
1942 1942
 		// No more forms found, finish up.
1943
-		give_set_upgrade_complete( 'v20_logs_upgrades' );
1943
+		give_set_upgrade_complete('v20_logs_upgrades');
1944 1944
 	}
1945 1945
 }
1946 1946
 
@@ -1956,19 +1956,19 @@  discard block
 block discarded – undo
1956 1956
 	$give_updates = Give_Updates::get_instance();
1957 1957
 
1958 1958
 	// form query
1959
-	$payments = new WP_Query( array(
1959
+	$payments = new WP_Query(array(
1960 1960
 			'paged'          => $give_updates->step,
1961 1961
 			'status'         => 'any',
1962 1962
 			'order'          => 'ASC',
1963
-			'post_type'      => array( 'give_forms', 'give_payment' ),
1963
+			'post_type'      => array('give_forms', 'give_payment'),
1964 1964
 			'posts_per_page' => 100,
1965 1965
 		)
1966 1966
 	);
1967 1967
 
1968
-	if ( $payments->have_posts() ) {
1969
-		$give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 );
1968
+	if ($payments->have_posts()) {
1969
+		$give_updates->set_percentage($payments->found_posts, $give_updates->step * 100);
1970 1970
 
1971
-		while ( $payments->have_posts() ) {
1971
+		while ($payments->have_posts()) {
1972 1972
 			$payments->the_post();
1973 1973
 			global $post;
1974 1974
 
@@ -1980,19 +1980,19 @@  discard block
 block discarded – undo
1980 1980
 				ARRAY_A
1981 1981
 			);
1982 1982
 
1983
-			if ( ! empty( $meta_data ) ) {
1984
-				foreach ( $meta_data as $index => $data ) {
1983
+			if ( ! empty($meta_data)) {
1984
+				foreach ($meta_data as $index => $data) {
1985 1985
 					// Check for duplicate meta values.
1986
-					if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) .  " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) {
1986
+					if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) {
1987 1987
 						continue;
1988 1988
 					}
1989 1989
 					
1990
-					switch ( $post->post_type ) {
1990
+					switch ($post->post_type) {
1991 1991
 						case 'give_forms':
1992 1992
 							$data['form_id'] = $data['post_id'];
1993
-							unset( $data['post_id'] );
1993
+							unset($data['post_id']);
1994 1994
 
1995
-							Give()->form_meta->insert( $data );
1995
+							Give()->form_meta->insert($data);
1996 1996
 							// @todo: delete form meta from post meta table after releases 2.0.
1997 1997
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
1998 1998
 
@@ -2000,9 +2000,9 @@  discard block
 block discarded – undo
2000 2000
 
2001 2001
 						case 'give_payment':
2002 2002
 							$data['payment_id'] = $data['post_id'];
2003
-							unset( $data['post_id'] );
2003
+							unset($data['post_id']);
2004 2004
 
2005
-							Give()->payment_meta->insert( $data );
2005
+							Give()->payment_meta->insert($data);
2006 2006
 
2007 2007
 							// @todo: delete donation meta from post meta table after releases 2.0.
2008 2008
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 		wp_reset_postdata();
2018 2018
 	} else {
2019 2019
 		// No more forms found, finish up.
2020
-		give_set_upgrade_complete( 'v20_move_metadata_into_new_table' );
2020
+		give_set_upgrade_complete('v20_move_metadata_into_new_table');
2021 2021
 	}
2022 2022
 
2023 2023
 }
@@ -2033,44 +2033,44 @@  discard block
 block discarded – undo
2033 2033
 	/* @var Give_Updates $give_updates */
2034 2034
 	$give_updates = Give_Updates::get_instance();
2035 2035
 
2036
-	$donors = Give()->donors->get_donors( array(
2036
+	$donors = Give()->donors->get_donors(array(
2037 2037
 		'paged'  => $give_updates->step,
2038 2038
 		'number' => 100,
2039
-	) );
2039
+	));
2040 2040
 
2041
-	if ( $donors ) {
2042
-		$give_updates->set_percentage( count( $donors ), $give_updates->step * 100 );
2041
+	if ($donors) {
2042
+		$give_updates->set_percentage(count($donors), $give_updates->step * 100);
2043 2043
 		// Loop through Donors
2044
-		foreach ( $donors as $donor ) {
2044
+		foreach ($donors as $donor) {
2045 2045
 
2046
-			$donor_name       = explode( ' ', $donor->name, 2 );
2047
-			$donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' );
2048
-			$donor_last_name  = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' );
2046
+			$donor_name       = explode(' ', $donor->name, 2);
2047
+			$donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name');
2048
+			$donor_last_name  = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name');
2049 2049
 
2050 2050
 			// If first name meta of donor is not created, then create it.
2051
-			if ( ! $donor_first_name && isset( $donor_name[0] ) ) {
2052
-				Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] );
2051
+			if ( ! $donor_first_name && isset($donor_name[0])) {
2052
+				Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]);
2053 2053
 			}
2054 2054
 
2055 2055
 			// If last name meta of donor is not created, then create it.
2056
-			if ( ! $donor_last_name && isset( $donor_name[1] ) ) {
2057
-				Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] );
2056
+			if ( ! $donor_last_name && isset($donor_name[1])) {
2057
+				Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]);
2058 2058
 			}
2059 2059
 
2060 2060
 			// If Donor is connected with WP User then update user meta.
2061
-			if ( $donor->user_id ) {
2062
-				if ( isset( $donor_name[0] ) ) {
2063
-					update_user_meta( $donor->user_id, 'first_name', $donor_name[0] );
2061
+			if ($donor->user_id) {
2062
+				if (isset($donor_name[0])) {
2063
+					update_user_meta($donor->user_id, 'first_name', $donor_name[0]);
2064 2064
 				}
2065
-				if ( isset( $donor_name[1] ) ) {
2066
-					update_user_meta( $donor->user_id, 'last_name', $donor_name[1] );
2065
+				if (isset($donor_name[1])) {
2066
+					update_user_meta($donor->user_id, 'last_name', $donor_name[1]);
2067 2067
 				}
2068 2068
 			}
2069 2069
 		}
2070 2070
 
2071 2071
 	} else {
2072 2072
 		// The Update Ran.
2073
-		give_set_upgrade_complete( 'v20_upgrades_donor_name' );
2073
+		give_set_upgrade_complete('v20_upgrades_donor_name');
2074 2074
 	}
2075 2075
 
2076 2076
 }
@@ -2099,15 +2099,15 @@  discard block
 block discarded – undo
2099 2099
 
2100 2100
 	$users = $user_query->get_results();
2101 2101
 
2102
-	if ( $users ) {
2103
-		$give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 );
2102
+	if ($users) {
2103
+		$give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100);
2104 2104
 
2105 2105
 		// Loop through Donors
2106
-		foreach ( $users as $user ) {
2106
+		foreach ($users as $user) {
2107 2107
 			/* @var Give_Donor $donor */
2108
-			$donor = new Give_Donor( $user->ID, true );
2108
+			$donor = new Give_Donor($user->ID, true);
2109 2109
 
2110
-			if ( ! $donor->id ) {
2110
+			if ( ! $donor->id) {
2111 2111
 				continue;
2112 2112
 			}
2113 2113
 
@@ -2123,10 +2123,10 @@  discard block
 block discarded – undo
2123 2123
 				)
2124 2124
 			);
2125 2125
 
2126
-			if ( ! empty( $address ) ) {
2127
-				$address = maybe_unserialize( $address );
2128
-				$donor->add_address( 'personal', $address );
2129
-				$donor->add_address( 'billing[]', $address );
2126
+			if ( ! empty($address)) {
2127
+				$address = maybe_unserialize($address);
2128
+				$donor->add_address('personal', $address);
2129
+				$donor->add_address('billing[]', $address);
2130 2130
 
2131 2131
 
2132 2132
 				// @todo: delete _give_user_address from user meta after releases 2.0.
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
 
2137 2137
 	} else {
2138 2138
 		// The Update Ran.
2139
-		give_set_upgrade_complete( 'v20_upgrades_user_address' );
2139
+		give_set_upgrade_complete('v20_upgrades_user_address');
2140 2140
 	}
2141 2141
 
2142 2142
 }
@@ -2160,15 +2160,15 @@  discard block
 block discarded – undo
2160 2160
 	);
2161 2161
 
2162 2162
 	// Alter customer table
2163
-	foreach ( $tables as $old_table => $new_table ) {
2163
+	foreach ($tables as $old_table => $new_table) {
2164 2164
 		if (
2165
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $old_table ) ) &&
2166
-			! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", $new_table ) )
2165
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $old_table)) &&
2166
+			! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", $new_table))
2167 2167
 		) {
2168
-			$wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" );
2168
+			$wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}");
2169 2169
 
2170
-			if ( "{$wpdb->prefix}give_donormeta" === $new_table ) {
2171
-				$wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" );
2170
+			if ("{$wpdb->prefix}give_donormeta" === $new_table) {
2171
+				$wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)");
2172 2172
 			}
2173 2173
 		}
2174 2174
 	}
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 	$give_updates->percentage = 100;
2177 2177
 
2178 2178
 	// No more forms found, finish up.
2179
-	give_set_upgrade_complete( 'v20_rename_donor_tables' );
2179
+	give_set_upgrade_complete('v20_rename_donor_tables');
2180 2180
 
2181 2181
 	// Re initiate donor classes.
2182 2182
 	Give()->donors     = new Give_DB_Donors();
@@ -2191,22 +2191,22 @@  discard block
 block discarded – undo
2191 2191
  * @global wpdb $wpdb
2192 2192
  * @return void
2193 2193
  */
2194
-function give_v201_create_tables(){
2194
+function give_v201_create_tables() {
2195 2195
 	global $wpdb;
2196 2196
 
2197
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta" ) ) ) {
2197
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_paymentmeta"))) {
2198 2198
 		Give()->payment_meta->create_table();
2199 2199
 	}
2200 2200
 
2201
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta" ) ) ) {
2201
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_formmeta"))) {
2202 2202
 		Give()->form_meta->create_table();
2203 2203
 	}
2204 2204
 
2205
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs" ) ) ) {
2205
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logs"))) {
2206 2206
 		Give()->logs->log_db->create_table();
2207 2207
 	}
2208 2208
 
2209
-	if ( ! $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta" ) ) ) {
2209
+	if ( ! $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_logmeta"))) {
2210 2210
 		Give()->logs->logmeta_db->create_table();
2211 2211
 	}
2212 2212
 }
@@ -2231,31 +2231,31 @@  discard block
 block discarded – undo
2231 2231
   				$wpdb->posts.post_date >= '2018-01-08 00:00:00'
2232 2232
 			)
2233 2233
 			AND $wpdb->posts.post_type = 'give_payment'
2234
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2234
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2235 2235
 			ORDER BY $wpdb->posts.post_date ASC 
2236 2236
 			LIMIT 100
2237
-			OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) )
2237
+			OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100))
2238 2238
 	);
2239 2239
 
2240
-	if ( ! empty( $payments ) ) {
2241
-		$give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) );
2240
+	if ( ! empty($payments)) {
2241
+		$give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100));
2242 2242
 
2243
-		foreach ( $payments as $payment_id ) {
2244
-			$post = get_post( $payment_id );
2245
-			setup_postdata( $post );
2243
+		foreach ($payments as $payment_id) {
2244
+			$post = get_post($payment_id);
2245
+			setup_postdata($post);
2246 2246
 
2247 2247
 			// Do not add new meta keys if already refactored.
2248
-			if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) {
2248
+			if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) {
2249 2249
 				continue;
2250 2250
 			}
2251 2251
 
2252 2252
 
2253 2253
 			// Split _give_payment_meta meta.
2254 2254
 			// @todo Remove _give_payment_meta after releases 2.0
2255
-			$payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true );
2255
+			$payment_meta = give_get_meta($post->ID, '_give_payment_meta', true);
2256 2256
 
2257
-			if ( ! empty( $payment_meta ) ) {
2258
-				_give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta );
2257
+			if ( ! empty($payment_meta)) {
2258
+				_give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta);
2259 2259
 			}
2260 2260
 
2261 2261
 			$deprecated_meta_keys = array(
@@ -2264,9 +2264,9 @@  discard block
 block discarded – undo
2264 2264
 				'_give_payment_user_ip'     => '_give_payment_donor_ip',
2265 2265
 			);
2266 2266
 
2267
-			foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) {
2267
+			foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) {
2268 2268
 				// Do not add new meta key if already exist.
2269
-				if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) {
2269
+				if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) {
2270 2270
 					continue;
2271 2271
 				}
2272 2272
 
@@ -2275,25 +2275,25 @@  discard block
 block discarded – undo
2275 2275
 					array(
2276 2276
 						'post_id' => $post->ID,
2277 2277
 						'meta_key' => $new_meta_key,
2278
-						'meta_value' => give_get_meta( $post->ID, $old_meta_key, true )
2278
+						'meta_value' => give_get_meta($post->ID, $old_meta_key, true)
2279 2279
 					)
2280 2280
 				);
2281 2281
 			}
2282 2282
 
2283 2283
 			// Bailout
2284
-			if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) {
2284
+			if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) {
2285 2285
 				/* @var Give_Donor $donor */
2286
-				$donor = new Give_Donor( $donor_id );
2286
+				$donor = new Give_Donor($donor_id);
2287 2287
 
2288
-				$address['line1']   = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' );
2289
-				$address['line2']   = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' );
2290
-				$address['city']    = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' );
2291
-				$address['state']   = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' );
2292
-				$address['zip']     = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' );
2293
-				$address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' );
2288
+				$address['line1']   = give_get_meta($post->ID, '_give_donor_billing_address1', true, '');
2289
+				$address['line2']   = give_get_meta($post->ID, '_give_donor_billing_address2', true, '');
2290
+				$address['city']    = give_get_meta($post->ID, '_give_donor_billing_city', true, '');
2291
+				$address['state']   = give_get_meta($post->ID, '_give_donor_billing_state', true, '');
2292
+				$address['zip']     = give_get_meta($post->ID, '_give_donor_billing_zip', true, '');
2293
+				$address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, '');
2294 2294
 
2295 2295
 				// Save address.
2296
-				$donor->add_address( 'billing[]', $address );
2296
+				$donor->add_address('billing[]', $address);
2297 2297
 			}
2298 2298
 
2299 2299
 		}// End while().
@@ -2304,7 +2304,7 @@  discard block
 block discarded – undo
2304 2304
 		// $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) );
2305 2305
 
2306 2306
 		// No more forms found, finish up.
2307
-		give_set_upgrade_complete( 'v201_upgrades_payment_metadata' );
2307
+		give_set_upgrade_complete('v201_upgrades_payment_metadata');
2308 2308
 	}
2309 2309
 }
2310 2310
 
@@ -2324,18 +2324,18 @@  discard block
 block discarded – undo
2324 2324
 			SELECT ID FROM $wpdb->posts 
2325 2325
 			WHERE 1=1
2326 2326
 			AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' )
2327
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2327
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2328 2328
 			ORDER BY $wpdb->posts.post_date ASC 
2329 2329
 			LIMIT 100
2330
-			OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) )
2330
+			OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100))
2331 2331
 	);
2332 2332
 
2333
-	if ( ! empty( $payments ) ) {
2334
-		$give_updates->set_percentage( give_get_total_post_type_count( array( 'give_forms', 'give_payment' ) ), $give_updates->step * 100 );
2333
+	if ( ! empty($payments)) {
2334
+		$give_updates->set_percentage(give_get_total_post_type_count(array('give_forms', 'give_payment')), $give_updates->step * 100);
2335 2335
 
2336
-		foreach ( $payments as $payment_id ) {
2337
-			$post = get_post( $payment_id );
2338
-			setup_postdata( $post );
2336
+		foreach ($payments as $payment_id) {
2337
+			$post = get_post($payment_id);
2338
+			setup_postdata($post);
2339 2339
 
2340 2340
 			$meta_data = $wpdb->get_results(
2341 2341
 				$wpdb->prepare(
@@ -2345,19 +2345,19 @@  discard block
 block discarded – undo
2345 2345
 				ARRAY_A
2346 2346
 			);
2347 2347
 
2348
-			if ( ! empty( $meta_data ) ) {
2349
-				foreach ( $meta_data as $index => $data ) {
2348
+			if ( ! empty($meta_data)) {
2349
+				foreach ($meta_data as $index => $data) {
2350 2350
 					// Check for duplicate meta values.
2351
-					if( $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) .  " WHERE meta_id=%d", $data['meta_id'] ), ARRAY_A ) ) {
2351
+					if ($result = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta)." WHERE meta_id=%d", $data['meta_id']), ARRAY_A)) {
2352 2352
 						continue;
2353 2353
 					}
2354 2354
 
2355
-					switch ( $post->post_type ) {
2355
+					switch ($post->post_type) {
2356 2356
 						case 'give_forms':
2357 2357
 							$data['form_id'] = $data['post_id'];
2358
-							unset( $data['post_id'] );
2358
+							unset($data['post_id']);
2359 2359
 
2360
-							Give()->form_meta->insert( $data );
2360
+							Give()->form_meta->insert($data);
2361 2361
 							// @todo: delete form meta from post meta table after releases 2.0.
2362 2362
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
2363 2363
 
@@ -2365,9 +2365,9 @@  discard block
 block discarded – undo
2365 2365
 
2366 2366
 						case 'give_payment':
2367 2367
 							$data['payment_id'] = $data['post_id'];
2368
-							unset( $data['post_id'] );
2368
+							unset($data['post_id']);
2369 2369
 
2370
-							Give()->payment_meta->insert( $data );
2370
+							Give()->payment_meta->insert($data);
2371 2371
 
2372 2372
 							// @todo: delete donation meta from post meta table after releases 2.0.
2373 2373
 							/*delete_post_meta( get_the_ID(), $data['meta_key'] );*/
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 		wp_reset_postdata();
2383 2383
 	} else {
2384 2384
 		// No more forms found, finish up.
2385
-		give_set_upgrade_complete( 'v201_move_metadata_into_new_table' );
2385
+		give_set_upgrade_complete('v201_move_metadata_into_new_table');
2386 2386
 	}
2387 2387
 
2388 2388
 }
@@ -2403,26 +2403,26 @@  discard block
 block discarded – undo
2403 2403
 			SELECT ID FROM $wpdb->posts 
2404 2404
 			WHERE 1=1
2405 2405
 			AND $wpdb->posts.post_type = 'give_log'
2406
-			AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "')
2406
+			AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."')
2407 2407
 			ORDER BY $wpdb->posts.post_date ASC 
2408 2408
 			LIMIT 100
2409
-			OFFSET " . ( 1 === $give_updates->step ? 0 : ( $give_updates->step * 100 ) )
2409
+			OFFSET ".(1 === $give_updates->step ? 0 : ($give_updates->step * 100))
2410 2410
 	);
2411 2411
 
2412
-	if ( ! empty( $logs ) ) {
2413
-		$give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 );
2412
+	if ( ! empty($logs)) {
2413
+		$give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100);
2414 2414
 
2415
-		foreach ( $logs as $log_id ) {
2416
-			$post = get_post( $log_id );
2417
-			setup_postdata( $post );
2415
+		foreach ($logs as $log_id) {
2416
+			$post = get_post($log_id);
2417
+			setup_postdata($post);
2418 2418
 
2419
-			if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) {
2419
+			if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) {
2420 2420
 				continue;
2421 2421
 			}
2422 2422
 
2423
-			$term      = get_the_terms( $post->ID, 'give_log_type' );
2424
-			$term      = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
2425
-			$term_name = ! empty( $term ) ? $term->slug : '';
2423
+			$term      = get_the_terms($post->ID, 'give_log_type');
2424
+			$term      = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
2425
+			$term_name = ! empty($term) ? $term->slug : '';
2426 2426
 
2427 2427
 			$log_data = array(
2428 2428
 				'ID'           => $post->ID,
@@ -2435,29 +2435,29 @@  discard block
 block discarded – undo
2435 2435
 			);
2436 2436
 			$log_meta = array();
2437 2437
 
2438
-			if ( $old_log_meta = get_post_meta( $post->ID ) ) {
2439
-				foreach ( $old_log_meta as $meta_key => $meta_value ) {
2440
-					switch ( $meta_key ) {
2438
+			if ($old_log_meta = get_post_meta($post->ID)) {
2439
+				foreach ($old_log_meta as $meta_key => $meta_value) {
2440
+					switch ($meta_key) {
2441 2441
 						case '_give_log_payment_id':
2442
-							$log_data['log_parent']        = current( $meta_value );
2442
+							$log_data['log_parent']        = current($meta_value);
2443 2443
 							$log_meta['_give_log_form_id'] = $post->post_parent;
2444 2444
 							break;
2445 2445
 
2446 2446
 						default:
2447
-							$log_meta[ $meta_key ] = current( $meta_value );
2447
+							$log_meta[$meta_key] = current($meta_value);
2448 2448
 					}
2449 2449
 				}
2450 2450
 			}
2451 2451
 
2452
-			if ( 'api_request' === $term_name ) {
2452
+			if ('api_request' === $term_name) {
2453 2453
 				$log_meta['_give_log_api_query'] = $post->post_excerpt;
2454 2454
 			}
2455 2455
 
2456
-			$wpdb->insert( "{$wpdb->prefix}give_logs", $log_data );
2456
+			$wpdb->insert("{$wpdb->prefix}give_logs", $log_data);
2457 2457
 
2458
-			if ( ! empty( $log_meta ) ) {
2459
-				foreach ( $log_meta as $meta_key => $meta_value ) {
2460
-					Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value );
2458
+			if ( ! empty($log_meta)) {
2459
+				foreach ($log_meta as $meta_key => $meta_value) {
2460
+					Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value);
2461 2461
 				}
2462 2462
 			}
2463 2463
 
@@ -2470,7 +2470,7 @@  discard block
 block discarded – undo
2470 2470
 		Give()->logs->delete_cache();
2471 2471
 
2472 2472
 		// No more forms found, finish up.
2473
-		give_set_upgrade_complete( 'v201_logs_upgrades' );
2473
+		give_set_upgrade_complete('v201_logs_upgrades');
2474 2474
 	}
2475 2475
 }
2476 2476
 
@@ -2481,55 +2481,55 @@  discard block
 block discarded – undo
2481 2481
  * @since  2.0.1
2482 2482
  * @return void
2483 2483
  */
2484
-function give_v201_add_missing_donors_callback(){
2484
+function give_v201_add_missing_donors_callback() {
2485 2485
 	global $wpdb;
2486 2486
 	give_v201_create_tables();
2487 2487
 
2488
-	if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) ) {
2489
-		$customers  = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' );
2490
-		$donors     = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' );
2488
+	if ($wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))) {
2489
+		$customers  = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id');
2490
+		$donors     = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id');
2491 2491
 		$donor_data = array();
2492 2492
 
2493
-		if ( $missing_donors = array_diff( $customers, $donors ) ) {
2494
-			foreach ( $missing_donors as $donor_id ) {
2493
+		if ($missing_donors = array_diff($customers, $donors)) {
2494
+			foreach ($missing_donors as $donor_id) {
2495 2495
 				$donor_data[] = array(
2496
-					'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ),
2497
-					'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ),
2496
+					'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)),
2497
+					'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)),
2498 2498
 
2499 2499
 				);
2500 2500
 			}
2501 2501
 		}
2502 2502
 
2503
-		if( ! empty( $donor_data ) ) {
2503
+		if ( ! empty($donor_data)) {
2504 2504
 			$donor_table_name = Give()->donors->table_name;
2505 2505
 			$donor_meta_table_name = Give()->donor_meta->table_name;
2506 2506
 
2507 2507
 			Give()->donors->table_name = "{$wpdb->prefix}give_donors";
2508 2508
 			Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta";
2509 2509
 
2510
-			foreach ( $donor_data as $donor ) {
2510
+			foreach ($donor_data as $donor) {
2511 2511
 				$donor['info'][0] = (array) $donor['info'][0];
2512 2512
 
2513 2513
 				// Prevent duplicate meta id issue.
2514
-				if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ){
2514
+				if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) {
2515 2515
 					continue;
2516 2516
 				}
2517 2517
 
2518
-				$donor_id = Give()->donors->add( $donor['info'][0] );
2518
+				$donor_id = Give()->donors->add($donor['info'][0]);
2519 2519
 
2520
-				if( ! empty( $donor['meta'] ) ) {
2521
-					foreach ( $donor['meta'] as $donor_meta ) {
2520
+				if ( ! empty($donor['meta'])) {
2521
+					foreach ($donor['meta'] as $donor_meta) {
2522 2522
 						$donor_meta = (array) $donor_meta;
2523 2523
 
2524 2524
 						// Prevent duplicate meta id issue.
2525
-						if( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ){
2526
-							unset( $donor_meta['meta_id'] );
2525
+						if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) {
2526
+							unset($donor_meta['meta_id']);
2527 2527
 						}
2528 2528
 
2529 2529
 						$donor_meta['donor_id'] = $donor_meta['customer_id'];
2530
-						unset( $donor_meta['customer_id'] );
2530
+						unset($donor_meta['customer_id']);
2531 2531
 
2532
-						Give()->donor_meta->insert( $donor_meta );
2532
+						Give()->donor_meta->insert($donor_meta);
2533 2533
 					}
2534 2534
 				}
2535 2535
 
@@ -2548,35 +2548,35 @@  discard block
 block discarded – undo
2548 2548
 					)
2549 2549
 				);
2550 2550
 
2551
-				$donor = new Give_Donor( $donor_id );
2551
+				$donor = new Give_Donor($donor_id);
2552 2552
 
2553
-				if ( ! empty( $address ) ) {
2554
-					$address = maybe_unserialize( $address );
2555
-					$donor->add_address( 'personal', $address );
2556
-					$donor->add_address( 'billing[]', $address );
2553
+				if ( ! empty($address)) {
2554
+					$address = maybe_unserialize($address);
2555
+					$donor->add_address('personal', $address);
2556
+					$donor->add_address('billing[]', $address);
2557 2557
 				}
2558 2558
 
2559
-				$donor_name       = explode( ' ', $donor->name, 2 );
2560
-				$donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' );
2561
-				$donor_last_name  = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' );
2559
+				$donor_name       = explode(' ', $donor->name, 2);
2560
+				$donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name');
2561
+				$donor_last_name  = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name');
2562 2562
 
2563 2563
 				// If first name meta of donor is not created, then create it.
2564
-				if ( ! $donor_first_name && isset( $donor_name[0] ) ) {
2565
-					Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] );
2564
+				if ( ! $donor_first_name && isset($donor_name[0])) {
2565
+					Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]);
2566 2566
 				}
2567 2567
 
2568 2568
 				// If last name meta of donor is not created, then create it.
2569
-				if ( ! $donor_last_name && isset( $donor_name[1] ) ) {
2570
-					Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] );
2569
+				if ( ! $donor_last_name && isset($donor_name[1])) {
2570
+					Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]);
2571 2571
 				}
2572 2572
 
2573 2573
 				// If Donor is connected with WP User then update user meta.
2574
-				if ( $donor->user_id ) {
2575
-					if ( isset( $donor_name[0] ) ) {
2576
-						update_user_meta( $donor->user_id, 'first_name', $donor_name[0] );
2574
+				if ($donor->user_id) {
2575
+					if (isset($donor_name[0])) {
2576
+						update_user_meta($donor->user_id, 'first_name', $donor_name[0]);
2577 2577
 					}
2578
-					if ( isset( $donor_name[1] ) ) {
2579
-						update_user_meta( $donor->user_id, 'last_name', $donor_name[1] );
2578
+					if (isset($donor_name[1])) {
2579
+						update_user_meta($donor->user_id, 'last_name', $donor_name[1]);
2580 2580
 					}
2581 2581
 				}
2582 2582
 			}
@@ -2587,5 +2587,5 @@  discard block
 block discarded – undo
2587 2587
 	}
2588 2588
 
2589 2589
 	Give_Updates::get_instance()->percentage = 100;
2590
-	give_set_upgrade_complete('v201_add_missing_donors' );
2590
+	give_set_upgrade_complete('v201_add_missing_donors');
2591 2591
 }
2592 2592
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 1 patch
Spacing   +206 added lines, -212 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,97 +398,97 @@  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->data ) ? 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->data) ? wp_list_pluck($batch->data, 'id') : array();
413 411
 		$log_data             = '';
414
-		$doing_upgrade_args   = get_option( 'give_doing_upgrade' );
412
+		$doing_upgrade_args   = get_option('give_doing_upgrade');
415 413
 
416
-		if( ! empty( $doing_upgrade_args ) ) {
417
-			$log_data .= 'Doing update:' . "\n";
418
-			$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
414
+		if ( ! empty($doing_upgrade_args)) {
415
+			$log_data .= 'Doing update:'."\n";
416
+			$log_data .= print_r($doing_upgrade_args, true)."\n";
419 417
 		}
420 418
 
421
-		if ( ! empty( $batch->data ) ) {
419
+		if ( ! empty($batch->data)) {
422 420
 
423
-			foreach ( $batch->data as $index => $update ) {
424
-				$log_data = print_r( $update, true ) . "\n";
421
+			foreach ($batch->data as $index => $update) {
422
+				$log_data = print_r($update, true)."\n";
425 423
 
426
-				if ( ! is_callable( $update['callback'] ) ) {
427
-					$log_data .= 'Removing missing callback update: ' . "{$update['id']}\n";
428
-					unset( $batch->data[ $index ] );
424
+				if ( ! is_callable($update['callback'])) {
425
+					$log_data .= 'Removing missing callback update: '."{$update['id']}\n";
426
+					unset($batch->data[$index]);
429 427
 				}
430 428
 
431
-				if ( ! empty( $update['depend'] ) ) {
429
+				if ( ! empty($update['depend'])) {
432 430
 
433
-					foreach ( $update['depend'] as $depend ) {
434
-						if ( give_has_upgrade_completed( $depend ) ) {
435
-							$log_data .= 'Completed update: ' . "{$depend}\n";
431
+					foreach ($update['depend'] as $depend) {
432
+						if (give_has_upgrade_completed($depend)) {
433
+							$log_data .= 'Completed update: '."{$depend}\n";
436 434
 							continue;
437 435
 						}
438 436
 
439
-						if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) {
440
-							$log_data .= 'Adding missing update: ' . "{$depend}\n";
441
-							array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] );
437
+						if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) {
438
+							$log_data .= 'Adding missing update: '."{$depend}\n";
439
+							array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]);
442 440
 						}
443 441
 					}
444 442
 				}
445 443
 			}
446 444
 		}
447 445
 
448
-		if ( $new_updates = $this->get_updates( 'database', 'new' ) ) {
449
-			$all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array();
446
+		if ($new_updates = $this->get_updates('database', 'new')) {
447
+			$all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array();
450 448
 
451
-			foreach ( $new_updates as $index => $new_update ) {
452
-				if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) {
453
-					unset( $new_updates[ $index ] );
449
+			foreach ($new_updates as $index => $new_update) {
450
+				if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) {
451
+					unset($new_updates[$index]);
454 452
 				}
455 453
 			}
456 454
 
457
-			if ( ! empty( $new_updates ) ) {
458
-				$log_data .= 'Adding new update: ' . "\n";
459
-				$log_data .= print_r( $new_updates, true ) . "\n";
455
+			if ( ! empty($new_updates)) {
456
+				$log_data .= 'Adding new update: '."\n";
457
+				$log_data .= print_r($new_updates, true)."\n";
460 458
 
461
-				$batch->data = array_merge( (array) $batch->data, $new_updates );
462
-				update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) );
459
+				$batch->data = array_merge((array) $batch->data, $new_updates);
460
+				update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates)));
463 461
 			}
464 462
 		}
465 463
 
466
-		if ( $batch_data_count !== count( $batch->data ) ) {
467
-			$log_data .= 'Updating batch' . "\n";
468
-			$log_data .= print_r( $batch, true );
464
+		if ($batch_data_count !== count($batch->data)) {
465
+			$log_data .= 'Updating batch'."\n";
466
+			$log_data .= print_r($batch, true);
469 467
 
470
-			$doing_upgrade_args['heading']          = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) );
468
+			$doing_upgrade_args['heading']          = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count'));
471 469
 			$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage();
472
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
470
+			update_option('give_doing_upgrade', $doing_upgrade_args);
473 471
 
474
-			if ( ! empty( $batch->key ) ) {
475
-				update_option( $batch->key, $batch->data );
472
+			if ( ! empty($batch->key)) {
473
+				update_option($batch->key, $batch->data);
476 474
 			} else {
477 475
 
478
-				update_option( 'give_db_update_count', count( $batch->data ) );
476
+				update_option('give_db_update_count', count($batch->data));
479 477
 
480 478
 				$doing_upgrade_args['update']  = $give_updates->update;
481
-				$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) );
479
+				$doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, count($batch->data));
482 480
 
483
-				update_option( 'give_doing_upgrade', $doing_upgrade_args );
481
+				update_option('give_doing_upgrade', $doing_upgrade_args);
484 482
 
485
-				foreach ( $batch->data as $data ) {
486
-					Give_Updates::$background_updater->push_to_queue( $data );
483
+				foreach ($batch->data as $data) {
484
+					Give_Updates::$background_updater->push_to_queue($data);
487 485
 				}
488 486
 
489 487
 				Give_Updates::$background_updater->save();
490 488
 			}
491 489
 
492 490
 
493
-			Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' );
491
+			Give()->logs->add('Update Health Check', $log_data, 0, 'update');
494 492
 		}
495 493
 	}
496 494
 
@@ -503,63 +501,63 @@  discard block
 block discarded – undo
503 501
 	 */
504 502
 	public function __show_notice() {
505 503
 		// Bailout.
506
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
504
+		if ( ! current_user_can('manage_give_settings')) {
507 505
 			return;
508 506
 		}
509 507
 
510 508
 		// Run DB updates.
511
-		if ( ! empty( $_GET['give-run-db-update'] ) ) {
509
+		if ( ! empty($_GET['give-run-db-update'])) {
512 510
 			$this->run_db_update();
513 511
 		}
514 512
 
515 513
 
516 514
 		// Bailout.
517
-		if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) {
515
+		if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
518 516
 			return;
519 517
 		}
520 518
 
521 519
 		// Show notice if upgrade paused.
522
-		if ( self::$background_updater->is_paused_process() ) {
520
+		if (self::$background_updater->is_paused_process()) {
523 521
 			ob_start();
524 522
 			?>
525 523
 			<p>
526
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
527
-				&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' ); ?>
524
+				<strong><?php _e('Database Update', 'give'); ?></strong>
525
+				&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'); ?>
528 526
 			</p>
529 527
 			<p class="submit">
530
-				<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">
531
-					<?php _e( 'Restart the updater', 'give' ); ?>
528
+				<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">
529
+					<?php _e('Restart the updater', 'give'); ?>
532 530
 				</a>
533 531
 			</p>
534 532
 			<script type="text/javascript">
535 533
 				jQuery('.give-restart-updater-btn').click('click', function () {
536
-					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
534
+					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
537 535
 				});
538 536
 			</script>
539 537
 			<?php
540 538
 			$desc_html = ob_get_clean();
541 539
 
542 540
 
543
-			Give()->notices->register_notice( array(
541
+			Give()->notices->register_notice(array(
544 542
 				'id'          => 'give_upgrade_db',
545 543
 				'type'        => 'error',
546 544
 				'dismissible' => false,
547 545
 				'description' => $desc_html,
548
-			) );
546
+			));
549 547
 		}
550 548
 
551 549
 		// Bailout if doing upgrades.
552
-		if( $this->is_doing_updates() ) {
550
+		if ($this->is_doing_updates()) {
553 551
 			return;
554 552
 		}
555 553
 
556 554
 		// Show notice if ajax is not working.
557
-		if ( ! give_test_ajax_works() ) {
555
+		if ( ! give_test_ajax_works()) {
558 556
 			Give()->notices->register_notice(
559 557
 				array(
560 558
 					'id'          => 'give_db_upgrade_ajax_inaccessible',
561 559
 					'type'        => 'error',
562
-					'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%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;' ),
560
+					'description' => sprintf('%1$s <a href="%2$s" target="_blank">%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;'),
563 561
 					'show'        => true,
564 562
 				)
565 563
 			);
@@ -568,46 +566,46 @@  discard block
 block discarded – undo
568 566
 		}
569 567
 
570 568
 		// Show db upgrade completed notice.
571
-		if ( ! empty( $_GET['give-db-update-completed'] ) ) {
572
-			Give()->notices->register_notice( array(
569
+		if ( ! empty($_GET['give-db-update-completed'])) {
570
+			Give()->notices->register_notice(array(
573 571
 				'id'          => 'give_db_upgrade_completed',
574 572
 				'type'        => 'updated',
575
-				'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
573
+				'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
576 574
 				'show'        => true,
577
-			) );
575
+			));
578 576
 
579 577
 			// Start update.
580
-		} elseif ( ! empty( $_GET['give-run-db-update'] ) ) {
578
+		} elseif ( ! empty($_GET['give-run-db-update'])) {
581 579
 			$this->run_db_update();
582 580
 
583 581
 			// Show run the update notice.
584
-		} elseif ( $this->get_total_new_db_update_count() ) {
582
+		} elseif ($this->get_total_new_db_update_count()) {
585 583
 			ob_start();
586 584
 			?>
587 585
 			<p>
588
-				<strong><?php _e( 'Database Update', 'give' ); ?></strong>
589
-				&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' ); ?>
586
+				<strong><?php _e('Database Update', 'give'); ?></strong>
587
+				&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'); ?>
590 588
 			</p>
591 589
 			<p class="submit">
592
-				<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">
593
-					<?php _e( 'Run the updater', 'give' ); ?>
590
+				<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">
591
+					<?php _e('Run the updater', 'give'); ?>
594 592
 				</a>
595 593
 			</p>
596 594
 			<script type="text/javascript">
597 595
 				jQuery('.give-run-update-now').click('click', function () {
598
-					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
596
+					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
599 597
 				});
600 598
 			</script>
601 599
 			<?php
602 600
 			$desc_html = ob_get_clean();
603 601
 
604 602
 
605
-			Give()->notices->register_notice( array(
603
+			Give()->notices->register_notice(array(
606 604
 				'id'          => 'give_upgrade_db',
607 605
 				'type'        => 'updated',
608 606
 				'dismissible' => false,
609 607
 				'description' => $desc_html,
610
-			) );
608
+			));
611 609
 		}
612 610
 	}
613 611
 
@@ -618,7 +616,7 @@  discard block
 block discarded – undo
618 616
 	 * @access public
619 617
 	 */
620 618
 	public function render_complete_page() {
621
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
619
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
622 620
 	}
623 621
 
624 622
 	/**
@@ -628,7 +626,7 @@  discard block
 block discarded – undo
628 626
 	 * @access public
629 627
 	 */
630 628
 	public function render_page() {
631
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
629
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
632 630
 	}
633 631
 
634 632
 	/**
@@ -639,26 +637,26 @@  discard block
 block discarded – undo
639 637
 	 */
640 638
 	private function run_db_update() {
641 639
 		// Bailout.
642
-		if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) {
640
+		if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) {
643 641
 			return;
644 642
 		}
645 643
 
646
-		$updates = $this->get_updates( 'database', 'new' );
644
+		$updates = $this->get_updates('database', 'new');
647 645
 
648
-		foreach ( $updates as $update ) {
649
-			self::$background_updater->push_to_queue( $update );
646
+		foreach ($updates as $update) {
647
+			self::$background_updater->push_to_queue($update);
650 648
 		}
651 649
 
652
-		add_option( 'give_db_update_count', count( $updates ), '', 'no' );
650
+		add_option('give_db_update_count', count($updates), '', 'no');
653 651
 
654
-		add_option( 'give_doing_upgrade', array(
652
+		add_option('give_doing_upgrade', array(
655 653
 			'update_info' => $updates[0],
656 654
 			'step'        => 1,
657 655
 			'update'      => 1,
658
-			'heading'     => sprintf( 'Update %s of %s', 1, count( $updates ) ),
656
+			'heading'     => sprintf('Update %s of %s', 1, count($updates)),
659 657
 			'percentage'  => 0,
660 658
 			'total_percentage'  => 0,
661
-		), '', 'no' );
659
+		), '', 'no');
662 660
 
663 661
 		self::$background_updater->save()->dispatch();
664 662
 	}
@@ -672,11 +670,11 @@  discard block
 block discarded – undo
672 670
 	 */
673 671
 	public function __flush_resume_updates() {
674 672
 		//delete_option( 'give_doing_upgrade' );
675
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
673
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
676 674
 
677 675
 		// Reset counter.
678 676
 		$this->step = $this->percentage = 0;
679
-		++ $this->update;
677
+		++$this->update;
680 678
 	}
681 679
 
682 680
 
@@ -691,7 +689,7 @@  discard block
 block discarded – undo
691 689
 	public function __give_start_updating() {
692 690
 		// Check permission.
693 691
 		if (
694
-			! current_user_can( 'manage_give_settings' ) ||
692
+			! current_user_can('manage_give_settings') ||
695 693
 			$this->is_doing_updates()
696 694
 		) {
697 695
 			wp_send_json_error();
@@ -699,7 +697,7 @@  discard block
 block discarded – undo
699 697
 
700 698
 		// @todo: validate nonce
701 699
 		// @todo: set http method to post
702
-		if ( empty( $_POST['run_db_update'] ) ) {
700
+		if (empty($_POST['run_db_update'])) {
703 701
 			wp_send_json_error();
704 702
 		}
705 703
 
@@ -718,21 +716,21 @@  discard block
 block discarded – undo
718 716
 	 * @return string
719 717
 	 */
720 718
 	public function __give_db_updates_info() {
721
-		$update_info   = get_option( 'give_doing_upgrade' );
719
+		$update_info   = get_option('give_doing_upgrade');
722 720
 		$response_type = '';
723 721
 
724
-		if ( empty( $update_info ) ) {
725
-			$update_info   = array(
726
-				'message'    => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ),
727
-				'heading'    => __( 'Updates Completed.', 'give' ),
722
+		if (empty($update_info)) {
723
+			$update_info = array(
724
+				'message'    => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'),
725
+				'heading'    => __('Updates Completed.', 'give'),
728 726
 				'percentage' => 0,
729 727
 			);
730 728
 			$response_type = 'success';
731 729
 
732
-			delete_option( 'give_show_db_upgrade_complete_notice' );
730
+			delete_option('give_show_db_upgrade_complete_notice');
733 731
 		}
734 732
 
735
-		$this->send_ajax_response( $update_info, $response_type );
733
+		$this->send_ajax_response($update_info, $response_type);
736 734
 	}
737 735
 
738 736
 	/**
@@ -744,7 +742,7 @@  discard block
 block discarded – undo
744 742
 	 * @param        $data
745 743
 	 * @param string $type
746 744
 	 */
747
-	public function send_ajax_response( $data, $type = '' ) {
745
+	public function send_ajax_response($data, $type = '') {
748 746
 		$default = array(
749 747
 			'message'    => '',
750 748
 			'heading'    => '',
@@ -754,24 +752,24 @@  discard block
 block discarded – undo
754 752
 		);
755 753
 
756 754
 		// Set data.
757
-		$data = wp_parse_args( $data, $default );
755
+		$data = wp_parse_args($data, $default);
758 756
 
759 757
 		// Enable cache.
760 758
 		Give_Cache::enable();
761 759
 
762
-		switch ( $type ) {
760
+		switch ($type) {
763 761
 			case 'success':
764
-				wp_send_json_success( $data );
762
+				wp_send_json_success($data);
765 763
 				break;
766 764
 
767 765
 			case 'error':
768
-				wp_send_json_error( $data );
766
+				wp_send_json_error($data);
769 767
 				break;
770 768
 
771 769
 			default:
772
-				wp_send_json( array(
770
+				wp_send_json(array(
773 771
 					'data' => $data,
774
-				) );
772
+				));
775 773
 				break;
776 774
 		}
777 775
 	}
@@ -785,12 +783,12 @@  discard block
 block discarded – undo
785 783
 	 * @param $total
786 784
 	 * @param $current_total
787 785
 	 */
788
-	public function set_percentage( $total, $current_total ) {
786
+	public function set_percentage($total, $current_total) {
789 787
 		// Set percentage.
790
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
788
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
791 789
 
792 790
 		// Verify percentage.
793
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
791
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
794 792
 	}
795 793
 
796 794
 	/**
@@ -803,22 +801,22 @@  discard block
 block discarded – undo
803 801
 	 *
804 802
 	 * @return bool|null
805 803
 	 */
806
-	public function is_parent_updates_completed( $update ) {
804
+	public function is_parent_updates_completed($update) {
807 805
 		// Bailout.
808
-		if ( empty( $update['depend'] ) ) {
806
+		if (empty($update['depend'])) {
809 807
 			return true;
810 808
 		}
811 809
 
812 810
 		// Check if dependency is valid or not.
813
-		if ( ! $this->has_valid_dependency( $update ) ) {
811
+		if ( ! $this->has_valid_dependency($update)) {
814 812
 			return null;
815 813
 		}
816 814
 
817 815
 		$is_dependency_completed = true;
818 816
 
819
-		foreach ( $update['depend'] as $depend ) {
817
+		foreach ($update['depend'] as $depend) {
820 818
 
821
-			if ( ! give_has_upgrade_completed( $depend ) ) {
819
+			if ( ! give_has_upgrade_completed($depend)) {
822 820
 				$is_dependency_completed = false;
823 821
 				break;
824 822
 			}
@@ -835,7 +833,7 @@  discard block
 block discarded – undo
835 833
 	 * @return bool
836 834
 	 */
837 835
 	public function is_doing_updates() {
838
-		return (bool) get_option( 'give_doing_upgrade' );
836
+		return (bool) get_option('give_doing_upgrade');
839 837
 	}
840 838
 
841 839
 
@@ -849,7 +847,7 @@  discard block
 block discarded – undo
849 847
 	 *
850 848
 	 * @return bool
851 849
 	 */
852
-	public function has_valid_dependency( $update ) {
850
+	public function has_valid_dependency($update) {
853 851
 		$is_valid_dependency = true;
854 852
 		// $update_ids          = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' );
855 853
 		//
@@ -875,32 +873,32 @@  discard block
 block discarded – undo
875 873
 	 *
876 874
 	 * @return array
877 875
 	 */
878
-	public function get_updates( $update_type = '', $status = 'all' ) {
876
+	public function get_updates($update_type = '', $status = 'all') {
879 877
 		// return all updates.
880
-		if ( empty( $update_type ) ) {
878
+		if (empty($update_type)) {
881 879
 			return $this->updates;
882 880
 		}
883 881
 
884 882
 		// Get specific update.
885
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
883
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
886 884
 
887 885
 		// Bailout.
888
-		if ( empty( $updates ) ) {
886
+		if (empty($updates)) {
889 887
 			return $updates;
890 888
 		}
891 889
 
892
-		switch ( $status ) {
890
+		switch ($status) {
893 891
 			case 'new':
894 892
 				// Remove already completed updates.
895 893
 				$completed_updates = give_get_completed_upgrades();
896 894
 
897
-				if ( ! empty( $completed_updates ) ) {
898
-					foreach ( $updates as $index => $update ) {
899
-						if ( in_array( $update['id'], $completed_updates ) ) {
900
-							unset( $updates[ $index ] );
895
+				if ( ! empty($completed_updates)) {
896
+					foreach ($updates as $index => $update) {
897
+						if (in_array($update['id'], $completed_updates)) {
898
+							unset($updates[$index]);
901 899
 						}
902 900
 					}
903
-					$updates = array_values( $updates );
901
+					$updates = array_values($updates);
904 902
 				}
905 903
 
906 904
 				break;
@@ -917,7 +915,7 @@  discard block
 block discarded – undo
917 915
 	 * @return int
918 916
 	 */
919 917
 	public function get_total_plugin_update_count() {
920
-		return count( $this->get_updates( 'plugin' ) );
918
+		return count($this->get_updates('plugin'));
921 919
 	}
922 920
 
923 921
 	/**
@@ -932,7 +930,7 @@  discard block
 block discarded – undo
932 930
 		$db_update_count     = $this->get_pending_db_update_count();
933 931
 		$plugin_update_count = $this->get_total_plugin_update_count();
934 932
 
935
-		return ( $db_update_count + $plugin_update_count );
933
+		return ($db_update_count + $plugin_update_count);
936 934
 	}
937 935
 
938 936
 	/**
@@ -944,7 +942,7 @@  discard block
 block discarded – undo
944 942
 	 * @return int
945 943
 	 */
946 944
 	public function get_pending_db_update_count() {
947
-		return count( $this->get_updates( 'database', 'new' ) );
945
+		return count($this->get_updates('database', 'new'));
948 946
 	}
949 947
 
950 948
 	/**
@@ -956,7 +954,7 @@  discard block
 block discarded – undo
956 954
 	 * @return int
957 955
 	 */
958 956
 	public function get_total_db_update_count() {
959
-		return count( $this->get_updates( 'database', 'all' ) );
957
+		return count($this->get_updates('database', 'all'));
960 958
 	}
961 959
 
962 960
 	/**
@@ -969,8 +967,7 @@  discard block
 block discarded – undo
969 967
 	 */
970 968
 	public function get_total_new_db_update_count() {
971 969
 		return $this->is_doing_updates() ?
972
-			get_option( 'give_db_update_count' ) :
973
-			$this->get_pending_db_update_count();
970
+			get_option('give_db_update_count') : $this->get_pending_db_update_count();
974 971
 	}
975 972
 
976 973
 	/**
@@ -982,11 +979,10 @@  discard block
 block discarded – undo
982 979
 	 * @return int
983 980
 	 */
984 981
 	public function get_running_db_update() {
985
-		$current_update = get_option( 'give_doing_upgrade' );
982
+		$current_update = get_option('give_doing_upgrade');
986 983
 
987 984
 		return $this->is_doing_updates() ?
988
-			$current_update['update'] :
989
-			1;
985
+			$current_update['update'] : 1;
990 986
 	}
991 987
 
992 988
 	/**
@@ -998,23 +994,21 @@  discard block
 block discarded – undo
998 994
 	 */
999 995
 	public function get_db_update_processing_percentage() {
1000 996
 		// Bailout.
1001
-		if ( ! $this->get_total_new_db_update_count() ) {
997
+		if ( ! $this->get_total_new_db_update_count()) {
1002 998
 			return 0;
1003 999
 		}
1004 1000
 
1005
-		$resume_update            = get_option( 'give_doing_upgrade' );
1006
-		$update_count_percentages = ( ( $this->get_running_db_update() - 1 ) / $this->get_total_new_db_update_count() ) * 100;
1007
-		$update_percentage_share  = ( 1 / $this->get_total_new_db_update_count() ) * 100;
1008
-		$upgrade_percentage       = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 );
1001
+		$resume_update            = get_option('give_doing_upgrade');
1002
+		$update_count_percentages = (($this->get_running_db_update() - 1) / $this->get_total_new_db_update_count()) * 100;
1003
+		$update_percentage_share  = (1 / $this->get_total_new_db_update_count()) * 100;
1004
+		$upgrade_percentage       = (($resume_update['percentage'] * $update_percentage_share) / 100);
1009 1005
 
1010 1006
 		$final_percentage = $update_count_percentages + $upgrade_percentage;
1011 1007
 
1012 1008
 		return $this->is_doing_updates() ?
1013
-			( absint( $final_percentage ) ?
1014
-				absint( $final_percentage ) :
1015
-				round( $final_percentage, 2 )
1016
-			) :
1017
-			0;
1009
+			(absint($final_percentage) ?
1010
+				absint($final_percentage) : round($final_percentage, 2)
1011
+			) : 0;
1018 1012
 	}
1019 1013
 }
1020 1014
 
Please login to merge, or discard this patch.
includes/admin/payments/payments-history.php 1 patch
Spacing   +23 added lines, -23 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
 
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
  * @return      void
25 25
 */
26 26
 function give_payment_history_page() {
27
-	if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) {
28
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php';
27
+	if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) {
28
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php';
29 29
 	} else {
30
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
30
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
31 31
 		$payments_table = new Give_Payment_History_Table();
32 32
 		$payments_table->prepare_items();
33 33
 	?>
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 		 *
42 42
 		 * @since 1.7
43 43
 		 */
44
-		do_action( 'give_payments_page_top' );
44
+		do_action('give_payments_page_top');
45 45
 		?>
46 46
 		<hr class="wp-header-end">
47 47
 
48
-		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
48
+		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
49 49
 			<input type="hidden" name="post_type" value="give_forms" />
50 50
 			<input type="hidden" name="page" value="give-payment-history" />
51 51
 			<?php $payments_table->views() ?>
52 52
 			<?php $payments_table->advanced_filters(); ?>
53 53
 		</form>
54 54
 
55
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
55
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
56 56
 			<input type="hidden" name="post_type" value="give_forms" />
57 57
 			<input type="hidden" name="page" value="give-payment-history" />
58 58
 			<?php
59
-			if ( ! empty( $_GET['donor'] ) ) {
60
-				echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) );
59
+			if ( ! empty($_GET['donor'])) {
60
+				echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor']));
61 61
 			}
62 62
 
63 63
 			$payments_table->display();
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		 *
71 71
 		 * @since 1.7
72 72
 		 */
73
-		do_action( 'give_payments_page_bottom' );
73
+		do_action('give_payments_page_bottom');
74 74
 		?>
75 75
 
76 76
 	</div>
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
  * @param $title
88 88
  * @return string
89 89
  */
90
-function give_view_order_details_title( $admin_title, $title ) {
90
+function give_view_order_details_title($admin_title, $title) {
91 91
 
92
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) {
92
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base) {
93 93
 		return $admin_title;
94 94
 	}
95 95
 
96
-	if( ! isset( $_GET['give-action'] ) ) {
96
+	if ( ! isset($_GET['give-action'])) {
97 97
 		return $admin_title;
98 98
 	}
99 99
 
100
-	switch( $_GET['give-action'] ) :
100
+	switch ($_GET['give-action']) :
101 101
 
102 102
 		case 'view-payment-details' :
103 103
 			$title = sprintf(
104 104
 				/* translators: %s: admin title */
105
-				esc_html__( 'View Donation Details - %s', 'give' ),
105
+				esc_html__('View Donation Details - %s', 'give'),
106 106
 				$admin_title
107 107
 			);
108 108
 			break;
109 109
 		case 'edit-payment' :
110 110
 			$title = sprintf(
111 111
 				/* translators: %s: admin title */
112
-				esc_html__( 'Edit Donation - %s', 'give' ),
112
+				esc_html__('Edit Donation - %s', 'give'),
113 113
 				$admin_title
114 114
 			);
115 115
 			break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 	return $title;
122 122
 }
123
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
123
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
124 124
 
125 125
 /**
126 126
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen.
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
  * @param $context
133 133
  * @return string
134 134
  */
135
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
135
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
136 136
 
137
-	$post = get_post( $post_id );
137
+	$post = get_post($post_id);
138 138
 
139
-	if( ! $post ) {
139
+	if ( ! $post) {
140 140
 		return $url;
141 141
 	}
142 142
 
143
-	if( 'give_payment' != $post->post_type ) {
143
+	if ('give_payment' != $post->post_type) {
144 144
 		return $url;
145 145
 	}
146 146
 
147
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id );
147
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id);
148 148
 
149 149
 	return $url;
150 150
 }
151
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
151
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.
give.php 1 patch
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 // Exit if accessed directly.
42
-if ( ! defined( 'ABSPATH' ) ) {
42
+if ( ! defined('ABSPATH')) {
43 43
 	exit;
44 44
 }
45 45
 
46
-if ( ! class_exists( 'Give' ) ) :
46
+if ( ! class_exists('Give')) :
47 47
 
48 48
 	/**
49 49
 	 * Main Give Class
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		 * @return    Give
238 238
 		 */
239 239
 		public static function instance() {
240
-			if ( is_null( self::$_instance ) ) {
240
+			if (is_null(self::$_instance)) {
241 241
 				self::$_instance = new self();
242 242
 			}
243 243
 
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 		 */
250 250
 		public function __construct() {
251 251
 			// PHP version
252
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
253
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
252
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
253
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
254 254
 			}
255 255
 
256 256
 			// Bailout: Need minimum php version to load plugin.
257
-			if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
258
-				add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) );
257
+			if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) {
258
+				add_action('admin_notices', array($this, 'minmum_phpversion_notice'));
259 259
 
260 260
 				return;
261 261
 			}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 			$this->includes();
266 266
 			$this->init_hooks();
267 267
 
268
-			do_action( 'give_loaded' );
268
+			do_action('give_loaded');
269 269
 		}
270 270
 
271 271
 		/**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 		 * @since  1.8.9
275 275
 		 */
276 276
 		private function init_hooks() {
277
-			register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
278
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
277
+			register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
278
+			add_action('plugins_loaded', array($this, 'init'), 0);
279 279
 		}
280 280
 
281 281
 		/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			 *
291 291
 			 * @since 1.8.9
292 292
 			 */
293
-			do_action( 'before_give_init' );
293
+			do_action('before_give_init');
294 294
 
295 295
 			// Set up localization.
296 296
 			$this->load_textdomain();
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			 *
321 321
 			 * @since 1.8.7
322 322
 			 */
323
-			do_action( 'give_init', $this );
323
+			do_action('give_init', $this);
324 324
 
325 325
 		}
326 326
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		 */
338 338
 		public function __clone() {
339 339
 			// Cloning instances of the class is forbidden.
340
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
340
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
341 341
 		}
342 342
 
343 343
 		/**
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		 */
351 351
 		public function __wakeup() {
352 352
 			// Unserializing instances of the class is forbidden.
353
-			give_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
353
+			give_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
354 354
 		}
355 355
 
356 356
 		/**
@@ -364,33 +364,33 @@  discard block
 block discarded – undo
364 364
 		private function setup_constants() {
365 365
 
366 366
 			// Plugin version
367
-			if ( ! defined( 'GIVE_VERSION' ) ) {
368
-				define( 'GIVE_VERSION', '2.0.2' );
367
+			if ( ! defined('GIVE_VERSION')) {
368
+				define('GIVE_VERSION', '2.0.2');
369 369
 			}
370 370
 
371 371
 			// Plugin Root File
372
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
373
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
372
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
373
+				define('GIVE_PLUGIN_FILE', __FILE__);
374 374
 			}
375 375
 
376 376
 			// Plugin Folder Path
377
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
378
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( GIVE_PLUGIN_FILE ) );
377
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
378
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(GIVE_PLUGIN_FILE));
379 379
 			}
380 380
 
381 381
 			// Plugin Folder URL
382
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
383
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( GIVE_PLUGIN_FILE ) );
382
+			if ( ! defined('GIVE_PLUGIN_URL')) {
383
+				define('GIVE_PLUGIN_URL', plugin_dir_url(GIVE_PLUGIN_FILE));
384 384
 			}
385 385
 
386 386
 			// Plugin Basename aka: "give/give.php"
387
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
388
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( GIVE_PLUGIN_FILE ) );
387
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
388
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(GIVE_PLUGIN_FILE));
389 389
 			}
390 390
 
391 391
 			// Make sure CAL_GREGORIAN is defined
392
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
393
-				define( 'CAL_GREGORIAN', 1 );
392
+			if ( ! defined('CAL_GREGORIAN')) {
393
+				define('CAL_GREGORIAN', 1);
394 394
 			}
395 395
 		}
396 396
 
@@ -408,152 +408,152 @@  discard block
 block discarded – undo
408 408
 			/**
409 409
 			 * Load libraries.
410 410
 			 */
411
-			if ( ! class_exists( 'WP_Async_Request' ) ) {
412
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-async-request.php' );
411
+			if ( ! class_exists('WP_Async_Request')) {
412
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-async-request.php');
413 413
 			}
414 414
 
415
-			if ( ! class_exists( 'WP_Background_Process' ) ) {
416
-				include_once( GIVE_PLUGIN_DIR . 'includes/libraries/wp-background-process.php' );
415
+			if ( ! class_exists('WP_Background_Process')) {
416
+				include_once(GIVE_PLUGIN_DIR.'includes/libraries/wp-background-process.php');
417 417
 			}
418 418
 
419 419
 			/**
420 420
 			 * Load plugin files
421 421
 			 */
422
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
423
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
422
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
423
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
424 424
 			$give_options = give_get_settings();
425 425
 
426
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
427
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-async-process.php';
428
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
429
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
430
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
431
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
432
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
433
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
434
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
435
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
436
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-tooltips.php';
437
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
438
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-translation.php';
439
-
440
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
441
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
442
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
443
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
444
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-meta.php';
445
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
446
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
447
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
448
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
449
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
450
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
451
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
452
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
453
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
454
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-payment-meta.php';
455
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-form-meta.php';
456
-
457
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
458
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
459
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
460
-			require_once GIVE_PLUGIN_DIR . 'includes/import-functions.php';
461
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
462
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
463
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
464
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
465
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
466
-			require_once GIVE_PLUGIN_DIR . 'includes/currency-functions.php';
467
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
468
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
469
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
470
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
471
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
472
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
473
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
474
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
475
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
476
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
477
-
478
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/backward-compatibility.php';
479
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
480
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
481
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
482
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
483
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
484
-
485
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
486
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
487
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
488
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
489
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
490
-
491
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
492
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
493
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notifications.php';
494
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
495
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
496
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
497
-
498
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/class-give-donors-query.php';
499
-			require_once GIVE_PLUGIN_DIR . 'includes/donors/backward-compatibility.php';
500
-
501
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
502
-
503
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
504
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
426
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
427
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-async-process.php';
428
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
429
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
430
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
431
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
432
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
433
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
434
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
435
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
436
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-tooltips.php';
437
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
438
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-translation.php';
439
+
440
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
441
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
442
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
443
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
444
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-meta.php';
445
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
446
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
447
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
448
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
449
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
450
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
451
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
452
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
453
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
454
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-payment-meta.php';
455
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-form-meta.php';
456
+
457
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
458
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
459
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
460
+			require_once GIVE_PLUGIN_DIR.'includes/import-functions.php';
461
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
462
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
463
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
464
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
465
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
466
+			require_once GIVE_PLUGIN_DIR.'includes/currency-functions.php';
467
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
468
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
469
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
470
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
471
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
472
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
473
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
474
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
475
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
476
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
477
+
478
+			require_once GIVE_PLUGIN_DIR.'includes/payments/backward-compatibility.php';
479
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
480
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
481
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
482
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
483
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
484
+
485
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
486
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
487
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
488
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
489
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
490
+
491
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
492
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
493
+			require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notifications.php';
494
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
495
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
496
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
497
+
498
+			require_once GIVE_PLUGIN_DIR.'includes/donors/class-give-donors-query.php';
499
+			require_once GIVE_PLUGIN_DIR.'includes/donors/backward-compatibility.php';
500
+
501
+			require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php';
502
+
503
+			if (defined('WP_CLI') && WP_CLI) {
504
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
505 505
 			}
506 506
 
507
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
508
-
509
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
510
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
511
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
512
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
513
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
514
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
515
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
516
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
517
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
518
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
519
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-blank-slate.php';
520
-
521
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
522
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
523
-
524
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
525
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
526
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
527
-
528
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
529
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
530
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
531
-
532
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
533
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
534
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
535
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
536
-
537
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php';
538
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php';
539
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php';
540
-
541
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
542
-
543
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
544
-
545
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
546
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
547
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
548
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
549
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
550
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
551
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
552
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
553
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
507
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
508
+
509
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
510
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
511
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
512
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
513
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
514
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
515
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
516
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
517
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
518
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
519
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-blank-slate.php';
520
+
521
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
522
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
523
+
524
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
525
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
526
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
527
+
528
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
529
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
530
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
531
+
532
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
533
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
534
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
535
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
536
+
537
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php';
538
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php';
539
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php';
540
+
541
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php';
542
+
543
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
544
+
545
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
546
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
547
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
548
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
549
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
550
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
551
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
552
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
553
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
554 554
 			}// End if().
555 555
 
556
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
556
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
557 557
 
558 558
 		}
559 559
 
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		public function load_textdomain() {
569 569
 
570 570
 			// Set filter for Give's languages directory
571
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
572
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
571
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
572
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
573 573
 
574 574
 			// Traditional WordPress plugin locale filter.
575
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
576
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
575
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
576
+			$locale = apply_filters('plugin_locale', $locale, 'give');
577 577
 
578
-			unload_textdomain( 'give' );
579
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
580
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
578
+			unload_textdomain('give');
579
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
580
+			load_plugin_textdomain('give', false, $give_lang_dir);
581 581
 
582 582
 		}
583 583
 
@@ -590,17 +590,17 @@  discard block
 block discarded – undo
590 590
 		 */
591 591
 		public function minmum_phpversion_notice() {
592 592
 			// Bailout.
593
-			if ( ! is_admin() ) {
593
+			if ( ! is_admin()) {
594 594
 				return;
595 595
 			}
596 596
 
597
-			$notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>';
598
-			$notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>';
599
-			$notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>';
600
-			$notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
601
-			$notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>';
602
-			$notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
603
-			$notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>';
597
+			$notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>';
598
+			$notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>';
599
+			$notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>';
600
+			$notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>';
601
+			$notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>';
602
+			$notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>';
603
+			$notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>';
604 604
 
605 605
 			echo sprintf(
606 606
 				'<div class="notice notice-error">%1$s</div>',
Please login to merge, or discard this patch.