Passed
Push — master ( ae5aa5...55fff1 )
by Brian
05:20
created
includes/class-wpinv-cache-helper.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
      * Hook in methods.
15 15
      */
16 16
     public static function init() {
17
-        add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 );
18
-        add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
17
+        add_action('init', array(__CLASS__, 'init_hooks'), 0);
18
+        add_action('admin_notices', array(__CLASS__, 'notices'));
19 19
     }
20 20
 
21 21
     public static function init_hooks() {
22
-        if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) {
23
-            $checkout_page = wpinv_get_option( 'checkout_page', '' );
24
-            $success_page  = wpinv_get_option( 'success_page', '' );
25
-            $failure_page  = wpinv_get_option( 'failure_page', '' );
26
-            $history_page  = wpinv_get_option( 'invoice_history_page', '' );
27
-            $subscr_page   = wpinv_get_option( 'invoice_subscription_page', '' );
28
-            if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) {
22
+        if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) {
23
+            $checkout_page = wpinv_get_option('checkout_page', '');
24
+            $success_page  = wpinv_get_option('success_page', '');
25
+            $failure_page  = wpinv_get_option('failure_page', '');
26
+            $history_page  = wpinv_get_option('invoice_history_page', '');
27
+            $subscr_page   = wpinv_get_option('invoice_subscription_page', '');
28
+            if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) {
29 29
                 return;
30 30
             }
31 31
 
@@ -39,34 +39,34 @@  discard block
 block discarded – undo
39 39
             $page_uris[] = 'p=' . $subscr_page;
40 40
 
41 41
             // Exclude permalinks
42
-            $checkout_page  = get_post( $checkout_page );
43
-            $success_page   = get_post( $success_page );
44
-            $failure_page   = get_post( $failure_page );
45
-            $history_page   = get_post( $history_page );
46
-            $subscr_page    = get_post( $subscr_page );
42
+            $checkout_page  = get_post($checkout_page);
43
+            $success_page   = get_post($success_page);
44
+            $failure_page   = get_post($failure_page);
45
+            $history_page   = get_post($history_page);
46
+            $subscr_page    = get_post($subscr_page);
47 47
 
48
-            if ( ! is_null( $checkout_page ) ) {
48
+            if (!is_null($checkout_page)) {
49 49
                 $page_uris[] = '/' . $checkout_page->post_name;
50 50
             }
51
-            if ( ! is_null( $success_page ) ) {
51
+            if (!is_null($success_page)) {
52 52
                 $page_uris[] = '/' . $success_page->post_name;
53 53
             }
54
-            if ( ! is_null( $failure_page ) ) {
54
+            if (!is_null($failure_page)) {
55 55
                 $page_uris[] = '/' . $failure_page->post_name;
56 56
             }
57
-            if ( ! is_null( $history_page ) ) {
57
+            if (!is_null($history_page)) {
58 58
                 $page_uris[] = '/' . $history_page->post_name;
59 59
             }
60
-            if ( ! is_null( $subscr_page ) ) {
60
+            if (!is_null($subscr_page)) {
61 61
                 $page_uris[] = '/' . $subscr_page->post_name;
62 62
             }
63 63
 
64
-            set_transient( 'wpinv_cache_excluded_uris', $page_uris );
64
+            set_transient('wpinv_cache_excluded_uris', $page_uris);
65 65
         }
66 66
 
67
-        if ( is_array( $page_uris ) ) {
68
-            foreach ( $page_uris as $uri ) {
69
-                if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) {
67
+        if (is_array($page_uris)) {
68
+            foreach ($page_uris as $uri) {
69
+                if (strstr($_SERVER['REQUEST_URI'], $uri)) {
70 70
                     self::nocache();
71 71
                     break;
72 72
                 }
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
      * @access private
80 80
      */
81 81
     private static function nocache() {
82
-        if ( ! defined( 'DONOTCACHEPAGE' ) ) {
83
-            define( 'DONOTCACHEPAGE', true );
82
+        if (!defined('DONOTCACHEPAGE')) {
83
+            define('DONOTCACHEPAGE', true);
84 84
         }
85
-        if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
86
-            define( 'DONOTCACHEOBJECT', true );
85
+        if (!defined('DONOTCACHEOBJECT')) {
86
+            define('DONOTCACHEOBJECT', true);
87 87
         }
88
-        if ( ! defined( 'DONOTCACHEDB' ) ) {
89
-            define( 'DONOTCACHEDB', true );
88
+        if (!defined('DONOTCACHEDB')) {
89
+            define('DONOTCACHEDB', true);
90 90
         }
91 91
         nocache_headers();
92 92
     }
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
      * notices function.
96 96
      */
97 97
     public static function notices() {
98
-        if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
98
+        if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) {
99 99
             return;
100 100
         }
101 101
 
102
-        $config   = w3_instance( 'W3_Config' );
103
-        $enabled  = $config->get_integer( 'dbcache.enabled' );
104
-        $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) );
102
+        $config   = w3_instance('W3_Config');
103
+        $enabled  = $config->get_integer('dbcache.enabled');
104
+        $settings = array_map('trim', $config->get_array('dbcache.reject.sql'));
105 105
 
106
-        if ( $enabled && ! in_array( '_wp_session_', $settings ) ) {
106
+        if ($enabled && !in_array('_wp_session_', $settings)) {
107 107
             ?>
108 108
             <div class="error">
109
-                <p><?php printf( wp_kses_post( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ) ), '<code>_wp_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ); ?></p>
109
+                <p><?php printf(wp_kses_post(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing')), '<code>_wp_session_</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache'))); ?></p>
110 110
             </div>
111 111
             <?php
112 112
         }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 3 patches
Switch Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -508,39 +508,39 @@  discard block
 block discarded – undo
508 508
 
509 509
 								switch ( $key ) {
510 510
 
511
-								case 'total':
512
-										echo '<strong>';
513
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
-										echo '</strong>';
515
-									break;
516
-
517
-								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
-									break;
520
-
521
-								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
-									break;
524
-
525
-								case 'status':
526
-										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
528
-										$status = $payment->get_status_label_html();
529
-										}
530
-
531
-										echo wp_kses_post( $status );
532
-									break;
533
-
534
-								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536
-
537
-										if ( ! is_admin() ) {
538
-										$link = esc_url( $payment->get_view_url() );
539
-										}
540
-
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
-									break;
511
+								    case 'total':
512
+										    echo '<strong>';
513
+										    wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
+										    echo '</strong>';
515
+									    break;
516
+
517
+								    case 'relationship':
518
+										    echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
+									    break;
520
+
521
+								    case 'date':
522
+									    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
+									    break;
524
+
525
+								    case 'status':
526
+										    $status = $payment->get_status_nicename();
527
+										    if ( is_admin() ) {
528
+										    $status = $payment->get_status_label_html();
529
+										    }
530
+
531
+										    echo wp_kses_post( $status );
532
+									    break;
533
+
534
+								    case 'invoice':
535
+										    $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536
+
537
+										    if ( ! is_admin() ) {
538
+										    $link = esc_url( $payment->get_view_url() );
539
+										    }
540
+
541
+										    $invoice = esc_html( $payment->get_number() );
542
+										    echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
+									    break;
544 544
 										}
545 545
 
546 546
 								echo '</td>';
@@ -635,37 +635,37 @@  discard block
 block discarded – undo
635 635
 
636 636
 								switch ( $key ) {
637 637
 
638
-								case 'item_name':
639
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
640
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
638
+								    case 'item_name':
639
+										    $item_name = get_the_title( $subscription_group_item['item_id'] );
640
+										    $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
641 641
 
642
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
643
-										echo esc_html( $item_name );
644
-										} else {
645
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
646
-											}
642
+										    if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
643
+										    echo esc_html( $item_name );
644
+										    } else {
645
+										    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
646
+											    }
647 647
 
648
-									break;
648
+									    break;
649 649
 
650
-								case 'price':
651
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
652
-									break;
650
+								    case 'price':
651
+									    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
652
+									    break;
653 653
 
654
-								case 'tax':
655
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
656
-									break;
654
+								    case 'tax':
655
+									    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
656
+									    break;
657 657
 
658
-								case 'discount':
659
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
660
-									break;
658
+								    case 'discount':
659
+									    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
660
+									    break;
661 661
 
662
-								case 'initial':
663
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
664
-									break;
662
+								    case 'initial':
663
+									    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
664
+									    break;
665 665
 
666
-								case 'recurring':
667
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
668
-									break;
666
+								    case 'recurring':
667
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
668
+									    break;
669 669
 
670 670
 										}
671 671
 
@@ -689,29 +689,29 @@  discard block
 block discarded – undo
689 689
 
690 690
 								switch ( $key ) {
691 691
 
692
-								case 'item_name':
693
-										echo esc_html( $subscription_group_fee['name'] );
694
-									break;
692
+								    case 'item_name':
693
+										    echo esc_html( $subscription_group_fee['name'] );
694
+									    break;
695 695
 
696
-								case 'price':
697
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
698
-									break;
696
+								    case 'price':
697
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
698
+									    break;
699 699
 
700
-								case 'tax':
701
-									echo '&mdash;';
702
-									break;
700
+								    case 'tax':
701
+									    echo '&mdash;';
702
+									    break;
703 703
 
704
-								case 'discount':
705
-										echo '&mdash;';
706
-									break;
704
+								    case 'discount':
705
+										    echo '&mdash;';
706
+									    break;
707 707
 
708
-								case 'initial':
709
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
710
-									break;
708
+								    case 'initial':
709
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
710
+									    break;
711 711
 
712
-								case 'recurring':
713
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
714
-									break;
712
+								    case 'recurring':
713
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
714
+									    break;
715 715
 
716 716
 										}
717 717
 
@@ -816,39 +816,39 @@  discard block
 block discarded – undo
816 816
 
817 817
 								switch ( $key ) {
818 818
 
819
-								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
821
-									break;
822
-
823
-								case 'item':
824
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
-											echo wp_kses_post( implode( ' | ', $markup ) );
826
-									break;
827
-
828
-								case 'renewals':
829
-									$max_bills = $_suscription->get_bill_times();
830
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
-									break;
832
-
833
-								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
-									break;
836
-
837
-								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
-									break;
840
-
841
-								case 'subscription':
842
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
-										printf(
844
-                                            '%1$s#%2$s%3$s',
845
-                                            '<a href="' . esc_url( $url ) . '">',
846
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
-											'</a>'
848
-                                        );
849
-
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
-									break;
819
+								    case 'status':
820
+										    echo wp_kses_post( $_suscription->get_status_label_html() );
821
+									    break;
822
+
823
+								    case 'item':
824
+											    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
825
+											    echo wp_kses_post( implode( ' | ', $markup ) );
826
+									    break;
827
+
828
+								    case 'renewals':
829
+									    $max_bills = $_suscription->get_bill_times();
830
+									    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
831
+									    break;
832
+
833
+								    case 'renewal_date':
834
+										    echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
+									    break;
836
+
837
+								    case 'start_date':
838
+										    echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
+									    break;
840
+
841
+								    case 'subscription':
842
+										    $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
843
+										    printf(
844
+                                                '%1$s#%2$s%3$s',
845
+                                                '<a href="' . esc_url( $url ) . '">',
846
+                                                '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
+											    '</a>'
848
+                                            );
849
+
850
+											    echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
+									    break;
852 852
 
853 853
 										}
854 854
 
Please login to merge, or discard this patch.
Indentation   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-				aui()->alert(
28
+                aui()->alert(
29 29
                     array(
30
-						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-					),
33
-					true
30
+                        'type'    => 'danger',
31
+                        'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                    ),
33
+                    true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+                } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
37 37
 
38
-				// Display a single subscription.
39
-				wpinv_recurring_subscription_details();
40
-				} else {
38
+                // Display a single subscription.
39
+                wpinv_recurring_subscription_details();
40
+                } else {
41 41
 
42
-				// Display a list of available subscriptions.
43
-				getpaid_print_subscriptions_list();
44
-				}
42
+                // Display a list of available subscriptions.
43
+                getpaid_print_subscriptions_list();
44
+                }
45 45
 
46
-			?>
46
+            ?>
47 47
 
48 48
 		</div>
49 49
 	</div>
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function getpaid_print_subscriptions_list() {
62 62
 
63
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
64
-	$subscribers_table->prepare_items();
63
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
64
+    $subscribers_table->prepare_items();
65 65
 
66
-	?>
66
+    ?>
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
@@ -82,42 +82,42 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85
-	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
85
+    // Fetch the subscription.
86
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
87
+    if ( ! $sub->exists() ) {
88 88
 
89
-		aui()->alert(
90
-			array(
91
-				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
93
-			),
94
-			true
95
-		);
89
+        aui()->alert(
90
+            array(
91
+                'type'    => 'danger',
92
+                'content' => __( 'Subscription not found.', 'invoicing' ),
93
+            ),
94
+            true
95
+        );
96 96
 
97
-		return;
98
-	}
97
+        return;
98
+    }
99 99
 
100
-	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
+    // Use metaboxes to display the subscription details.
101
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
103 103
 
104
-	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
104
+    $subscription_id     = $sub->get_id();
105
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
-	}
108
+    if ( 1 < count( $subscription_groups ) ) {
109
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
+    }
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
-	}
112
+    if ( ! empty( $subscription_group ) ) {
113
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
+    }
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
119 119
 
120
-	?>
120
+    ?>
121 121
 
122 122
 		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
123 123
 
@@ -157,49 +157,49 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function getpaid_admin_subscription_details_metabox( $sub ) {
159 159
 
160
-	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
-
164
-	// Prepare subscription detail columns.
165
-	$fields = apply_filters(
166
-		'getpaid_subscription_admin_page_fields',
167
-		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => _n( 'Item', 'Items', $items_count, 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
178
-		)
179
-	);
180
-
181
-	if ( ! $sub->is_active() ) {
182
-
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
185
-		}
186
-
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
189
-		}
190
-	} elseif ( $sub->is_last_renewal() ) {
191
-
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
194
-		}
195
-	}
196
-
197
-	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
200
-	}
201
-
202
-	?>
160
+    // Subscription items.
161
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
+
164
+    // Prepare subscription detail columns.
165
+    $fields = apply_filters(
166
+        'getpaid_subscription_admin_page_fields',
167
+        array(
168
+            'subscription' => __( 'Subscription', 'invoicing' ),
169
+            'customer'     => __( 'Customer', 'invoicing' ),
170
+            'amount'       => __( 'Amount', 'invoicing' ),
171
+            'start_date'   => __( 'Start Date', 'invoicing' ),
172
+            'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
+            'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
+            'item'         => _n( 'Item', 'Items', $items_count, 'invoicing' ),
175
+            'gateway'      => __( 'Payment Method', 'invoicing' ),
176
+            'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
+            'status'       => __( 'Status', 'invoicing' ),
178
+        )
179
+    );
180
+
181
+    if ( ! $sub->is_active() ) {
182
+
183
+        if ( isset( $fields['renews_on'] ) ) {
184
+            unset( $fields['renews_on'] );
185
+        }
186
+
187
+        if ( isset( $fields['gateway'] ) ) {
188
+            unset( $fields['gateway'] );
189
+        }
190
+    } elseif ( $sub->is_last_renewal() ) {
191
+
192
+        if ( isset( $fields['renews_on'] ) ) {
193
+            $fields['renews_on'] = __( 'End Date', 'invoicing' );
194
+        }
195
+    }
196
+
197
+    $profile_id = $sub->get_profile_id();
198
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
+        unset( $fields['profile_id'] );
200
+    }
201
+
202
+    ?>
203 203
 
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+    $username = __( '(Missing User)', 'invoicing' );
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+    $user = get_userdata( $subscription->get_customer_id() );
239
+    if ( $user ) {
240 240
 
241
-		$username = sprintf(
242
-			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
-		);
241
+        $username = sprintf(
242
+            '<a href="user-edit.php?user_id=%s">%s</a>',
243
+            absint( $user->ID ),
244
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
+        );
246 246
 
247
-	}
247
+    }
248 248
 
