Passed
Push — master ( af6e37...385462 )
by Brian
04:02
created
includes/admin/register-settings.php 1 patch
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = wpinv_clean( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246 246
 }
247 247
 
248 248
 /**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
293 293
 
294
-		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
294
+        // Key specific filter.
295
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
     foreach ( $new_rates as $rate ) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
356
-		$tax_rates[]     = $rate;
351
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
+        $rate['name']    = sanitize_text_field( $rate['name'] );
353
+        $rate['state']   = sanitize_text_field( $rate['state'] );
354
+        $rate['country'] = sanitize_text_field( $rate['country'] );
355
+        $rate['global']  = empty( $rate['state'] );
356
+        $tax_rates[]     = $rate;
357 357
 
358
-	}
358
+    }
359 359
 
360 360
     update_option( 'wpinv_tax_rates', $tax_rates );
361 361
 
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
     $tabs['general']  = __( 'General', 'invoicing' );
374 374
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375 375
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
376
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
-	}
378
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
+    }
381 381
 
382 382
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383 383
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
         ) ),
416 416
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417 417
             'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
418
+            'rates' => __( 'Tax Rates', 'invoicing' ),
419
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
420 420
         ) ),
421 421
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422 422
             'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
423
+        ) ),
424 424
 
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426 426
 
427 427
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428 428
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -442,51 +442,51 @@  discard block
 block discarded – undo
442 442
 }
443 443
 
444 444
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
445
-	$pages_options = array();
445
+    $pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
449
-	}
447
+    if( $default_label !== NULL && $default_label !== false ) {
448
+        $pages_options = array( '' => $default_label ); // Blank option
449
+    }
450 450
 
451
-	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
454
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
451
+    $pages = get_pages();
452
+    if ( $pages ) {
453
+        foreach ( $pages as $page ) {
454
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455 455
             $pages_options[ $page->ID ] = $title;
456
-		}
457
-	}
456
+        }
457
+    }
458 458
 
459
-	return $pages_options;
459
+    return $pages_options;
460 460
 }
461 461
 
462 462
 function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
463
+    if ( !empty( $args['desc'] ) ) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468 468
 function wpinv_hidden_callback( $args ) {
469
-	global $wpinv_options;
470
-
471
-	if ( isset( $args['set_value'] ) ) {
472
-		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
475
-	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
477
-	}
478
-
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
-		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
482
-		$name  = '';
483
-	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
-	}
486
-
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
469
+    global $wpinv_options;
470
+
471
+    if ( isset( $args['set_value'] ) ) {
472
+        $value = $args['set_value'];
473
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
+        $value = $wpinv_options[ $args['id'] ];
475
+    } else {
476
+        $value = isset( $args['std'] ) ? $args['std'] : '';
477
+    }
478
+
479
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
+        $args['readonly'] = true;
481
+        $value = isset( $args['std'] ) ? $args['std'] : '';
482
+        $name  = '';
483
+    } else {
484
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
+    }
486
+
487
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
488 488
     
489
-	echo $html;
489
+    echo $html;
490 490
 }
491 491
 
492 492
 /**
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
  */
495 495
 function wpinv_checkbox_callback( $args ) {
496 496
 
497
-	$std = isset( $args['std'] ) ? $args['std'] : '';
498
-	$std = wpinv_get_option( $args['id'], $std );
499
-	$id  = esc_attr( $args['id'] );
497
+    $std = isset( $args['std'] ) ? $args['std'] : '';
498
+    $std = wpinv_get_option( $args['id'], $std );
499
+    $id  = esc_attr( $args['id'] );
500 500
 
501
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
502
-	?>
501
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
502
+    ?>
503 503
 		<fieldset>
504 504
 			<label>
505 505
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -511,77 +511,77 @@  discard block
 block discarded – undo
511 511
 
512 512
 function wpinv_multicheck_callback( $args ) {
513 513
 	
514
-	global $wpinv_options;
514
+    global $wpinv_options;
515 515
 
516
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
517
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
516
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
517
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518 518
 
519
-	if ( ! empty( $args['options'] ) ) {
519
+    if ( ! empty( $args['options'] ) ) {
520 520
 
521
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
522
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
521
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
522
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523 523
 
524
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
524
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525 525
         foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
528
-				$enabled = $sanitize_key;
529
-			} else { 
530
-				$enabled = NULL; 
531
-			}
532
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
-		endforeach;
535
-		echo '</div>';
536
-		echo '<p class="description">' . $args['desc'] . '</p>';
537
-	}
526
+            $sanitize_key = wpinv_sanitize_key( $key );
527
+            if ( in_array( $sanitize_key, $value ) ) { 
528
+                $enabled = $sanitize_key;
529
+            } else { 
530
+                $enabled = NULL; 
531
+            }
532
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+        endforeach;
535
+        echo '</div>';
536
+        echo '<p class="description">' . $args['desc'] . '</p>';
537
+    }
538 538
 }
539 539
 
