Test Failed
Pull Request — master (#2482)
by Devin
05:37
created
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * Return the calculated completion percentage.
217 217
 	 *
218 218
 	 * @since 1.8.12
219
-	 * @return int
219
+	 * @return double
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222 222
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
+	/**
357
+	 * @param integer $page
358
+	 */
356 359
 	public function get_delete_ids( $donation_ids, $page ) {
357 360
 		$index            = $page --;
358 361
 		$count            = count( $donation_ids );
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 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
 
@@ -116,34 +116,34 @@  discard block
 block discarded – undo
116 116
 		$donor_ids    = array();
117 117
 
118 118
 		// Check if the ajax request if running for the first time.
119
-		if ( 1 === (int) $this->step ) {
119
+		if (1 === (int) $this->step) {
120 120
 			// Delete all the form ids.
121
-			$this->delete_option( $this->form_key );
121
+			$this->delete_option($this->form_key);
122 122
 			// Delete all the donation ids.
123
-			$this->delete_option( $this->donation_key );
123
+			$this->delete_option($this->donation_key);
124 124
 			// Delete all the donor ids.
125
-			$this->delete_option( $this->donor_key );
125
+			$this->delete_option($this->donor_key);
126 126
 
127 127
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
128
-			$this->update_option( $this->step_key, 'count' );
128
+			$this->update_option($this->step_key, 'count');
129 129
 
130 130
 			// Delete tha page count of the step.
131
-			$this->update_option( $this->step_on_key, '0' );
131
+			$this->update_option($this->step_on_key, '0');
132 132
 		} else {
133 133
 			// Get the old donors list.
134
-			$donor_ids = $this->get_option( $this->donor_key );
134
+			$donor_ids = $this->get_option($this->donor_key);
135 135
 
136 136
 			// Get the old donation list.
137
-			$donation_ids = $this->get_option( $this->donation_key );
137
+			$donation_ids = $this->get_option($this->donation_key);
138 138
 		}
139 139
 
140 140
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
141 141
 		$step = (int) $this->get_step();
142
-		if ( 1 === $step ) {
142
+		if (1 === $step) {
143 143
 			/**
144 144
 			 * Will add or update the donation and donor data by running wp query.
145 145
 			 */
146
-			$this->count( $step, $donation_ids, $donor_ids );
146
+			$this->count($step, $donation_ids, $donor_ids);
147 147
 		}
148 148
 	}
149 149
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param array $donation_ids Contain the list of all the donation id's that has being add before this
155 155
 	 * @param array $donor_ids Contain the list of all the donors id's that has being add before this
156 156
 	 */
157
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
157
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
158 158
 
159 159
 		// Get the Page count by default it's zero.
160 160
 		$paged = (int) $this->get_step_page();
161 161
 		// Incresed the page count by one.
162
-		++ $paged;
162
+		++$paged;
163 163
 
164 164
 		/**
165 165
 		 * Filter add to alter the argument before the wp quest run
166 166
 		 */
167
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
167
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
168 168
 			'post_type'      => 'give_payment',
169 169
 			'post_status'    => 'any',
170 170
 			'posts_per_page' => $this->per_step,
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
 			'meta_key'       => '_give_payment_import',
173 173
 			'meta_value_num' => 1,
174 174
 			'meta_compare'   => '=',
175
-		) );
175
+		));
176 176
 
177 177
 		// Reset the post data.
178 178
 		wp_reset_postdata();
179 179
 		// Getting the new donation.
180
-		$donation_posts = new WP_Query( $args );
180
+		$donation_posts = new WP_Query($args);
181 181
 
182 182
 		// The Loop.