249
-	echo wp_kses_post( $username );
249
+    echo wp_kses_post( $username );
250 250
 }
251 251
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
252 252
 
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258 258
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
259
+    $amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
+    echo wp_kses_post( "<span>$amount</span>" );
261 261
 }
262 262
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
263 263
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
270 270
 
271
-	printf(
272
-		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
275
-	);
271
+    printf(
272
+        '<a href="%s">#%s</a>',
273
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
+        absint( $subscription->get_id() )
275
+    );
276 276
 
277 277
 }
278 278
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
  */
285 285
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
-		aui()->input(
289
-			array(
290
-				'type'        => 'text',
291
-				'id'          => 'wpinv_subscription_date_created',
292
-				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
294
-				'label_type'  => 'hidden',
295
-				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
-				'no_wrap'     => true,
298
-				'size'        => 'sm',
299
-			),
300
-			true
301
-		);
302
-	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
-	}
287
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
+        aui()->input(
289
+            array(
290
+                'type'        => 'text',
291
+                'id'          => 'wpinv_subscription_date_created',
292
+                'name'        => 'wpinv_subscription_date_created',
293
+                'label'       => __( 'Start Date', 'invoicing' ),
294
+                'label_type'  => 'hidden',
295
+                'placeholder' => 'YYYY-MM-DD',
296
+                'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
+                'no_wrap'     => true,
298
+                'size'        => 'sm',
299
+            ),
300
+            true
301
+        );
302
+    } else {
303
+        echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
+    }
305 305
 
306 306
 }
307 307
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
@@ -313,24 +313,24 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
-		aui()->input(
318
-			array(
319
-				'type'        => 'text',
320
-				'id'          => 'wpinv_subscription_expiration',
321
-				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
323
-				'label_type'  => 'hidden',
324
-				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
-				'no_wrap'     => true,
327
-				'size'        => 'sm',
328
-			),
329
-			true
330
-		);
331
-	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
-	}
316
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
+        aui()->input(
318
+            array(
319
+                'type'        => 'text',
320
+                'id'          => 'wpinv_subscription_expiration',
321
+                'name'        => 'wpinv_subscription_expiration',
322
+                'label'       => __( 'Renews On', 'invoicing' ),
323
+                'label_type'  => 'hidden',
324
+                'placeholder' => 'YYYY-MM-DD',
325
+                'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
+                'no_wrap'     => true,
327
+                'size'        => 'sm',
328
+            ),
329
+            true
330
+        );
331
+    } else {
332
+        echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
+    }
334 334
 }
335 335
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
336 336
 
@@ -341,32 +341,32 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
343 343
 
344
-	$max_bills    = $subscription->get_bill_times();
345
-	$times_billed = (int) $subscription->get_times_billed();
346
-
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
-		aui()->input(
349
-			array(
350
-				'type'             => 'number',
351
-				'id'               => 'wpinv_subscription_max_bill_times',
352
-				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
354
-				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
-				'no_wrap'          => true,
358
-				'size'             => 'sm',
359
-				'input_group_left' => sprintf(
360
-					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
362
-					$times_billed
363
-				),
364
-			),
365
-			true
366
-		);
367
-	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
-	}
344
+    $max_bills    = $subscription->get_bill_times();
345
+    $times_billed = (int) $subscription->get_times_billed();
346
+
347
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
+        aui()->input(
349
+            array(
350
+                'type'             => 'number',
351
+                'id'               => 'wpinv_subscription_max_bill_times',
352
+                'name'             => 'wpinv_subscription_max_bill_times',
353
+                'label'            => __( 'Maximum bill times', 'invoicing' ),
354
+                'label_type'       => 'hidden',
355
+                'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
+                'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
+                'no_wrap'          => true,
358
+                'size'             => 'sm',
359
+                'input_group_left' => sprintf(
360
+                    // translators: %d: Number of times billed
361
+                    __( '%d of', 'invoicing' ),
362
+                    $times_billed
363
+                ),
364
+            ),
365
+            true
366
+        );
367
+    } else {
368
+        echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
+    }
370 370
 }
371 371
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
372 372
 
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
-		return;
384
-	}
381
+    if ( empty( $subscription_group ) ) {
382
+        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
+        return;
384
+    }
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
+    echo wp_kses_post( implode( ' | ', $markup ) );
388 388
 
389 389
 }
390 390
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
398 398
 
399
-	$gateway = $subscription->get_gateway();
399
+    $gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
-	} else {
404
-		echo '&mdash;';
405
-	}
401
+    if ( ! empty( $gateway ) ) {
402
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
+    } else {
404
+        echo '&mdash;';
405
+    }
406 406
 
407 407
 }
408 408
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415 415
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
416
+    echo wp_kses_post( $subscription->get_status_label_html() );
417 417
 }
418 418
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
419 419
 
@@ -424,28 +424,28 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
426 426
 
427
-	$profile_id = $subscription->get_profile_id();
428
-
429
-	aui()->input(
430
-		array(
431
-			'type'              => 'text',
432
-			'id'                => 'wpinv_subscription_profile_id',
433
-			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
435
-			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
438
-			'input_group_right' => '',
439
-			'no_wrap'           => true,
440
-			'size'              => 'sm',
441
-		),
442
-		true
443
-	);
444
-
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
-	}
427
+    $profile_id = $subscription->get_profile_id();
428
+
429
+    aui()->input(
430
+        array(
431
+            'type'              => 'text',
432
+            'id'                => 'wpinv_subscription_profile_id',
433
+            'name'              => 'wpinv_subscription_profile_id',
434
+            'label'             => __( 'Profile Id', 'invoicing' ),
435
+            'label_type'        => 'hidden',
436
+            'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
+            'value'             => esc_attr( $profile_id ),
438
+            'input_group_right' => '',
439
+            'no_wrap'           => true,
440
+            'size'              => 'sm',
441
+        ),
442
+        true
443
+    );
444
+
445
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
+    if ( ! empty( $url ) ) {
447
+        echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
+    }
449 449
 
450 450
 }
451 451
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -457,40 +457,40 @@  discard block
 block discarded – undo
457 457
  */
458 458
 function getpaid_admin_subscription_update_metabox( $subscription ) {
459 459
 
460
-	?>
460
+    ?>
461 461
 	<div class="mt-3">
462 462
 
463 463
 		<?php
464
-			aui()->select(
465
-				array(
466
-					'options'   => getpaid_get_subscription_statuses(),
467
-					'name'      => 'subscription_status',
468
-					'id'        => 'subscription_status_update_select',
469
-					'required'  => true,
470
-					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
-					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
475
-				),
476
-				true
477
-			);
478
-		?>
464
+            aui()->select(
465
+                array(
466
+                    'options'   => getpaid_get_subscription_statuses(),
467
+                    'name'      => 'subscription_status',
468
+                    'id'        => 'subscription_status_update_select',
469
+                    'required'  => true,
470
+                    'no_wrap'   => false,
471
+                    'label'     => __( 'Subscription Status', 'invoicing' ),
472
+                    'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
+                    'select2'   => true,
474
+                    'value'     => $subscription->get_status( 'edit' ),
475
+                ),
476
+                true
477
+            );
478
+        ?>
479 479
 
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
481 481
 
482 482
 		<?php
483
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
483
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
484 484
 
485
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
486
-			$anchor = __( 'Renew Subscription', 'invoicing' );
487
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
485
+            $url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
486
+            $anchor = __( 'Renew Subscription', 'invoicing' );
487
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
488 488
 
489
-			if ( $subscription->is_active() ) {
490
-			echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
491
-			}
489
+            if ( $subscription->is_active() ) {
490
+            echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
491
+            }
492 492
 
493
-	echo '</div></div>';
493
+    echo '</div></div>';
494 494
 }
495 495
 
496 496
 /**
@@ -501,33 +501,33 @@  discard block
 block discarded – undo
501 501
  */
502 502
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
503 503
 
504
-	$columns = apply_filters(
505
-		'getpaid_subscription_related_invoices_columns',
506
-		array(
507
-			'invoice'      => __( 'Invoice', 'invoicing' ),
508
-			'relationship' => __( 'Relationship', 'invoicing' ),
509
-			'date'         => __( 'Date', 'invoicing' ),
510
-			'status'       => __( 'Status', 'invoicing' ),
511
-			'total'        => __( 'Total', 'invoicing' ),
512
-		),
513
-		$subscription
514
-	);
515
-
516
-	// Prepare the invoices.
517
-	$payments = $subscription->get_child_payments( ! is_admin() );
518
-	$parent   = $subscription->get_parent_invoice();
519
-
520
-	if ( $parent->exists() ) {
521
-		$payments = array_merge( array( $parent ), $payments );
522
-	}
523
-
524
-	$table_class = 'w-100 bg-white';
525
-
526
-	if ( ! is_admin() ) {
527
-		$table_class = 'table table-bordered';
528
-	}
529
-
530
-	?>
504
+    $columns = apply_filters(
505
+        'getpaid_subscription_related_invoices_columns',
506
+        array(
507
+            'invoice'      => __( 'Invoice', 'invoicing' ),
508
+            'relationship' => __( 'Relationship', 'invoicing' ),
509
+            'date'         => __( 'Date', 'invoicing' ),
510
+            'status'       => __( 'Status', 'invoicing' ),
511
+            'total'        => __( 'Total', 'invoicing' ),
512
+        ),
513
+        $subscription
514
+    );
515
+
516
+    // Prepare the invoices.
517
+    $payments = $subscription->get_child_payments( ! is_admin() );
518
+    $parent   = $subscription->get_parent_invoice();
519
+
520
+    if ( $parent->exists() ) {
521
+        $payments = array_merge( array( $parent ), $payments );
522
+    }
523
+
524
+    $table_class = 'w-100 bg-white';
525
+
526
+    if ( ! is_admin() ) {
527
+        $table_class = 'table table-bordered';
528
+    }
529
+
530
+    ?>
531 531
 		<div class="m-0" style="overflow: auto;">
532 532
 
533 533
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 				<thead>
536 536
 					<tr>
537 537
 						<?php
538
-							foreach ( $columns as $key => $label ) {
539
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
540
-							}
541
-						?>
538
+                            foreach ( $columns as $key => $label ) {
539
+                            echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
540
+                            }
541
+                        ?>
542 542
 					</tr>
543 543
 				</thead>
544 544
 
@@ -554,72 +554,72 @@  discard block
 block discarded – undo
554 554
 
555 555
 					<?php
556 556
 
557
-						foreach ( $payments as $payment ) :
557
+                        foreach ( $payments as $payment ) :
558 558
 
559
-						// Ensure that we have an invoice.
560
-						$payment = new WPInv_Invoice( $payment );
559
+                        // Ensure that we have an invoice.
560
+                        $payment = new WPInv_Invoice( $payment );
561 561
 
562
-						// Abort if the invoice is invalid...
563
-						if ( ! $payment->exists() ) {
564
-							continue;
565
-							}
562
+                        // Abort if the invoice is invalid...
563
+                        if ( ! $payment->exists() ) {
564
+                            continue;
565
+                            }
566 566
 
567
-						// ... or belongs to a different subscription.
568
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
569
-							continue;
570
-							}
567
+                        // ... or belongs to a different subscription.
568
+                        if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
569
+                            continue;
570
+                            }
571 571
 
572
-						echo '<tr>';
572
+                        echo '<tr>';
573 573
 
574
-						foreach ( array_keys( $columns ) as $key ) {
574
+                        foreach ( array_keys( $columns ) as $key ) {
575 575
 
576
-							echo "<td class='p-2 text-left'>";
576
+                            echo "<td class='p-2 text-left'>";
577 577
 
578
-								switch ( $key ) {
578
+                                switch ( $key ) {
579 579
 
580
-								case 'total':
581
-										echo '<strong>';
582
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
-										echo '</strong>';
584
-									break;
580
+                                case 'total':
581
+                                        echo '<strong>';
582
+                                        wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
+                                        echo '</strong>';
584
+                                    break;
585 585
 
586
-								case 'relationship':
587
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
-									break;
586
+                                case 'relationship':
587
+                                        echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
+                                    break;
589 589
 
590
-								case 'date':
591
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
-									break;
590
+                                case 'date':
591
+                                    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
+                                    break;
593 593
 
594
-								case 'status':
595
-										$status = $payment->get_status_nicename();
596
-										if ( is_admin() ) {
597
-										$status = $payment->get_status_label_html();
598
-										}
594
+                                case 'status':
595
+                                        $status = $payment->get_status_nicename();
596
+                                        if ( is_admin() ) {
597
+                                        $status = $payment->get_status_label_html();
598
+                                        }
599 599
 
600
-										echo wp_kses_post( $status );
601
-									break;
600
+                                        echo wp_kses_post( $status );
601
+                                    break;
602 602
 
603
-								case 'invoice':
604
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
603
+                                case 'invoice':
604
+                                        $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
605 605
 
606
-										if ( ! is_admin() ) {
607
-										$link = esc_url( $payment->get_view_url() );
608
-										}
606
+                                        if ( ! is_admin() ) {
607
+                                        $link = esc_url( $payment->get_view_url() );
608
+                                        }
609 609
 
610
-										$invoice = esc_html( $payment->get_number() );
611
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
612
-									break;
613
-										}
610
+                                        $invoice = esc_html( $payment->get_number() );
611
+                                        echo wp_kses_post( "<a href='$link'>$invoice</a>" );
612
+                                    break;
613
+                                        }
614 614
 
615
-								echo '</td>';
615
+                                echo '</td>';
616 616
 
617
-							}
617
+                            }
618 618
 