540 540
 function wpinv_payment_icons_callback( $args ) {
541
-	global $wpinv_options;
541
+    global $wpinv_options;
542 542
     
543 543
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
545
+    if ( ! empty( $args['options'] ) ) {
546
+        foreach( $args['options'] as $key => $option ) {
547 547
             $sanitize_key = wpinv_sanitize_key( $key );
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
-				$enabled = $option;
551
-			} else {
552
-				$enabled = NULL;
553
-			}
554
-
555
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556
-
557
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
558
-
559
-				if ( wpinv_string_is_image_url( $key ) ) {
560
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
-				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
563
-
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
-					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
-						$content_dir = WP_CONTENT_DIR;
569
-
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
571
-							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
574
-						}
575
-
576
-						$image = str_replace( $content_dir, content_url(), $image );
577
-					}
578
-
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
-				}
581
-			echo $option . '</label>';
582
-		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
-	}
549
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
+                $enabled = $option;
551
+            } else {
552
+                $enabled = NULL;
553
+            }
554
+
555
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556
+
557
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
558
+
559
+                if ( wpinv_string_is_image_url( $key ) ) {
560
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+                } else {
562
+                    $card = strtolower( str_replace( ' ', '', $option ) );
563
+
564
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+                    } else {
567
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
+                        $content_dir = WP_CONTENT_DIR;
569
+
570
+                        if ( function_exists( 'wp_normalize_path' ) ) {
571
+                            // Replaces backslashes with forward slashes for Windows systems
572
+                            $image = wp_normalize_path( $image );
573
+                            $content_dir = wp_normalize_path( $content_dir );
574
+                        }
575
+
576
+                        $image = str_replace( $content_dir, content_url(), $image );
577
+                    }
578
+
579
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
+                }
581
+            echo $option . '</label>';
582
+        }
583
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
+    }
585 585
 }
586 586
 
587 587
 /**
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
  */
590 590
 function wpinv_radio_callback( $args ) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
594
-	?>
592
+    $std = isset( $args['std'] ) ? $args['std'] : '';
593
+    $std = wpinv_get_option( $args['id'], $std );
594
+    ?>
595 595
 		<fieldset>
596 596
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597 597
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			</ul>
606 606
 		</fieldset>
607 607
 	<?php
608
-	getpaid_settings_description_callback( $args );
608
+    getpaid_settings_description_callback( $args );
609 609
 }
610 610
 
611 611
 /**
@@ -613,50 +613,50 @@  discard block
 block discarded – undo
613 613
  */
614 614
 function getpaid_settings_description_callback( $args ) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
618
-		echo "<p class='description'>$description</p>";
619
-	}
616
+    if ( ! empty( $args['desc'] ) ) {
617
+        $description = wp_kses_post( $args['desc'] );
618
+        echo "<p class='description'>$description</p>";
619
+    }
620 620
 
621 621
 }
622 622
 
623 623
 function wpinv_gateways_callback( $args ) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
625
+    $gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626 626
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		$sanitize_key = wpinv_sanitize_key( $key );
628
+    foreach ( $args['options'] as $key => $option ) :
629
+        $sanitize_key = wpinv_sanitize_key( $key );
630 630
         
631 631
         if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
632
-			$enabled = '1';
633
-		else
634
-			$enabled = null;
632
+            $enabled = '1';
633
+        else
634
+            $enabled = null;
635 635
 
636
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
-	endforeach;
636
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
+    endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642
-	global $wpinv_options;
642
+    global $wpinv_options;
643 643
     
644 644
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
645 645
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646 646
 
647
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
647
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
650
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
649
+    foreach ( $args['options'] as $key => $option ) :
650
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651 651
             $selected = selected( $key, $args['selected'], false );
652 652
         } else {
653 653
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
654 654
         }
655
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
656
-	endforeach;
655
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
656
+    endforeach;
657 657
 
658
-	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
658
+    echo '</select>';
659
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
  */
668 668
 function wpinv_settings_attrs_helper( $args ) {
669 669
 
670
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
671
-	$id           = esc_attr( $args['id'] );
672
-	$placeholder  = esc_attr( $args['placeholder'] );
670
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
671
+    $id           = esc_attr( $args['id'] );
672
+    $placeholder  = esc_attr( $args['placeholder'] );
673 673
 
674
-	if ( ! empty( $args['faux'] ) ) {
675
-		$args['readonly'] = true;
676
-		$name             = '';
677
-	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
679
-		$name   = "wpinv_settings[$id]";
680
-	}
674
+    if ( ! empty( $args['faux'] ) ) {
675
+        $args['readonly'] = true;
676
+        $name             = '';
677
+    } else {
678
+        $value  = wpinv_get_option( $args['id'], $value );
679
+        $name   = "wpinv_settings[$id]";
680
+    }
681 681
 
682
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
-	$class    = esc_attr( $args['class'] );
684
-	$style    = esc_attr( $args['style'] );
685
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
682
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
+    $class    = esc_attr( $args['class'] );
684
+    $style    = esc_attr( $args['style'] );
685
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
686 686
 
687
-	$onchange = '';
687
+    $onchange = '';
688 688
     if ( ! empty( $args['onchange'] ) ) {
689 689
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
-	}
690
+    }
691 691
 
692
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
692
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
693 693
 }
694 694
 
695 695
 /**
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
  */