183
-		if ( $donation_posts->have_posts() ) {
184
-			while ( $donation_posts->have_posts() ) {
183
+		if ($donation_posts->have_posts()) {
184
+			while ($donation_posts->have_posts()) {
185 185
 				$add_author = true;
186 186
 				$donation_posts->the_post();
187 187
 				global $post;
188 188
 				// Add the donation id in side the array.
189 189
 				$donation_ids[] = $post->ID;
190 190
 
191
-				$donor_id = (int) get_post_meta( $post->ID, '_give_payment_customer_id', true );
192
-				if ( ! empty( $donor_id ) ) {
193
-					$donor = new Give_Donor( $donor_id );
194
-					if ( ! empty( $donor->id ) ) {
195
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
191
+				$donor_id = (int) get_post_meta($post->ID, '_give_payment_customer_id', true);
192
+				if ( ! empty($donor_id)) {
193
+					$donor = new Give_Donor($donor_id);
194
+					if ( ! empty($donor->id)) {
195
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
196 196
 							$add_author = false;
197
-							$count      = (int) count( $donor->payment_ids );
198
-							if ( 1 === $count ) {
199
-								Give()->donors->delete( $donor->id );
197
+							$count      = (int) count($donor->payment_ids);
198
+							if (1 === $count) {
199
+								Give()->donors->delete($donor->id);
200 200
 							} else {
201
-								$donor->remove_payment( $post->ID );
201
+								$donor->remove_payment($post->ID);
202 202
 								$donor->decrease_donation_count();
203 203
 							}
204 204
 						}
205 205
 					}
206 206
 				}
207 207
 
208
-				if ( ! empty( $add_author ) ) {
208
+				if ( ! empty($add_author)) {
209 209
 					// Add the donor id in side the array.
210 210
 					$donor_ids[] = (int) $post->post_author;
211 211
 				}
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 		$max_num_pages = (int) $donation_posts->max_num_pages;
221 221
 
222 222
 		// Check current page is less then max number of page or not
223
-		if ( $paged < $max_num_pages ) {
223
+		if ($paged < $max_num_pages) {
224 224
 			// Update the curretn page virable for the next step
225
-			$this->update_option( $this->step_on_key, $paged );
225
+			$this->update_option($this->step_on_key, $paged);
226 226
 
227 227
 			// Calculating percentage.
228 228
 			$page_remain          = $max_num_pages - $paged;
229
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
229
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
230 230
 			$this->step_completed = $paged;
231 231
 		} else {
232
-			$donation_ids_count = count( $donor_ids );
233
-			$this->update_option( $this->step_key, 'donation' );
234
-			$this->update_option( $this->step_on_key, '0' );
232
+			$donation_ids_count = count($donor_ids);
233
+			$this->update_option($this->step_key, 'donation');
234
+			$this->update_option($this->step_on_key, '0');
235 235
 		}
236 236
 
237
-		$donor_ids = array_unique( $donor_ids );
238
-		$this->update_option( $this->donor_key, $donor_ids );
239
-		$this->update_option( $this->donation_key, $donation_ids );
237
+		$donor_ids = array_unique($donor_ids);
238
+		$this->update_option($this->donor_key, $donor_ids);
239
+		$this->update_option($this->donation_key, $donation_ids);
240 240
 
241 241
 		wp_reset_postdata();
242 242
 	}
@@ -248,34 +248,34 @@  discard block
 block discarded – undo
248 248
 	 * @return int
249 249
 	 */
250 250
 	public function get_percentage_complete() {
251
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
251
+		return ceil((100 * $this->step_completed) / $this->total_step);
252 252
 	}
253 253
 
254 254
 	public function process_step() {
255 255
 
256
-		if ( ! $this->can_export() ) {
257
-			wp_die( __( 'You do not have permission to delete Import transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
256
+		if ( ! $this->can_export()) {
257
+			wp_die(__('You do not have permission to delete Import transactions.', 'give'), __('Error', 'give'), array('response' => 403));
258 258
 		}
259 259
 
260 260
 		$had_data = $this->get_data();
261 261
 
262
-		if ( $had_data ) {
262
+		if ($had_data) {
263 263
 			$this->done = false;
264 264
 
265 265
 			return true;
266 266
 		} else {
267
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
268
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
267
+			update_option('give_earnings_total', give_get_total_earnings(true));
268
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
269 269
 
270
-			$this->delete_option( $this->donation_key );
270
+			$this->delete_option($this->donation_key);
271 271
 
272 272
 			// Reset the sequential order numbers
273
-			if ( give_get_option( 'enable_sequential' ) ) {
274
-				delete_option( 'give_last_payment_number' );
273
+			if (give_get_option('enable_sequential')) {
274
+				delete_option('give_last_payment_number');
275 275
 			}
276 276
 
277 277
 			$this->done    = true;
278
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
278
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
279 279
 
280 280
 			return false;
281 281
 		}
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	public function get_data() {
294 294
 
295 295
 		// Get the donation id's.
296
-		$donation_ids = $this->get_option( $this->donation_key );
296
+		$donation_ids = $this->get_option($this->donation_key);
297 297
 
298 298
 		/**
299 299
 		 * Return false id not Import donation is found.
300 300
 		 */
301
-		if ( empty( $donation_ids ) ) {
301
+		if (empty($donation_ids)) {
302 302
 			$this->is_empty   = true;
303 303
 			$this->total_step = 1;
304 304
 
@@ -309,110 +309,110 @@  discard block
 block discarded – undo
309 309
 		$step = (int) $this->get_step();
310 310
 
311 311
 		// get teh donor ids.
312
-		$donor_ids = $this->get_option( $this->donor_key );
312
+		$donor_ids = $this->get_option($this->donor_key);
313 313
 
314 314
 		// In step to we delete all the donation in loop.
315
-		if ( 2 === $step ) {
315
+		if (2 === $step) {
316 316
 			$pass_to_donor = false;
317 317
 			$page          = (int) $this->get_step_page();
318
-			$page ++;
319
-			$count = count( $donation_ids );
318
+			$page++;
319
+			$count = count($donation_ids);
320 320
 
321
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
321
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
322 322
 			$this->step_completed = $page;
323 323
 
324 324
 
325
-			if ( $count > $this->per_step ) {
325
+			if ($count > $this->per_step) {
326 326
 
327
-				$this->update_option( $this->step_on_key, $page );
328
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
329
-				$current_page = (int) ceil( $count / $this->per_step );
327
+				$this->update_option($this->step_on_key, $page);
328
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
329
+				$current_page = (int) ceil($count / $this->per_step);
330 330
 
331
-				if ( $page === $current_page ) {
331
+				if ($page === $current_page) {
332 332
 					$pass_to_donor = true;
333 333
 				}
334 334
 			} else {
335 335
 				$pass_to_donor = true;
336 336
 			}
337 337
 
338
-			if ( true === $pass_to_donor ) {
339
-				$this->update_option( $this->step_key, 'donor' );
340
-				$this->update_option( $this->step_on_key, '0' );
338
+			if (true === $pass_to_donor) {
339
+				$this->update_option($this->step_key, 'donor');
340
+				$this->update_option($this->step_on_key, '0');
341 341
 			}
342 342
 
343 343
 			// Get the old form list.
344
-			$form_ids = (array) $this->get_option( $this->form_key );
344
+			$form_ids = (array) $this->get_option($this->form_key);
345 345
 
346
-			foreach ( $donation_ids as $item ) {
347
-				$form_ids[] = get_post_meta( $item, '_give_payment_form_id', true );
346
+			foreach ($donation_ids as $item) {
347
+				$form_ids[] = get_post_meta($item, '_give_payment_form_id', true);
348 348
 
349 349
 				// Delete the main payment.
350
-				give_delete_donation( absint( $item ) );
350
+				give_delete_donation(absint($item));
351 351
 			}
352 352
 
353 353
 			// update the new form list.
354
-			$this->update_option( $this->form_key, $form_ids );
354
+			$this->update_option($this->form_key, $form_ids);
355 355
 		}
356 356
 
357 357
 
358 358
 		// Here we delete all the donor
359
-		if ( 3 === $step ) {
359
+		if (3 === $step) {
360 360
 
361 361
 			// Get the old form list.
362
-			$form_ids = (array) $this->get_option( $this->form_key );
363
-			if ( ! empty( $form_ids ) ) {
364
-				$form_ids = array_unique( $form_ids );
365
-				foreach ( $form_ids as $form_id ) {
366
-					give_recount_form_income_donation( (int) $form_id );
362
+			$form_ids = (array) $this->get_option($this->form_key);
363
+			if ( ! empty($form_ids)) {
364
+				$form_ids = array_unique($form_ids);
365
+				foreach ($form_ids as $form_id) {
366
+					give_recount_form_income_donation((int) $form_id);
367 367
 				}
368 368
 			}
369 369
 			// update the new form list.
370
-			$this->update_option( $this->form_key, array() );
370
+			$this->update_option($this->form_key, array());
371 371
 
372 372
 			$page  = (int) $this->get_step_page();
373
-			$count = count( $donor_ids );
373
+			$count = count($donor_ids);
374 374
 
375
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
376
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
375
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
376
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
377 377
 
378
-			if ( ! empty( $donor_ids[ $page ] ) ) {
379
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
378
+			if ( ! empty($donor_ids[$page])) {
379
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
380 380
 					'post_status'    => 'any',
381 381
 					'posts_per_page' => 1,
382
-					'author'         => $donor_ids[ $page ]
383
-				) );
382
+					'author'         => $donor_ids[$page]
383
+				));
384 384
 
385 385
 				$donations = array();
386
-				$payments  = new Give_Payments_Query( $args );
386
+				$payments  = new Give_Payments_Query($args);
387 387
 				$payments  = $payments->get_payments();
388
-				if ( empty( $payments ) ) {
389
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
388
+				if (empty($payments)) {
389
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
390 390
 
391 391
 					/**
392 392
 					 * If Checked then delete WP user.
393 393
 					 *
394 394
 					 * @since 1.8.14
395 395
 					 */
396
-					if ( 'on' === (string) $_REQUEST['delete-import-donors'] ) {
397
-						wp_delete_user( $donor_ids[ $page ] );
396
+					if ('on' === (string) $_REQUEST['delete-import-donors']) {
397
+						wp_delete_user($donor_ids[$page]);
398 398
 					}
399 399
 				} else {
400
-					foreach ( $payments as $payment ) {
400
+					foreach ($payments as $payment) {
401 401
 						$donations[] = $payment->ID;
402 402
 					}
403 403
 
404
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
404
+					$donor          = new Give_Donor($donor_ids[$page], true);
405 405
 					$data_to_update = array(
406
-						'purchase_count' => count( $donations ),
407
-						'payment_ids'    => implode( ',', $donations ),
406
+						'purchase_count' => count($donations),
407
+						'payment_ids'    => implode(',', $donations),
408 408
 					);
409
-					$donor->update( $data_to_update );
409
+					$donor->update($data_to_update);
410 410
 				}
411 411
 			}
412 412
 
413
-			$page ++;
414
-			$this->update_option( $this->step_on_key, $page );
415
-			if ( $count === $page ) {
413
+			$page++;
414
+			$this->update_option($this->step_on_key, $page);
415
+			if ($count === $page) {
416 416
 				$this->is_empty = false;
417 417
 
418 418
 				return false;
@@ -424,24 +424,24 @@  discard block
 block discarded – undo
424 424
 		return true;
425 425
 	}
426 426
 
427
-	public function get_delete_ids( $donation_ids, $page ) {
428
-		$index            = $page --;
429
-		$count            = count( $donation_ids );
427
+	public function get_delete_ids($donation_ids, $page) {
428
+		$index            = $page--;
429
+		$count            = count($donation_ids);
430 430
 		$temp             = 0;
431 431
 		$current_page     = 0;
432 432
 		$post_delete      = $this->per_step;
433 433
 		$page_donation_id = array();
434 434
 
435
-		foreach ( $donation_ids as $item ) {
436
-			$temp ++;
437
-			$page_donation_id[ $current_page ][] = $item;
438
-			if ( $temp === $post_delete ) {
439
-				$current_page ++;
435
+		foreach ($donation_ids as $item) {
436
+			$temp++;
437
+			$page_donation_id[$current_page][] = $item;
438
+			if ($temp === $post_delete) {
439
+				$current_page++;
440 440
 				$temp = 0;
441 441
 			}
442 442
 		}
443 443
 
444
-		return $page_donation_id[ $page ];
444
+		return $page_donation_id[$page];
445 445
 	}
446 446
 
447 447
 	/**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return mixed       Returns the data from the database
455 455
 	 */
456
-	public function get_option( $key, $defalut_value = false ) {
457
-		return get_option( $key, $defalut_value );
456
+	public function get_option($key, $defalut_value = false) {
457
+		return get_option($key, $defalut_value);
458 458
 	}
459 459
 
460 460
 	/**
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @return void
469 469
 	 */
470
-	public function update_option( $key, $value ) {
471
-		update_option( $key, $value, false );
470
+	public function update_option($key, $value) {
471
+		update_option($key, $value, false);
472 472
 	}
473 473
 
474 474
 	/**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return void
482 482
 	 */
483
-	public function delete_option( $key ) {
484
-		delete_option( $key );
483
+	public function delete_option($key) {
484
+		delete_option($key);
485 485
 	}
486 486
 
487 487
 	/**
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 	 * @return int|string
493 493
 	 */
494 494
 	private function get_step() {
495
-		$step_key = (string) $this->get_option( $this->step_key, false );
496
-		if ( 'count' === $step_key ) {
495
+		$step_key = (string) $this->get_option($this->step_key, false);
496
+		if ('count' === $step_key) {
497 497
 			return 1;
498
-		} elseif ( 'donation' === $step_key ) {
498
+		} elseif ('donation' === $step_key) {
499 499
 			return 2;
500
-		} elseif ( 'donor' === $step_key ) {
500
+		} elseif ('donor' === $step_key) {
501 501
 			return 3;
502 502
 		} else {
503 503
 			return $step_key;
@@ -508,6 +508,6 @@  discard block
 block discarded – undo
508 508
 	 * Get the current $page value in the ajax.
509 509
 	 */
510 510
 	private function get_step_page() {
511
-		return $this->get_option( $this->step_on_key, false );
511
+		return $this->get_option($this->step_on_key, false);
512 512
 	}
513 513
 }
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -671,7 +671,7 @@
 block discarded – undo
671 671
 /**
672 672
  * This function will check whether the donor email is primary or additional.
673 673
  *
674
- * @param $email Donor Email.
674
+ * @param string $email Donor Email.
675 675
  *
676 676
  * @since 1.8.13
677 677
  *
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return      bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return      array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount());
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return      int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return      float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param string $username
331 331
 	 * @param bool   $form_id
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( ! is_email( $email ) ) {
357
+	} elseif ( ! is_email($email)) {
358 358
 		// Validate email.
359
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
359
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( $registering_new_user ) {
362
+	} elseif ($registering_new_user) {
363 363
 
364 364
 		// If donor email is not primary
365
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
365
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
366 366
 			// Check if email exists.
367
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
367
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
368 368
 			$valid = false;
369 369
 		}
370 370
 	}
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @param string $email
379 379
 	 * @param bool   $registering_new_user
380 380
 	 */
381
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
381
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
382 382
 
383 383
 	return $valid;
384 384
 }
@@ -394,34 +394,34 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return bool
396 396
  */
397
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
397
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
398 398
 	$valid = true;
399 399
 
400 400
 	// Passwords Validation For New Donors Only
401
-	if ( $registering_new_user ) {
401
+	if ($registering_new_user) {
402 402
 		// Password or confirmation missing.
403
-		if ( ! $password ) {
403
+		if ( ! $password) {
404 404
 			// The password is invalid.
405
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
405
+			give_set_error('password_empty', __('Enter a password.', 'give'));
406 406
 			$valid = false;
407
-		} elseif ( ! $confirm_password ) {
407
+		} elseif ( ! $confirm_password) {
408 408
 			// Confirmation password is invalid.
409
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
409
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
410 410
 			$valid = false;
411 411
 		}
412 412
 	}
413 413
 	// Passwords Validation For New Donors as well as Existing Donors
414
-	if ( $password || $confirm_password ) {
415
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
414
+	if ($password || $confirm_password) {
415
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
416 416
 			// Seems Weak Password
417
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
417
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
418 418
 			$valid = false;
419 419
 		}
420
-		if ( $password && $confirm_password ) {
420
+		if ($password && $confirm_password) {
421 421
 			// Verify confirmation matches.
422
-			if ( $password != $confirm_password ) {
422
+			if ($password != $confirm_password) {
423 423
 				// Passwords do not match
424
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
424
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
425 425
 				$valid = false;
426 426
 			}
427 427
 		}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @param string $confirm_password
438 438
 	 * @param bool   $registering_new_user
439 439
 	 */
440
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
440
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
441 441
 
442 442
 	return $valid;
443 443
 }
@@ -455,20 +455,20 @@  discard block
 block discarded – undo
455 455
  *
456 456
  * @return      void
457 457
  */
458
-function give_add_past_donations_to_new_user( $user_id ) {
458
+function give_add_past_donations_to_new_user($user_id) {
459 459
 
460
-	$email = get_the_author_meta( 'user_email', $user_id );
460
+	$email = get_the_author_meta('user_email', $user_id);
461 461
 
462
-	$payments = give_get_payments( array(
462
+	$payments = give_get_payments(array(
463 463
 		'output' => 'payments',
464 464
 		's' => $email,
465
-	) );
465
+	));
466 466
 
467
-	if ( $payments ) {
468
-		foreach ( $payments as $payment ) {
467
+	if ($payments) {
468
+		foreach ($payments as $payment) {
469 469
 			/* @var $payment \Give_Payment */
470 470
 
471
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
471
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
472 472
 				continue;
473 473
 			}
474 474
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 
481 481
 }
482 482
 
483
-add_action( 'user_register', 'give_add_past_donations_to_new_user' );
483
+add_action('user_register', 'give_add_past_donations_to_new_user');
484 484
 
485 485
 
486 486
 /**
@@ -506,34 +506,34 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @return        array The donor's address, if any
508 508
  */
509
-function give_get_donor_address( $user_id = 0 ) {
510
-	if ( empty( $user_id ) ) {
509
+function give_get_donor_address($user_id = 0) {
510
+	if (empty($user_id)) {
511 511
 		$user_id = get_current_user_id();
512 512
 	}
513 513
 
514
-	$address = (array) get_user_meta( $user_id, '_give_user_address', true );
514
+	$address = (array) get_user_meta($user_id, '_give_user_address', true);
515 515
 
516
-	if ( ! isset( $address['line1'] ) ) {
516
+	if ( ! isset($address['line1'])) {
517 517
 		$address['line1'] = '';
518 518
 	}
519 519
 
520
-	if ( ! isset( $address['line2'] ) ) {
520
+	if ( ! isset($address['line2'])) {
521 521
 		$address['line2'] = '';
522 522
 	}
523 523
 
524
-	if ( ! isset( $address['city'] ) ) {
524
+	if ( ! isset($address['city'])) {
525 525
 		$address['city'] = '';
526 526
 	}
527 527
 
528
-	if ( ! isset( $address['zip'] ) ) {
528
+	if ( ! isset($address['zip'])) {
529 529
 		$address['zip'] = '';
530 530
 	}
531 531
 
532
-	if ( ! isset( $address['country'] ) ) {
532
+	if ( ! isset($address['country'])) {
533 533
 		$address['country'] = '';
534 534
 	}
535 535
 
536
-	if ( ! isset( $address['state'] ) ) {
536
+	if ( ! isset($address['state'])) {
537 537
 		$address['state'] = '';
538 538
 	}
539 539
 
@@ -553,53 +553,53 @@  discard block
 block discarded – undo
553 553
  *
554 554
  * @return        void
555 555
  */
556
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
556
+function give_new_user_notification($user_id = 0, $user_data = array()) {
557 557
 
558
-	if ( empty( $user_id ) || empty( $user_data ) ) {
558
+	if (empty($user_id) || empty($user_data)) {
559 559
 		return;
560 560
 	}
561
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
561
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
562 562
 
563 563
 	// New User Registration: Email sends to the site admin.
564 564
 	$emails = Give()->emails;
565
-	$emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
565
+	$emails->__set('heading', esc_html__('New User Registration', 'give'));
566 566
 
567 567
 	/* translators: %s: site name */
568
-	$message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n";
568
+	$message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n";
569 569
 	/* translators: %s: user login */
570
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
570
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
571 571
 	/* translators: %s: user email */
572
-	$message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n";
572
+	$message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n";
573 573
 
574
-	$message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view &raquo;', 'give' ) . '</a>' . "\r\n";
574
+	$message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view &raquo;', 'give').'</a>'."\r\n";
575 575
 
576 576
 	$emails->send(
577
-		get_option( 'admin_email' ),
577
+		get_option('admin_email'),
578 578
 		sprintf(
579 579
 			/* translators: %s: site name */
580
-			esc_attr__( '[%s] New User Registration', 'give' ),
580
+			esc_attr__('[%s] New User Registration', 'give'),
581 581
 			$blogname
582 582
 		),
583 583
 		$message
584 584
 	);
585 585
 
586 586
 	// Account Information: Email sends to donor who registered.
587
-	$emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) );
587
+	$emails->__set('heading', esc_html__('Account Information', 'give'));
588 588
 
589
-	$message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n";
589
+	$message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n";
590 590
 
591 591
 	/* translators: %s: user login */
592
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
592
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
593 593
 	/* translators: %s: password */
594
-	$message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n";
594
+	$message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n";
595 595
 
596
-	$message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login &raquo;', 'give' ) . '</a>' . "\r\n";
596
+	$message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login &raquo;', 'give').'</a>'."\r\n";
597 597
 
598 598
 	$emails->send(
599 599
 		$user_data['user_email'],
600 600
 		sprintf(
601 601
 			/* translators: %s: site name */
602
-			esc_attr__( '[%s] Your username and password', 'give' ),
602
+			esc_attr__('[%s] Your username and password', 'give'),
603 603
 			$blogname
604 604
 		),
605 605
 		$message
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
 }
609 609
 
610
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
610
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
611 611
 
612 612
 
613 613
 /**
@@ -623,34 +623,34 @@  discard block
 block discarded – undo
623 623
  *
624 624
  * @return      string
625 625
  */
626
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
626
+function give_get_donor_name_by($id = 0, $from = 'donation') {
627 627
 
628 628
 	// ID shouldn't be empty
629
-	if ( empty( $id ) ) {
629
+	if (empty($id)) {
630 630
 		return;
631 631
 	}
632 632
 
633 633
 	$name = '';
634 634
 
635
-	switch ( $from ) {
635
+	switch ($from) {
636 636
 
637 637
 		case 'donation':
638 638
 
639
-			$user_info = give_get_payment_meta_user_info( $id );
640
-			$name = trim( "{$user_info['first_name']} {$user_info['last_name']}" );
639
+			$user_info = give_get_payment_meta_user_info($id);
640
+			$name = trim("{$user_info['first_name']} {$user_info['last_name']}");
641 641
 
642 642
 		break;
643 643
 
644 644
 		case 'donor':
645 645
 
646
-			$donor = new Give_Donor( $id );
646
+			$donor = new Give_Donor($id);
647 647
 			$name = $donor->name;
648 648
 
649 649
 		break;
650 650
 
651 651
 	}
652 652
 
653
-	return trim( $name );
653
+	return trim($name);
654 654
 
655 655
 }
656 656
 
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
  * @param  string $email Donor Email.
663 663
  * @return boolean  The user's ID on success, and false on failure.
664 664
  */
665
-function give_donor_email_exists( $email ) {
666
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
665
+function give_donor_email_exists($email) {
666
+	if (Give()->donors->get_donor_by('email', $email)) {
667 667
 		return true;
668 668
 	}
669 669
 	return false;
@@ -678,12 +678,12 @@  discard block
 block discarded – undo
678 678
  *
679 679
  * @return bool
680 680
  */
681
-function give_is_additional_email( $email ) {
681
+function give_is_additional_email($email) {
682 682
 	global $wpdb;
683
-	$meta_table  = Give()->donor_meta->table_name;
684
-	$donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
683
+	$meta_table = Give()->donor_meta->table_name;
684
+	$donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
685 685
 
686
-	if ( empty( $donor_id ) ) {
686
+	if (empty($donor_id)) {
687 687
 		return false;
688 688
 	}
689 689
 	return true;
Please login to merge, or discard this patch.
includes/error-tracking.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return mixed array if errors are present, false if none found
26 26
  */
27 27
 function give_get_errors() {
28
-	return Give()->session->get( 'give_errors' );
28
+	return Give()->session->get('give_errors');
29 29
 }
30 30
 
31 31
 /**
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return void
44 44
  */
45
-function give_set_error( $error_id, $error_message, $notice_args = array() ) {
45
+function give_set_error($error_id, $error_message, $notice_args = array()) {
46 46
 	$errors = give_get_errors();
47
-	if ( ! $errors ) {
47
+	if ( ! $errors) {
48 48
 		$errors = array();
49 49
 	}
50 50
 
51
-	if( is_array( $notice_args ) && ! empty( $notice_args ) ) {
52
-		$errors[ $error_id ] = array(
51
+	if (is_array($notice_args) && ! empty($notice_args)) {
52
+		$errors[$error_id] = array(
53 53
 			'message'     => $error_message,
54 54
 			'notice_args' => $notice_args,
55 55
 		);
56 56
 	} else {
57 57
 		// Backward compatibility v<1.8.11.
58
-		$errors[ $error_id ] = $error_message;
58
+		$errors[$error_id] = $error_message;
59 59
 	}
60 60
 
61
-	Give()->session->set( 'give_errors', $errors );
61
+	Give()->session->set('give_errors', $errors);
62 62
 }
63 63
 
64 64
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return void
70 70
  */
71 71
 function give_clear_errors() {
72
-	Give()->session->set( 'give_errors', null );
72
+	Give()->session->set('give_errors', null);
73 73
 }
74 74
 
75 75
 /**
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
  *
83 83
  * @return void
84 84
  */
85
-function give_unset_error( $error_id ) {
85
+function give_unset_error($error_id) {
86 86
 	$errors = give_get_errors();
87
-	if ( $errors ) {
87
+	if ($errors) {
88 88
 		/**
89 89
 		 * Check If $error_id exists in the array.
90 90
 		 * If exists then unset it.
91 91
 		 *
92 92
 		 * @since 1.8.13
93 93
 		 */
94
-		if ( isset( $errors[ $error_id ] ) ) {
95
-			unset( $errors[ $error_id ] );
94
+		if (isset($errors[$error_id])) {
95
+			unset($errors[$error_id]);
96 96
 		}
97
-		Give()->session->set( 'give_errors', $errors );
97
+		Give()->session->set('give_errors', $errors);
98 98
 	}
99 99
 }
100 100
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return string
106 106
  */
107 107
 function _give_die_handler() {
108
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
108
+	if (defined('GIVE_UNIT_TESTS')) {
109 109
 		return '_give_die_handler';
110 110
 	} else {
111 111
 		die();
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_die( $message = '', $title = '', $status = 400 ) {
129
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
130
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
131
-	wp_die( $message, $title, array( 'response' => $status ) );
128
+function give_die($message = '', $title = '', $status = 400) {
129
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
130
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
131
+	wp_die($message, $title, array('response' => $status));
132 132
 }
Please login to merge, or discard this patch.
includes/class-give-db.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @since  1.0
167 167
 	 * @access public
168
-     *
169
-     * @param  int    $column       Column ID.
170
-     * @param  string $column_where Column name.
171
-     * @param  string $column_value Column value.
172
-     *
168
+	 *
169
+	 * @param  int    $column       Column ID.
170
+	 * @param  string $column_where Column name.
171
+	 * @param  string $column_value Column value.
172
+	 *
173 173
 	 * @return string
174 174
 	 */
175 175
 	public function get_column_by( $column, $column_where, $column_value ) {
176
-        /* @var WPDB $wpdb */
177
-        global $wpdb;
176
+		/* @var WPDB $wpdb */
177
+		global $wpdb;
178 178
 
179 179
 		// Bailout.
180 180
 		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @since  1.0
193 193
 	 * @access public
194
-     *
195
-     * @param  array  $data
196
-     * @param  string $type
197
-     *
194
+	 *
195
+	 * @param  array  $data
196
+	 * @param  string $type
197
+	 *
198 198
 	 * @return int
199 199
 	 */
200 200
 	public function insert( $data, $type = '' ) {
201
-        /* @var WPDB $wpdb */
202
-        global $wpdb;
201
+		/* @var WPDB $wpdb */
202
+		global $wpdb;
203 203
 
204 204
 		// Set default values.
205 205
 		$data = wp_parse_args( $data, $this->get_column_defaults() );
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @since  1.0
248 248
 	 * @access public
249
-     *
250
-     * @param  int    $row_id Column ID
251
-     * @param  array  $data
252
-     * @param  string $where  Column value
253
-     *
249
+	 *
250
+	 * @param  int    $row_id Column ID
251
+	 * @param  array  $data
252
+	 * @param  string $where  Column value
253
+	 *
254 254
 	 * @return bool
255 255
 	 */
256 256
 	public function update( $row_id, $data = array(), $where = '' ) {
257
-        /* @var WPDB $wpdb */
258
-        global $wpdb;
257
+		/* @var WPDB $wpdb */
258
+		global $wpdb;
259 259
 
260 260
 		// Row ID must be positive integer
261 261
 		$row_id = absint( $row_id );
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @since  1.0
295 295
 	 * @access public
296
-     *
297
-     * @param  int $row_id Column ID.
298
-     *
296
+	 *
297
+	 * @param  int $row_id Column ID.
298
+	 *
299 299
 	 * @return bool
300 300
 	 */
301 301
 	public function delete( $row_id = 0 ) {
302
-        /* @var WPDB $wpdb */
303
-        global $wpdb;
302
+		/* @var WPDB $wpdb */
303
+		global $wpdb;
304 304
 
305 305
 		// Row ID must be positive integer
306 306
 		$row_id = absint( $row_id );
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @since  1.3.2
323 323
 	 * @access public
324
-     *
324
+	 *
325 325
 	 * @param  string $table The table name.
326
-     *
326
+	 *
327 327
 	 * @return bool          If the table name exists.
328 328
 	 */
329 329
 	public function table_exists( $table ) {
330
-        /* @var WPDB $wpdb */
330
+		/* @var WPDB $wpdb */
331 331
 		global $wpdb;
332 332
 
333 333
 		$table = sanitize_text_field( $table );
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105 105
 		// Bailout.
106
-		if ( empty( $row_id ) ) {
106
+		if (empty($row_id)) {
107 107
 			return null;
108 108
 		}
109 109
 
110
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
110
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
111 111
 	}
112 112
 
113 113
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return object
123 123
 	 */
124
-	public function get_by( $column, $row_id ) {
124
+	public function get_by($column, $row_id) {
125 125
 		/* @var WPDB $wpdb */
126 126
 		global $wpdb;
127 127
 
128 128
 		// Bailout.
129
-		if ( empty( $column ) || empty( $row_id ) ) {
129
+		if (empty($column) || empty($row_id)) {
130 130
 			return null;
131 131
 		}
132 132
 
133
-		$column = esc_sql( $column );
133
+		$column = esc_sql($column);
134 134
 
135
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
135
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string      Column value.
148 148
 	 */
149
-	public function get_column( $column, $row_id ) {
149
+	public function get_column($column, $row_id) {
150 150
 		/* @var WPDB $wpdb */
151 151
 		global $wpdb;
152 152
 
153 153
 		// Bailout.
154
-		if ( empty( $column ) || empty( $row_id ) ) {
154
+		if (empty($column) || empty($row_id)) {
155 155
 			return null;
156 156
 		}
157 157
 
158
-		$column = esc_sql( $column );
158
+		$column = esc_sql($column);
159 159
 
160
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
160
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
      *
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_column_by( $column, $column_where, $column_value ) {
175
+	public function get_column_by($column, $column_where, $column_value) {
176 176
         /* @var WPDB $wpdb */
177 177
         global $wpdb;
178 178
 
179 179
 		// Bailout.
180
-		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
180
+		if (empty($column) || empty($column_where) || empty($column_value)) {
181 181
 			return null;
182 182
 		}
183 183
 
184
-		$column_where = esc_sql( $column_where );
185
-		$column       = esc_sql( $column );
186
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
184
+		$column_where = esc_sql($column_where);
185
+		$column       = esc_sql($column);
186
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
187 187
 	}
188 188
 
189 189
 	/**
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
      *
198 198
 	 * @return int
199 199
 	 */
200
-	public function insert( $data, $type = '' ) {
200
+	public function insert($data, $type = '') {
201 201
         /* @var WPDB $wpdb */
202 202
         global $wpdb;
203 203
 
204 204
 		// Set default values.
205
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
205
+		$data = wp_parse_args($data, $this->get_column_defaults());
206 206
 
207 207
 		/**
208 208
 		 * Fires before inserting data to the database.
@@ -211,22 +211,22 @@  discard block
 block discarded – undo
211 211
 		 *
212 212
 		 * @param array $data
213 213
 		 */
214
-		do_action( "give_pre_insert_{$type}", $data );
214
+		do_action("give_pre_insert_{$type}", $data);
215 215
 
216 216
 		// Initialise column format array
217 217
 		$column_formats = $this->get_columns();
218 218
 
219 219
 		// Force fields to lower case
220
-		$data = array_change_key_case( $data );
220
+		$data = array_change_key_case($data);
221 221
 
222 222
 		// White list columns
223
-		$data = array_intersect_key( $data, $column_formats );
223
+		$data = array_intersect_key($data, $column_formats);
224 224
 
225 225
 		// Reorder $column_formats to match the order of columns given in $data
226
-		$data_keys      = array_keys( $data );
227
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
226
+		$data_keys      = array_keys($data);
227
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
228 228
 
229
-		$wpdb->insert( $this->table_name, $data, $column_formats );
229
+		$wpdb->insert($this->table_name, $data, $column_formats);
230 230
 
231 231
 		/**
232 232
 		 * Fires after inserting data to the database.
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 * @param int   $insert_id
237 237
 		 * @param array $data
238 238
 		 */
239
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
239
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
240 240
 
241 241
 		return $wpdb->insert_id;
242 242
 	}
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
      *
254 254
 	 * @return bool
255 255
 	 */
256
-	public function update( $row_id, $data = array(), $where = '' ) {
256
+	public function update($row_id, $data = array(), $where = '') {
257 257
         /* @var WPDB $wpdb */
258 258
         global $wpdb;
259 259
 
260 260
 		// Row ID must be positive integer
261
-		$row_id = absint( $row_id );
261
+		$row_id = absint($row_id);
262 262
 
263
-		if ( empty( $row_id ) ) {
263
+		if (empty($row_id)) {
264 264
 			return false;
265 265
 		}
266 266
 
267
-		if ( empty( $where ) ) {
267
+		if (empty($where)) {
268 268
 			$where = $this->primary_key;
269 269
 		}
270 270
 
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 		$column_formats = $this->get_columns();
273 273
 
274 274
 		// Force fields to lower case
275
-		$data = array_change_key_case( $data );
275
+		$data = array_change_key_case($data);
276 276
 
277 277
 		// White list columns
278
-		$data = array_intersect_key( $data, $column_formats );
278
+		$data = array_intersect_key($data, $column_formats);
279 279
 
280 280
 		// Reorder $column_formats to match the order of columns given in $data
281
-		$data_keys      = array_keys( $data );
282
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
281
+		$data_keys      = array_keys($data);
282
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
283 283
 
284
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
284
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
285 285
 			return false;
286 286
 		}
287 287
 
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
      *
299 299
 	 * @return bool
300 300
 	 */
301
-	public function delete( $row_id = 0 ) {
301
+	public function delete($row_id = 0) {
302 302
         /* @var WPDB $wpdb */
303 303
         global $wpdb;
304 304
 
305 305
 		// Row ID must be positive integer
306
-		$row_id = absint( $row_id );
306
+		$row_id = absint($row_id);
307 307
 
308
-		if ( empty( $row_id ) ) {
308
+		if (empty($row_id)) {
309 309
 			return false;
310 310
 		}
311 311
 
312
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
312
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
313 313
 			return false;
314 314
 		}
315 315
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
      *
327 327
 	 * @return bool          If the table name exists.
328 328
 	 */
329
-	public function table_exists( $table ) {
329
+	public function table_exists($table) {
330 330
         /* @var WPDB $wpdb */
331 331
 		global $wpdb;
332 332
 
333
-		$table = sanitize_text_field( $table );
333
+		$table = sanitize_text_field($table);
334 334
 
335
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
335
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
336 336
 	}
337 337
 
338 338
 	/**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
345 345
 	 */
346 346
 	public function installed() {
347
-		return $this->table_exists( $this->table_name );
347
+		return $this->table_exists($this->table_name);
348 348
 	}
349 349
 
350 350
 	/**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @access public
355 355
 	 */
356 356
 	public function register_table() {
357
-		$current_version = get_option( $this->table_name . '_db_version' );
358
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
357
+		$current_version = get_option($this->table_name.'_db_version');
358
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
359 359
 			$this->create_table();
360 360
 		}
361 361
 	}
@@ -366,5 +366,5 @@  discard block
 block discarded – undo
366 366
 	 * @since  1.8.9
367 367
 	 * @access public
368 368
 	 */
369
-	public function create_table(){}
369
+	public function create_table() {}
370 370
 }
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), 9999 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), 9999);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string|array      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key    = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key    = sanitize_key($key);
181 181
 		$return = false;
182 182
 
183
-		if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) {
183
+		if (isset($this->session[$key]) && ! empty($this->session[$key])) {
184 184
 
185
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches );
186
-			if ( ! empty( $matches ) ) {
187
-				$this->set( $key, null );
185
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches);
186
+			if ( ! empty($matches)) {
187
+				$this->set($key, null);
188 188
 
189 189
 				return false;
190 190
 			}
191 191
 
192
-			if ( is_numeric( $this->session[ $key ] ) ) {
193
-				$return = $this->session[ $key ];
192
+			if (is_numeric($this->session[$key])) {
193
+				$return = $this->session[$key];
194 194
 			} else {
195 195
 
196
-				$maybe_json = json_decode( $this->session[ $key ] );
196
+				$maybe_json = json_decode($this->session[$key]);
197 197
 
198 198
 				// Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON.
199
-				if ( is_null( $maybe_json ) ) {
200
-					$is_serialized = is_serialized( $this->session[ $key ] );
201
-					if ( $is_serialized ) {
202
-						$value = @unserialize( $this->session[ $key ] );
203
-						$this->set( $key, (array) $value );
199
+				if (is_null($maybe_json)) {
200
+					$is_serialized = is_serialized($this->session[$key]);
201
+					if ($is_serialized) {
202
+						$value = @unserialize($this->session[$key]);
203
+						$this->set($key, (array) $value);
204 204
 						$return = $value;
205 205
 					} else {
206
-						$return = $this->session[ $key ];
206
+						$return = $this->session[$key];
207 207
 					}
208 208
 				} else {
209
-					$return = json_decode( $this->session[ $key ], true );
209
+					$return = json_decode($this->session[$key], true);
210 210
 				}
211 211
 
212 212
 			}
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string        Session variable.
231 231
 	 */
232
-	public function set( $key, $value ) {
232
+	public function set($key, $value) {
233 233
 
234
-		$key = sanitize_key( $key );
234
+		$key = sanitize_key($key);
235 235
 
236
-		if ( is_array( $value ) ) {
237
-			$this->session[ $key ] = wp_json_encode( $value );
236
+		if (is_array($value)) {
237
+			$this->session[$key] = wp_json_encode($value);
238 238
 		} else {
239
-			$this->session[ $key ] = esc_attr( $value );
239
+			$this->session[$key] = esc_attr($value);
240 240
 		}
241 241
 
242
-		if ( $this->use_php_sessions ) {
243
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
242
+		if ($this->use_php_sessions) {
243
+			$_SESSION['give'.$this->prefix] = $this->session;
244 244
 		}
245 245
 
246
-		return $this->session[ $key ];
246
+		return $this->session[$key];
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @hook
259 259
 	 */
260 260
 	public function set_session_cookies() {
261
-		if ( ! headers_sent() ) {
262
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
263
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
264
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
261
+		if ( ! headers_sent()) {
262
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
263
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
264
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
265 265
 		}
266 266
 	}
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function set_expiration_variant_time() {
279 279
 
280
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
280
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
281 281
 	}
282 282
 
283 283
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function set_expiration_time() {
294 294
 
295
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
295
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
296 296
 	}
297 297
 
298 298
 	/**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		$ret = false;
311 311
 
312 312
 		// If the database variable is already set, no need to run auto detection.
313
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
313
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
314 314
 
315
-		if ( ! $give_use_php_sessions ) {
315
+		if ( ! $give_use_php_sessions) {
316 316
 
317 317
 			// Attempt to detect if the server supports PHP sessions.
318
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
318
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
319 319
 
320
-				$this->set( 'give_use_php_sessions', 1 );
320
+				$this->set('give_use_php_sessions', 1);
321 321
 
322
-				if ( $this->get( 'give_use_php_sessions' ) ) {
322
+				if ($this->get('give_use_php_sessions')) {
323 323
 
324 324
 					$ret = true;
325 325
 
326 326
 					// Set the database option.
327
-					update_option( 'give_use_php_sessions', true );
327
+					update_option('give_use_php_sessions', true);
328 328
 
329 329
 				}
330 330
 			}
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
337
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
337
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
338 338
 			$ret = true;
339
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
339
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
340 340
 			$ret = false;
341 341
 		}
342 342
 
343
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
343
+		return (bool) apply_filters('give_use_php_sessions', $ret);
344 344
 	}
345 345
 
346 346
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$start_session = true;
359 359
 
360
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
360
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
361 361
 
362
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
362
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
363 363
 				'feed',
364 364
 				'feed',
365 365
 				'feed/rss',
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 				'feed/rdf',
368 368
 				'feed/atom',
369 369
 				'comments/feed/',
370
-			) );
371
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
372
-			$uri       = untrailingslashit( $uri );
373
-			if ( in_array( $uri, $blacklist ) ) {
370
+			));
371
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
372
+			$uri       = untrailingslashit($uri);
373
+			if (in_array($uri, $blacklist)) {
374 374
 				$start_session = false;
375 375
 			}
376
-			if ( false !== strpos( $uri, 'feed=' ) ) {
376
+			if (false !== strpos($uri, 'feed=')) {
377 377
 				$start_session = false;
378 378
 			}
379
-			if ( is_admin() ) {
379
+			if (is_admin()) {
380 380
 				$start_session = false;
381 381
 			}
382 382
 		}
383 383
 
384
-		return apply_filters( 'give_start_session', $start_session );
384
+		return apply_filters('give_start_session', $start_session);
385 385
 	}
386 386
 
387 387
 	/**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	public function maybe_start_session() {
399 399
 
400
-		if ( ! $this->should_start_session() ) {
400
+		if ( ! $this->should_start_session()) {
401 401
 			return;
402 402
 		}
403 403
 
404
-		if ( ! session_id() && ! headers_sent() ) {
404
+		if ( ! session_id() && ! headers_sent()) {
405 405
 			session_start();
406 406
 		}
407 407
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 		$expiration = false;
422 422
 
423
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
423
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
424 424
 
425
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
425
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
426 426
 
427 427
 		}
428 428
 
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -70,24 +70,24 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param array $args
72 72
 	 */
73
-	public function register( $args ) {
73
+	public function register($args) {
74 74
 		$args_default = array(
75 75
 			'id'       => '',
76 76
 			'version'  => '',
77 77
 			'callback' => '',
78 78
 		);
79 79
 
80
-		$args = wp_parse_args( $args, $args_default );
80
+		$args = wp_parse_args($args, $args_default);
81 81
 
82 82
 		// You can only register database upgrade.
83 83
 		$args['type'] = 'database';
84 84
 
85 85
 		// Bailout.
86
-		if ( empty( $args['id'] ) || empty( $args['version'] ) || empty( $args['callback'] ) || ! is_callable( $args['callback'] ) ) {
86
+		if (empty($args['id']) || empty($args['version']) || empty($args['callback']) || ! is_callable($args['callback'])) {
87 87
 			return;
88 88
 		}
89 89
 
90
-		$this->updates[ $args['type'] ][] = $args;
90
+		$this->updates[$args['type']][] = $args;
91 91
 	}
92 92
 
93 93
 
@@ -102,32 +102,32 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array
104 104
 	 */
105
-	public function get_updates( $update_type = '', $status = 'all' ) {
105
+	public function get_updates($update_type = '', $status = 'all') {
106 106
 		// return all updates.
107
-		if ( empty( $update_type ) ) {
107
+		if (empty($update_type)) {
108 108
 			return $this->updates;
109 109
 		}
110 110
 
111 111
 		// Get specific update.
112
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
112
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
113 113
 
114 114
 		// Bailout.
115
-		if ( empty( $updates ) ) {
115
+		if (empty($updates)) {
116 116
 			return $updates;
117 117
 		}
118 118
 
119
-		switch ( $status ) {
119
+		switch ($status) {
120 120
 			case 'new':
121 121
 				// Remove already completed updates.
122 122
 				$completed_updates = give_get_completed_upgrades();
123 123
 
124
-				if ( ! empty( $completed_updates ) ) {
125
-					foreach ( $updates as $index => $update ) {
126
-						if ( in_array( $update['id'], $completed_updates ) ) {
127
-							unset( $updates[ $index ] );
124
+				if ( ! empty($completed_updates)) {
125
+					foreach ($updates as $index => $update) {
126
+						if (in_array($update['id'], $completed_updates)) {
127
+							unset($updates[$index]);
128 128
 						}
129 129
 					}
130
-					$updates = array_values( $updates );
130
+					$updates = array_values($updates);
131 131
 				}
132 132
 
133 133
 				break;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return static
145 145
 	 */
146 146
 	static function get_instance() {
147
-		if ( is_null( self::$instance ) ) {
147
+		if (is_null(self::$instance)) {
148 148
 			self::$instance = new self();
149 149
 		}
150 150
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 		/**
163 163
 		 * Setup hooks.
164 164
 		 */
165
-		add_action( 'init', array( $this, '__register_upgrade' ), 9999 );
166
-		add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 );
167
-		add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 );
168
-		add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 );
169
-		add_action( 'wp_ajax_give_do_ajax_updates', array( $this, '__give_ajax_updates' ) );
165
+		add_action('init', array($this, '__register_upgrade'), 9999);
166
+		add_action('admin_init', array($this, '__change_donations_label'), 9999);
167
+		add_action('admin_menu', array($this, '__register_menu'), 9999);
168
+		add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999);
169
+		add_action('wp_ajax_give_do_ajax_updates', array($this, '__give_ajax_updates'));
170 170
 
171 171
 		/**
172 172
 		 * Load file
173 173
 		 */
174
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
174
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
175 175
 	}
176 176
 
177 177
 	/**
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 		$addons         = give_get_plugins();
185 185
 		$plugin_updates = get_plugin_updates();
186 186
 
187
-		foreach ( $addons as $key => $info ) {
188
-			if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) {
187
+		foreach ($addons as $key => $info) {
188
+			if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) {
189 189
 				continue;
190 190
 			}
191 191
 
192
-			$this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] );
192
+			$this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]);
193 193
 		}
194 194
 	}
195 195
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @access public
202 202
 	 */
203 203
 	public function __register_upgrade() {
204
-		if ( ! is_admin() ) {
204
+		if ( ! is_admin()) {
205 205
 			return;
206 206
 		}
207 207
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		 *
211 211
 		 * @since 1.8.12
212 212
 		 */
213
-		do_action( 'give_register_updates', $this );
213
+		do_action('give_register_updates', $this);
214 214
 	}
215 215
 
216 216
 	/**
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 		global $submenu;
225 225
 
226 226
 		// Bailout.
227
-		if ( empty( $menu ) || ! $this->get_update_count() ) {
227
+		if (empty($menu) || ! $this->get_update_count()) {
228 228
 			return;
229 229
 		}
230 230
 
231
-		foreach ( $menu as $index => $menu_item ) {
232
-			if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) {
231
+		foreach ($menu as $index => $menu_item) {
232
+			if ('edit.php?post_type=give_forms' !== $menu_item[2]) {
233 233
 				continue;
234 234
 			}
235 235
 
236
-			$menu[ $index ][0] = sprintf(
237
-				__( 'Donations %s', 'give' ),
236
+			$menu[$index][0] = sprintf(
237
+				__('Donations %s', 'give'),
238 238
 				sprintf(
239 239
 					'<span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>',
240 240
 					$this->get_update_count()
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
 		// Bailout.
260 260
 		if ( ! $this->get_update_count()) {
261 261
 			// Show complete update message if still on update setting page.
262
-			if ( isset($_GET['page']) && 'give-updates' === $_GET['page'] ) {
262
+			if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
263 263
 				// Upgrades
264 264
 				add_submenu_page(
265 265
 					'edit.php?post_type=give_forms',
266
-					esc_html__( 'Give Updates Complete', 'give' ),
267
-					__( 'Updates', 'give' ),
266
+					esc_html__('Give Updates Complete', 'give'),
267
+					__('Updates', 'give'),
268 268
 					'manage_give_settings',
269 269
 					'give-updates',
270
-					array( $this, 'render_complete_page' )
270
+					array($this, 'render_complete_page')
271 271
 				);
272 272
 			}
273 273
 
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 		// Upgrades
278 278
 		add_submenu_page(
279 279
 			'edit.php?post_type=give_forms',
280
-			esc_html__( 'Give Updates', 'give' ),
280
+			esc_html__('Give Updates', 'give'),
281 281
 			sprintf(
282 282
 				'%1$s <span class="update-plugins count-%2$d"><span class="plugin-count">%2$d</span></span>',
283
-				__( 'Updates', 'give' ),
283
+				__('Updates', 'give'),
284 284
 				$this->get_update_count()
285 285
 			),
286 286
 			'manage_give_settings',
287 287
 			'give-updates',
288
-			array( $this, 'render_page' )
288
+			array($this, 'render_page')
289 289
 		);
290 290
 	}
291 291
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @return int
298 298
 	 */
299 299
 	public function get_db_update_count() {
300
-		return count( $this->get_updates( 'database', 'new' ) );
300
+		return count($this->get_updates('database', 'new'));
301 301
 	}
302 302
 
303 303
 	/**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @access public
308 308
 	 */
309 309
 	public function render_complete_page() {
310
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
310
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
311 311
 	}
312 312
 
313 313
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @access public
318 318
 	 */
319 319
 	public function render_page() {
320
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
320
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
321 321
 	}
322 322
 
323 323
 	/**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return int
329 329
 	 */
330 330
 	public function get_plugin_update_count() {
331
-		return count( $this->get_updates( 'plugin' ) );
331
+		return count($this->get_updates('plugin'));
332 332
 	}
333 333
 
334 334
 	/**
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$db_update_count     = $this->get_db_update_count();
344 344
 		$plugin_update_count = $this->get_plugin_update_count();
345 345
 
346
-		return ( $db_update_count + $plugin_update_count );
346
+		return ($db_update_count + $plugin_update_count);
347 347
 	}
348 348
 
349 349
 
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	 * @access public
355 355
 	 */
356 356
 	public function __flush_resume_updates() {
357
-		delete_option( 'give_doing_upgrade' );
358
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
357
+		delete_option('give_doing_upgrade');
358
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
359 359
 
360 360
 		// Reset counter.
361 361
 		$this->step = $this->percentage = 0;
362
-		++ $this->update;
362
+		++$this->update;
363 363
 	}
364 364
 
365 365
 	/**
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function __give_ajax_updates() {
372 372
 		// Check permission.
373
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
373
+		if ( ! current_user_can('manage_give_settings')) {
374 374
 			$this->send_ajax_response(
375 375
 				array(
376
-					'message' => esc_html__( 'You do not have permission to do Give upgrades.', 'give' ),
376
+					'message' => esc_html__('You do not have permission to do Give upgrades.', 'give'),
377 377
 				),
378 378
 				'error'
379 379
 			);
380 380
 		}
381 381
 
382 382
 		// Set params.
383
-		$this->step   = absint( $_POST['step'] );
384
-		$this->update = absint( $_POST['update'] );
383
+		$this->step   = absint($_POST['step']);
384
+		$this->update = absint($_POST['update']);
385 385
 
386 386
 		// Bailout: step and update must be positive and greater then zero.
387
-		if ( ! $this->step ) {
387
+		if ( ! $this->step) {
388 388
 			$this->send_ajax_response(
389 389
 				array(
390
-					'message'    => __( 'Please reload this page  and try again', 'give' ),
390
+					'message'    => __('Please reload this page  and try again', 'give'),
391 391
 					'heading'    => '',
392 392
 					'percentage' => 0,
393 393
 				),
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 		}
397 397
 
398 398
 		// Get updates.
399
-		$updates = $this->get_updates( 'database', 'new' );
399
+		$updates = $this->get_updates('database', 'new');
400 400
 
401 401
 		// Bailout if we do not have nay updates.
402
-		if ( empty( $updates ) ) {
402
+		if (empty($updates)) {
403 403
 			$this->send_ajax_response(
404 404
 				array(
405
-					'message'    => __( 'The database is already up to date.', 'give' ),
406
-					'heading'    => __( 'Updates Completed.', 'give' ),
405
+					'message'    => __('The database is already up to date.', 'give'),
406
+					'heading'    => __('Updates Completed.', 'give'),
407 407
 					'percentage' => 0,
408 408
 				),
409 409
 				'success'
@@ -411,26 +411,26 @@  discard block
 block discarded – undo
411 411
 		}
412 412
 
413 413
 		// Process update.
414
-		foreach ( $updates as $index => $update ) {
414
+		foreach ($updates as $index => $update) {
415 415
 			// Check if update depend upon any other update.
416
-			if ( ! empty( $update['depend'] ) && ! give_has_upgrade_completed( $update['depend'] ) ) {
416
+			if ( ! empty($update['depend']) && ! give_has_upgrade_completed($update['depend'])) {
417 417
 				continue;
418 418
 			}
419 419
 
420 420
 			// Run update.
421
-			if ( is_array( $update['callback'] ) ) {
421
+			if (is_array($update['callback'])) {
422 422
 				$update['callback'][0]->$update['callback'][1]();
423 423
 			} else {
424 424
 				$update['callback']();
425 425
 			}
426 426
 
427 427
 			// Check if current update completed or not.
428
-			if ( give_has_upgrade_completed( $update['id'] ) ) {
429
-				if ( 1 === count( $updates ) ) {
428
+			if (give_has_upgrade_completed($update['id'])) {
429
+				if (1 === count($updates)) {
430 430
 					$this->send_ajax_response(
431 431
 						array(
432
-							'message'    => __( 'Database updated successfully.', 'give' ),
433
-							'heading'    => __( 'Updates Completed.', 'give' ),
432
+							'message'    => __('Database updated successfully.', 'give'),
433
+							'heading'    => __('Updates Completed.', 'give'),
434 434
 							'percentage' => 0,
435 435
 						),
436 436
 						'success'
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 
441 441
 			$doing_upgrade_args = array(
442 442
 				'update_info' => $update,
443
-				'step'        => ++ $this->step,
443
+				'step'        => ++$this->step,
444 444
 				'update'      => $this->update,
445
-				'heading'     => sprintf( 'Update %s of {update_count}', $this->update ),
445
+				'heading'     => sprintf('Update %s of {update_count}', $this->update),
446 446
 				'percentage'  => $this->percentage,
447 447
 			);
448 448
 
449 449
 			// Cache upgrade.
450
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
450
+			update_option('give_doing_upgrade', $doing_upgrade_args);
451 451
 
452
-			$this->send_ajax_response( $doing_upgrade_args );
452
+			$this->send_ajax_response($doing_upgrade_args);
453 453
 		}// End foreach().
454 454
 	}
455 455
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 * @param        $data
463 463
 	 * @param string $type
464 464
 	 */
465
-	public function send_ajax_response( $data, $type = '' ) {
465
+	public function send_ajax_response($data, $type = '') {
466 466
 		$default = array(
467 467
 			'message'    => '',
468 468
 			'heading'    => '',
@@ -472,21 +472,21 @@  discard block
 block discarded – undo
472 472
 		);
473 473
 
474 474
 		// Set data.
475
-		$data = wp_parse_args( $data, $default );
475
+		$data = wp_parse_args($data, $default);
476 476
 
477
-		switch ( $type ) {
477
+		switch ($type) {
478 478
 			case 'success':
479
-				wp_send_json_success( $data );
479
+				wp_send_json_success($data);
480 480
 				break;
481 481
 
482 482
 			case 'error':
483
-				wp_send_json_error( $data );
483
+				wp_send_json_error($data);
484 484
 				break;
485 485
 
486 486
 			default:
487
-				wp_send_json( array(
487
+				wp_send_json(array(
488 488
 					'data' => $data,
489
-				) );
489
+				));
490 490
 				break;
491 491
 		}
492 492
 	}
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 	public function resume_updates() {
504 504
 		$status = false;
505 505
 
506
-		if ( $update = get_option( 'give_doing_upgrade' ) ) {
507
-			$status = ! empty( $update['step'] ) ? $update['step'] : $status;
506
+		if ($update = get_option('give_doing_upgrade')) {
507
+			$status = ! empty($update['step']) ? $update['step'] : $status;
508 508
 		}
509 509
 
510 510
 		return $status;
@@ -520,12 +520,12 @@  discard block
 block discarded – undo
520 520
 	 * @param $total
521 521
 	 * @param $current_total
522 522
 	 */
523
-	public function set_percentage( $total, $current_total ) {
523
+	public function set_percentage($total, $current_total) {
524 524
 		// Set percentage.
525
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
525
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
526 526
 
527 527
 		// Verify percentage.
528
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
528
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
529 529
 	}
530 530
 }
531 531
 
Please login to merge, or discard this patch.
includes/admin/forms/class-metabox-form-data.php 2 patches
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -662,9 +662,12 @@  discard block
 block discarded – undo
662 662
 							<a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>">
663 663
 								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
664 664
 									<?php echo $form_data_tab['icon-html']; ?>
665
-								<?php else : ?>
665
+								<?php else {
666
+	: ?>
666 667
 									<span class="give-icon give-icon-default"></span>
667
-								<?php endif; ?>
668
+								<?php endif;
669
+}
670
+?>
668 671
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
669 672
 							</a>
670 673
 							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
@@ -674,9 +677,12 @@  discard block
 block discarded – undo
674 677
 											<a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>">
675 678
 												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
676 679
 													<?php echo $sub_tab['icon-html']; ?>
677
-												<?php else : ?>
680
+												<?php else {
681
+	: ?>
678 682
 													<span class="give-icon give-icon-default"></span>
679
-												<?php endif; ?>
683
+												<?php endif;
684
+}
685
+?>
680 686
 												<span class="give-label"><?php echo $sub_tab['label']; ?></span>
681 687
 											</a>
682 688
 										</li>
@@ -703,11 +709,14 @@  discard block
 block discarded – undo
703 709
 						</div>
704 710
 
705 711
 						<?php do_action( "give_after_{$setting['id']}_settings" ); ?>
706
-					<?php else : ?>
712
+					<?php else {
713
+	: ?>
707 714
 						<?php if ( $this->has_sub_tab( $setting ) ) : ?>
708 715
 							<?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
709 716
 								<?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
710
-									<div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
717
+									<div id="<?php echo $sub_fields['id'];
718
+}
719
+?>" class="panel give_options_panel give-hidden">
711 720
 										<?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
712 721
 											<?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
713 722
 												<?php give_render_field( $sub_field ); ?>
Please login to merge, or discard this patch.
Spacing   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function __construct() {
48 48
 		$this->metabox_id    = 'give-metabox-form-data';
49
-		$this->metabox_label = __( 'Donation Form Options', 'give' );
49
+		$this->metabox_label = __('Donation Form Options', 'give');
50 50
 
51 51
 		// Setup.
52
-		add_action( 'admin_init', array( $this, 'setup' ) );
52
+		add_action('admin_init', array($this, 'setup'));
53 53
 
54 54
 		// Add metabox.
55
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 );
55
+		add_action('add_meta_boxes', array($this, 'add_meta_box'), 10);
56 56
 
57 57
 		// Save form meta.
58
-		add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 );
58
+		add_action('save_post_give_forms', array($this, 'save'), 10, 2);
59 59
 
60 60
 		// cmb2 old setting loaders.
61 61
 		// add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) );
62 62
 		// Add offline donations options.
63
-		add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 );
63
+		add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1);
64 64
 
65 65
 		// Maintain active tab query parameter after save.
66
-		add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 );
66
+		add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2);
67 67
 	}
68 68
 
69 69
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	function get_settings() {
89 89
 		$post_id           = give_get_admin_post_id();
90
-		$price_placeholder = give_format_decimal( '1.00', false, false );
90
+		$price_placeholder = give_format_decimal('1.00', false, false);
91 91
 
92 92
 		// Start with an underscore to hide fields from custom fields list
93 93
 		$prefix = '_give_';
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 			/**
97 97
 			 * Repeatable Field Groups
98 98
 			 */
99
-			'form_field_options'    => apply_filters( 'give_forms_field_options', array(
99
+			'form_field_options'    => apply_filters('give_forms_field_options', array(
100 100
 				'id'        => 'form_field_options',
101
-				'title'     => __( 'Donation Options', 'give' ),
101
+				'title'     => __('Donation Options', 'give'),
102 102
 				'icon-html' => '<span class="give-icon give-icon-heart"></span>',
103
-				'fields'    => apply_filters( 'give_forms_donation_form_metabox_fields', array(
103
+				'fields'    => apply_filters('give_forms_donation_form_metabox_fields', array(
104 104
 					// Donation Option.
105 105
 					array(
106
-						'name'        => __( 'Donation Option', 'give' ),
107
-						'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ),
108
-						'id'          => $prefix . 'price_option',
106
+						'name'        => __('Donation Option', 'give'),
107
+						'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
108
+						'id'          => $prefix.'price_option',
109 109
 						'type'        => 'radio_inline',
110 110
 						'default'     => 'multi',
111
-						'options'     => apply_filters( 'give_forms_price_options', array(
112
-							'multi' => __( 'Multi-level Donation', 'give' ),
113
-							'set'   => __( 'Set Donation', 'give' ),
114
-						) ),
111
+						'options'     => apply_filters('give_forms_price_options', array(
112
+							'multi' => __('Multi-level Donation', 'give'),
113
+							'set'   => __('Set Donation', 'give'),
114
+						)),
115 115
 					),
116 116
 					array(
117
-						'name'        => __( 'Set Donation', 'give' ),
118
-						'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ),
119
-						'id'          => $prefix . 'set_price',
117
+						'name'        => __('Set Donation', 'give'),
118
+						'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
119
+						'id'          => $prefix.'set_price',
120 120
 						'type'        => 'text_small',
121 121
 						'data_type'   => 'price',
122 122
 						'attributes'  => array(
@@ -126,34 +126,34 @@  discard block
 block discarded – undo
126 126
 					),
127 127
 					// Display Style.
128 128
 					array(
129
-						'name'          => __( 'Display Style', 'give' ),
130
-						'description'   => __( 'Set how the donations levels will display on the form.', 'give' ),
131
-						'id'            => $prefix . 'display_style',
129
+						'name'          => __('Display Style', 'give'),
130
+						'description'   => __('Set how the donations levels will display on the form.', 'give'),
131
+						'id'            => $prefix.'display_style',
132 132
 						'type'          => 'radio_inline',
133 133
 						'default'       => 'buttons',
134 134
 						'options'       => array(
135
-							'buttons'  => __( 'Buttons', 'give' ),
136
-							'radios'   => __( 'Radios', 'give' ),
137
-							'dropdown' => __( 'Dropdown', 'give' ),
135
+							'buttons'  => __('Buttons', 'give'),
136
+							'radios'   => __('Radios', 'give'),
137
+							'dropdown' => __('Dropdown', 'give'),
138 138
 						),
139 139
 						'wrapper_class' => 'give-hidden',
140 140
 					),
141 141
 					// Custom Amount.
142 142
 					array(
143
-						'name'        => __( 'Custom Amount', 'give' ),
144
-						'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ),
145
-						'id'          => $prefix . 'custom_amount',
143
+						'name'        => __('Custom Amount', 'give'),
144
+						'description' => __('Do you want the user to be able to input their own donation amount?', 'give'),
145
+						'id'          => $prefix.'custom_amount',
146 146
 						'type'        => 'radio_inline',
147 147
 						'default'     => 'disabled',
148 148
 						'options'     => array(
149
-							'enabled'  => __( 'Enabled', 'give' ),
150
-							'disabled' => __( 'Disabled', 'give' ),
149
+							'enabled'  => __('Enabled', 'give'),
150
+							'disabled' => __('Disabled', 'give'),
151 151
 						),
152 152
 					),
153 153
 					array(
154
-						'name'          => __( 'Minimum Amount', 'give' ),
155
-						'description'   => __( 'Enter the minimum custom donation amount.', 'give' ),
156
-						'id'            => $prefix . 'custom_amount_minimum',
154
+						'name'          => __('Minimum Amount', 'give'),
155
+						'description'   => __('Enter the minimum custom donation amount.', 'give'),
156
+						'id'            => $prefix.'custom_amount_minimum',
157 157
 						'type'          => 'text_small',
158 158
 						'data_type'     => 'price',
159 159
 						'attributes'    => array(
@@ -163,37 +163,37 @@  discard block
 block discarded – undo
163 163
 						'wrapper_class' => 'give-hidden',
164 164
 					),
165 165
 					array(
166
-						'name'          => __( 'Custom Amount Text', 'give' ),
167
-						'description'   => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ),
168
-						'id'            => $prefix . 'custom_amount_text',
166
+						'name'          => __('Custom Amount Text', 'give'),
167
+						'description'   => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
168
+						'id'            => $prefix.'custom_amount_text',
169 169
 						'type'          => 'text_medium',
170 170
 						'attributes'    => array(
171 171
 							'rows'        => 3,
172
-							'placeholder' => __( 'Give a Custom Amount', 'give' ),
172
+							'placeholder' => __('Give a Custom Amount', 'give'),
173 173
 						),
174 174
 						'wrapper_class' => 'give-hidden',
175 175
 					),
176 176
 					// Donation Levels.
177 177
 					array(
178
-						'id'            => $prefix . 'donation_levels',
178
+						'id'            => $prefix.'donation_levels',
179 179
 						'type'          => 'group',
180 180
 						'options'       => array(
181
-							'add_button'    => __( 'Add Level', 'give' ),
182
-							'header_title'  => __( 'Donation Level', 'give' ),
181
+							'add_button'    => __('Add Level', 'give'),
182
+							'header_title'  => __('Donation Level', 'give'),
183 183
 							'remove_button' => '<span class="dashicons dashicons-no"></span>',
184 184
 						),
185 185
 						'wrapper_class' => 'give-hidden',
186 186
 						// Fields array works the same, except id's only need to be unique for this group.
187 187
 						// Prefix is not needed.
188
-						'fields'        => apply_filters( 'give_donation_levels_table_row', array(
188
+						'fields'        => apply_filters('give_donation_levels_table_row', array(
189 189
 							array(
190
-								'name' => __( 'ID', 'give' ),
191
-								'id'   => $prefix . 'id',
190
+								'name' => __('ID', 'give'),
191
+								'id'   => $prefix.'id',
192 192
 								'type' => 'levels_id',
193 193
 							),
194 194
 							array(
195
-								'name'       => __( 'Amount', 'give' ),
196
-								'id'         => $prefix . 'amount',
195
+								'name'       => __('Amount', 'give'),
196
+								'id'         => $prefix.'amount',
197 197
 								'type'       => 'text_small',
198 198
 								'data_type'  => 'price',
199 199
 								'attributes' => array(
@@ -202,112 +202,112 @@  discard block
 block discarded – undo
202 202
 								),
203 203
 							),
204 204
 							array(
205
-								'name'       => __( 'Text', 'give' ),
206
-								'id'         => $prefix . 'text',
205
+								'name'       => __('Text', 'give'),
206
+								'id'         => $prefix.'text',
207 207
 								'type'       => 'text',
208 208
 								'attributes' => array(
209
-									'placeholder' => __( 'Donation Level', 'give' ),
209
+									'placeholder' => __('Donation Level', 'give'),
210 210
 									'class'       => 'give-multilevel-text-field',
211 211
 								),
212 212
 							),
213 213
 							array(
214
-								'name' => __( 'Default', 'give' ),
215
-								'id'   => $prefix . 'default',
214
+								'name' => __('Default', 'give'),
215
+								'id'   => $prefix.'default',
216 216
 								'type' => 'give_default_radio_inline',
217 217
 							),
218
-						) ),
218
+						)),
219 219
 					),
220 220
 					array(
221 221
 						'name'  => 'donation_options_docs',
222 222
 						'type'  => 'docs_link',
223 223
 						'url'   => 'http://docs.givewp.com/form-donation-options',
224
-						'title' => __( 'Donation Options', 'give' ),
224
+						'title' => __('Donation Options', 'give'),
225 225
 					),
226 226
 				),
227 227
 					$post_id
228 228
 				),
229
-			) ),
229
+			)),
230 230
 
231 231
 			/**
232 232
 			 * Display Options
233 233
 			 */
234
-			'form_display_options'  => apply_filters( 'give_form_display_options', array(
234
+			'form_display_options'  => apply_filters('give_form_display_options', array(
235 235
 					'id'        => 'form_display_options',
236
-					'title'     => __( 'Form Display', 'give' ),
236
+					'title'     => __('Form Display', 'give'),
237 237
 					'icon-html' => '<span class="give-icon give-icon-display"></span>',
238
-					'fields'    => apply_filters( 'give_forms_display_options_metabox_fields', array(
238
+					'fields'    => apply_filters('give_forms_display_options_metabox_fields', array(
239 239
 						array(
240
-							'name'    => __( 'Display Options', 'give' ),
241
-							'desc'    => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ),
242
-							'id'      => $prefix . 'payment_display',
240
+							'name'    => __('Display Options', 'give'),
241
+							'desc'    => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'),
242
+							'id'      => $prefix.'payment_display',
243 243
 							'type'    => 'radio_inline',
244 244
 							'options' => array(
245
-								'onpage' => __( 'All Fields', 'give' ),
246
-								'modal'  => __( 'Modal', 'give' ),
247
-								'reveal' => __( 'Reveal', 'give' ),
248
-								'button' => __( 'Button', 'give' ),
245
+								'onpage' => __('All Fields', 'give'),
246
+								'modal'  => __('Modal', 'give'),
247
+								'reveal' => __('Reveal', 'give'),
248
+								'button' => __('Button', 'give'),
249 249
 							),
250 250
 							'default' => 'onpage',
251 251
 						),
252 252
 						array(
253
-							'id'            => $prefix . 'reveal_label',
254
-							'name'          => __( 'Continue Button', 'give' ),
255
-							'desc'          => __( 'The button label for displaying the additional payment fields.', 'give' ),
253
+							'id'            => $prefix.'reveal_label',
254
+							'name'          => __('Continue Button', 'give'),
255
+							'desc'          => __('The button label for displaying the additional payment fields.', 'give'),
256 256
 							'type'          => 'text_small',
257 257
 							'attributes'    => array(
258
-								'placeholder' => __( 'Donate Now', 'give' ),
258
+								'placeholder' => __('Donate Now', 'give'),
259 259
 							),
260 260
 							'wrapper_class' => 'give-hidden',
261 261
 						),
262 262
 						array(
263
-							'id'         => $prefix . 'checkout_label',
264
-							'name'       => __( 'Submit Button', 'give' ),
265
-							'desc'       => __( 'The button label for completing a donation.', 'give' ),
263
+							'id'         => $prefix.'checkout_label',
264
+							'name'       => __('Submit Button', 'give'),
265
+							'desc'       => __('The button label for completing a donation.', 'give'),
266 266
 							'type'       => 'text_small',
267 267
 							'attributes' => array(
268
-								'placeholder' => __( 'Donate Now', 'give' ),
268
+								'placeholder' => __('Donate Now', 'give'),
269 269
 							),
270 270
 						),
271 271
 						array(
272
-							'name' => __( 'Default Gateway', 'give' ),
273
-							'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ),
274
-							'id'   => $prefix . 'default_gateway',
272
+							'name' => __('Default Gateway', 'give'),
273
+							'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
274
+							'id'   => $prefix.'default_gateway',
275 275
 							'type' => 'default_gateway',
276 276
 						),
277 277
 						array(
278
-							'name'    => __( 'Guest Donations', 'give' ),
279
-							'desc'    => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ),
280
-							'id'      => $prefix . 'logged_in_only',
278
+							'name'    => __('Guest Donations', 'give'),
279
+							'desc'    => __('Do you want to allow non-logged-in users to make donations?', 'give'),
280
+							'id'      => $prefix.'logged_in_only',
281 281
 							'type'    => 'radio_inline',
282 282
 							'default' => 'enabled',
283 283
 							'options' => array(
284
-								'enabled'  => __( 'Enabled', 'give' ),
285
-								'disabled' => __( 'Disabled', 'give' ),
284
+								'enabled'  => __('Enabled', 'give'),
285
+								'disabled' => __('Disabled', 'give'),
286 286
 							),
287 287
 						),
288 288
 						array(
289
-							'name'    => __( 'Registration', 'give' ),
290
-							'desc'    => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ),
291
-							'id'      => $prefix . 'show_register_form',
289
+							'name'    => __('Registration', 'give'),
290
+							'desc'    => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
291
+							'id'      => $prefix.'show_register_form',
292 292
 							'type'    => 'radio',
293 293
 							'options' => array(
294
-								'none'         => __( 'None', 'give' ),
295
-								'registration' => __( 'Registration', 'give' ),
296
-								'login'        => __( 'Login', 'give' ),
297
-								'both'         => __( 'Registration + Login', 'give' ),
294
+								'none'         => __('None', 'give'),
295
+								'registration' => __('Registration', 'give'),
296
+								'login'        => __('Login', 'give'),
297
+								'both'         => __('Registration + Login', 'give'),
298 298
 							),
299 299
 							'default' => 'none',
300 300
 						),
301 301
 						array(
302
-							'name'    => __( 'Floating Labels', 'give' ),
302
+							'name'    => __('Floating Labels', 'give'),
303 303
 							/* translators: %s: forms http://docs.givewp.com/form-floating-labels */
304
-							'desc'    => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
305
-							'id'      => $prefix . 'form_floating_labels',
304
+							'desc'    => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')),
305
+							'id'      => $prefix.'form_floating_labels',
306 306
 							'type'    => 'radio_inline',
307 307
 							'options' => array(
308
-								'global'   => __( 'Global Option', 'give' ),
309
-								'enabled'  => __( 'Enabled', 'give' ),
310
-								'disabled' => __( 'Disabled', 'give' ),
308
+								'global'   => __('Global Option', 'give'),
309
+								'enabled'  => __('Enabled', 'give'),
310
+								'disabled' => __('Disabled', 'give'),
311 311
 							),
312 312
 							'default' => 'global',
313 313
 						),
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 							'name'  => 'form_display_docs',
316 316
 							'type'  => 'docs_link',
317 317
 							'url'   => 'http://docs.givewp.com/form-display-options',
318
-							'title' => __( 'Form Display', 'give' ),
318
+							'title' => __('Form Display', 'give'),
319 319
 						),
320 320
 					),
321 321
 						$post_id
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
 			/**
327 327
 			 * Donation Goals
328 328
 			 */
329
-			'donation_goal_options' => apply_filters( 'give_donation_goal_options', array(
329
+			'donation_goal_options' => apply_filters('give_donation_goal_options', array(
330 330
 				'id'        => 'donation_goal_options',
331
-				'title'     => __( 'Donation Goal', 'give' ),
331
+				'title'     => __('Donation Goal', 'give'),
332 332
 				'icon-html' => '<span class="give-icon give-icon-target"></span>',
333
-				'fields'    => apply_filters( 'give_forms_donation_goal_metabox_fields', array(
333
+				'fields'    => apply_filters('give_forms_donation_goal_metabox_fields', array(
334 334
 					// Goals
335 335
 					array(
336
-						'name'        => __( 'Donation Goal', 'give' ),
337
-						'description' => __( 'Do you want to set a donation goal for this form?', 'give' ),
338
-						'id'          => $prefix . 'goal_option',
336
+						'name'        => __('Donation Goal', 'give'),
337
+						'description' => __('Do you want to set a donation goal for this form?', 'give'),
338
+						'id'          => $prefix.'goal_option',
339 339
 						'type'        => 'radio_inline',
340 340
 						'default'     => 'disabled',
341 341
 						'options'     => array(
342
-							'enabled'  => __( 'Enabled', 'give' ),
343
-							'disabled' => __( 'Disabled', 'give' ),
342
+							'enabled'  => __('Enabled', 'give'),
343
+							'disabled' => __('Disabled', 'give'),
344 344
 						),
345 345
 					),
346 346
 					array(
347
-						'name'          => __( 'Goal Amount', 'give' ),
348
-						'description'   => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ),
349
-						'id'            => $prefix . 'set_goal',
347
+						'name'          => __('Goal Amount', 'give'),
348
+						'description'   => __('This is the monetary goal amount you want to reach for this form.', 'give'),
349
+						'id'            => $prefix.'set_goal',
350 350
 						'type'          => 'text_small',
351 351
 						'data_type'     => 'price',
352 352
 						'attributes'    => array(
@@ -357,97 +357,97 @@  discard block
 block discarded – undo
357 357
 					),
358 358
 
359 359
 					array(
360
-						'name'          => __( 'Goal Format', 'give' ),
361
-						'description'   => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ),
362
-						'id'            => $prefix . 'goal_format',
360
+						'name'          => __('Goal Format', 'give'),
361
+						'description'   => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'),
362
+						'id'            => $prefix.'goal_format',
363 363
 						'type'          => 'radio_inline',
364 364
 						'default'       => 'amount',
365 365
 						'options'       => array(
366
-							'amount'     => __( 'Amount', 'give' ),
367
-							'percentage' => __( 'Percentage', 'give' ),
366
+							'amount'     => __('Amount', 'give'),
367
+							'percentage' => __('Percentage', 'give'),
368 368
 						),
369 369
 						'wrapper_class' => 'give-hidden',
370 370
 					),
371 371
 					array(
372
-						'name'          => __( 'Progress Bar Color', 'give' ),
373
-						'desc'          => __( 'Customize the color of the goal progress bar.', 'give' ),
374
-						'id'            => $prefix . 'goal_color',
372
+						'name'          => __('Progress Bar Color', 'give'),
373
+						'desc'          => __('Customize the color of the goal progress bar.', 'give'),
374
+						'id'            => $prefix.'goal_color',
375 375
 						'type'          => 'colorpicker',
376 376
 						'default'       => '#2bc253',
377 377
 						'wrapper_class' => 'give-hidden',
378 378
 					),
379 379
 
380 380
 					array(
381
-						'name'          => __( 'Close Form', 'give' ),
382
-						'desc'          => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
383
-						'id'            => $prefix . 'close_form_when_goal_achieved',
381
+						'name'          => __('Close Form', 'give'),
382
+						'desc'          => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
383
+						'id'            => $prefix.'close_form_when_goal_achieved',
384 384
 						'type'          => 'radio_inline',
385 385
 						'default'       => 'disabled',
386 386
 						'options'       => array(
387
-							'enabled'  => __( 'Enabled', 'give' ),
388
-							'disabled' => __( 'Disabled', 'give' ),
387
+							'enabled'  => __('Enabled', 'give'),
388
+							'disabled' => __('Disabled', 'give'),
389 389
 						),
390 390
 						'wrapper_class' => 'give-hidden',
391 391
 					),
392 392
 					array(
393
-						'name'          => __( 'Goal Achieved Message', 'give' ),
394
-						'desc'          => __( 'Do you want to display a custom message when the goal is closed?', 'give' ),
395
-						'id'            => $prefix . 'form_goal_achieved_message',
393
+						'name'          => __('Goal Achieved Message', 'give'),
394
+						'desc'          => __('Do you want to display a custom message when the goal is closed?', 'give'),
395
+						'id'            => $prefix.'form_goal_achieved_message',
396 396
 						'type'          => 'wysiwyg',
397
-						'default'       => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
397
+						'default'       => __('Thank you to all our donors, we have met our fundraising goal.', 'give'),
398 398
 						'wrapper_class' => 'give-hidden',
399 399
 					),
400 400
 					array(
401 401
 						'name'  => 'donation_goal_docs',
402 402
 						'type'  => 'docs_link',
403 403
 						'url'   => 'http://docs.givewp.com/form-donation-goal',
404
-						'title' => __( 'Donation Goal', 'give' ),
404
+						'title' => __('Donation Goal', 'give'),
405 405
 					),
406 406
 				),
407 407
 					$post_id
408 408
 				),
409
-			) ),
409
+			)),
410 410
 
411 411
 			/**
412 412
 			 * Content Field
413 413
 			 */
414
-			'form_content_options'  => apply_filters( 'give_forms_content_options', array(
414
+			'form_content_options'  => apply_filters('give_forms_content_options', array(
415 415
 				'id'        => 'form_content_options',
416
-				'title'     => __( 'Form Content', 'give' ),
416
+				'title'     => __('Form Content', 'give'),
417 417
 				'icon-html' => '<span class="give-icon give-icon-edit"></span>',
418
-				'fields'    => apply_filters( 'give_forms_content_options_metabox_fields', array(
418
+				'fields'    => apply_filters('give_forms_content_options_metabox_fields', array(
419 419
 
420 420
 					// Donation content.
421 421
 					array(
422
-						'name'        => __( 'Display Content', 'give' ),
423
-						'description' => __( 'Do you want to add custom content to this form?', 'give' ),
424
-						'id'          => $prefix . 'display_content',
422
+						'name'        => __('Display Content', 'give'),
423
+						'description' => __('Do you want to add custom content to this form?', 'give'),
424
+						'id'          => $prefix.'display_content',
425 425
 						'type'        => 'radio_inline',
426 426
 						'options'     => array(
427
-							'enabled'  => __( 'Enabled', 'give' ),
428
-							'disabled' => __( 'Disabled', 'give' ),
427
+							'enabled'  => __('Enabled', 'give'),
428
+							'disabled' => __('Disabled', 'give'),
429 429
 						),
430 430
 						'default'     => 'disabled',
431 431
 					),
432 432
 
433 433
 					// Content placement.
434 434
 					array(
435
-						'name'          => __( 'Content Placement', 'give' ),
436
-						'description'   => __( 'This option controls where the content appears within the donation form.', 'give' ),
437
-						'id'            => $prefix . 'content_placement',
435
+						'name'          => __('Content Placement', 'give'),
436
+						'description'   => __('This option controls where the content appears within the donation form.', 'give'),
437
+						'id'            => $prefix.'content_placement',
438 438
 						'type'          => 'radio_inline',
439
-						'options'       => apply_filters( 'give_forms_content_options_select', array(
440
-								'give_pre_form'  => __( 'Above fields', 'give' ),
441
-								'give_post_form' => __( 'Below fields', 'give' ),
439
+						'options'       => apply_filters('give_forms_content_options_select', array(
440
+								'give_pre_form'  => __('Above fields', 'give'),
441
+								'give_post_form' => __('Below fields', 'give'),
442 442
 							)
443 443
 						),
444 444
 						'default'       => 'give_pre_form',
445 445
 						'wrapper_class' => 'give-hidden',
446 446
 					),
447 447
 					array(
448
-						'name'          => __( 'Content', 'give' ),
449
-						'description'   => __( 'This content will display on the single give form page.', 'give' ),
450
-						'id'            => $prefix . 'form_content',
448
+						'name'          => __('Content', 'give'),
449
+						'description'   => __('This content will display on the single give form page.', 'give'),
450
+						'id'            => $prefix.'form_content',
451 451
 						'type'          => 'wysiwyg',
452 452
 						'wrapper_class' => 'give-hidden',
453 453
 					),
@@ -455,51 +455,51 @@  discard block
 block discarded – undo
455 455
 						'name'  => 'form_content_docs',
456 456
 						'type'  => 'docs_link',
457 457
 						'url'   => 'http://docs.givewp.com/form-content',
458
-						'title' => __( 'Form Content', 'give' ),
458
+						'title' => __('Form Content', 'give'),
459 459
 					),
460 460
 				),
461 461
 					$post_id
462 462
 				),
463
-			) ),
463
+			)),
464 464
 
465 465
 			/**
466 466
 			 * Terms & Conditions
467 467
 			 */
468
-			'form_terms_options'    => apply_filters( 'give_forms_terms_options', array(
468
+			'form_terms_options'    => apply_filters('give_forms_terms_options', array(
469 469
 				'id'        => 'form_terms_options',
470
-				'title'     => __( 'Terms & Conditions', 'give' ),
470
+				'title'     => __('Terms & Conditions', 'give'),
471 471
 				'icon-html' => '<span class="give-icon give-icon-checklist"></span>',
472
-				'fields'    => apply_filters( 'give_forms_terms_options_metabox_fields', array(
472
+				'fields'    => apply_filters('give_forms_terms_options_metabox_fields', array(
473 473
 					// Donation Option
474 474
 					array(
475
-						'name'        => __( 'Terms and Conditions', 'give' ),
476
-						'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ),
477
-						'id'          => $prefix . 'terms_option',
475
+						'name'        => __('Terms and Conditions', 'give'),
476
+						'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'),
477
+						'id'          => $prefix.'terms_option',
478 478
 						'type'        => 'radio_inline',
479
-						'options'     => apply_filters( 'give_forms_content_options_select', array(
480
-								'global'   => __( 'Global Option', 'give' ),
481
-								'enabled'  => __( 'Customize', 'give' ),
482
-								'disabled' => __( 'Disable', 'give' ),
479
+						'options'     => apply_filters('give_forms_content_options_select', array(
480
+								'global'   => __('Global Option', 'give'),
481
+								'enabled'  => __('Customize', 'give'),
482
+								'disabled' => __('Disable', 'give'),
483 483
 							)
484 484
 						),
485 485
 						'default'     => 'global',
486 486
 					),
487 487
 					array(
488
-						'id'            => $prefix . 'agree_label',
489
-						'name'          => __( 'Agreement Label', 'give' ),
490
-						'desc'          => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ),
488
+						'id'            => $prefix.'agree_label',
489
+						'name'          => __('Agreement Label', 'give'),
490
+						'desc'          => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
491 491
 						'type'          => 'text',
492 492
 						'size'          => 'regular',
493 493
 						'attributes'    => array(
494
-							'placeholder' => __( 'Agree to Terms?', 'give' ),
494
+							'placeholder' => __('Agree to Terms?', 'give'),
495 495
 						),
496 496
 						'wrapper_class' => 'give-hidden',
497 497
 					),
498 498
 					array(
499
-						'id'            => $prefix . 'agree_text',
500
-						'name'          => __( 'Agreement Text', 'give' ),
501
-						'desc'          => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
502
-						'default'       => give_get_option( 'agreement_text' ),
499
+						'id'            => $prefix.'agree_text',
500
+						'name'          => __('Agreement Text', 'give'),
501
+						'desc'          => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
502
+						'default'       => give_get_option('agreement_text'),
503 503
 						'type'          => 'wysiwyg',
504 504
 						'wrapper_class' => 'give-hidden',
505 505
 					),
@@ -507,18 +507,18 @@  discard block
 block discarded – undo
507 507
 						'name'  => 'terms_docs',
508 508
 						'type'  => 'docs_link',
509 509
 						'url'   => 'http://docs.givewp.com/form-terms',
510
-						'title' => __( 'Terms and Conditions', 'give' ),
510
+						'title' => __('Terms and Conditions', 'give'),
511 511
 					),
512 512
 				),
513 513
 					$post_id
514 514
 				),
515
-			) ),
515
+			)),
516 516
 		);
517 517
 
518 518
 		/**
519 519
 		 * Filter the metabox tabbed panel settings.
520 520
 		 */
521
-		$settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id );
521
+		$settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id);
522 522
 
523 523
 		// Output.
524 524
 		return $settings;
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
 		add_meta_box(
536 536
 			$this->get_metabox_ID(),
537 537
 			$this->get_metabox_label(),
538
-			array( $this, 'output' ),
539
-			array( 'give_forms' ),
538
+			array($this, 'output'),
539
+			array('give_forms'),
540 540
 			'normal',
541 541
 			'high'
542 542
 		);
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 	function enqueue_script() {
554 554
 		global $post;
555 555
 
556
-		if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
556
+		if (is_object($post) && 'give_forms' === $post->post_type) {
557 557
 
558 558
 		}
559 559
 	}
@@ -591,32 +591,32 @@  discard block
 block discarded – undo
591 591
 	public function get_tabs() {
592 592
 		$tabs = array();
593 593
 
594
-		if ( ! empty( $this->settings ) ) {
595
-			foreach ( $this->settings as $setting ) {
596
-				if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) {
594
+		if ( ! empty($this->settings)) {
595
+			foreach ($this->settings as $setting) {
596
+				if ( ! isset($setting['id']) || ! isset($setting['title'])) {
597 597
 					continue;
598 598
 				}
599 599
 				$tab = array(
600 600
 					'id'        => $setting['id'],
601 601
 					'label'     => $setting['title'],
602
-					'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ),
602
+					'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''),
603 603
 				);
604 604
 
605
-				if ( $this->has_sub_tab( $setting ) ) {
606
-					if ( empty( $setting['sub-fields'] ) ) {
605
+				if ($this->has_sub_tab($setting)) {
606
+					if (empty($setting['sub-fields'])) {
607 607
 						$tab = array();
608 608
 					} else {
609
-						foreach ( $setting['sub-fields'] as $sub_fields ) {
609
+						foreach ($setting['sub-fields'] as $sub_fields) {
610 610
 							$tab['sub-fields'][] = array(
611 611
 								'id'        => $sub_fields['id'],
612 612
 								'label'     => $sub_fields['title'],
613
-								'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ),
613
+								'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''),
614 614
 							);
615 615
 						}
616 616
 					}
617 617
 				}
618 618
 
619
-				if ( ! empty( $tab ) ) {
619
+				if ( ! empty($tab)) {
620 620
 					$tabs[] = $tab;
621 621
 				}
622 622
 			}
@@ -634,33 +634,33 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public function output() {
636 636
 		// Bailout.
637
-		if ( $form_data_tabs = $this->get_tabs() ) :
638
-			$active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options';
639
-			wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' );
637
+		if ($form_data_tabs = $this->get_tabs()) :
638
+			$active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options';
639
+			wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce');
640 640
 			?>
641 641
 			<input id="give_form_active_tab" type="hidden" name="give_form_active_tab">
642 642
 			<div class="give-metabox-panel-wrap">
643 643
 				<ul class="give-form-data-tabs give-metabox-tabs">
644
-					<?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?>
644
+					<?php foreach ($form_data_tabs as $index => $form_data_tab) : ?>
645 645
 						<?php
646 646
 						// Determine if current tab is active.
647 647
 						$is_active = $active_tab === $form_data_tab['id'] ? true : false;
648 648
 						?>
649
-						<li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>">
649
+						<li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>">
650 650
 							<a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>">
651
-								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
651
+								<?php if ( ! empty($form_data_tab['icon-html'])) : ?>
652 652
 									<?php echo $form_data_tab['icon-html']; ?>
653 653
 								<?php else : ?>
654 654
 									<span class="give-icon give-icon-default"></span>
655 655
 								<?php endif; ?>
656 656
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
657 657
 							</a>
658
-							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
658
+							<?php if ($this->has_sub_tab($form_data_tab)) : ?>
659 659
 								<ul class="give-metabox-sub-tabs give-hidden">
660
-									<?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?>
660
+									<?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?>
661 661
 										<li class="<?php echo "{$sub_tab['id']}_tab"; ?>">
662 662
 											<a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>">
663
-												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
663
+												<?php if ( ! empty($sub_tab['icon-html'])) : ?>
664 664
 													<?php echo $sub_tab['icon-html']; ?>
665 665
 												<?php else : ?>
666 666
 													<span class="give-icon give-icon-default"></span>
@@ -675,30 +675,30 @@  discard block
 block discarded – undo
675 675
 					<?php endforeach; ?>
676 676
 				</ul>
677 677
 
678
-				<?php foreach ( $this->settings as $setting ) : ?>
679
-					<?php if ( ! $this->has_sub_tab( $setting ) ) : ?>
680
-						<?php do_action( "give_before_{$setting['id']}_settings" ); ?>
678
+				<?php foreach ($this->settings as $setting) : ?>
679
+					<?php if ( ! $this->has_sub_tab($setting)) : ?>
680
+						<?php do_action("give_before_{$setting['id']}_settings"); ?>
681 681
 						<?php
682 682
 						// Determine if current panel is active.
683 683
 						$is_active = $active_tab === $setting['id'] ? true : false;
684 684
 						?>
685
-						<div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>">
686
-							<?php if ( ! empty( $setting['fields'] ) ) : ?>
687
-								<?php foreach ( $setting['fields'] as $field ) : ?>
688
-									<?php give_render_field( $field ); ?>
685
+						<div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>">
686
+							<?php if ( ! empty($setting['fields'])) : ?>
687
+								<?php foreach ($setting['fields'] as $field) : ?>
688
+									<?php give_render_field($field); ?>
689 689
 								<?php endforeach; ?>
690 690
 							<?php endif; ?>
691 691
 						</div>
692 692
 
693
-						<?php do_action( "give_after_{$setting['id']}_settings" ); ?>
693
+						<?php do_action("give_after_{$setting['id']}_settings"); ?>
694 694
 					<?php else : ?>
695
-						<?php if ( $this->has_sub_tab( $setting ) ) : ?>
696
-							<?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
697
-								<?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
695
+						<?php if ($this->has_sub_tab($setting)) : ?>
696
+							<?php if ( ! empty($setting['sub-fields'])) : ?>
697
+								<?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?>
698 698
 									<div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
699
-										<?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
700
-											<?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
701
-												<?php give_render_field( $sub_field ); ?>
699
+										<?php if ( ! empty($sub_fields['fields'])) : ?>
700
+											<?php foreach ($sub_fields['fields'] as $sub_field) : ?>
701
+												<?php give_render_field($sub_field); ?>
702 702
 											<?php endforeach; ?>
703 703
 										<?php endif; ?>
704 704
 									</div>
@@ -722,9 +722,9 @@  discard block
 block discarded – undo
722 722
 	 *
723 723
 	 * @return bool
724 724
 	 */
725
-	private function has_sub_tab( $field_setting ) {
725
+	private function has_sub_tab($field_setting) {
726 726
 		$has_sub_tab = false;
727
-		if ( array_key_exists( 'sub-fields', $field_setting ) ) {
727
+		if (array_key_exists('sub-fields', $field_setting)) {
728 728
 			$has_sub_tab = true;
729 729
 		}
730 730
 
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 	 * @return array
740 740
 	 */
741 741
 	function cmb2_metabox_settings() {
742
-		$all_cmb2_settings   = apply_filters( 'cmb2_meta_boxes', array() );
742
+		$all_cmb2_settings   = apply_filters('cmb2_meta_boxes', array());
743 743
 		$give_forms_settings = $all_cmb2_settings;
744 744
 
745 745
 		// Filter settings: Use only give forms related settings.
746
-		foreach ( $all_cmb2_settings as $index => $setting ) {
747
-			if ( ! in_array( 'give_forms', $setting['object_types'] ) ) {
748
-				unset( $give_forms_settings[ $index ] );
746
+		foreach ($all_cmb2_settings as $index => $setting) {
747
+			if ( ! in_array('give_forms', $setting['object_types'])) {
748
+				unset($give_forms_settings[$index]);
749 749
 			}
750 750
 		}
751 751
 
@@ -763,96 +763,96 @@  discard block
 block discarded – undo
763 763
 	 *
764 764
 	 * @return void
765 765
 	 */
766
-	public function save( $post_id, $post ) {
766
+	public function save($post_id, $post) {
767 767
 
768 768
 		// $post_id and $post are required.
769
-		if ( empty( $post_id ) || empty( $post ) ) {
769
+		if (empty($post_id) || empty($post)) {
770 770
 			return;
771 771
 		}
772 772
 
773 773
 		// Don't save meta boxes for revisions or autosaves.
774
-		if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
774
+		if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
775 775
 			return;
776 776
 		}
777 777
 
778 778
 		// Check the nonce.
779
-		if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) {
779
+		if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) {
780 780
 			return;
781 781
 		}
782 782
 
783 783
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
784
-		if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
784
+		if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) {
785 785
 			return;
786 786
 		}
787 787
 
788 788
 		// Check user has permission to edit.
789
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
789
+		if ( ! current_user_can('edit_post', $post_id)) {
790 790
 			return;
791 791
 		}
792 792
 
793 793
 		// Fire action before saving form meta.
794
-		do_action( 'give_pre_process_give_forms_meta', $post_id, $post );
794
+		do_action('give_pre_process_give_forms_meta', $post_id, $post);
795 795
 
796 796
 		/**
797 797
 		 * Filter the meta key to save.
798 798
 		 * Third party addon developer can remove there meta keys from this array to handle saving data on there own.
799 799
 		 */
800
-		$form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() );
800
+		$form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings());
801 801
 
802 802
 		// Save form meta data.
803
-		if ( ! empty( $form_meta_keys ) ) {
804
-			foreach ( $form_meta_keys as $form_meta_key ) {
803
+		if ( ! empty($form_meta_keys)) {
804
+			foreach ($form_meta_keys as $form_meta_key) {
805 805
 
806 806
 				// Set default value for checkbox fields.
807 807
 				if (
808
-					! isset( $_POST[ $form_meta_key ] )
809
-					&& ( 'checkbox' === $this->get_field_type( $form_meta_key ) )
808
+					! isset($_POST[$form_meta_key])
809
+					&& ('checkbox' === $this->get_field_type($form_meta_key))
810 810
 				) {
811
-					$_POST[ $form_meta_key ] = '';
811
+					$_POST[$form_meta_key] = '';
812 812
 				}
813 813
 
814
-				if ( isset( $_POST[ $form_meta_key ] ) ) {
815
-					$setting_field = $this->get_setting_field( $form_meta_key );
816
-					if ( ! empty( $setting_field['type'] ) ) {
817
-						switch ( $setting_field['type'] ) {
814
+				if (isset($_POST[$form_meta_key])) {
815
+					$setting_field = $this->get_setting_field($form_meta_key);
816
+					if ( ! empty($setting_field['type'])) {
817
+						switch ($setting_field['type']) {
818 818
 							case 'textarea':
819 819
 							case 'wysiwyg':
820
-								$form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] );
820
+								$form_meta_value = wp_kses_post($_POST[$form_meta_key]);
821 821
 								break;
822 822
 
823 823
 							case 'group':
824 824
 								$form_meta_value = array();
825 825
 
826
-								foreach ( $_POST[ $form_meta_key ] as $index => $group ) {
826
+								foreach ($_POST[$form_meta_key] as $index => $group) {
827 827
 
828 828
 									// Do not save template input field values.
829
-									if ( '{{row-count-placeholder}}' === $index ) {
829
+									if ('{{row-count-placeholder}}' === $index) {
830 830
 										continue;
831 831
 									}
832 832
 
833 833
 									$group_meta_value = array();
834
-									foreach ( $group as $field_id => $field_value ) {
835
-										switch ( $this->get_field_type( $field_id, $form_meta_key ) ) {
834
+									foreach ($group as $field_id => $field_value) {
835
+										switch ($this->get_field_type($field_id, $form_meta_key)) {
836 836
 											case 'wysiwyg':
837
-												$group_meta_value[ $field_id ] = wp_kses_post( $field_value );
837
+												$group_meta_value[$field_id] = wp_kses_post($field_value);
838 838
 												break;
839 839
 
840 840
 											default:
841
-												$group_meta_value[ $field_id ] = give_clean( $field_value );
841
+												$group_meta_value[$field_id] = give_clean($field_value);
842 842
 										}
843 843
 									}
844 844
 
845
-									if ( ! empty( $group_meta_value ) ) {
846
-										$form_meta_value[ $index ] = $group_meta_value;
845
+									if ( ! empty($group_meta_value)) {
846
+										$form_meta_value[$index] = $group_meta_value;
847 847
 									}
848 848
 								}
849 849
 
850 850
 								// Arrange repeater field keys in order.
851
-								$form_meta_value = array_values( $form_meta_value );
851
+								$form_meta_value = array_values($form_meta_value);
852 852
 								break;
853 853
 
854 854
 							default:
855
-								$form_meta_value = give_clean( $_POST[ $form_meta_key ] );
855
+								$form_meta_value = give_clean($_POST[$form_meta_key]);
856 856
 						}// End switch().
857 857
 
858 858
 						/**
@@ -862,24 +862,24 @@  discard block
 block discarded – undo
862 862
 						 */
863 863
 						$form_meta_value = apply_filters(
864 864
 							'give_pre_save_form_meta_value',
865
-							$this->sanitize_form_meta( $form_meta_value, $setting_field ),
865
+							$this->sanitize_form_meta($form_meta_value, $setting_field),
866 866
 							$form_meta_key,
867 867
 							$this,
868 868
 							$post_id
869 869
 						);
870 870
 
871 871
 						// Save data.
872
-						give_update_meta( $post_id, $form_meta_key, $form_meta_value );
872
+						give_update_meta($post_id, $form_meta_key, $form_meta_value);
873 873
 
874 874
 						// Fire after saving form meta key.
875
-						do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post );
875
+						do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post);
876 876
 					}// End if().
877 877
 				}// End if().
878 878
 			}// End foreach().
879 879
 		}// End if().
880 880
 
881 881
 		// Fire action after saving form meta.
882
-		do_action( 'give_post_process_give_forms_meta', $post_id, $post );
882
+		do_action('give_post_process_give_forms_meta', $post_id, $post);
883 883
 	}
884 884
 
885 885
 
@@ -892,10 +892,10 @@  discard block
 block discarded – undo
892 892
 	 *
893 893
 	 * @return string
894 894
 	 */
895
-	private function get_field_id( $field ) {
895
+	private function get_field_id($field) {
896 896
 		$field_id = '';
897 897
 
898
-		if ( array_key_exists( 'id', $field ) ) {
898
+		if (array_key_exists('id', $field)) {
899 899
 			$field_id = $field['id'];
900 900
 
901 901
 		}
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 	 *
913 913
 	 * @return array
914 914
 	 */
915
-	private function get_fields_id( $setting ) {
915
+	private function get_fields_id($setting) {
916 916
 		$meta_keys = array();
917 917
 
918
-		if ( ! empty( $setting ) ) {
919
-			foreach ( $setting['fields'] as $field ) {
920
-				if ( $field_id = $this->get_field_id( $field ) ) {
918
+		if ( ! empty($setting)) {
919
+			foreach ($setting['fields'] as $field) {
920
+				if ($field_id = $this->get_field_id($field)) {
921 921
 					$meta_keys[] = $field_id;
922 922
 				}
923 923
 			}
@@ -935,14 +935,14 @@  discard block
 block discarded – undo
935 935
 	 *
936 936
 	 * @return array
937 937
 	 */
938
-	private function get_sub_fields_id( $setting ) {
938
+	private function get_sub_fields_id($setting) {
939 939
 		$meta_keys = array();
940 940
 
941
-		if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) {
942
-			foreach ( $setting['sub-fields'] as $fields ) {
943
-				if ( ! empty( $fields['fields'] ) ) {
944
-					foreach ( $fields['fields'] as $field ) {
945
-						if ( $field_id = $this->get_field_id( $field ) ) {
941
+		if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) {
942
+			foreach ($setting['sub-fields'] as $fields) {
943
+				if ( ! empty($fields['fields'])) {
944
+					foreach ($fields['fields'] as $field) {
945
+						if ($field_id = $this->get_field_id($field)) {
946 946
 							$meta_keys[] = $field_id;
947 947
 						}
948 948
 					}
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
 	private function get_meta_keys_from_settings() {
965 965
 		$meta_keys = array();
966 966
 
967
-		foreach ( $this->settings as $setting ) {
968
-			if ( $this->has_sub_tab( $setting ) ) {
969
-				$meta_key = $this->get_sub_fields_id( $setting );
967
+		foreach ($this->settings as $setting) {
968
+			if ($this->has_sub_tab($setting)) {
969
+				$meta_key = $this->get_sub_fields_id($setting);
970 970
 			} else {
971
-				$meta_key = $this->get_fields_id( $setting );
971
+				$meta_key = $this->get_fields_id($setting);
972 972
 			}
973 973
 
974
-			$meta_keys = array_merge( $meta_keys, $meta_key );
974
+			$meta_keys = array_merge($meta_keys, $meta_key);
975 975
 		}
976 976
 
977 977
 		return $meta_keys;
@@ -988,10 +988,10 @@  discard block
 block discarded – undo
988 988
 	 *
989 989
 	 * @return string
990 990
 	 */
991
-	function get_field_type( $field_id, $group_id = '' ) {
992
-		$field = $this->get_setting_field( $field_id, $group_id );
991
+	function get_field_type($field_id, $group_id = '') {
992
+		$field = $this->get_setting_field($field_id, $group_id);
993 993
 
994
-		$type = array_key_exists( 'type', $field )
994
+		$type = array_key_exists('type', $field)
995 995
 			? $field['type']
996 996
 			: '';
997 997
 
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 	 *
1010 1010
 	 * @return array
1011 1011
 	 */
1012
-	private function get_field( $setting, $field_id ) {
1012
+	private function get_field($setting, $field_id) {
1013 1013
 		$setting_field = array();
1014 1014
 
1015
-		if ( ! empty( $setting['fields'] ) ) {
1016
-			foreach ( $setting['fields'] as $field ) {
1017
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) {
1015
+		if ( ! empty($setting['fields'])) {
1016
+			foreach ($setting['fields'] as $field) {
1017
+				if (array_key_exists('id', $field) && $field['id'] === $field_id) {
1018 1018
 					$setting_field = $field;
1019 1019
 					break;
1020 1020
 				}
@@ -1034,12 +1034,12 @@  discard block
 block discarded – undo
1034 1034
 	 *
1035 1035
 	 * @return array
1036 1036
 	 */
1037
-	private function get_sub_field( $setting, $field_id ) {
1037
+	private function get_sub_field($setting, $field_id) {
1038 1038
 		$setting_field = array();
1039 1039
 
1040
-		if ( ! empty( $setting['sub-fields'] ) ) {
1041
-			foreach ( $setting['sub-fields'] as $fields ) {
1042
-				if ( $field = $this->get_field( $fields, $field_id ) ) {
1040
+		if ( ! empty($setting['sub-fields'])) {
1041
+			foreach ($setting['sub-fields'] as $fields) {
1042
+				if ($field = $this->get_field($fields, $field_id)) {
1043 1043
 					$setting_field = $field;
1044 1044
 					break;
1045 1045
 				}
@@ -1059,17 +1059,17 @@  discard block
 block discarded – undo
1059 1059
 	 *
1060 1060
 	 * @return array
1061 1061
 	 */
1062
-	function get_setting_field( $field_id, $group_id = '' ) {
1062
+	function get_setting_field($field_id, $group_id = '') {
1063 1063
 		$setting_field = array();
1064 1064
 
1065 1065
 		$_field_id = $field_id;
1066
-		$field_id  = empty( $group_id ) ? $field_id : $group_id;
1066
+		$field_id  = empty($group_id) ? $field_id : $group_id;
1067 1067
 
1068
-		if ( ! empty( $this->settings ) ) {
1069
-			foreach ( $this->settings as $setting ) {
1068
+		if ( ! empty($this->settings)) {
1069
+			foreach ($this->settings as $setting) {
1070 1070
 				if (
1071
-					( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) )
1072
-					|| ( $setting_field = $this->get_field( $setting, $field_id ) )
1071
+					($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id)))
1072
+					|| ($setting_field = $this->get_field($setting, $field_id))
1073 1073
 				) {
1074 1074
 					break;
1075 1075
 				}
@@ -1077,9 +1077,9 @@  discard block
 block discarded – undo
1077 1077
 		}
1078 1078
 
1079 1079
 		// Get field from group.
1080
-		if ( ! empty( $group_id ) ) {
1081
-			foreach ( $setting_field['fields'] as $field ) {
1082
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) {
1080
+		if ( ! empty($group_id)) {
1081
+			foreach ($setting_field['fields'] as $field) {
1082
+				if (array_key_exists('id', $field) && $field['id'] === $_field_id) {
1083 1083
 					$setting_field = $field;
1084 1084
 				}
1085 1085
 			}
@@ -1098,14 +1098,14 @@  discard block
 block discarded – undo
1098 1098
 	 *
1099 1099
 	 * @return mixed
1100 1100
 	 */
1101
-	function add_offline_donations_setting_tab( $settings ) {
1102
-		if ( give_is_gateway_active( 'offline' ) ) {
1103
-			$settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array(
1101
+	function add_offline_donations_setting_tab($settings) {
1102
+		if (give_is_gateway_active('offline')) {
1103
+			$settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array(
1104 1104
 				'id'        => 'offline_donations_options',
1105
-				'title'     => __( 'Offline Donations', 'give' ),
1105
+				'title'     => __('Offline Donations', 'give'),
1106 1106
 				'icon-html' => '<span class="give-icon give-icon-purse"></span>',
1107
-				'fields'    => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ),
1108
-			) );
1107
+				'fields'    => apply_filters('give_forms_offline_donations_metabox_fields', array()),
1108
+			));
1109 1109
 		}
1110 1110
 
1111 1111
 		return $settings;
@@ -1123,22 +1123,22 @@  discard block
 block discarded – undo
1123 1123
 	 *
1124 1124
 	 * @return mixed
1125 1125
 	 */
1126
-	function sanitize_form_meta( $meta_value, $setting_field ) {
1127
-		switch ( $setting_field['type'] ) {
1126
+	function sanitize_form_meta($meta_value, $setting_field) {
1127
+		switch ($setting_field['type']) {
1128 1128
 			case 'group':
1129
-				if ( ! empty( $setting_field['fields'] ) ) {
1130
-					foreach ( $setting_field['fields'] as $field ) {
1131
-						if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) {
1129
+				if ( ! empty($setting_field['fields'])) {
1130
+					foreach ($setting_field['fields'] as $field) {
1131
+						if (empty($field['data_type']) || 'price' !== $field['data_type']) {
1132 1132
 							continue;
1133 1133
 						}
1134 1134
 
1135
-						foreach ( $meta_value as $index => $meta_data ) {
1136
-							if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) {
1135
+						foreach ($meta_value as $index => $meta_data) {
1136
+							if ( ! isset($meta_value[$index][$field['id']])) {
1137 1137
 								continue;
1138 1138
 							}
1139 1139
 
1140
-							$meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] )
1141
-								? give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] )
1140
+							$meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']])
1141
+								? give_sanitize_amount_for_db($meta_value[$index][$field['id']])
1142 1142
 								: 0;
1143 1143
 						}
1144 1144
 					}
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 				break;
1147 1147
 
1148 1148
 			default:
1149
-				if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) {
1150
-					$meta_value = $meta_value ? give_sanitize_amount_for_db( $meta_value ) : 0;
1149
+				if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) {
1150
+					$meta_value = $meta_value ? give_sanitize_amount_for_db($meta_value) : 0;
1151 1151
 				}
1152 1152
 		}
1153 1153
 
@@ -1165,12 +1165,12 @@  discard block
 block discarded – undo
1165 1165
 	 *
1166 1166
 	 * @return string The URL after redirect.
1167 1167
 	 */
1168
-	public function maintain_active_tab( $location, $post_id ) {
1168
+	public function maintain_active_tab($location, $post_id) {
1169 1169
 		if (
1170
-			'give_forms' === get_post_type( $post_id ) &&
1171
-			! empty( $_POST['give_form_active_tab'] )
1170
+			'give_forms' === get_post_type($post_id) &&
1171
+			! empty($_POST['give_form_active_tab'])
1172 1172
 		) {
1173
-			$location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location );
1173
+			$location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location);
1174 1174
 		}
1175 1175
 
1176 1176
 		return $location;
Please login to merge, or discard this patch.
includes/admin/class-blank-slate.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.8.13
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -75,63 +75,63 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function init() {
77 77
 		// Bail early if screen cannot be detected.
78
-		if ( empty( $this->screen ) ) {
78
+		if (empty($this->screen)) {
79 79
 			return null;
80 80
 		}
81 81
 
82 82
 		$content = array();
83 83
 
84 84
 		// Define content and hook into the appropriate action.
85
-		switch ( $this->screen ) {
85
+		switch ($this->screen) {
86 86
 			// Forms screen.
87 87
 			case 'edit-give_forms':
88
-				$this->form = $this->post_exists( 'give_forms' );
88
+				$this->form = $this->post_exists('give_forms');
89 89
 
90
-				if ( $this->form ) {
90
+				if ($this->form) {
91 91
 					// Form exists. Bail out.
92 92
 					return false;
93 93
 				} else {
94 94
 					// No forms exist.
95
-					$content = $this->get_content( 'no_forms' );
95
+					$content = $this->get_content('no_forms');
96 96
 				}
97 97
 
98
-				add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) );
98
+				add_action('manage_posts_extra_tablenav', array($this, 'render'));
99 99
 				break;
100 100
 			// Donations screen.
101 101
 			case 'give_forms_page_give-payment-history':
102
-				$this->form     = $this->post_exists( 'give_forms' );
103
-				$this->donation = $this->post_exists( 'give_payment' );
102
+				$this->form     = $this->post_exists('give_forms');
103
+				$this->donation = $this->post_exists('give_payment');
104 104
 
105
-				if ( $this->donation ) {
105
+				if ($this->donation) {
106 106
 					// Donation exists. Bail out.
107 107
 					return false;
108
-				} elseif ( ! $this->form ) {
108
+				} elseif ( ! $this->form) {
109 109
 					// No forms and no donations exist.
110
-					$content = $this->get_content( 'no_donations_or_forms' );
110
+					$content = $this->get_content('no_donations_or_forms');
111 111
 				} else {
112 112
 					// No donations exist but a form does exist.
113
-					$content = $this->get_content( 'no_donations' );
113
+					$content = $this->get_content('no_donations');
114 114
 				}
115 115
 
116
-				add_action( 'give_payments_page_bottom', array( $this, 'render' ) );
116
+				add_action('give_payments_page_bottom', array($this, 'render'));
117 117
 				break;
118 118
 			// Donors screen.
119 119
 			case 'give_forms_page_give-donors':
120
-				$this->form  = $this->post_exists( 'give_forms' );
120
+				$this->form  = $this->post_exists('give_forms');
121 121
 				$this->donor = $this->donor_exists();
122 122
 
123
-				if ( $this->donor ) {
123
+				if ($this->donor) {
124 124
 					// Donor exists. Bail out.
125 125
 					return false;
126
-				} elseif ( ! $this->form ) {
126
+				} elseif ( ! $this->form) {
127 127
 					// No forms and no donors exist.
128
-					$content = $this->get_content( 'no_donors_or_forms' );
128
+					$content = $this->get_content('no_donors_or_forms');
129 129
 				} else {
130 130
 					// No donors exist but a form does exist.
131
-					$content = $this->get_content( 'no_donors' );
131
+					$content = $this->get_content('no_donors');
132 132
 				}
133 133
 
134
-				add_action( 'give_donors_table_bottom', array( $this, 'render' ) );
134
+				add_action('give_donors_table_bottom', array($this, 'render'));
135 135
 				break;
136 136
 			default:
137 137
 				return null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$this->content = $content;
141 141
 
142 142
 		// Hide non-essential UI elements.
143
-		add_action( 'admin_head', array( $this, 'hide_ui' ) );
143
+		add_action('admin_head', array($this, 'hide_ui'));
144 144
 	}
145 145
 
146 146
 	/**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param string $which The location of the list table hook: 'top' or 'bottom'.
152 152
 	 */
153
-	public function render( $which = 'bottom') {
153
+	public function render($which = 'bottom') {
154 154
 		// Bail out to prevent content from rendering twice.
155
-		if ( 'top' === $which ) {
155
+		if ('top' === $which) {
156 156
 			return null;
157 157
 		}
158 158
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 		 *
178 178
 		 * @param string $screen The current screen ID.
179 179
 		 */
180
-		$content = apply_filters( 'give_blank_slate_content', $this->content, $screen );
180
+		$content = apply_filters('give_blank_slate_content', $this->content, $screen);
181 181
 
182
-		$template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php';
182
+		$template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php';
183 183
 
184 184
 		include $template_path;
185 185
 	}
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 * @param string $post_type Post type used in the query.
202 202
 	 * @return bool True if post exists, otherwise false.
203 203
 	 */
204
-	private function post_exists( $post_type ) {
204
+	private function post_exists($post_type) {
205 205
 		// Attempt to get a single post of the post type.
206
-		$query = new WP_Query( array(
206
+		$query = new WP_Query(array(
207 207
 			'post_type'              => $post_type,
208 208
 			'posts_per_page'         => 1,
209 209
 			'no_found_rows'          => false,
210 210
 			'update_post_meta_cache' => false,
211 211
 			'update_post_term_cache' => false,
212 212
 			'fields'                 => 'ids',
213
-			'post_status'            => array( 'any', 'trash' ),
214
-		) );
213
+			'post_status'            => array('any', 'trash'),
214
+		));
215 215
 
216 216
 		return $query->have_posts();
217 217
 	}
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @return bool True if donor exists, otherwise false.
225 225
 	 */
226 226
 	private function donor_exists() {
227
-		$donors = Give()->donors->get_donors( array( 'number' => 1 ) );
227
+		$donors = Give()->donors->get_donors(array('number' => 1));
228 228
 
229
-		return ! empty( $donors );
229
+		return ! empty($donors);
230 230
 	}
231 231
 
232 232
 	/**
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 * @param string $context The key used to determine which content is returned.
238 238
 	 * @return array Blank slate content.
239 239
 	 */
240
-	private function get_content( $context ) {
240
+	private function get_content($context) {
241 241
 		// Define default content.
242 242
 		$defaults = array(
243
-			'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg',
244
-			'image_alt' => __( 'Give Icon', 'give' ),
245
-			'heading'   => __( 'No donation forms  found.', 'give' ),
246
-			'message'   => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
247
-			'cta_text'  => __( 'Create Donation Form', 'give' ),
248
-			'cta_link'  => admin_url( 'post-new.php?post_type=give_forms' ),
243
+			'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg',
244
+			'image_alt' => __('Give Icon', 'give'),
245
+			'heading'   => __('No donation forms  found.', 'give'),
246
+			'message'   => __('The first step towards accepting online donations is to create a form.', 'give'),
247
+			'cta_text'  => __('Create Donation Form', 'give'),
248
+			'cta_link'  => admin_url('post-new.php?post_type=give_forms'),
249 249
 			'help'      => sprintf(
250
-				__( 'Need help? Get started with %sGive 101%s.', 'wbpr' ),
250
+				__('Need help? Get started with %sGive 101%s.', 'wbpr'),
251 251
 				'<a href="http://docs.givewp.com/give101/" target="_blank">',
252 252
 				'</a>'
253 253
 			),
@@ -256,40 +256,40 @@  discard block
 block discarded – undo
256 256
 		// Define contextual content.
257 257
 		$content = array(
258 258
 			'no_donations_or_forms' => array(
259
-				'heading' => __( 'No donations found.', 'give' ),
260
-				'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ),
259
+				'heading' => __('No donations found.', 'give'),
260
+				'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'),
261 261
 			),
262 262
 			'no_donations'          => array(
263
-				'heading'  => __( 'No donations found.', 'give' ),
264
-				'message'  => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ),
265
-				'cta_text' => __( 'View All Forms', 'give' ),
266
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
263
+				'heading'  => __('No donations found.', 'give'),
264
+				'message'  => __('When your first donation arrives, a record of the donation will appear here.', 'give'),
265
+				'cta_text' => __('View All Forms', 'give'),
266
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
267 267
 				'help'     => sprintf(
268
-					__( 'Need help? Learn more about %sDonations%s.', 'wbpr' ),
268
+					__('Need help? Learn more about %sDonations%s.', 'wbpr'),
269 269
 					'<a href="http://docs.givewp.com/core-donations/">',
270 270
 					'</a>'
271 271
 				),
272 272
 			),
273 273
 			'no_donors_or_forms'    => array(
274
-				'heading' => __( 'No donors  found.', 'give' ),
275
-				'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ),
274
+				'heading' => __('No donors  found.', 'give'),
275
+				'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'),
276 276
 			),
277 277
 			'no_donors'             => array(
278
-				'heading'  => __( 'No donors found.', 'give' ),
279
-				'message'  => __( 'When your first donation arrives, the donor will appear here.', 'give' ),
280
-				'cta_text' => __( 'View All Forms', 'give' ),
281
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
278
+				'heading'  => __('No donors found.', 'give'),
279
+				'message'  => __('When your first donation arrives, the donor will appear here.', 'give'),
280
+				'cta_text' => __('View All Forms', 'give'),
281
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
282 282
 				'help'     => sprintf(
283
-					__( 'Need help? Learn more about %sDonors%s.', 'wbpr' ),
283
+					__('Need help? Learn more about %sDonors%s.', 'wbpr'),
284 284
 					'<a href="http://docs.givewp.com/core-donors/">',
285 285
 					'</a>'
286 286
 				),
287 287
 			),
288 288
 		);
289 289
 
290
-		if ( isset( $content[ $context ] ) ) {
290
+		if (isset($content[$context])) {
291 291
 			// Merge contextual content with defaults.
292
-			return wp_parse_args( $content[ $context ], $defaults );
292
+			return wp_parse_args($content[$context], $defaults);
293 293
 		} else {
294 294
 			// Return defaults if context is undefined.
295 295
 			return $defaults;
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,5 +95,8 @@
 block discarded – undo
95 95
 		<?php endif; ?>
96 96
 		<?php echo $form_close_tag; ?>
97 97
 	</div>
98
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
98
+<?php else {
99
+	: echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
100
+}
101
+?>
99 102
 <?php endif; ?>
100 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 // Bailout: Do not output anything if setting tab is not defined.
10
-if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) :
10
+if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) :
11 11
 	/**
12 12
 	 * Filter the form action.
13 13
 	 *
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @since 1.8
19 19
 	 */
20
-	$form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
20
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
21 21
 
22 22
 	/**
23 23
 	 * Filter the main form tab.
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @since 1.8
31 31
 	 */
32
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' );
33
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
32
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
33
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
34 34
 	?>
35
-	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>">
35
+	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>">
36 36
 		<?php
37 37
 		echo $form_open_tag;
38 38
 
39 39
 		/* @var Give_Settings_Page $current_setting_obj */
40 40
 		if (
41
-			! empty( $current_setting_obj ) &&
42
-			method_exists( $current_setting_obj, 'get_heading_html' )
41
+			! empty($current_setting_obj) &&
42
+			method_exists($current_setting_obj, 'get_heading_html')
43 43
 		) {
44 44
 			echo $current_setting_obj->get_heading_html();
45 45
 		} else {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			// Backward compatibility.
48 48
 			echo sprintf(
49 49
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
50
-				esc_html( $tabs[ $current_tab ] )
50
+				esc_html($tabs[$current_tab])
51 51
 			);
52 52
 		}
53 53
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 		?>
56 56
 		<div class="nav-tab-wrapper give-nav-tab-wrapper">
57 57
 			<?php
58
-			foreach ( $tabs as $name => $label ) {
59
-				echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>';
58
+			foreach ($tabs as $name => $label) {
59
+				echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>';
60 60
 			}
61 61
 
62 62
 			/**
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 			 *
69 69
 			 * @since 1.8
70 70
 			 */
71
-			do_action( self::$setting_filter_prefix . '_tabs' );
71
+			do_action(self::$setting_filter_prefix.'_tabs');
72 72
 			?>
73 73
 		</div>
74 74
 		<div class="give-sub-nav-tab-wrapper">
75
-			<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
75
+			<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
76 76
 			</a>
77 77
 			<nav class="give-sub-nav-tab give-hidden"></nav>
78 78
 		</div>
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		 *
88 88
 		 * @since 1.8
89 89
 		 */
90
-		do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
90
+		do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
91 91
 
92 92
 		/**
93 93
 		 * Trigger Action.
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		 *
99 99
 		 * @since 1.8
100 100
 		 */
101
-		do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
101
+		do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
102 102
 
103
-		if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
103
+		if (empty($GLOBALS['give_hide_save_button'])) : ?>
104 104
 			<div class="give-submit-wrap">
105
-				<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
106
-				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/>
105
+				<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
106
+				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/>
107 107
 			</div>
108 108
 		<?php endif; ?>
109 109
 		<?php echo $form_close_tag; ?>
110 110
 	</div>
111
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
111
+<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?>
112 112
 <?php endif; ?>
113 113
\ No newline at end of file
Please login to merge, or discard this patch.