619
-						echo '</tr>';
619
+                        echo '</tr>';
620 620
 
621
-						endforeach;
622
-					?>
621
+                        endforeach;
622
+                    ?>
623 623
 
624 624
 				</tbody>
625 625
 
@@ -637,42 +637,42 @@  discard block
 block discarded – undo
637 637
  */
638 638
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
639 639
 
640
-	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
640
+    // Fetch the subscription group.
641
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
-		return;
645
-	}
643
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
+        return;
645
+    }
646 646
 
647
-	// Prepare table columns.
648
-	$columns = apply_filters(
649
-		'getpaid_subscription_item_details_columns',
650
-		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
655
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
657
-		),
658
-		$subscription
659
-	);
647
+    // Prepare table columns.
648
+    $columns = apply_filters(
649
+        'getpaid_subscription_item_details_columns',
650
+        array(
651
+            'item_name' => __( 'Item', 'invoicing' ),
652
+            'price'     => __( 'Price', 'invoicing' ),
653
+            'tax'       => __( 'Tax', 'invoicing' ),
654
+            'discount'  => __( 'Discount', 'invoicing' ),
655
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
656
+            'recurring' => __( 'Subtotal', 'invoicing' ),
657
+        ),
658
+        $subscription
659
+    );
660 660
 
661
-	// Prepare the invoices.
661
+    // Prepare the invoices.
662 662
 
663
-	$invoice = $subscription->get_parent_invoice();
663
+    $invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
667
-	}
665
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
+        unset( $columns['tax'] );
667
+    }
668 668
 
669
-	$table_class = 'w-100 bg-white';
669
+    $table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
672
-		$table_class = 'table table-bordered';
673
-	}
671
+    if ( ! is_admin() ) {
672
+        $table_class = 'table table-bordered';
673
+    }
674 674
 
675
-	?>
675
+    ?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678 678
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
-							}
687
-						?>
684
+                            foreach ( $columns as $key => $label ) {
685
+                            echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
+                            }
687
+                        ?>
688 688
 					</tr>
689 689
 				</thead>
690 690
 
@@ -692,106 +692,106 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+                        foreach ( $subscription_group['items'] as $subscription_group_item ) :
696 696
 
697
-						echo '<tr>';
697
+                        echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+                        foreach ( array_keys( $columns ) as $key ) {
700 700
 
701
-							$class = 'text-left';
701
+                            $class = 'text-left';
702 702
 
703
-							echo "<td class='p-2 text-left'>";
703
+                            echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+                                switch ( $key ) {
706 706
 
707
-								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
707
+                                case 'item_name':
708
+                                        $item_name = get_the_title( $subscription_group_item['item_id'] );
709
+                                        $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
713
-										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
-											}
711
+                                        if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
+                                        echo esc_html( $item_name );
713
+                                        } else {
714
+                                        printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
+                                            }
716 716
 
717
-									break;
717
+                                    break;
718 718
 
719
-								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
-									break;
719
+                                case 'price':
720
+                                    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
+                                    break;
722 722
 
723
-								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
-									break;
723
+                                case 'tax':
724
+                                    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
+                                    break;
726 726
 
727
-								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
-									break;
727
+                                case 'discount':
728
+                                    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
+                                    break;
730 730
 
731
-								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
-									break;
731
+                                case 'initial':
732
+                                    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
+                                    break;
734 734
 
735
-								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
-									break;
735
+                                case 'recurring':
736
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
+                                    break;
738 738
 
739
-										}
739
+                                        }
740 740
 
741
-								echo '</td>';
741
+                                echo '</td>';
742 742
 
743
-							}
743
+                            }
744 744
 
745
-						echo '</tr>';
745
+                        echo '</tr>';
746 746
 
747
-						endforeach;
747
+                        endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+                        foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
750 750
 
751
-						echo '<tr>';
751
+                        echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+                        foreach ( array_keys( $columns ) as $key ) {
754 754
 
755
-							$class = 'text-left';
755
+                            $class = 'text-left';
756 756
 
757
-							echo "<td class='p-2 text-left'>";
757
+                            echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+                                switch ( $key ) {
760 760
 
761
-								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
763
-									break;
761
+                                case 'item_name':
762
+                                        echo esc_html( $subscription_group_fee['name'] );
763
+                                    break;
764 764
 
765
-								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
-									break;
765
+                                case 'price':
766
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
+                                    break;
768 768
 
769
-								case 'tax':
770
-									echo '&mdash;';
771
-									break;
769
+                                case 'tax':
770
+                                    echo '&mdash;';
771
+                                    break;
772 772
 
773
-								case 'discount':
774
-										echo '&mdash;';
775
-									break;
773
+                                case 'discount':
774
+                                        echo '&mdash;';
775
+                                    break;
776 776
 
777
-								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
-									break;
777
+                                case 'initial':
778
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
+                                    break;
780 780
 
781
-								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
-									break;
781
+                                case 'recurring':
782
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
+                                    break;
784 784
 
785
-										}
785
+                                        }
786 786
 
787
-								echo '</td>';
787
+                                echo '</td>';
788 788
 
789
-							}
789
+                            }
790 790
 
791
-						echo '</tr>';
791
+                        echo '</tr>';
792 792
 
793
-						endforeach;
794
-					?>
793
+                        endforeach;
794
+                    ?>
795 795
 
796 796
 				</tbody>
797 797
 
@@ -810,38 +810,38 @@  discard block
 block discarded – undo
810 810
  */
811 811
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
812 812
 
813
-	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
-
816
-	if ( empty( $subscription_groups ) ) {
817
-		return;
818
-	}
819
-
820
-	// Prepare table columns.
821
-	$columns = apply_filters(
822
-		'getpaid_subscription_related_subscriptions_columns',
823
-		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
830
-		),
831
-		$subscription
832
-	);
833
-
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
836
-	}
837
-
838
-	$table_class = 'w-100 bg-white';
839
-
840
-	if ( ! is_admin() ) {
841
-		$table_class = 'table table-bordered';
842
-	}
843
-
844
-	?>
813
+    // Fetch the subscription groups.
814
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
+
816
+    if ( empty( $subscription_groups ) ) {
817
+        return;
818
+    }
819
+
820
+    // Prepare table columns.
821
+    $columns = apply_filters(
822
+        'getpaid_subscription_related_subscriptions_columns',
823
+        array(
824
+            'subscription' => __( 'Subscription', 'invoicing' ),
825
+            'start_date'   => __( 'Start Date', 'invoicing' ),
826
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
+            'renewals'     => __( 'Payments', 'invoicing' ),
828
+            'item'         => __( 'Items', 'invoicing' ),
829
+            'status'       => __( 'Status', 'invoicing' ),
830
+        ),
831
+        $subscription
832
+    );
833
+
834
+    if ( $subscription->get_status() == 'pending' ) {
835
+        unset( $columns['start_date'], $columns['renewal_date'] );
836
+    }
837
+
838
+    $table_class = 'w-100 bg-white';
839
+
840
+    if ( ! is_admin() ) {
841
+        $table_class = 'table table-bordered';
842
+    }
843
+
844
+    ?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847 847
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
-							}
856
-						?>
853
+                            foreach ( $columns as $key => $label ) {
854
+                            echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
+                            }
856
+                        ?>
857 857
 					</tr>
858 858
 				</thead>
859 859
 
@@ -861,74 +861,74 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+                        foreach ( $subscription_groups as $subscription_group ) :
865 865
 
866
-						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
-							continue;
869
-							}
866
+                        // Do not list current subscription.
867
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
+                            continue;
869
+                            }
870 870
 
871
-						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
871
+                        // Ensure the subscription exists.
872
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
873 873
 
874
-						if ( ! $_suscription->exists() ) {
875
-							continue;
876
-							}
874
+                        if ( ! $_suscription->exists() ) {
875
+                            continue;
876
+                            }
877 877
 
878
-						echo '<tr>';
878
+                        echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+                        foreach ( array_keys( $columns ) as $key ) {
881 881
 
882
-							$class = 'text-left';
882
+                            $class = 'text-left';
883 883
 
884
-							echo "<td class='p-2 text-left'>";
884
+                            echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+                                switch ( $key ) {
887 887
 
888
-								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
890
-									break;
888
+                                case 'status':
889
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
890
+                                    break;
891 891
 
892
-								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
895
-									break;
892
+                                case 'item':
893
+                                            $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
+                                            echo wp_kses_post( implode( ' | ', $markup ) );
895
+                                    break;
896 896
 
897
-								case 'renewals':
898
-									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
-									break;
897
+                                case 'renewals':
898
+                                    $max_bills = $_suscription->get_bill_times();
899
+                                    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
+                                    break;
901 901
 
902
-								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
-									break;
902
+                                case 'renewal_date':
903
+                                        echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
+                                    break;
905 905
 
906
-								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
-									break;
906
+                                case 'start_date':
907
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
+                                    break;
909 909
 
910
-								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
-										printf(
910
+                                case 'subscription':
911
+                                        $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
+                                        printf(
913 913
                                             '%1$s#%2$s%3$s',
914 914
                                             '<a href="' . esc_url( $url ) . '">',
915 915
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
916
-											'</a>'
916
+                                            '</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
-									break;
919
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
+                                    break;
921 921
 
922
-										}
922
+                                        }
923 923
 
924
-								echo '</td>';
924
+                                echo '</td>';
925 925
 
926
-							}
926
+                            }
927 927
 
928
-						echo '</tr>';
928
+                        echo '</tr>';
929 929
 
930
-						endforeach;
931
-					?>
930
+                        endforeach;
931
+                    ?>
932 932
 
933 933
 				</tbody>
934 934
 
Please login to merge, or discard this patch.
Spacing   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 				aui()->alert(
29 29
                     array(
30 30
 						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+						'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 					),
33 33
 					true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+				} elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) {
37 37
 
38 38
 				// Display a single subscription.
39 39
 				wpinv_recurring_subscription_details();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
70
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
70
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
71 71
 		<?php $subscribers_table->display(); ?>
72 72
 	</form>
73 73
 	<?php
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85 85
 	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
86
+	$sub = new WPInv_Subscription((int) $_GET['id']);
87
+	if (!$sub->exists()) {
88 88
 
89 89
 		aui()->alert(
90 90
 			array(
91 91
 				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
+				'content' => __('Subscription not found.', 'invoicing'),
93 93
 			),
94 94
 			true
95 95
 		);
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
102
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
103 103
 
104 104
 	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
106
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+	if (1 < count($subscription_groups)) {
109
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
110 110
 	}
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+	if (!empty($subscription_group)) {
113
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
114 114
 	}
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
119 119
 
120 120
 	?>
121 121
 
122
-		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
122
+		<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>">
123 123
 
124
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
125
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
126
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
124
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
125
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
126
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
127 127
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
128 128
 			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
129 129
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
132 132
 
133 133
 					<div id="postbox-container-1" class="postbox-container">
134
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
134
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
135 135
 					</div>
136 136
 
137 137
 					<div id="postbox-container-2" class="postbox-container">
138
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
139
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
138
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
139
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
140 140
 					</div>
141 141
 
142 142
 				</div>
@@ -155,48 +155,48 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * @param WPInv_Subscription $sub
157 157
  */
158
-function getpaid_admin_subscription_details_metabox( $sub ) {
158
+function getpaid_admin_subscription_details_metabox($sub) {
159 159
 
160 160
 	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
162
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
163 163
 
164 164
 	// Prepare subscription detail columns.
165 165
 	$fields = apply_filters(
166 166
 		'getpaid_subscription_admin_page_fields',
167 167
 		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => _n( 'Item', 'Items', $items_count, 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
168
+			'subscription' => __('Subscription', 'invoicing'),
169
+			'customer'     => __('Customer', 'invoicing'),
170
+			'amount'       => __('Amount', 'invoicing'),
171
+			'start_date'   => __('Start Date', 'invoicing'),
172
+			'renews_on'    => __('Next Payment', 'invoicing'),
173
+			'renewals'     => __('Collected Payments', 'invoicing'),
174
+			'item'         => _n('Item', 'Items', $items_count, 'invoicing'),
175
+			'gateway'      => __('Payment Method', 'invoicing'),
176
+			'profile_id'   => __('Profile ID', 'invoicing'),
177
+			'status'       => __('Status', 'invoicing'),
178 178
 		)
179 179
 	);
180 180
 
181
-	if ( ! $sub->is_active() ) {
181
+	if (!$sub->is_active()) {
182 182
 
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
183
+		if (isset($fields['renews_on'])) {
184
+			unset($fields['renews_on']);
185 185
 		}
186 186
 
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
187
+		if (isset($fields['gateway'])) {
188
+			unset($fields['gateway']);
189 189
 		}
190
-	} elseif ( $sub->is_last_renewal() ) {
190
+	} elseif ($sub->is_last_renewal()) {
191 191
 
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
192
+		if (isset($fields['renews_on'])) {
193
+			$fields['renews_on'] = __('End Date', 'invoicing');
194 194
 		}
195 195
 	}
196 196
 
197 197
 	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
198
+	if (empty($profile_id) && isset($fields['profile_id'])) {
199
+		unset($fields['profile_id']);
200 200
 	}
201 201
 
202 202
 	?>
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
206 206
 
207
-				<?php foreach ( $fields as $key => $label ) : ?>
207
+				<?php foreach ($fields as $key => $label) : ?>
208 208
 
209
-					<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
209
+					<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
210 210
 
211 211
 						<th class="w-25" style="font-weight: 500;">
212
-							<?php echo esc_html( $label ); ?>
212
+							<?php echo esc_html($label); ?>
213 213
 						</th>
214 214
 
215 215
 						<td class="w-75 text-muted">
216
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
216
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
217 217
 						</td>
218 218
 
219 219
 					</tr>
@@ -231,144 +231,144 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @param WPInv_Subscription $subscription
233 233
  */
234
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
234
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+	$username = __('(Missing User)', 'invoicing');
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+	$user = get_userdata($subscription->get_customer_id());
239
+	if ($user) {
240 240
 
241 241
 		$username = sprintf(
242 242
 			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
243
+			absint($user->ID),
244
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
245 245
 		);
246 246
 
247 247
 	}
248 248
 
249
-	echo wp_kses_post( $username );
249
+	echo wp_kses_post($username);
250 250
 }
251
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
251
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
252 252
 
253 253
 /**
254 254
  * Displays the subscription amount.
255 255
  *
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
258
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
259
+	$amount = getpaid_get_formatted_subscription_amount($subscription);
260
+	echo wp_kses_post("<span>$amount</span>");
261 261
 }
262
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
262
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
263 263
 
264 264
 /**
265 265
  * Displays the subscription id.
266 266
  *
267 267
  * @param WPInv_Subscription $subscription
268 268
  */
269
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
269
+function getpaid_admin_subscription_metabox_display_id($subscription) {
270 270
 
271 271
 	printf(
272 272
 		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
273
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
274
+		absint($subscription->get_id())
275 275
 	);
276 276
 
277 277
 }
278
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
278
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
279 279
 
280 280
 /**
281 281
  * Displays the subscription renewal date.
282 282
  *
283 283
  * @param WPInv_Subscription $subscription
284 284
  */
285
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
285
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
287
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
288 288
 		aui()->input(
289 289
 			array(
290 290
 				'type'        => 'text',
291 291
 				'id'          => 'wpinv_subscription_date_created',
292 292
 				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
293
+				'label'       => __('Start Date', 'invoicing'),
294 294
 				'label_type'  => 'hidden',
295 295
 				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
296
+				'value'       => esc_attr($subscription->get_date_created('edit')),
297 297
 				'no_wrap'     => true,
298 298
 				'size'        => 'sm',
299 299
 			),
300 300
 			true
301 301
 		);
302 302
 	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
303
+		echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
304 304
 	}
305 305
 
306 306
 }
307
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
307
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
308 308
 
309 309
 /**
310 310
  * Displays the subscription renewal date.
311 311
  *
312 312
  * @param WPInv_Subscription $subscription
313 313
  */
314
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
314
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
316
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
317 317
 		aui()->input(
318 318
 			array(
319 319
 				'type'        => 'text',
320 320
 				'id'          => 'wpinv_subscription_expiration',
321 321
 				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
322
+				'label'       => __('Renews On', 'invoicing'),
323 323
 				'label_type'  => 'hidden',
324 324
 				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
325
+				'value'       => esc_attr($subscription->get_expiration('edit')),
326 326
 				'no_wrap'     => true,
327 327
 				'size'        => 'sm',
328 328
 			),
329 329
 			true
330 330
 		);
331 331
 	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
332
+		echo esc_html(getpaid_format_date_value($subscription->get_expiration()));
333 333
 	}
334 334
 }