698 698
 function wpinv_text_callback( $args ) {
699 699
 
700
-	$desc = wp_kses_post( $args['desc'] );
701
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
-	$attr = wpinv_settings_attrs_helper( $args );
700
+    $desc = wp_kses_post( $args['desc'] );
701
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
+    $attr = wpinv_settings_attrs_helper( $args );
703 703
 
704
-	?>
704
+    ?>
705 705
 		<label style="width: 100%;">
706 706
 			<input type="text" <?php echo $attr; ?>>
707 707
 			<?php echo $desc; ?>
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
  */
716 716
 function wpinv_number_callback( $args ) {
717 717
 
718
-	$desc = wp_kses_post( $args['desc'] );
719
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
-	$attr = wpinv_settings_attrs_helper( $args );
721
-	$max  = intval( $args['max'] );
722
-	$min  = intval( $args['min'] );
723
-	$step = floatval( $args['step'] );
718
+    $desc = wp_kses_post( $args['desc'] );
719
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
+    $attr = wpinv_settings_attrs_helper( $args );
721
+    $max  = intval( $args['max'] );
722
+    $min  = intval( $args['min'] );
723
+    $step = floatval( $args['step'] );
724 724
 
725
-	?>
725
+    ?>
726 726
 		<label style="width: 100%;">
727 727
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
728 728
 			<?php echo $desc; ?>
@@ -732,48 +732,48 @@  discard block
 block discarded – undo
732 732
 }
733 733
 
734 734
 function wpinv_textarea_callback( $args ) {
735
-	global $wpinv_options;
735
+    global $wpinv_options;
736 736
     
737 737
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
741
-	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
743
-	}
739
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
+        $value = $wpinv_options[ $args['id'] ];
741
+    } else {
742
+        $value = isset( $args['std'] ) ? $args['std'] : '';
743
+    }
744 744
     
745 745
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746 746
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747 747
 
748
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
748
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750 750
 
751
-	echo $html;
751
+    echo $html;
752 752
 }
753 753
 
754 754
 function wpinv_password_callback( $args ) {
755
-	global $wpinv_options;
755
+    global $wpinv_options;
756 756
     
757 757
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
761
-	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
763
-	}
759
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
+        $value = $wpinv_options[ $args['id'] ];
761
+    } else {
762
+        $value = isset( $args['std'] ) ? $args['std'] : '';
763
+    }
764 764
 
765
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
765
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
768 768
 
769
-	echo $html;
769
+    echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773
-	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
-		'<strong>' . $args['id'] . '</strong>'
776
-	);
773
+    printf(
774
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
+        '<strong>' . $args['id'] . '</strong>'
776
+    );
777 777
 }
778 778
 
779 779
 /**
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
  */
782 782
 function wpinv_select_callback( $args ) {
783 783
 
784
-	$desc   = wp_kses_post( $args['desc'] );
785
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
-	$attr   = wpinv_settings_attrs_helper( $args );
787
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value  = wpinv_get_option( $args['id'], $value );
784
+    $desc   = wp_kses_post( $args['desc'] );
785
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
+    $attr   = wpinv_settings_attrs_helper( $args );
787
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
788
+    $value  = wpinv_get_option( $args['id'], $value );
789 789
 
790
-	?>
790
+    ?>
791 791
 		<label style="width: 100%;">
792 792
 			<select <?php echo $attr; ?>>
793 793
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -801,123 +801,123 @@  discard block
 block discarded – undo
801 801
 }
802 802
 
803 803
 function wpinv_color_select_callback( $args ) {
804
-	global $wpinv_options;
804
+    global $wpinv_options;
805 805
     
806 806
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
810
-	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
812
-	}
808
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
+        $value = $wpinv_options[ $args['id'] ];
810
+    } else {
811
+        $value = isset( $args['std'] ) ? $args['std'] : '';
812
+    }
813 813
 
814
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
815 815
 
816
-	foreach ( $args['options'] as $option => $color ) {
817
-		$selected = selected( $option, $value, false );
818
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
819
-	}
816
+    foreach ( $args['options'] as $option => $color ) {
817
+        $selected = selected( $option, $value, false );
818
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
819
+    }
820 820
 
821
-	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
821
+    $html .= '</select>';
822
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823 823
 
824
-	echo $html;
824
+    echo $html;
825 825
 }
826 826
 
827 827
 function wpinv_rich_editor_callback( $args ) {
828
-	global $wpinv_options, $wp_version;
828
+    global $wpinv_options, $wp_version;
829 829
     
830 830
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
831 831
 
832
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
-		$value = $wpinv_options[ $args['id'] ];
832
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
+        $value = $wpinv_options[ $args['id'] ];
834 834
 
835
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
-		}
838
-	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
840
-	}
835
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
+            $value = isset( $args['std'] ) ? $args['std'] : '';
837
+        }
838
+    } else {
839
+        $value = isset( $args['std'] ) ? $args['std'] : '';
840
+    }
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
843 843
 
844
-	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
846
-		ob_start();
847
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
848
-		$html .= ob_get_clean();
849
-	} else {
850
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
-	}
844
+    $html = '<div class="getpaid-settings-editor-input">';
845
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
846
+        ob_start();
847
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
848
+        $html .= ob_get_clean();
849
+    } else {
850
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
+    }
852 852
 
853
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
854 854
 
855
-	echo $html;
855
+    echo $html;
856 856
 }
857 857
 
858 858
 function wpinv_upload_callback( $args ) {
859
-	global $wpinv_options;
859
+    global $wpinv_options;
860 860
     
861 861
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
-		$value = $wpinv_options[$args['id']];
865
-	} else {
866
-		$value = isset($args['std']) ? $args['std'] : '';
867
-	}
863
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
+        $value = $wpinv_options[$args['id']];
865
+    } else {
866
+        $value = isset($args['std']) ? $args['std'] : '';
867
+    }
868 868
 
869
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
869
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
873 873
 
874
-	echo $html;
874
+    echo $html;
875 875
 }
876 876
 
877 877
 function wpinv_color_callback( $args ) {
878
-	global $wpinv_options;
878
+    global $wpinv_options;
879 879
     
880 880
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
884
-	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
886
-	}
882
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
+        $value = $wpinv_options[ $args['id'] ];
884
+    } else {
885
+        $value = isset( $args['std'] ) ? $args['std'] : '';
886
+    }
887 887
 