335
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
335
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
336 336
 
337 337
 /**
338 338
  * Displays the subscription renewal count.
339 339
  *
340 340
  * @param WPInv_Subscription $subscription
341 341
  */
342
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
342
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
343 343
 
344 344
 	$max_bills    = $subscription->get_bill_times();
345 345
 	$times_billed = (int) $subscription->get_times_billed();
346 346
 
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
347
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) {
348 348
 		aui()->input(
349 349
 			array(
350 350
 				'type'             => 'number',
351 351
 				'id'               => 'wpinv_subscription_max_bill_times',
352 352
 				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
353
+				'label'            => __('Maximum bill times', 'invoicing'),
354 354
 				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
355
+				'placeholder'      => __('Unlimited', 'invoicing'),
356
+				'value'            => empty($max_bills) ? '' : (int) $max_bills,
357 357
 				'no_wrap'          => true,
358 358
 				'size'             => 'sm',
359 359
 				'input_group_left' => sprintf(
360 360
 					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
361
+					__('%d of', 'invoicing'),
362 362
 					$times_billed
363 363
 				),
364 364
 			),
365 365
 			true
366 366
 		);
367 367
 	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
368
+		echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
369 369
 	}
370 370
 }
371
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
371
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
372 372
 
373 373
 /**
374 374
  * Displays the subscription item.
@@ -376,53 +376,53 @@  discard block
 block discarded – undo
376 376
  * @param WPInv_Subscription $subscription
377 377
  * @param false|array $subscription_group
378 378
  */
379
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
379
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
381
+	if (empty($subscription_group)) {
382
+		echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
383 383
 		return;
384 384
 	}
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
387
+	echo wp_kses_post(implode(' | ', $markup));
388 388
 
389 389
 }
390
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
390
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
391 391
 
392 392
 /**
393 393
  * Displays the subscription gateway.
394 394
  *
395 395
  * @param WPInv_Subscription $subscription
396 396
  */
397
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
397
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
398 398
 
399 399
 	$gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
401
+	if (!empty($gateway)) {
402
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
403 403
 	} else {
404 404
 		echo '&mdash;';
405 405
 	}
406 406
 
407 407
 }
408
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
408
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
409 409
 
410 410
 /**
411 411
  * Displays the subscription status.
412 412
  *
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
415
+function getpaid_admin_subscription_metabox_display_status($subscription) {
416
+	echo wp_kses_post($subscription->get_status_label_html());
417 417
 }
418
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
418
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
419 419
 
420 420
 /**
421 421
  * Displays the subscription profile id.
422 422
  *
423 423
  * @param WPInv_Subscription $subscription
424 424
  */
425
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
425
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
426 426
 
427 427
 	$profile_id = $subscription->get_profile_id();
428 428
 
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 			'type'              => 'text',
432 432
 			'id'                => 'wpinv_subscription_profile_id',
433 433
 			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
434
+			'label'             => __('Profile Id', 'invoicing'),
435 435
 			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
436
+			'placeholder'       => __('Profile Id', 'invoicing'),
437
+			'value'             => esc_attr($profile_id),
438 438
 			'input_group_right' => '',
439 439
 			'no_wrap'           => true,
440 440
 			'size'              => 'sm',
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 		true
443 443
 	);
444 444
 
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
445
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
446
+	if (!empty($url)) {
447
+		echo '&nbsp;<a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448 448
 	}
449 449
 
450 450
 }
451
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
451
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
452 452
 
453 453
 /**
454 454
  * Displays the subscriptions update metabox.
455 455
  *
456 456
  * @param WPInv_Subscription $subscription
457 457
  */
458
-function getpaid_admin_subscription_update_metabox( $subscription ) {
458
+function getpaid_admin_subscription_update_metabox($subscription) {
459 459
 
460 460
 	?>
461 461
 	<div class="mt-3">
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 					'id'        => 'subscription_status_update_select',
469 469
 					'required'  => true,
470 470
 					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
471
+					'label'     => __('Subscription Status', 'invoicing'),
472
+					'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'),
473 473
 					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
474
+					'value'     => $subscription->get_status('edit'),
475 475
 				),
476 476
 				true
477 477
 			);
@@ -480,14 +480,14 @@  discard block
 block discarded – undo
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
481 481
 
482 482
 		<?php
483
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
483
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
484 484
 
485
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
486
-			$anchor = __( 'Renew Subscription', 'invoicing' );
487
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
485
+			$url    = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce');
486
+			$anchor = __('Renew Subscription', 'invoicing');
487
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
488 488
 