888
-	$default = isset( $args['std'] ) ? $args['std'] : '';
888
+    $default = isset( $args['std'] ) ? $args['std'] : '';
889 889
 
890
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
890
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892 892
 
893
-	echo $html;
893
+    echo $html;
894 894
 }
895 895
 
896 896
 function wpinv_country_states_callback($args) {
897
-	global $wpinv_options;
897
+    global $wpinv_options;
898 898
     
899 899
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
902
-		$placeholder = $args['placeholder'];
903
-	} else {
904
-		$placeholder = '';
905
-	}
901
+    if ( isset( $args['placeholder'] ) ) {
902
+        $placeholder = $args['placeholder'];
903
+    } else {
904
+        $placeholder = '';
905
+    }
906 906
 
907
-	$states = wpinv_get_country_states();
907
+    $states = wpinv_get_country_states();
908 908
 
909
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
909
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911 911
 
912
-	foreach ( $states as $option => $name ) {
913
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
915
-	}
912
+    foreach ( $states as $option => $name ) {
913
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
915
+    }
916 916
 
917
-	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
917
+    $html .= '</select>';
918
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919 919
 
920
-	echo $html;
920
+    echo $html;
921 921
 }
922 922
 
923 923
 /**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  */
926 926
 function wpinv_tax_rates_callback() {
927 927
 	
928
-	?>
928
+    ?>
929 929
 		</td>
930 930
 	</tr>
931 931
 	<tr class="bsui">
@@ -940,17 +940,17 @@  discard block
 block discarded – undo
940 940
  * Displays a tax rate' edit row.
941 941
  */
942 942
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
943
-	ob_start();
943
+    ob_start();
944 944
 
945
-	$key                      = sanitize_key( $key );
946
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
945
+    $key                      = sanitize_key( $key );
946
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
948 948
 
949
-	if ( $echo ) {
950
-		echo ob_get_clean();
951
-	} else {
952
-		return ob_get_clean(); 
953
-	}
949
+    if ( $echo ) {
950
+        echo ob_get_clean();
951
+    } else {
952
+        return ob_get_clean(); 
953
+    }
954 954
 
955 955
 }
956 956
 
@@ -977,14 +977,14 @@  discard block
 block discarded – undo
977 977
                 </td>
978 978
                 <td>
979 979
 					<a href="<?php
980
-						echo esc_url(
981
-							wp_nonce_url(
982
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
983
-								'getpaid-nonce',
984
-								'getpaid-nonce'
985
-							)
986
-						);
987
-					?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
980
+                        echo esc_url(
981
+                            wp_nonce_url(
982
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
983
+                                'getpaid-nonce',
984
+                                'getpaid-nonce'
985
+                            )
986
+                        );
987
+                    ?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
988 988
                 </td>
989 989
             </tr>
990 990
 			<tr>
@@ -994,14 +994,14 @@  discard block
 block discarded – undo
994 994
                 </td>
995 995
                 <td>
996 996
 					<a href="<?php
997
-						echo esc_url(
998
-							wp_nonce_url(
999
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1000
-								'getpaid-nonce',
1001
-								'getpaid-nonce'
1002
-							)
1003
-						);
1004
-					?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
997
+                        echo esc_url(
998
+                            wp_nonce_url(
999
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1000
+                                'getpaid-nonce',
1001
+                                'getpaid-nonce'
1002
+                            )
1003
+                        );
1004
+                    ?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a>
1005 1005
                 </td>
1006 1006
             </tr>
1007 1007
 			<?php do_action( 'wpinv_tools_row' ); ?>
@@ -1013,19 +1013,19 @@  discard block
 block discarded – undo
1013 1013
 }
1014 1014
 
1015 1015
 function wpinv_descriptive_text_callback( $args ) {
1016
-	echo wp_kses_post( $args['desc'] );
1016
+    echo wp_kses_post( $args['desc'] );
1017 1017
 }
1018 1018
 
1019 1019
 function wpinv_raw_html_callback( $args ) {
1020
-	echo $args['desc'];
1020
+    echo $args['desc'];
1021 1021
 }
1022 1022
 
1023 1023
 function wpinv_hook_callback( $args ) {
1024
-	do_action( 'wpinv_' . $args['id'], $args );
1024
+    do_action( 'wpinv_' . $args['id'], $args );
1025 1025
 }
1026 1026
 
1027 1027
 function wpinv_set_settings_cap() {
1028
-	return wpinv_get_capability();
1028
+    return wpinv_get_capability();
1029 1029
 }
1030 1030
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1031 1031
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -14,75 +14,75 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66 66
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
70
-		do_action( 'getpaid_init_admin_hooks', $this );
67
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
70
+        do_action( 'getpaid_init_admin_hooks', $this );
71 71
 
72 72
     }
73 73
 
74 74
     /**
75
-	 * Register admin scripts
76
-	 *
77
-	 */
78
-	public function enqeue_scripts() {
75
+     * Register admin scripts
76
+     *
77
+     */
78
+    public function enqeue_scripts() {
79 79
         global $current_screen, $pagenow;
80 80
 
81
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
82
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
81
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
82
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
83 83
 
84 84
         if ( ! empty( $current_screen->post_type ) ) {
85
-			$page = $current_screen->post_type;
85
+            $page = $current_screen->post_type;
86 86
         }
87 87
 
88 88
         // General styles.
@@ -105,54 +105,54 @@  discard block
 block discarded – undo
105 105
         }
106 106
 
107 107
         // Payment form scripts.
108
-		if ( 'wpi_payment_form' == $page && $editing ) {
108
+        if ( 'wpi_payment_form' == $page && $editing ) {
109 109
             $this->load_payment_form_scripts();
110 110
         }
111 111
 
112
-		if ( $page == 'wpinv-subscriptions' ) {
113
-			wp_enqueue_script( 'postbox' );
114
-		}
112
+        if ( $page == 'wpinv-subscriptions' ) {
113
+            wp_enqueue_script( 'postbox' );
114
+        }
115 115
 
116 116
     }
117 117
 
118 118
     /**
119
-	 * Returns admin js translations.
120
-	 *
121
-	 */
122
-	protected function get_admin_i18() {
119
+     * Returns admin js translations.
120
+     *
121
+     */
122
+    protected function get_admin_i18() {
123 123
         global $post;
124 124
 
125
-		$date_range = array(
126
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
127
-		);
125
+        $date_range = array(
126
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
127
+        );
128 128
 
129
-		if ( $date_range['period'] == 'custom' ) {
129
+        if ( $date_range['period'] == 'custom' ) {
130 130
 			
131
-			if ( isset( $_GET['from'] ) ) {
132
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
133
-			}
131
+            if ( isset( $_GET['from'] ) ) {
132
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
133
+            }
134 134
 
135
-			if ( isset( $_GET['to'] ) ) {
136
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
137
-			}
135
+            if ( isset( $_GET['to'] ) ) {
136
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
137
+            }
138 138
 
139
-		}
139
+        }
140 140
 
141 141
         $i18n = array(
142 142
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
143 143
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
144
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
145
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
146
-			'rest_root'                 => esc_url_raw( rest_url() ),
147
-			'date_range'                => $date_range,
144
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
145
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
146
+            'rest_root'                 => esc_url_raw( rest_url() ),
147
+            'date_range'                => $date_range,
148 148
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
149 149
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
150 150
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
151 151
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
152 152
             'tax'                       => wpinv_tax_amount(),
153 153
             'discount'                  => 0,
154
-			'currency_symbol'           => wpinv_currency_symbol(),
155
-			'currency'                  => wpinv_get_currency(),
154
+            'currency_symbol'           => wpinv_currency_symbol(),
155
+            'currency'                  => wpinv_get_currency(),
156 156
             'currency_pos'              => wpinv_currency_position(),
157 157
             'thousand_sep'              => wpinv_thousands_separator(),
158 158
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -175,112 +175,112 @@  discard block
 block discarded – undo
175 175
             'searching'                 => __( 'Searching', 'invoicing' ),
176 176
         );
177 177
 
178
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
178
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
179 179
 
180
-			$invoice              = new WPInv_Invoice( $post );
181
-			$i18n['save_invoice'] = sprintf(
182
-				__( 'Save %s', 'invoicing' ),
183
-				ucfirst( $invoice->get_invoice_quote_type() )
184
-			);
180
+            $invoice              = new WPInv_Invoice( $post );
181
+            $i18n['save_invoice'] = sprintf(
182
+                __( 'Save %s', 'invoicing' ),
183
+                ucfirst( $invoice->get_invoice_quote_type() )
184
+            );
185 185
 
186
-			$i18n['invoice_description'] = sprintf(
187
-				__( '%s Description', 'invoicing' ),
188
-				ucfirst( $invoice->get_invoice_quote_type() )
189
-			);
186
+            $i18n['invoice_description'] = sprintf(
187
+                __( '%s Description', 'invoicing' ),
188
+                ucfirst( $invoice->get_invoice_quote_type() )
189
+            );
190 190
 
191
-		}
192
-		return $i18n;
193
-	}
191
+        }
192
+        return $i18n;
193
+    }
194 194
 
195
-	/**
196
-	 * Change the admin footer text on GetPaid admin pages.
197
-	 *
198
-	 * @since  2.0.0
199
-	 * @param  string $footer_text
200
-	 * @return string
201
-	 */
202
-	public function admin_footer_text( $footer_text ) {
203
-		global $current_screen;
195
+    /**
196
+     * Change the admin footer text on GetPaid admin pages.
197
+     *
198
+     * @since  2.0.0
199
+     * @param  string $footer_text
200
+     * @return string
201
+     */
202
+    public function admin_footer_text( $footer_text ) {
203
+        global $current_screen;
204 204
 
205
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
205
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
206 206
 
207 207
         if ( ! empty( $current_screen->post_type ) ) {
208
-			$page = $current_screen->post_type;
208
+            $page = $current_screen->post_type;
209 209
         }
210 210
 
211 211
         // General styles.
212 212
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
213 213
 
214
-			// Change the footer text
215
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
216
-
217
-				$rating_url  = esc_url(
218
-					wp_nonce_url(
219
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
220
-						'getpaid-nonce',
221
-						'getpaid-nonce'
222
-						)
223
-				);
224
-
225
-				$footer_text = sprintf(
226
-					/* translators: %s: five stars */
227
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
228
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
229
-				);
230
-
231
-			} else {
232
-
233
-				$footer_text = sprintf(
234
-					/* translators: %s: GetPaid */
235
-					__( 'Thank you for using %s!', 'invoicing' ),
236
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
237
-				);
238
-
239
-			}
240
-
241
-		}
242
-
243
-		return $footer_text;
244
-	}
245
-
246
-	/**
247
-	 * Redirects to wp.org to rate the plugin.
248
-	 *
249
-	 * @since  2.0.0
250
-	 */
251
-	public function redirect_to_wordpress_rating_page() {
252
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
253
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
254
-		exit;
255
-	}
214
+            // Change the footer text
215
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
216
+
217
+                $rating_url  = esc_url(
218
+                    wp_nonce_url(
219
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
220
+                        'getpaid-nonce',
221
+                        'getpaid-nonce'
222
+                        )
223
+                );
224
+
225
+                $footer_text = sprintf(
226
+                    /* translators: %s: five stars */
227
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
228
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
229
+                );
230
+
231
+            } else {
232
+
233
+                $footer_text = sprintf(
234
+                    /* translators: %s: GetPaid */
235
+                    __( 'Thank you for using %s!', 'invoicing' ),
236
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
237
+                );
238
+
239
+            }
240
+
241
+        }
242
+
243
+        return $footer_text;
244
+    }
256 245
 