489
-			if ( $subscription->is_active() ) {
490
-			echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
489
+			if ($subscription->is_active()) {
490
+			echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>";
491 491
 			}
492 492
 
493 493
 	echo '</div></div>';
@@ -499,44 +499,44 @@  discard block
 block discarded – undo
499 499
  * @param WPInv_Subscription $subscription
500 500
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
501 501
  */
502
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
502
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
503 503
 
504 504
 	$columns = apply_filters(
505 505
 		'getpaid_subscription_related_invoices_columns',
506 506
 		array(
507
-			'invoice'      => __( 'Invoice', 'invoicing' ),
508
-			'relationship' => __( 'Relationship', 'invoicing' ),
509
-			'date'         => __( 'Date', 'invoicing' ),
510
-			'status'       => __( 'Status', 'invoicing' ),
511
-			'total'        => __( 'Total', 'invoicing' ),
507
+			'invoice'      => __('Invoice', 'invoicing'),
508
+			'relationship' => __('Relationship', 'invoicing'),
509
+			'date'         => __('Date', 'invoicing'),
510
+			'status'       => __('Status', 'invoicing'),
511
+			'total'        => __('Total', 'invoicing'),
512 512
 		),
513 513
 		$subscription
514 514
 	);
515 515
 
516 516
 	// Prepare the invoices.
517
-	$payments = $subscription->get_child_payments( ! is_admin() );
517
+	$payments = $subscription->get_child_payments(!is_admin());
518 518
 	$parent   = $subscription->get_parent_invoice();
519 519
 
520
-	if ( $parent->exists() ) {
521
-		$payments = array_merge( array( $parent ), $payments );
520
+	if ($parent->exists()) {
521
+		$payments = array_merge(array($parent), $payments);
522 522
 	}
523 523
 
524 524
 	$table_class = 'w-100 bg-white';
525 525
 
526
-	if ( ! is_admin() ) {
526
+	if (!is_admin()) {
527 527
 		$table_class = 'table table-bordered';
528 528
 	}
529 529
 
530 530
 	?>
531 531
 		<div class="m-0" style="overflow: auto;">
532 532
 
533
-			<table class="<?php echo esc_attr( $table_class ); ?>">
533
+			<table class="<?php echo esc_attr($table_class); ?>">
534 534
 
535 535
 				<thead>
536 536
 					<tr>
537 537
 						<?php
538
-							foreach ( $columns as $key => $label ) {
539
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
538
+							foreach ($columns as $key => $label) {
539
+							echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
540 540
 							}
541 541
 						?>
542 542
 					</tr>
@@ -544,71 +544,71 @@  discard block
 block discarded – undo
544 544
 
545 545
 				<tbody>
546 546
 
547
-					<?php if ( empty( $payments ) ) : ?>
547
+					<?php if (empty($payments)) : ?>
548 548
 						<tr>
549
-							<td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted">
550
-								<?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?>
549
+							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
550
+								<?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?>
551 551
 							</td>
552 552
 						</tr>
553 553
 					<?php endif; ?>
554 554
 
555 555
 					<?php
556 556
 
557
-						foreach ( $payments as $payment ) :
557
+						foreach ($payments as $payment) :
558 558
 
559 559
 						// Ensure that we have an invoice.
560
-						$payment = new WPInv_Invoice( $payment );
560
+						$payment = new WPInv_Invoice($payment);
561 561
 
562 562
 						// Abort if the invoice is invalid...
563
-						if ( ! $payment->exists() ) {
563
+						if (!$payment->exists()) {
564 564
 							continue;
565 565
 							}
566 566
 
567 567
 						// ... or belongs to a different subscription.
568
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
568
+						if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
569 569
 							continue;
570 570
 							}
571 571
 
572 572
 						echo '<tr>';
573 573
 
574
-						foreach ( array_keys( $columns ) as $key ) {
574
+						foreach (array_keys($columns) as $key) {
575 575
 
576 576
 							echo "<td class='p-2 text-left'>";
577 577
 
578
-								switch ( $key ) {
578
+								switch ($key) {
579 579
 
580 580
 								case 'total':
581 581
 										echo '<strong>';
582
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
582
+										wpinv_the_price($payment->get_total(), $payment->get_currency());
583 583
 										echo '</strong>';
584 584
 									break;
585 585
 
586 586
 								case 'relationship':
587
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
587
+										echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing');
588 588
 									break;
589 589
 
590 590
 								case 'date':
591
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
591
+									echo esc_html(getpaid_format_date_value($payment->get_date_created()));
592 592
 									break;
593 593
 
594 594
 								case 'status':
595 595
 										$status = $payment->get_status_nicename();
596
-										if ( is_admin() ) {
596
+										if (is_admin()) {
597 597
 										$status = $payment->get_status_label_html();
598 598
 										}
599 599
 
600
-										echo wp_kses_post( $status );
600
+										echo wp_kses_post($status);
601 601
 									break;
602 602
 
603 603
 								case 'invoice':
604
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
604
+										$link = esc_url(get_edit_post_link($payment->get_id()));
605 605
 
606
-										if ( ! is_admin() ) {
607
-										$link = esc_url( $payment->get_view_url() );
606
+										if (!is_admin()) {
607
+										$link = esc_url($payment->get_view_url());
608 608
 										}
609 609
 
610
-										$invoice = esc_html( $payment->get_number() );
611
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
610
+										$invoice = esc_html($payment->get_number());
611
+										echo wp_kses_post("<a href='$link'>$invoice</a>");
612 612
 									break;
613 613
 										}
614 614
 
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
  *
636 636
  * @param WPInv_Subscription $subscription
637 637
  */
638
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
638
+function getpaid_admin_subscription_item_details_metabox($subscription) {
639 639
 
640 640
 	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
641
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
643
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
644 644
 		return;
645 645
 	}
646 646
 
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
 	$columns = apply_filters(
649 649
 		'getpaid_subscription_item_details_columns',
650 650
 		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
651
+			'item_name' => __('Item', 'invoicing'),
652
+			'price'     => __('Price', 'invoicing'),
653
+			'tax'       => __('Tax', 'invoicing'),
654
+			'discount'  => __('Discount', 'invoicing'),
655 655
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
656
+			'recurring' => __('Subtotal', 'invoicing'),
657 657
 		),
658 658
 		$subscription
659 659
 	);
@@ -662,27 +662,27 @@  discard block
 block discarded – undo
662 662
 
663 663
 	$invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
665
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
666
+		unset($columns['tax']);
667 667
 	}
668 668
 
669 669
 	$table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
671
+	if (!is_admin()) {
672 672
 		$table_class = 'table table-bordered';
673 673
 	}
674 674
 
675 675
 	?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678
-			<table class="<?php echo esc_attr( $table_class ); ?>">
678
+			<table class="<?php echo esc_attr($table_class); ?>">
679 679
 
680 680
 				<thead>
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
684
+							foreach ($columns as $key => $label) {
685
+							echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
686 686
 							}
687 687
 						?>
688 688
 					</tr>
@@ -692,48 +692,48 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+						foreach ($subscription_group['items'] as $subscription_group_item) :
696 696
 
697 697
 						echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+						foreach (array_keys($columns) as $key) {
700 700
 
701 701
 							$class = 'text-left';
702 702
 
703 703
 							echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+								switch ($key) {
706 706
 
707 707
 								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
708
+										$item_name = get_the_title($subscription_group_item['item_id']);
709
+										$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
711
+										if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
712
+										echo esc_html($item_name);
713 713
 										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
714
+										printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
715 715
 											}
716 716
 
717 717
 									break;
718 718
 
719 719
 								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
720
+									wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency());
721 721
 									break;
722 722
 
723 723
 								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
724
+									wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency());
725 725
 									break;
726 726
 
727 727
 								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
728
+									wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency());
729 729
 									break;
730 730
 
731 731
 								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
732
+									wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
733 733
 									break;
734 734
 
735 735
 								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
736
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>');
737 737
 									break;
738 738
 
739 739
 										}
@@ -746,24 +746,24 @@  discard block
 block discarded – undo
746 746
 
747 747
 						endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
750 750
 
751 751
 						echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+						foreach (array_keys($columns) as $key) {
754 754
 
755 755
 							$class = 'text-left';
756 756
 
757 757
 							echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+								switch ($key) {
760 760
 
761 761
 								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
762
+										echo esc_html($subscription_group_fee['name']);
763 763
 									break;
764 764
 
765 765
 								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
766
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
767 767
 									break;
768 768
 
769 769
 								case 'tax':
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 									break;
776 776
 
777 777
 								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
778
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
779 779
 									break;
780 780
 
781 781
 								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
782
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>');
783 783
 									break;
784 784
 
785 785
 										}
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
  * @param WPInv_Subscription $subscription
809 809
  * @param bool $skip_current
810 810
  */
811
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
811
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
812 812
 
813 813
 	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
814
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
815 815
 
816
-	if ( empty( $subscription_groups ) ) {
816
+	if (empty($subscription_groups)) {
817 817
 		return;
818 818
 	}
819 819
 
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 	$columns = apply_filters(
822 822
 		'getpaid_subscription_related_subscriptions_columns',
823 823
 		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
824
+			'subscription' => __('Subscription', 'invoicing'),
825
+			'start_date'   => __('Start Date', 'invoicing'),
826
+			'renewal_date' => __('Next Payment', 'invoicing'),
827
+			'renewals'     => __('Payments', 'invoicing'),
828
+			'item'         => __('Items', 'invoicing'),
829
+			'status'       => __('Status', 'invoicing'),
830 830
 		),
831 831
 		$subscription
832 832
 	);
833 833
 
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
834
+	if ($subscription->get_status() == 'pending') {
835
+		unset($columns['start_date'], $columns['renewal_date']);
836 836
 	}
837 837
 
838 838
 	$table_class = 'w-100 bg-white';
839 839
 
840
-	if ( ! is_admin() ) {
840
+	if (!is_admin()) {
841 841
 		$table_class = 'table table-bordered';
842 842
 	}
843 843
 
844 844
 	?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847
-			<table class="<?php echo esc_attr( $table_class ); ?>">
847
+			<table class="<?php echo esc_attr($table_class); ?>">
848 848
 
849 849
 				<thead>
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
853
+							foreach ($columns as $key => $label) {
854
+							echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
855 855
 							}
856 856
 						?>
857 857
 					</tr>
@@ -861,62 +861,62 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+						foreach ($subscription_groups as $subscription_group) :
865 865
 
866 866
 						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
867
+						if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
868 868
 							continue;
869 869
 							}
870 870
 
871 871
 						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
872
+						$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
873 873
 
874
-						if ( ! $_suscription->exists() ) {
874
+						if (!$_suscription->exists()) {
875 875
 							continue;
876 876
 							}
877 877
 
878 878
 						echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+						foreach (array_keys($columns) as $key) {
881 881
 
882 882
 							$class = 'text-left';
883 883
 
884 884
 							echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+								switch ($key) {
887 887
 
888 888
 								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
889
+										echo wp_kses_post($_suscription->get_status_label_html());
890 890
 									break;
891 891
 
892 892
 								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
893
+											$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
894
+											echo wp_kses_post(implode(' | ', $markup));
895 895
 									break;
896 896
 
897 897
 								case 'renewals':
898 898
 									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
899
+									echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
900 900
 									break;
901 901
 
902 902
 								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
903
+										echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '&mdash;';
904 904
 									break;
905 905
 
906 906
 								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
907
+										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html(getpaid_format_date_value($_suscription->get_date_created()));
908 908
 									break;
909 909
 
910 910
 								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
911
+										$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
912 912
 										printf(
913 913
                                             '%1$s#%2$s%3$s',
914
-                                            '<a href="' . esc_url( $url ) . '">',
915
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
914
+                                            '<a href="' . esc_url($url) . '">',
915
+                                            '<strong>' . intval($_suscription->get_id()) . '</strong>',
916 916
 											'</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
919
+											echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription));
920 920
 									break;
921 921
 
922 922
 										}
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( ! defined( 'WPINC' ) ) {
3
+if (!defined('WPINC')) {
4 4
     exit;
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach ( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 } else {
20
-            echo '<li>' . esc_html__( 'There are no notes yet.', 'invoicing' ) . '</li>';
20
+            echo '<li>' . esc_html__('There are no notes yet.', 'invoicing') . '</li>';
21 21
         }
22 22
 
23 23
         echo '</ul>';
24 24
         ?>
25 25
         <div class="add_note">
26
-            <h4><?php esc_html_e( 'Add note', 'invoicing' ); ?></h4>
26
+            <h4><?php esc_html_e('Add note', 'invoicing'); ?></h4>
27 27
             <p>
28 28
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
29 29
             </p>
30 30
             <p>
31 31
                 <select name="invoice_note_type" id="invoice_note_type" class="regular-text">
32
-                    <option value=""><?php esc_html_e( 'Private note', 'invoicing' ); ?></option>
33
-                    <option value="customer"><?php esc_html_e( 'Note to customer', 'invoicing' ); ?></option>
32
+                    <option value=""><?php esc_html_e('Private note', 'invoicing'); ?></option>
33
+                    <option value="customer"><?php esc_html_e('Note to customer', 'invoicing'); ?></option>
34 34
                 </select>
35
-                <a href="#" class="add_note button"><?php esc_html_e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php esc_html_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
35
+                <a href="#" class="add_note button"><?php esc_html_e('Add', 'invoicing'); ?></a> <span class="description"><?php esc_html_e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
36 36
             </p>
37 37
         </div>
38 38
         <?php
Please login to merge, or discard this patch.
includes/error-functions.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -126,14 +126,14 @@
 block discarded – undo
126 126
  */
127 127
 function getpaid_doing_it_wrong( $function, $message, $version ) {
128 128
 
129
-	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130
-
131
-	if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
132
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
133
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
134
-	} else {
135
-		_doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
136
-	}
129
+    $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130
+
131
+    if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
132
+        do_action( 'doing_it_wrong_run', $function, $message, $version );
133
+        error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
134
+    } else {
135
+        _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
136
+    }
137 137
 
138 138
 }
139 139
 
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Returns the errors as html
@@ -15,35 +15,35 @@  discard block
 block discarded – undo
15 15
  * @param bool $wrap whether or not to wrap the errors.
16 16
  * @since  1.0.19
17 17
  */
18
-function getpaid_get_errors_html( $clear = true, $wrap = true ) {
18
+function getpaid_get_errors_html($clear = true, $wrap = true) {
19 19
 
20 20
     $errors = '';
21
-    foreach ( wpinv_get_errors() as $id => $error ) {
22
-        $type     = 'error';
21
+    foreach (wpinv_get_errors() as $id => $error) {
22
+        $type = 'error';
23 23
 
24
-        if ( is_array( $error ) ) {
24
+        if (is_array($error)) {
25 25
             $type  = $error['type'];
26 26
             $error = $error['text'];
27 27
         }
28 28
 
29
-        if ( $wrap ) {
29
+        if ($wrap) {
30 30
 
31 31
             $errors .= aui()->alert(
32 32
                 array(
33
-                    'content' => wp_kses_post( $error ),
33
+                    'content' => wp_kses_post($error),
34 34
                     'type'    => $type,
35 35
                 )
36 36
             );
37 37
 
38 38
         } else {
39 39
 
40
-            $id      = esc_attr( $id );
41
-            $error   = wp_kses_post( $error );
40
+            $id      = esc_attr($id);
41
+            $error   = wp_kses_post($error);
42 42
             $errors .= "<div data-code='$id'>$error</div>";
43 43
         }
44 44
     }
45 45
 
46
-    if ( $clear ) {
46
+    if ($clear) {
47 47
         wpinv_clear_errors();
48 48
     }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  * Prints (then clears) all available errors.
56 56
  */
57 57
 function wpinv_print_errors() {
58
-    echo wp_kses_post( getpaid_get_errors_html() );
58
+    echo wp_kses_post(getpaid_get_errors_html());
59 59
 }
60 60
 
61 61
 /**
@@ -69,54 +69,54 @@  discard block
 block discarded – undo
69 69
     $all_errors = array(
70 70
         'perm_cancel_subscription'   => array(
71 71
             'type' => 'error',
72
-            'text' => __( 'You do not have permission to cancel this subscription', 'invoicing' ),
72
+            'text' => __('You do not have permission to cancel this subscription', 'invoicing'),
73 73
         ),
74 74
         'cannot_cancel_subscription' => array(
75 75
             'type' => 'error',
76
-            'text' => __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ),
76
+            'text' => __('This subscription cannot be cancelled as it is not active.', 'invoicing'),
77 77
         ),
78 78
         'cancelled_subscription'     => array(
79 79
             'type' => 'success',
80
-            'text' => __( 'Subscription cancelled successfully.', 'invoicing' ),
80
+            'text' => __('Subscription cancelled successfully.', 'invoicing'),
81 81
         ),
82 82
         'address_updated'            => array(
83 83
             'type' => 'success',
84
-            'text' => __( 'Address updated successfully.', 'invoicing' ),
84
+            'text' => __('Address updated successfully.', 'invoicing'),
85 85
         ),
86 86
         'perm_delete_invoice'        => array(
87 87
             'type' => 'error',
88
-            'text' => __( 'You do not have permission to delete this invoice', 'invoicing' ),
88
+            'text' => __('You do not have permission to delete this invoice', 'invoicing'),
89 89
         ),
90 90
         'cannot_delete_invoice'      => array(
91 91
             'type' => 'error',
92
-            'text' => __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ),
92
+            'text' => __('This invoice cannot be deleted as it has already been paid.', 'invoicing'),
93 93
         ),
94 94
         'deleted_invoice'            => array(
95 95
             'type' => 'success',
96
-            'text' => __( 'Invoice deleted successfully.', 'invoicing' ),
96
+            'text' => __('Invoice deleted successfully.', 'invoicing'),
97 97
         ),
98 98
         'card_declined'              => array(
99 99
             'type' => 'error',
100
-            'text' => __( 'Your card was declined.', 'invoicing' ),
100
+            'text' => __('Your card was declined.', 'invoicing'),
101 101
         ),
102 102
         'invalid_currency'           => array(
103 103
             'type' => 'error',
104
-            'text' => __( 'The chosen payment gateway does not support this currency.', 'invoicing' ),
104
+            'text' => __('The chosen payment gateway does not support this currency.', 'invoicing'),
105 105
         ),
106 106
     );
107 107
 
108
-    $errors = apply_filters( 'wpinv_errors', array() );
108
+    $errors = apply_filters('wpinv_errors', array());
109 109
 
110
-    if ( isset( $_GET['wpinv-notice'] ) && isset( $all_errors[ $_GET['wpinv-notice'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
111
-        $errors[ $_GET['wpinv-notice'] ] = $all_errors[ $_GET['wpinv-notice'] ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
110
+    if (isset($_GET['wpinv-notice']) && isset($all_errors[$_GET['wpinv-notice']])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
111
+        $errors[$_GET['wpinv-notice']] = $all_errors[$_GET['wpinv-notice']]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
112 112
     }
113 113
 
114
-    if ( isset( $GLOBALS['wpinv_notice'] ) && isset( $all_errors[ $GLOBALS['wpinv_notice'] ] ) ) {
115
-        $errors[ $GLOBALS['wpinv_notice'] ] = $all_errors[ $GLOBALS['wpinv_notice'] ];
114
+    if (isset($GLOBALS['wpinv_notice']) && isset($all_errors[$GLOBALS['wpinv_notice']])) {
115
+        $errors[$GLOBALS['wpinv_notice']] = $all_errors[$GLOBALS['wpinv_notice']];
116 116
     }
117 117
 
118
-    if ( isset( $GLOBALS['wpinv_custom_notice'] ) ) {
119
-        $errors[ $GLOBALS['wpinv_custom_notice']['code'] ] = $GLOBALS['wpinv_custom_notice'];
118
+    if (isset($GLOBALS['wpinv_custom_notice'])) {
119
+        $errors[$GLOBALS['wpinv_custom_notice']['code']] = $GLOBALS['wpinv_custom_notice'];
120 120
     }
121 121
 
122 122
     return $errors;
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
  * @param string $error The error message.
130 130
  * @param string $type The error type.
131 131
  */
132
-function wpinv_set_error( $error_id, $message = '', $type = 'error' ) {
132
+function wpinv_set_error($error_id, $message = '', $type = 'error') {
133 133
 
134
-    if ( ! empty( $message ) ) {
134
+    if (!empty($message)) {
135 135
         $GLOBALS['wpinv_custom_notice'] = array(
136 136
             'code' => $error_id,
137 137
             'type' => $type,
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
  *
148 148
  */
149 149
 function wpinv_has_errors() {
150
-    return count( wpinv_get_errors() ) > 0;
150
+    return count(wpinv_get_errors()) > 0;
151 151
 }
152 152
 
153 153
 /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  */
157 157
 function wpinv_clear_errors() {
158
-    unset( $GLOBALS['wpinv_notice'] );
158
+    unset($GLOBALS['wpinv_notice']);
159 159
 }
160 160
 
161 161
 /**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
  *
164 164
  */
165 165
 function wpinv_unset_error() {
166
-    unset( $GLOBALS['wpinv_notice'] );
166
+    unset($GLOBALS['wpinv_notice']);
167 167
 }
168 168
 
169 169
 /**
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
  * @param string $message Message to log.
175 175
  * @param string $version Version the message was added in.
176 176
  */
177
-function getpaid_doing_it_wrong( $function, $message, $version ) {
177
+function getpaid_doing_it_wrong($function, $message, $version) {
178 178
 
179 179
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
180 180
 
181
-	if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
182
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
183
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
181
+	if (wp_doing_ajax() || defined('REST_REQUEST')) {
182
+		do_action('doing_it_wrong_run', $function, $message, $version);
183
+		error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
184 184
 	} else {
185
-		_doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
185
+		_doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version));
186 186
 	}
187 187
 
188 188
 }
@@ -196,41 +196,41 @@  discard block
 block discarded – undo
196 196
  * @param string $line The line that contains the error.
197 197
  * @param bool $exit Whether or not to exit function execution.
198 198
  */
199
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
199
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
200 200
 
201
-    if ( true === apply_filters( 'wpinv_log_errors', true ) ) {
201
+    if (true === apply_filters('wpinv_log_errors', true)) {
202 202
 
203 203
         // Ensure the log is a scalar.
204
-        if ( ! is_scalar( $log ) ) {
205
-            $log = print_r( $log, true );
204
+        if (!is_scalar($log)) {
205
+            $log = print_r($log, true);
206 206
         }
207 207
 
208 208
         // Add title.
209
-        if ( ! empty( $title ) ) {
210
-            $log  = $title . ' ' . trim( $log );
209
+        if (!empty($title)) {
210
+            $log = $title . ' ' . trim($log);
211 211
         }
212 212
 
213 213
         // Add the file to the label.
214
-        if ( ! empty( $file ) ) {
214
+        if (!empty($file)) {
215 215
             $log .= ' in ' . $file;
216 216
         }
217 217
 
218 218
         // Add the line number to the label.
219
-        if ( ! empty( $line ) ) {
219
+        if (!empty($line)) {
220 220
             $log .= ' on line ' . $line;
221 221
         }
222 222
 
223 223
         // Log the message.
224
-        error_log( trim( $log ) );
224
+        error_log(trim($log));
225 225
 
226 226
         // ... and a backtrace.
227
-        if ( false !== $title && false !== $file ) {
228
-            error_log( 'Backtrace ' . wp_debug_backtrace_summary() );
227
+        if (false !== $title && false !== $file) {
228
+            error_log('Backtrace ' . wp_debug_backtrace_summary());
229 229
         }
230 230
 }
231 231
 
232 232
     // Maybe exit.
233
-    if ( $exit ) {
233
+    if ($exit) {
234 234
         exit;
235 235
     }
236 236
 
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+                    foreach ( $tabs as $key => $label ) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+                echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,46 +50,46 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+				echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>");
76 76
 
77 77
 					}
78 78
 				?>
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-graph-downloader.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -12,218 +12,218 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Reports_Report
17
-	 */
18
-	public $handler;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 */
24
-	public function __construct() {
25
-		$this->handler = new GetPaid_Reports_Report();
26
-	}
27
-
28
-	/**
29
-	 * Prepares the datastore handler.
30
-	 *
31
-	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
-	 */
33
-	public function prepare_handler( $graph ) {
34
-
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
37
-		}
38
-
39
-		return new $this->handler->views[ $graph ]['class']();
40
-
41
-	}
42
-
43
-	/**
44
-	 * Prepares the output stream.
45
-	 *
46
-	 * @return resource
47
-	 */
48
-	public function prepare_output() {
49
-
50
-		$output  = fopen( 'php://output', 'w' );
51
-
52
-		if ( false === $output ) {
53
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
54
-		}
55
-
56
-		return $output;
57
-	}
58
-
59
-	/**
60
-	 * Prepares the file type.
61
-	 *
62
-	 * @return string
63
-	 */
64
-	public function prepare_file_type( $graph ) {
65
-
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
-
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
-
72
-		return $file_type;
73
-	}
74
-
75
-	/**
76
-	 * Handles the actual download.
77
-	 *
78
-	 */
79
-	public function download( $graph ) {
80
-		global $wpdb;
81
-
82
-		$handler   = $this->prepare_handler( $graph );
83
-		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} elseif ( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
92
-		} else {
93
-			$this->download_json( $stats, $stream, $headers );
94
-		}
95
-
96
-		fclose( $stream );
97
-		exit;
98
-	}
99
-
100
-	/**
101
-	 * Downloads graph as csv
102
-	 *
103
-	 * @param array $stats The stats being downloaded.
104
-	 * @param resource $stream The stream to output to.
105
-	 * @param array $headers The fields to stream.
106
-	 * @since       1.0.19
107
-	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
109
-
110
-		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
112
-
113
-		// Loop through
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
118
-		}
119
-
120
-	}
121
-
122
-	/**
123
-	 * Downloads graph as json
124
-	 *
125
-	 * @param array $stats The stats being downloaded.
126
-	 * @param resource $stream The stream to output to.
127
-	 * @param array $headers The fields to stream.
128
-	 * @since       1.0.19
129
-	 */
130
-	public function download_json( $stats, $stream, $headers ) {
131
-
132
-		$prepared = array();
133
-
134
-		// Loop through
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
137
-		}
138
-
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
140
-
141
-	}
142
-
143
-	/**
144
-	 * Downloads graph as xml
145
-	 *
146
-	 * @param array $stats The stats being downloaded.
147
-	 * @param resource $stream The stream to output to.
148
-	 * @param array $headers The fields to stream.
149
-	 * @since       1.0.19
150
-	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
152
-
153
-		$prepared = array();
154
-
155
-		// Loop through
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
158
-		}
159
-
160
-		$xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
-		$this->convert_array_xml( $prepared, $xml );
162
-
163
-		fwrite( $stream, $xml->asXML() );
164
-
165
-	}
166
-
167
-	/**
168
-	 * Converts stats array to xml
169
-	 *
170
-	 * @access      public
171
-	 * @since      1.0.19
172
-	 */
173
-	public function convert_array_xml( $data, $xml ) {
174
-
175
-		// Loop through
176
-		foreach ( $data as $key => $value ) {
177
-
178
-			$key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
179
-
180
-			if ( is_array( $value ) ) {
181
-
182
-				if ( is_numeric( $key ) ) {
183
-					$key = 'item' . $key; //dealing with <0/>..<n/> issues
184
-				}
185
-
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
188
-
189
-			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
191
-			}
15
+    /**
16
+     * @var GetPaid_Reports_Report
17
+     */
18
+    public $handler;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     */
24
+    public function __construct() {
25
+        $this->handler = new GetPaid_Reports_Report();
26
+    }
27
+
28
+    /**
29
+     * Prepares the datastore handler.
30
+     *
31
+     * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
+     */
33
+    public function prepare_handler( $graph ) {
34
+
35
+        if ( empty( $this->handler->views[ $graph ] ) ) {
36
+            wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
37
+        }
38
+
39
+        return new $this->handler->views[ $graph ]['class']();
40
+
41
+    }
42
+
43
+    /**
44
+     * Prepares the output stream.
45
+     *
46
+     * @return resource
47
+     */
48
+    public function prepare_output() {
49
+
50
+        $output  = fopen( 'php://output', 'w' );
51
+
52
+        if ( false === $output ) {
53
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
54
+        }
55
+
56
+        return $output;
57
+    }
58
+
59
+    /**
60
+     * Prepares the file type.
61
+     *
62
+     * @return string
63
+     */
64
+    public function prepare_file_type( $graph ) {
65
+
66
+        $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
+        $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
+
69
+        header( "Content-Type:application/$file_type" );
70
+        header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
+
72
+        return $file_type;
73
+    }
74
+
75
+    /**
76
+     * Handles the actual download.
77
+     *
78
+     */
79
+    public function download( $graph ) {
80
+        global $wpdb;
81
+
82
+        $handler   = $this->prepare_handler( $graph );
83
+        $stream    = $this->prepare_output();
84
+        $stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
+        $headers   = array( $handler->field, 'total', 'total_raw' );
86
+        $file_type = $this->prepare_file_type( $graph );
87
+
88
+        if ( 'csv' == $file_type ) {
89
+            $this->download_csv( $stats, $stream, $headers );
90
+        } elseif ( 'xml' == $file_type ) {
91
+            $this->download_xml( $stats, $stream, $headers );
92
+        } else {
93
+            $this->download_json( $stats, $stream, $headers );
94
+        }
95
+
96
+        fclose( $stream );
97
+        exit;
98
+    }
99
+
100
+    /**
101
+     * Downloads graph as csv
102
+     *
103
+     * @param array $stats The stats being downloaded.
104
+     * @param resource $stream The stream to output to.
105
+     * @param array $headers The fields to stream.
106
+     * @since       1.0.19
107
+     */
108
+    public function download_csv( $stats, $stream, $headers ) {
109
+
110
+        // Output the csv column headers.
111
+        fputcsv( $stream, $headers );
112
+
113
+        // Loop through
114
+        foreach ( $stats as $stat ) {
115
+            $row  = array_values( $this->prepare_row( $stat, $headers ) );
116
+            $row  = array_map( 'maybe_serialize', $row );
117
+            fputcsv( $stream, $row );
118
+        }
119
+
120
+    }
121
+
122
+    /**
123
+     * Downloads graph as json
124
+     *
125
+     * @param array $stats The stats being downloaded.
126
+     * @param resource $stream The stream to output to.
127
+     * @param array $headers The fields to stream.
128
+     * @since       1.0.19
129
+     */
130
+    public function download_json( $stats, $stream, $headers ) {
131
+
132
+        $prepared = array();
133
+
134
+        // Loop through
135
+        foreach ( $stats as $stat ) {
136
+            $prepared[] = $this->prepare_row( $stat, $headers );
137
+        }
138
+
139
+        fwrite( $stream, wp_json_encode( $prepared ) );
140
+
141
+    }
142
+
143
+    /**
144
+     * Downloads graph as xml
145
+     *
146
+     * @param array $stats The stats being downloaded.
147
+     * @param resource $stream The stream to output to.
148
+     * @param array $headers The fields to stream.
149
+     * @since       1.0.19
150
+     */
151
+    public function download_xml( $stats, $stream, $headers ) {
152
+
153
+        $prepared = array();
154
+
155
+        // Loop through
156
+        foreach ( $stats as $stat ) {
157
+            $prepared[] = $this->prepare_row( $stat, $headers );
158
+        }
159
+
160
+        $xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
+        $this->convert_array_xml( $prepared, $xml );
162
+
163
+        fwrite( $stream, $xml->asXML() );
164
+
165
+    }
166
+
167
+    /**
168
+     * Converts stats array to xml
169
+     *
170
+     * @access      public
171
+     * @since      1.0.19
172
+     */
173
+    public function convert_array_xml( $data, $xml ) {
174
+
175
+        // Loop through
176
+        foreach ( $data as $key => $value ) {
177
+
178
+            $key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
179
+
180
+            if ( is_array( $value ) ) {
181
+
182
+                if ( is_numeric( $key ) ) {
183
+                    $key = 'item' . $key; //dealing with <0/>..<n/> issues
184
+                }
185
+
186
+                $subnode = $xml->addChild( $key );
187
+                $this->convert_array_xml( $value, $subnode );
188
+
189
+            } else {
190
+                $xml->addChild( $key, htmlspecialchars( $value ) );
191
+            }
192 192
 }
193 193
 
194
-	}
194
+    }
195 195
 
196
-	/**
197
-	 * Prepares a single row for download.
198
-	 *
199
-	 * @param stdClass|array $row The row to prepare..
200
-	 * @param array $fields The fields to stream.
201
-	 * @since       1.0.19
202
-	 * @return array
203
-	 */
204
-	public function prepare_row( $row, $fields ) {
196
+    /**
197
+     * Prepares a single row for download.
198
+     *
199
+     * @param stdClass|array $row The row to prepare..
200
+     * @param array $fields The fields to stream.
201
+     * @since       1.0.19
202
+     * @return array
203
+     */
204
+    public function prepare_row( $row, $fields ) {
205 205
 
206
-		$prepared = array();
207
-		$row      = (array) $row;
206
+        $prepared = array();
207
+        $row      = (array) $row;
208 208
 
209
-		foreach ( $fields as $field ) {
209
+        foreach ( $fields as $field ) {
210 210
 
211
-			if ( $field === 'total' ) {
212
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
213
-				continue;
214
-			}
211
+            if ( $field === 'total' ) {
212
+                $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
213
+                continue;
214
+            }
215 215
 
216
-			if ( $field === 'total_raw' ) {
217
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
218
-				continue;
219
-			}
216
+            if ( $field === 'total_raw' ) {
217
+                $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
218
+                continue;
219
+            }
220 220
 
221
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
221
+            $prepared[ $field ] = strip_tags( $row[ $field ] );
222 222
 
223
-		}
223
+        }
224 224
 
225
-		return $prepared;
226
-	}
225
+        return $prepared;
226
+    }
227 227
 
228 228
 
229 229
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Graph_Downloader Class.
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32 32
 	 */
33
-	public function prepare_handler( $graph ) {
33
+	public function prepare_handler($graph) {
34 34
 
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 );
35
+		if (empty($this->handler->views[$graph])) {
36
+			wp_die(esc_html__('Invalid Graph', 'invoicing'), 400);
37 37
 		}
38 38
 
39
-		return new $this->handler->views[ $graph ]['class']();
39
+		return new $this->handler->views[$graph]['class']();
40 40
 
41 41
 	}
42 42
 
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function prepare_output() {
49 49
 
50
-		$output  = fopen( 'php://output', 'w' );
50
+		$output = fopen('php://output', 'w');
51 51
 
52
-		if ( false === $output ) {
53
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
52
+		if (false === $output) {
53
+			wp_die(esc_html__('Unsupported server', 'invoicing'), 500);
54 54
 		}
55 55
 
56 56
 		return $output;
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return string
63 63
 	 */
64
-	public function prepare_file_type( $graph ) {
64
+	public function prepare_file_type($graph) {
65 65
 
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
66
+		$file_type = empty($_REQUEST['file_type']) ? 'csv' : sanitize_text_field($_REQUEST['file_type']);
67
+		$file_name = wpinv_sanitize_key("getpaid-$graph-" . current_time('Y-m-d'));
68 68
 
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
69
+		header("Content-Type:application/$file_type");
70
+		header("Content-Disposition:attachment;filename=$file_name.$file_type");
71 71
 
72 72
 		return $file_type;
73 73
 	}
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
 	 * Handles the actual download.
77 77
 	 *
78 78
 	 */
79
-	public function download( $graph ) {
79
+	public function download($graph) {
80 80
 		global $wpdb;
81 81
 
82
-		$handler   = $this->prepare_handler( $graph );
82
+		$handler   = $this->prepare_handler($graph);
83 83
 		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} elseif ( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
84
+		$stats     = $wpdb->get_results($handler->get_sql($handler->get_range()));
85
+		$headers   = array($handler->field, 'total', 'total_raw');
86
+		$file_type = $this->prepare_file_type($graph);
87
+
88
+		if ('csv' == $file_type) {
89
+			$this->download_csv($stats, $stream, $headers);
90
+		} elseif ('xml' == $file_type) {
91
+			$this->download_xml($stats, $stream, $headers);
92 92
 		} else {
93
-			$this->download_json( $stats, $stream, $headers );
93
+			$this->download_json($stats, $stream, $headers);
94 94
 		}
95 95
 
96
-		fclose( $stream );
96
+		fclose($stream);
97 97
 		exit;
98 98
 	}
99 99
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	 * @param array $headers The fields to stream.
106 106
 	 * @since       1.0.19
107 107
 	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
108
+	public function download_csv($stats, $stream, $headers) {
109 109
 
110 110
 		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
111
+		fputcsv($stream, $headers);
112 112
 
113 113
 		// Loop through
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
114
+		foreach ($stats as $stat) {
115
+			$row  = array_values($this->prepare_row($stat, $headers));
116
+			$row  = array_map('maybe_serialize', $row);
117
+			fputcsv($stream, $row);
118 118
 		}
119 119
 
120 120
 	}
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	 * @param array $headers The fields to stream.
128 128
 	 * @since       1.0.19
129 129
 	 */
130
-	public function download_json( $stats, $stream, $headers ) {
130
+	public function download_json($stats, $stream, $headers) {
131 131
 
132 132
 		$prepared = array();
133 133
 
134 134
 		// Loop through
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
135
+		foreach ($stats as $stat) {
136
+			$prepared[] = $this->prepare_row($stat, $headers);
137 137
 		}
138 138
 
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
139
+		fwrite($stream, wp_json_encode($prepared));
140 140
 
141 141
 	}
142 142
 
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 	 * @param array $headers The fields to stream.
149 149
 	 * @since       1.0.19
150 150
 	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
151
+	public function download_xml($stats, $stream, $headers) {
152 152
 
153 153
 		$prepared = array();
154 154
 
155 155
 		// Loop through
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
156
+		foreach ($stats as $stat) {
157
+			$prepared[] = $this->prepare_row($stat, $headers);
158 158
 		}
159 159
 
160
-		$xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' );
161
-		$this->convert_array_xml( $prepared, $xml );
160
+		$xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
161
+		$this->convert_array_xml($prepared, $xml);
162 162
 
163
-		fwrite( $stream, $xml->asXML() );
163
+		fwrite($stream, $xml->asXML());
164 164
 
165 165
 	}
166 166
 
@@ -170,24 +170,24 @@  discard block
 block discarded – undo
170 170
 	 * @access      public
171 171
 	 * @since      1.0.19
172 172
 	 */
173
-	public function convert_array_xml( $data, $xml ) {
173
+	public function convert_array_xml($data, $xml) {
174 174
 
175 175
 		// Loop through
176
-		foreach ( $data as $key => $value ) {
176
+		foreach ($data as $key => $value) {
177 177
 
178
-			$key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key );
178
+			$key = preg_replace('/[^A-Za-z0-9_\-]/', '', $key);
179 179
 
180
-			if ( is_array( $value ) ) {
180
+			if (is_array($value)) {
181 181
 
182
-				if ( is_numeric( $key ) ) {
182
+				if (is_numeric($key)) {
183 183
 					$key = 'item' . $key; //dealing with <0/>..<n/> issues
184 184
 				}
185 185
 
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
186
+				$subnode = $xml->addChild($key);
187
+				$this->convert_array_xml($value, $subnode);
188 188
 
189 189
 			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
190
+				$xml->addChild($key, htmlspecialchars($value));
191 191
 			}
192 192
 }
193 193
 
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
 	 * @since       1.0.19
202 202
 	 * @return array
203 203
 	 */
204
-	public function prepare_row( $row, $fields ) {
204
+	public function prepare_row($row, $fields) {
205 205
 
206 206
 		$prepared = array();
207 207
 		$row      = (array) $row;
208 208
 
209
-		foreach ( $fields as $field ) {
209
+		foreach ($fields as $field) {
210 210
 
211
-			if ( $field === 'total' ) {
212
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
211
+			if ($field === 'total') {
212
+				$prepared[$field] = html_entity_decode(strip_tags(wpinv_price($row['total'])), ENT_QUOTES);
213 213
 				continue;
214 214
 			}
215 215
 
216
-			if ( $field === 'total_raw' ) {
217
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
216
+			if ($field === 'total_raw') {
217
+				$prepared[$field] = wpinv_round_amount(wpinv_sanitize_amount($row['total']));
218 218
 				continue;
219 219
 			}
220 220
 
221
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
221
+			$prepared[$field] = strip_tags($row[$field]);
222 222
 
223 223
 		}
224 224
 
Please login to merge, or discard this patch.
templates/invoice-history.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -42,92 +42,92 @@  discard block
 block discarded – undo
42 42
 					<tr class="wpinv-item wpinv-item-<?php echo esc_attr( $invoice->get_status() ); ?>">
43 43
 						<?php
44 44
 
45
-							foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
45
+                            foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
46 46
 
47
-							$column_id = sanitize_html_class( $column_id );
48
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47
+                            $column_id = sanitize_html_class( $column_id );
48
+                            $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
49 49
 
50
-							echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>";
51
-							switch ( $column_id ) {
50
+                            echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>";
51
+                            switch ( $column_id ) {
52 52
 
53
-								case 'invoice-number':
54
-									echo wp_kses_post( wpinv_invoice_link( $invoice ) );
55
-									break;
53
+                                case 'invoice-number':
54
+                                    echo wp_kses_post( wpinv_invoice_link( $invoice ) );
55
+                                    break;
56 56
 
57
-								case 'created-date':
58
-									echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) );
59
-									break;
57
+                                case 'created-date':
58
+                                    echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) );
59
+                                    break;
60 60
 
61
-								case 'payment-date':
62
-									if ( $invoice->needs_payment() ) {
63
-										echo '&mdash;';
64
-										} else {
65
-										echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) );
66
-										}
61
+                                case 'payment-date':
62
+                                    if ( $invoice->needs_payment() ) {
63
+                                        echo '&mdash;';
64
+                                        } else {
65
+                                        echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) );
66
+                                        }
67 67
 
68
-									break;
68
+                                    break;
69 69
 
70
-								case 'invoice-status':
71
-									echo wp_kses_post( $invoice->get_status_label_html() );
70
+                                case 'invoice-status':
71
+                                    echo wp_kses_post( $invoice->get_status_label_html() );
72 72
 
73
-									break;
73
+                                    break;
74 74
 
75
-								case 'invoice-total':
76
-									wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
75
+                                case 'invoice-total':
76
+                                    wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
77 77
 
78
-									break;
78
+                                    break;
79 79
 
80
-								case 'invoice-actions':
81
-									$actions = array(
80
+                                case 'invoice-actions':
81
+                                    $actions = array(
82 82
 
83
-										'pay'   => array(
84
-											'url'   => $invoice->get_checkout_payment_url(),
85
-											'name'  => __( 'Pay Now', 'invoicing' ),
86
-											'class' => 'btn-success',
87
-										),
83
+                                        'pay'   => array(
84
+                                            'url'   => $invoice->get_checkout_payment_url(),
85
+                                            'name'  => __( 'Pay Now', 'invoicing' ),
86
+                                            'class' => 'btn-success',
87
+                                        ),
88 88
 
89
-										'print' => array(
90
-											'url'   => $invoice->get_view_url(),
91
-											'name'  => __( 'View', 'invoicing' ),
92
-											'class' => 'btn-secondary',
93
-											'attrs' => 'target="_blank"',
94
-										),
95
-									);
89
+                                        'print' => array(
90
+                                            'url'   => $invoice->get_view_url(),
91
+                                            'name'  => __( 'View', 'invoicing' ),
92
+                                            'class' => 'btn-secondary',
93
+                                            'attrs' => 'target="_blank"',
94
+                                        ),
95
+                                    );
96 96
 
97
-									if ( ! $invoice->needs_payment() ) {
98
-										unset( $actions['pay'] );
99
-										}
97
+                                    if ( ! $invoice->needs_payment() ) {
98
+                                        unset( $actions['pay'] );
99
+                                        }
100 100
 
101
-									if ( $invoice->needs_payment() ) {
102
-										$actions['delete'] = array(
103
-											'url'   => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ),
104
-											'name'  => __( 'Delete', 'invoicing' ),
105
-											'class' => 'btn-danger',
106
-										);
107
-										}
101
+                                    if ( $invoice->needs_payment() ) {
102
+                                        $actions['delete'] = array(
103
+                                            'url'   => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ),
104
+                                            'name'  => __( 'Delete', 'invoicing' ),
105
+                                            'class' => 'btn-danger',
106
+                                        );
107
+                                        }
108 108
 
109
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
109
+                                    $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
110 110
 
111
-									foreach ( $actions as $key => $action ) {
112
-										$class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : '';
113
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>';
114
-										}
111
+                                    foreach ( $actions as $key => $action ) {
112
+                                        $class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : '';
113
+                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>';
114
+                                        }
115 115
 
116
-									break;
116
+                                    break;
117 117
 
118
-								default:
119
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
120
-									break;
118
+                                default:
119
+                                    do_action( "wpinv_user_invoices_column_$column_id", $invoice );
120
+                                    break;
121 121
 
122 122
 
123
-								}
123
+                                }
124 124
 
125
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
125
+                            do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
126 126
 
127
-							echo '</td>';
127
+                            echo '</td>';
128 128
 
129
-							endforeach;
130
-						?>
129
+                            endforeach;
130
+                        ?>
131 131
 					</tr>
132 132
 
133 133
 				<?php endforeach; ?>
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
142 142
 		<div class="invoicing-Pagination">
143 143
 			<?php
144
-			$big = 999999;
145
-
146
-			echo wp_kses_post(
147
-				paginate_links(
148
-					array(
149
-						'base'   => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
150
-						'format' => '?paged=%#%',
151
-						'total'  => $invoices->max_num_pages,
152
-					)
153
-				)
144
+            $big = 999999;
145
+
146
+            echo wp_kses_post(
147
+                paginate_links(
148
+                    array(
149
+                        'base'   => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
150
+                        'format' => '?paged=%#%',
151
+                        'total'  => $invoices->max_num_pages,
152
+                    )
153
+                )
154 154
             );
155
-			?>
155
+            ?>
156 156
 		</div>
157 157
 	<?php endif; ?>
158 158
 
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Current page.
13
-$current_page   = empty( $_GET['page'] ) ? 1 : absint( $_GET['page'] );
13
+$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']);
14 14
 
15 15
 // Fires before displaying user invoices.
16
-do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type );
16
+do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type);
17 17
 
18 18
 wpinv_print_errors();
19 19
 
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 
22 22
 
23 23
 	<div class="table-responsive">
24
-		<table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr( $post_type ); ?>">
24
+		<table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr($post_type); ?>">
25 25
 
26 26
 
27 27
 			<thead>
28 28
 				<tr>
29 29
 
30
-					<?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?>
31
-						<th class="<?php echo esc_attr( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : ''); ?> border-bottom-0">
32
-							<span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span>
30
+					<?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?>
31
+						<th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0">
32
+							<span class="nobr"><?php echo esc_html($column_name['title']); ?></span>
33 33
 						</th>
34 34
 					<?php endforeach; ?>
35 35
 
@@ -39,43 +39,43 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 			<tbody>
42
-				<?php foreach ( $invoices->invoices as $invoice ) : ?>
42
+				<?php foreach ($invoices->invoices as $invoice) : ?>
43 43
 
44
-					<tr class="wpinv-item wpinv-item-<?php echo esc_attr( $invoice->get_status() ); ?>">
44
+					<tr class="wpinv-item wpinv-item-<?php echo esc_attr($invoice->get_status()); ?>">
45 45
 						<?php
46 46
 
47
-							foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) :
47
+							foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) :
48 48
 
49
-							$column_id = sanitize_html_class( $column_id );
50
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
49
+							$column_id = sanitize_html_class($column_id);
50
+							$class     = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']);
51 51
 
52
-							echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>";
53
-							switch ( $column_id ) {
52
+							echo "<td class='" . esc_attr($column_id . ' ' . $class) . "'>";
53
+							switch ($column_id) {
54 54
 
55 55
 								case 'invoice-number':
56
-									echo wp_kses_post( wpinv_invoice_link( $invoice ) );
56
+									echo wp_kses_post(wpinv_invoice_link($invoice));
57 57
 									break;
58 58
 
59 59
 								case 'created-date':
60
-									echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) );
60
+									echo esc_html(getpaid_format_date_value($invoice->get_date_created()));
61 61
 									break;
62 62
 
63 63
 								case 'payment-date':
64
-									if ( $invoice->needs_payment() ) {
64
+									if ($invoice->needs_payment()) {
65 65
 										echo '&mdash;';
66 66
 										} else {
67
-										echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) );
67
+										echo esc_html(getpaid_format_date_value($invoice->get_date_completed()));
68 68
 										}
69 69
 
70 70
 									break;
71 71
 
72 72
 								case 'invoice-status':
73
-									echo wp_kses_post( $invoice->get_status_label_html() );
73
+									echo wp_kses_post($invoice->get_status_label_html());
74 74
 
75 75
 									break;
76 76
 
77 77
 								case 'invoice-total':
78
-									wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
78
+									wpinv_the_price($invoice->get_total(), $invoice->get_currency());
79 79
 
80 80
 									break;
81 81
 
@@ -84,47 +84,47 @@  discard block
 block discarded – undo
84 84
 
85 85
 										'pay'   => array(
86 86
 											'url'   => $invoice->get_checkout_payment_url(),
87
-											'name'  => __( 'Pay Now', 'invoicing' ),
87
+											'name'  => __('Pay Now', 'invoicing'),
88 88
 											'class' => 'btn-success',
89 89
 										),
90 90
 
91 91
 										'print' => array(
92 92
 											'url'   => $invoice->get_view_url(),
93
-											'name'  => __( 'View', 'invoicing' ),
93
+											'name'  => __('View', 'invoicing'),
94 94
 											'class' => 'btn-secondary',
95 95
 											'attrs' => 'target="_blank"',
96 96
 										),
97 97
 									);
98 98
 
99
-									if ( ! $invoice->needs_payment() ) {
100
-										unset( $actions['pay'] );
99
+									if (!$invoice->needs_payment()) {
100
+										unset($actions['pay']);
101 101
 										}
102 102
 
103
-									if ( $invoice->needs_payment() ) {
103
+									if ($invoice->needs_payment()) {
104 104
 										$actions['delete'] = array(
105
-											'url'   => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ),
106
-											'name'  => __( 'Delete', 'invoicing' ),
105
+											'url'   => getpaid_get_authenticated_action_url('delete_invoice', add_query_arg('invoice_id', $invoice->get_id())),
106
+											'name'  => __('Delete', 'invoicing'),
107 107
 											'class' => 'btn-danger',
108 108
 										);
109 109
 										}
110 110
 
111
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type );
111
+									$actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type);
112 112
 
113
-									foreach ( $actions as $key => $action ) {
114
-										$class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : '';
115
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>';
113
+									foreach ($actions as $key => $action) {
114
+										$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
115
+										echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . esc_attr($class . ' ' . sanitize_html_class($key)) . '" ' . (!empty($action['attrs']) ? esc_html($action['attrs']) : '') . '>' . esc_attr($action['name']) . '</a>';
116 116
 										}
117 117
 
118 118
 									break;
119 119
 
120 120
 								default:
121
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
121
+									do_action("wpinv_user_invoices_column_$column_id", $invoice);
122 122
 									break;
123 123
 
124 124
 
125 125
 								}
126 126
 
127
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
127
+							do_action("wpinv_user_invoices_column_after_$column_id", $invoice);
128 128
 
129 129
 							echo '</td>';
130 130
 
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 		</table>
139 139
 	</div>
140 140
 
141
-	<?php do_action( 'wpinv_before_user_invoices_pagination' ); ?>
141
+	<?php do_action('wpinv_before_user_invoices_pagination'); ?>
142 142
 
143
-	<?php if ( 1 < $invoices->max_num_pages ) : ?>
143
+	<?php if (1 < $invoices->max_num_pages) : ?>
144 144
 		<div class="invoicing-Pagination">
145 145
 			<?php
146 146
 			$big = 999999;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			echo wp_kses_post(
149 149
 				paginate_links(
150 150
 					array(
151
-						'base'   => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
151
+						'base'   => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
152 152
 						'format' => '?paged=%#%',
153 153
 						'total'  => $invoices->max_num_pages,
154 154
 					)
@@ -158,4 +158,4 @@  discard block
 block discarded – undo
158 158
 		</div>
159 159
 	<?php endif; ?>
160 160
 
161
-<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); ?>
161
+<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?>
Please login to merge, or discard this patch.
templates/emails/invoice-details.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,45 +8,45 @@  discard block
 block discarded – undo
8 8
  * @var WPInv_Invoice $invoice
9 9
  * @var array $columns
10 10
  */
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$meta_data = getpaid_get_invoice_meta( $invoice );
13
+$meta_data = getpaid_get_invoice_meta($invoice);
14 14
 
15
-if ( isset( $meta_data['status'] ) ) {
15
+if (isset($meta_data['status'])) {
16 16
     $meta_data['status']['value'] = $invoice->get_status_nicename();
17 17
 }
18 18
 
19
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin );
19
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin);
20 20
 
21 21
 ?>
22 22
 
23 23
 <div id="wpinv-email-details">
24 24
 
25 25
     <h3 class="invoice-details-title">
26
-        <?php echo sprintf( esc_html__( '%s Details', 'invoicing' ), esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) ); ?>
26
+        <?php echo sprintf(esc_html__('%s Details', 'invoicing'), esc_html(ucfirst($invoice->get_invoice_quote_type()))); ?>
27 27
     </h3>
28 28
 
29 29
     <table class="table table-bordered table-sm">
30 30
 
31
-        <?php foreach ( $meta_data as $key => $data ) : ?>
31
+        <?php foreach ($meta_data as $key => $data) : ?>
32 32
 
33
-            <?php if ( ! empty( $data['value'] ) ) : ?>
33
+            <?php if (!empty($data['value'])) : ?>
34 34
 
35
-                <?php do_action( "getpaid_before_email_details_$key", $invoice, $data ); ?>
35
+                <?php do_action("getpaid_before_email_details_$key", $invoice, $data); ?>
36 36
 
37
-                <tr class="getpaid-email-details-<?php echo esc_attr( $key ); ?>">
37
+                <tr class="getpaid-email-details-<?php echo esc_attr($key); ?>">
38 38
 
39 39
                     <td class="getpaid-lable-td">
40
-                        <?php echo esc_html( $data['label'] ); ?>
40
+                        <?php echo esc_html($data['label']); ?>
41 41
                     </td>
42 42
 
43 43
                     <td class="getpaid-value-td">
44
-                        <span class="getpaid-invoice-meta-<?php echo esc_attr( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span>
44
+                        <span class="getpaid-invoice-meta-<?php echo esc_attr($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span>
45 45
                     </td>
46 46
 
47 47
                 </tr>
48 48
 
49
-                <?php do_action( "getpaid_after_email_details_$key", $invoice, $data ); ?>
49
+                <?php do_action("getpaid_after_email_details_$key", $invoice, $data); ?>
50 50
 
51 51
             <?php endif; ?>
52 52
 
@@ -56,4 +56,4 @@  discard block
 block discarded – undo
56 56
 
57 57
 </div>
58 58
 
59
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
59
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
Please login to merge, or discard this patch.
templates/invoice/line-item.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -26,90 +26,90 @@
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
31 31
 
32
-					// Item name.
33
-					if ( 'name' === $column ) {
32
+                    // Item name.
33
+                    if ( 'name' === $column ) {
34 34
 
35
-						$has_featured_image = has_post_thumbnail( $item->get_id() );
35
+                        $has_featured_image = has_post_thumbnail( $item->get_id() );
36 36
 
37
-						if ( $has_featured_image ) {
38
-							echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
39
-							echo '<div class="getpaid-form-item-image-container mr-2">';
40
-							echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
41
-							echo '</div>';
42
-							echo '<div class="getpaid-form-item-name-container">';
43
-						}
37
+                        if ( $has_featured_image ) {
38
+                            echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
39
+                            echo '<div class="getpaid-form-item-image-container mr-2">';
40
+                            echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
41
+                            echo '</div>';
42
+                            echo '<div class="getpaid-form-item-name-container">';
43
+                        }
44 44
 
45
-						// Display the name.
46
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
45
+                        // Display the name.
46
+                        echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
47 47
 
48
-						// And an optional description.
49
-						$description = $item->get_description();
48
+                        // And an optional description.
49
+                        $description = $item->get_description();
50 50
 
51
-						if ( ! empty( $description ) ) {
52
-							echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
53
-						}
51
+                        if ( ! empty( $description ) ) {
52
+                            echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
53
+                        }
54 54
 
55
-						// Fires before printing the line item actions.
56
-						do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice );
55
+                        // Fires before printing the line item actions.
56
+                        do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice );
57 57
 
58
-						$actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
58
+                        $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
59 59
 
60
-						if ( ! empty( $actions ) ) {
60
+                        if ( ! empty( $actions ) ) {
61 61
 
62
-							$sanitized  = array();
63
-							foreach ( $actions as $key => $item_action ) {
64
-								$key         = sanitize_html_class( $key );
65
-								$item_action = wp_kses_post( $item_action );
66
-								$sanitized[] = "<span class='$key'>$item_action</span>";
67
-							}
62
+                            $sanitized  = array();
63
+                            foreach ( $actions as $key => $item_action ) {
64
+                                $key         = sanitize_html_class( $key );
65
+                                $item_action = wp_kses_post( $item_action );
66
+                                $sanitized[] = "<span class='$key'>$item_action</span>";
67
+                            }
68 68
 
69
-							echo "<small class='form-text getpaid-line-item-actions'>";
70
-							echo wp_kses_post( implode( ' | ', $sanitized ) );
71
-							echo '</small>';
69
+                            echo "<small class='form-text getpaid-line-item-actions'>";
70
+                            echo wp_kses_post( implode( ' | ', $sanitized ) );
71
+                            echo '</small>';
72 72
 
73
-						}
73
+                        }
74 74
 
75
-						if ( $has_featured_image ) {
76
-							echo '</div>';
77
-							echo '</div>';
78
-						}
79
-					}
75
+                        if ( $has_featured_image ) {
76
+                            echo '</div>';
77
+                            echo '</div>';
78
+                        }
79
+                    }
80 80
 
81
-					// Item price.
82
-					if ( 'price' === $column ) {
81
+                    // Item price.
82
+                    if ( 'price' === $column ) {
83 83
 
84
-					// Display the item price (or recurring price if this is a renewal invoice)
85
-					$price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
86
-					wpinv_the_price( $price, $invoice->get_currency() );
84
+                    // Display the item price (or recurring price if this is a renewal invoice)
85
+                    $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
86
+                    wpinv_the_price( $price, $invoice->get_currency() );
87 87
 
88
-					}
88
+                    }
89 89
 
90
-					// Tax rate.
91
-					if ( 'tax_rate' === $column ) {
92
-					echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
93
-					}
90
+                    // Tax rate.
91
+                    if ( 'tax_rate' === $column ) {
92
+                    echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
93
+                    }
94 94
 
95
-					// Item quantity.
96
-					if ( 'quantity' === $column ) {
97
-					echo (float) $item->get_quantity();
98
-					}
95
+                    // Item quantity.
96
+                    if ( 'quantity' === $column ) {
97
+                    echo (float) $item->get_quantity();
98
+                    }
99 99
 
100
-					// Item sub total.
101
-					if ( 'subtotal' === $column ) {
102
-					$subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
103
-					wpinv_the_price( $subtotal, $invoice->get_currency() );
104
-					}
100
+                    // Item sub total.
101
+                    if ( 'subtotal' === $column ) {
102
+                    $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
103
+                    wpinv_the_price( $subtotal, $invoice->get_currency() );
104
+                    }
105 105
 
106
-					// Fires when printing a line item column.
107
-					do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
106
+                    // Fires when printing a line item column.
107
+                    do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
108 108
 
109
-					// Fires after printing a line item column.
110
-					do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
109
+                    // Fires after printing a line item column.
110
+                    do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
111 111
 
112
-				?>
112
+                ?>
113 113
 
114 114
 			</div>
115 115
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,104 +10,104 @@
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-do_action( 'getpaid_before_invoice_line_item', $invoice, $item );
15
+do_action('getpaid_before_invoice_line_item', $invoice, $item);
16 16
 
17 17
 ?>
18 18
 
19
-<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr( $item->get_type() ); ?> border-bottom'>
19
+<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr($item->get_type()); ?> border-bottom'>
20 20
 
21 21
 	<div class="form-row row align-items-center">
22 22
 
23
-		<?php foreach ( array_keys( $columns ) as $column ) : ?>
23
+		<?php foreach (array_keys($columns) as $column) : ?>
24 24
 
25
-			<div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr( $column ); ?>">
25
+			<div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr($column); ?>">
26 26
 
27 27
 				<?php
28 28
 
29 29
 					// Fires before printing a line item column.
30
-					do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
30
+					do_action("getpaid_invoice_line_item_before_$column", $item, $invoice);
31 31
 
32 32
 					// Item name.
33
-					if ( 'name' === $column ) {
33
+					if ('name' === $column) {
34 34
 
35
-						$has_featured_image = has_post_thumbnail( $item->get_id() );
35
+						$has_featured_image = has_post_thumbnail($item->get_id());
36 36
 
37
-						if ( $has_featured_image ) {
37
+						if ($has_featured_image) {
38 38
 							echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">';
39 39
 							echo '<div class="getpaid-form-item-image-container mr-2">';
40
-							echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) );
40
+							echo get_the_post_thumbnail($item->get_id(), 'thumbnail', array('class' => 'getpaid-form-item-image mb-0'));
41 41
 							echo '</div>';
42 42
 							echo '<div class="getpaid-form-item-name-container">';
43 43
 						}
44 44
 
45 45
 						// Display the name.
46
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
46
+						echo '<div class="mb-1">' . esc_html($item->get_name()) . '</div>';
47 47
 
48 48
 						// And an optional description.
49 49
 						$description = $item->get_description();
50 50
 
51
-						if ( ! empty( $description ) ) {
52
-							echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>';
51
+						if (!empty($description)) {
52
+							echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post($description) . '</small>';
53 53
 						}
54 54
 
55 55
 						// Fires before printing the line item actions.
56
-						do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice );
56
+						do_action('getpaid_before_invoice_line_item_actions', $item, $invoice);
57 57
 
58
-						$actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
58
+						$actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice);
59 59
 
60
-						if ( ! empty( $actions ) ) {
60
+						if (!empty($actions)) {
61 61
 
62
-							$sanitized  = array();
63
-							foreach ( $actions as $key => $item_action ) {
64
-								$key         = sanitize_html_class( $key );
65
-								$item_action = wp_kses_post( $item_action );
62
+							$sanitized = array();
63
+							foreach ($actions as $key => $item_action) {
64
+								$key         = sanitize_html_class($key);
65
+								$item_action = wp_kses_post($item_action);
66 66
 								$sanitized[] = "<span class='$key'>$item_action</span>";
67 67
 							}
68 68
 
69 69
 							echo "<small class='form-text getpaid-line-item-actions'>";
70
-							echo wp_kses_post( implode( ' | ', $sanitized ) );
70
+							echo wp_kses_post(implode(' | ', $sanitized));
71 71
 							echo '</small>';
72 72
 
73 73
 						}
74 74
 
75
-						if ( $has_featured_image ) {
75
+						if ($has_featured_image) {
76 76
 							echo '</div>';
77 77
 							echo '</div>';
78 78
 						}
79 79
 					}
80 80
 
81 81
 					// Item price.
82
-					if ( 'price' === $column ) {
82
+					if ('price' === $column) {
83 83
 
84 84
 					// Display the item price (or recurring price if this is a renewal invoice)
85 85
 					$price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
86
-					wpinv_the_price( $price, $invoice->get_currency() );
86
+					wpinv_the_price($price, $invoice->get_currency());
87 87
 
88 88
 					}
89 89
 
90 90
 					// Tax rate.
91
-					if ( 'tax_rate' === $column ) {
92
-					echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
91
+					if ('tax_rate' === $column) {
92
+					echo floatval(round(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%';
93 93
 					}
94 94
 
95 95
 					// Item quantity.
96
-					if ( 'quantity' === $column ) {
96
+					if ('quantity' === $column) {
97 97
 					echo (float) $item->get_quantity();
98 98
 					}
99 99
 
100 100
 					// Item sub total.
101
-					if ( 'subtotal' === $column ) {
101
+					if ('subtotal' === $column) {
102 102
 					$subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
103
-					wpinv_the_price( $subtotal, $invoice->get_currency() );
103
+					wpinv_the_price($subtotal, $invoice->get_currency());
104 104
 					}
105 105
 
106 106
 					// Fires when printing a line item column.
107
-					do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
107
+					do_action("getpaid_invoice_line_item_$column", $item, $invoice);
108 108
 
109 109
 					// Fires after printing a line item column.
110
-					do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
110
+					do_action("getpaid_invoice_line_item_after_$column", $item, $invoice);
111 111
 
112 112
 				?>
113 113
 
Please login to merge, or discard this patch.