257 246
     /**
258
-	 * Loads payment form js.
259
-	 *
260
-	 */
261
-	protected function load_payment_form_scripts() {
247
+     * Redirects to wp.org to rate the plugin.
248
+     *
249
+     * @since  2.0.0
250
+     */
251
+    public function redirect_to_wordpress_rating_page() {
252
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
253
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
254
+        exit;
255
+    }
256
+
257
+    /**
258
+     * Loads payment form js.
259
+     *
260
+     */
261
+    protected function load_payment_form_scripts() {
262 262
         global $post;
263 263
 
264 264
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
265
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
266
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
265
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
266
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
267 267
 
268
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
269
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
268
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
269
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
270 270
 
271
-		wp_localize_script(
271
+        wp_localize_script(
272 272
             'wpinv-admin-payment-form-script',
273 273
             'wpinvPaymentFormAdmin',
274 274
             array(
275
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
276
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
277
-				'currency'      => wpinv_currency_symbol(),
278
-				'position'      => wpinv_currency_position(),
279
-				'decimals'      => (int) wpinv_decimals(),
280
-				'thousands_sep' => wpinv_thousands_separator(),
281
-				'decimals_sep'  => wpinv_decimal_separator(),
282
-				'form_items'    => gepaid_get_form_items( $post->ID ),
283
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
275
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
276
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
277
+                'currency'      => wpinv_currency_symbol(),
278
+                'position'      => wpinv_currency_position(),
279
+                'decimals'      => (int) wpinv_decimals(),
280
+                'thousands_sep' => wpinv_thousands_separator(),
281
+                'decimals_sep'  => wpinv_decimal_separator(),
282
+                'form_items'    => gepaid_get_form_items( $post->ID ),
283
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
284 284
             )
285 285
         );
286 286
 
@@ -289,20 +289,20 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
     /**
292
-	 * Add our classes to admin pages.
292
+     * Add our classes to admin pages.
293 293
      *
294 294
      * @param string $classes
295 295
      * @return string
296
-	 *
297
-	 */
296
+     *
297
+     */
298 298
     public function admin_body_class( $classes ) {
299
-		global $pagenow, $post, $current_screen;
299
+        global $pagenow, $post, $current_screen;
300 300
 
301 301
 
302 302
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
303 303
 
304 304
         if ( ! empty( $current_screen->post_type ) ) {
305
-			$page = $current_screen->post_type;
305
+            $page = $current_screen->post_type;
306 306
         }
307 307
 
308 308
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -311,59 +311,59 @@  discard block
 block discarded – undo
311 311
 
312 312
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
313 313
             $classes .= ' wpinv-cpt wpinv';
314
-		}
314
+        }
315 315
 		
316
-		if ( getpaid_is_invoice_post_type( $page ) ) {
316
+        if ( getpaid_is_invoice_post_type( $page ) ) {
317 317
             $classes .= ' getpaid-is-invoice-cpt';
318 318
         }
319 319
 
320
-		return $classes;
320
+        return $classes;
321 321
     }
322 322
 
323 323
     /**
324
-	 * Maybe show the AyeCode Connect Notice.
325
-	 */
326
-	public function init_ayecode_connect_helper(){
324
+     * Maybe show the AyeCode Connect Notice.
325
+     */
326
+    public function init_ayecode_connect_helper(){
327 327
 
328 328
         new AyeCode_Connect_Helper(
329 329
             array(
330
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
331
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
332
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
333
-				'connect_button'    => __("Connect Site","invoicing"),
334
-				'connecting_button'    => __("Connecting...","invoicing"),
335
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
336
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
330
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
331
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
332
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
333
+                'connect_button'    => __("Connect Site","invoicing"),
334
+                'connecting_button'    => __("Connecting...","invoicing"),
335
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
336
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
337 337
             ),
338 338
             array( 'wpi-addons' )
339 339
         );
340 340
 
341 341
     }
342 342
 
343
-	/**
344
-	 * Redirect users to settings on activation.
345
-	 *
346
-	 * @return void
347
-	 */
348
-	public function activation_redirect() {
343
+    /**
344
+     * Redirect users to settings on activation.
345
+     *
346
+     * @return void
347
+     */
348
+    public function activation_redirect() {
349 349
 
350
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
350
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
351 351
 
352
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
353
-			return;
354
-		}
352
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
353
+            return;
354
+        }
355 355
 
356
-		// Bail if activating from network, or bulk
357
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
358
-			return;
359
-		}
356
+        // Bail if activating from network, or bulk
357
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
358
+            return;
359
+        }
360 360
 
361
-	    update_option( 'wpinv_redirected_to_settings', 1 );
361
+        update_option( 'wpinv_redirected_to_settings', 1 );
362 362
 
363 363
         wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
364 364
         exit;
365 365
 
366
-	}
366
+    }
367 367
 
368 368
     /**
369 369
      * Fires an admin action after verifying that a user can fire them.
@@ -377,242 +377,242 @@  discard block
 block discarded – undo
377 377
 
378 378
     }
379 379
 
380
-	/**
380
+    /**
381 381
      * Sends a payment reminder to a customer.
382
-	 * 
383
-	 * @param array $args
382
+     * 
383
+     * @param array $args
384 384
      */
385 385
     public function send_customer_invoice( $args ) {
386
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
386
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
387 387
 
388
-		if ( $sent ) {
389
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
390
-		} else {
391
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
392
-		}
388
+        if ( $sent ) {
389
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
390
+        } else {
391
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
392
+        }
393 393
 
394
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
395
-		exit;
396
-	}
394
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
395
+        exit;
396
+    }
397 397
 
398
-	/**
398
+    /**
399 399
      * Sends a payment reminder to a customer.
400
-	 * 
401
-	 * @param array $args
400
+     * 
401
+     * @param array $args
402 402
      */
403 403
     public function send_customer_payment_reminder( $args ) {
404
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
404
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
405 405
 
406
-		if ( $sent ) {
407
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
408
-		} else {
409
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
410
-		}
406
+        if ( $sent ) {
407
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
408
+        } else {
409
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
410
+        }
411 411
 
412
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
413
-		exit;
414
-	}
412
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
413
+        exit;
414
+    }
415 415
 
416
-	/**
416
+    /**
417 417
      * Resets tax rates.
418
-	 * 
418
+     * 
419 419
      */
420 420
     public function admin_reset_tax_rates() {
421 421
 
422
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
423
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
424
-		exit;
422
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
423
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
424
+        exit;
425 425
 
426
-	}
426
+    }
427 427
 
428
-	/**
428
+    /**
429 429
      * Resets admin pages.
430
-	 * 
430
+     * 
431 431
      */
432 432
     public function admin_create_missing_pages() {
433
-		$installer = new GetPaid_Installer();
434
-		$installer->create_pages();
435
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
436
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
437
-		exit;
438
-	}
439
-
440
-	/**
433
+        $installer = new GetPaid_Installer();
434
+        $installer->create_pages();
435
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
436
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
437
+        exit;
438
+    }
439
+
440
+    /**
441 441
      * Creates an missing admin tables.
442
-	 * 
442
+     * 
443 443
      */
444 444
     public function admin_create_missing_tables() {
445
-		global $wpdb;
446
-		$installer = new GetPaid_Installer();
445
+        global $wpdb;
446
+        $installer = new GetPaid_Installer();
447 447
 
448
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
449
-			$installer->create_subscriptions_table();
448
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
449
+            $installer->create_subscriptions_table();
450 450
 
451
-			if ( $wpdb->last_error !== '' ) {
452
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
453
-			}
454
-		}
451
+            if ( $wpdb->last_error !== '' ) {
452
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
453
+            }
454
+        }
455 455
 
456
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
457
-			$installer->create_invoices_table();
456
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
457
+            $installer->create_invoices_table();
458 458
 
459
-			if ( $wpdb->last_error !== '' ) {
460
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
461
-			}
462
-		}
459
+            if ( $wpdb->last_error !== '' ) {
460
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
461
+            }
462
+        }
463 463
 
464
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
465
-			$installer->create_invoice_items_table();
464
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
465
+            $installer->create_invoice_items_table();
466 466
 
467
-			if ( $wpdb->last_error !== '' ) {
468
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
469
-			}
470
-		}
467
+            if ( $wpdb->last_error !== '' ) {
468
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
469
+            }
470
+        }
471 471
 
472
-		if ( ! $this->has_notices() ) {
473
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
474
-		}
472
+        if ( ! $this->has_notices() ) {
473
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
474
+        }
475 475
 
476
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
477
-		exit;
478
-	}
476
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
477
+        exit;
478
+    }
479 479
 
480 480
     /**
481
-	 * Returns an array of admin notices.
482
-	 *
483
-	 * @since       1.0.19
481
+     * Returns an array of admin notices.
482
+     *
483
+     * @since       1.0.19
484 484
      * @return array
485
-	 */
486
-	public function get_notices() {
487
-		$notices = get_option( 'wpinv_admin_notices' );
485
+     */
486
+    public function get_notices() {
487
+        $notices = get_option( 'wpinv_admin_notices' );
488 488
         return is_array( $notices ) ? $notices : array();
489
-	}
489
+    }
490 490
 
491
-	/**
492
-	 * Checks if we have any admin notices.
493
-	 *
494
-	 * @since       2.0.4
491
+    /**
492
+     * Checks if we have any admin notices.
493
+     *
494
+     * @since       2.0.4
495 495
      * @return array
496
-	 */
497
-	public function has_notices() {
498
-		return count( $this->get_notices() ) > 0;
499
-	}
500
-
501
-	/**
502
-	 * Clears all admin notices
503
-	 *
504
-	 * @access      public
505
-	 * @since       1.0.19
506
-	 */
507
-	public function clear_notices() {
508
-		delete_option( 'wpinv_admin_notices' );
509
-	}
510
-
511
-	/**
512
-	 * Saves a new admin notice
513
-	 *
514
-	 * @access      public
515
-	 * @since       1.0.19
516
-	 */
517
-	public function save_notice( $type, $message ) {
518
-		$notices = $this->get_notices();
519
-
520
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
521
-			$notices[ $type ] = array();
522
-		}
523
-
524
-		$notices[ $type ][] = $message;
525
-
526
-		update_option( 'wpinv_admin_notices', $notices );
527
-	}
528
-
529
-	/**
530
-	 * Displays a success notice
531
-	 *
532
-	 * @param       string $msg The message to qeue.
533
-	 * @access      public
534
-	 * @since       1.0.19
535
-	 */
536
-	public function show_success( $msg ) {
537
-		$this->save_notice( 'success', $msg );
538
-	}
539
-
540
-	/**
541
-	 * Displays a error notice
542
-	 *
543
-	 * @access      public
544
-	 * @param       string $msg The message to qeue.
545
-	 * @since       1.0.19
546
-	 */
547
-	public function show_error( $msg ) {
548
-		$this->save_notice( 'error', $msg );
549
-	}
550
-
551
-	/**
552
-	 * Displays a warning notice
553
-	 *
554
-	 * @access      public
555
-	 * @param       string $msg The message to qeue.
556
-	 * @since       1.0.19
557
-	 */
558
-	public function show_warning( $msg ) {
559
-		$this->save_notice( 'warning', $msg );
560
-	}
561
-
562
-	/**
563
-	 * Displays a info notice
564
-	 *
565
-	 * @access      public
566
-	 * @param       string $msg The message to qeue.
567
-	 * @since       1.0.19
568
-	 */
569
-	public function show_info( $msg ) {
570
-		$this->save_notice( 'info', $msg );
571
-	}
572
-
573
-	/**
574
-	 * Show notices
575
-	 *
576
-	 * @access      public
577
-	 * @since       1.0.19
578
-	 */
579
-	public function show_notices() {
496
+     */
497
+    public function has_notices() {
498
+        return count( $this->get_notices() ) > 0;
499
+    }
500
+
501
+    /**
502
+     * Clears all admin notices
503
+     *
504
+     * @access      public
505
+     * @since       1.0.19
506
+     */
507
+    public function clear_notices() {
508
+        delete_option( 'wpinv_admin_notices' );
509
+    }
510
+
511
+    /**
512
+     * Saves a new admin notice
513
+     *
514
+     * @access      public
515
+     * @since       1.0.19
516
+     */
517
+    public function save_notice( $type, $message ) {
518
+        $notices = $this->get_notices();
519
+
520
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
521
+            $notices[ $type ] = array();
522
+        }
523
+
524
+        $notices[ $type ][] = $message;
525
+
526
+        update_option( 'wpinv_admin_notices', $notices );
527
+    }
528
+
529
+    /**
530
+     * Displays a success notice
531
+     *
532
+     * @param       string $msg The message to qeue.
533
+     * @access      public
534
+     * @since       1.0.19
535
+     */
536
+    public function show_success( $msg ) {
537
+        $this->save_notice( 'success', $msg );
538
+    }
539
+
540
+    /**
541
+     * Displays a error notice
542
+     *
543
+     * @access      public
544
+     * @param       string $msg The message to qeue.
545
+     * @since       1.0.19
546
+     */
547
+    public function show_error( $msg ) {
548
+        $this->save_notice( 'error', $msg );
549
+    }
550
+
551
+    /**
552
+     * Displays a warning notice
553
+     *
554
+     * @access      public
555
+     * @param       string $msg The message to qeue.
556
+     * @since       1.0.19
557
+     */
558
+    public function show_warning( $msg ) {
559
+        $this->save_notice( 'warning', $msg );
560
+    }
561
+
562
+    /**
563
+     * Displays a info notice
564
+     *
565
+     * @access      public
566
+     * @param       string $msg The message to qeue.
567
+     * @since       1.0.19
568
+     */
569
+    public function show_info( $msg ) {
570
+        $this->save_notice( 'info', $msg );
571
+    }
572
+
573
+    /**
574
+     * Show notices
575
+     *
576
+     * @access      public
577
+     * @since       1.0.19
578
+     */
579
+    public function show_notices() {
580 580
 
581 581
         $notices = $this->get_notices();
582 582
         $this->clear_notices();
583 583
 
584
-		foreach ( $notices as $type => $messages ) {
584
+        foreach ( $notices as $type => $messages ) {
585 585
 
586
-			if ( ! is_array( $messages ) ) {
587
-				continue;
588
-			}
586
+            if ( ! is_array( $messages ) ) {
587
+                continue;
588
+            }
589 589
 
590 590
             $type  = sanitize_key( $type );
591
-			foreach ( $messages as $message ) {
591
+            foreach ( $messages as $message ) {
592 592
                 $message = wp_kses_post( $message );
593
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
593
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
594
+            }
595
+
596
+        }
597
+
598
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
599
+
600
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
601
+                $url     = esc_url(
602
+                    wp_nonce_url(
603
+                        add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
604
+                        'getpaid-nonce',
605
+                        'getpaid-nonce'
606
+                    )
607
+                );
608
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
609
+                $message2 = __( 'Generate Pages', 'invoicing' );
610
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
611
+                break;
594 612
             }
595 613
 
596 614
         }
597 615
 
598
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
599
-
600
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
601
-				$url     = esc_url(
602
-					wp_nonce_url(
603
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
604
-						'getpaid-nonce',
605
-						'getpaid-nonce'
606
-					)
607
-				);
608
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
609
-				$message2 = __( 'Generate Pages', 'invoicing' );
610
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
611
-				break;
612
-			}
613
-
614
-		}
615
-
616
-	}
616
+    }
617 617
 
618 618
 }
Please login to merge, or discard this patch.