Passed
Push — master ( 7a26f0...499ba9 )
by Brian
05:15
created
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
             aui()->select(
19 19
                 array(
20 20
                     'options' => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'    => "tax_rates[$key][country]",
25
-                    'id'      => uniqid( 'tax_rate_country' ),
26
-                    'value'   => esc_html( $tax_rate['country'] ),
27
-                    'label'   => __( 'Country', 'invoicing' ),
25
+                    'id'      => uniqid('tax_rate_country'),
26
+                    'value'   => esc_html($tax_rate['country']),
27
+                    'label'   => __('Country', 'invoicing'),
28 28
                     'class'   => 'wpinv_country',
29 29
                     'no_wrap' => true,
30 30
                 ),
@@ -37,35 +37,35 @@  discard block
 block discarded – undo
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php esc_html_e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ); ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php esc_html_e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key); ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php esc_html_e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][rate]" value="<?php echo esc_attr( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php esc_html_e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][rate]" value="<?php echo esc_attr($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php esc_html_e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][reduced_rate]" value="<?php echo esc_attr( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php esc_html_e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][reduced_rate]" value="<?php echo esc_attr($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php esc_html_e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php esc_html_e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo esc_attr($key); ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rates-edit.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 $tax_rates  = GetPaid_Tax::get_all_tax_rates();
10 10
 $dummy_rate = array(
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     'global'       => true,
14 14
     'rate'         => wpinv_get_default_tax_rate(),
15 15
     'reduced_rate' => 5,
16
-    'name'         => __( 'VAT', 'invoicing' ),
16
+    'name'         => __('VAT', 'invoicing'),
17 17
 );
18 18
 
19 19
 $reset_url = wp_nonce_url(
20
-    add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ),
20
+    add_query_arg('getpaid-admin-action', 'reset_tax_rates'),
21 21
     'getpaid-nonce',
22 22
     'getpaid-nonce'
23 23
 );
@@ -25,34 +25,34 @@  discard block
 block discarded – undo
25 25
 ?>
26 26
 <div class="table-responsive">
27 27
     <table id="wpinv_tax_rates" class="widefat fixed table">
28
-        <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption>
28
+        <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption>
29 29
 
30 30
         <thead>
31 31
             <tr class="table-light">
32 32
 
33 33
                 <th scope="col" class="border-bottom border-top">
34
-                    <?php esc_html_e( 'Country', 'invoicing' ); ?>
35
-                    <?php getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static', true ); ?>
34
+                    <?php esc_html_e('Country', 'invoicing'); ?>
35
+                    <?php getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static', true); ?>
36 36
                 </th>
37 37
 
38 38
                 <th scope="col" class="border-bottom border-top">
39
-                    <?php esc_html_e( 'State', 'invoicing' ); ?>
40
-                    <?php getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static', true ); ?>
39
+                    <?php esc_html_e('State', 'invoicing'); ?>
40
+                    <?php getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static', true); ?>
41 41
                 </th>
42 42
 
43 43
                 <th scope="col" class="border-bottom border-top">
44
-                    <?php esc_html_e( 'Standard Rate %', 'invoicing' ); ?>
45
-                    <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static', true ); ?>
44
+                    <?php esc_html_e('Standard Rate %', 'invoicing'); ?>
45
+                    <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static', true); ?>
46 46
                 </th>
47 47
 
48 48
                 <th scope="col" class="border-bottom border-top">
49
-                    <?php esc_html_e( 'Reduced Rate %', 'invoicing' ); ?>
50
-                    <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static', true ); ?>
49
+                    <?php esc_html_e('Reduced Rate %', 'invoicing'); ?>
50
+                    <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static', true); ?>
51 51
                 </th>
52 52
 
53 53
                 <th scope="col" class="border-bottom border-top">
54
-                    <?php esc_html_e( 'Tax Name', 'invoicing' ); ?>
55
-                    <?php getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static', true ); ?>
54
+                    <?php esc_html_e('Tax Name', 'invoicing'); ?>
55
+                    <?php getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static', true); ?>
56 56
                 </th>
57 57
 
58 58
                 <th scope="col" class="border-bottom border-top" style="width:32px">&nbsp;</th>
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
         </thead>
62 62
 
63 63
         <tbody>
64
-            <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?>
64
+            <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?>
65 65
         </tbody>
66 66
 
67 67
         <tfoot>
68 68
             <tr class="table-light">
69 69
                 <td colspan="6" class="border-top">
70 70
 
71
-                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>">
72
-                        <span><?php esc_html_e( 'Add Tax Rate', 'invoicing' ); ?></span>
71
+                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>">
72
+                        <span><?php esc_html_e('Add Tax Rate', 'invoicing'); ?></span>
73 73
                     </button>
74 74
 
75
-                    <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>">
76
-                        <span><?php esc_html_e( 'Reset Tax Rates', 'invoicing' ); ?></span>
75
+                    <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>">
76
+                        <span><?php esc_html_e('Reset Tax Rates', 'invoicing'); ?></span>
77 77
                     </a>
78 78
                 </td>
79 79
             </tr>
@@ -82,6 +82,6 @@  discard block
 block discarded – undo
82 82
 </div>
83 83
 
84 84
 <script type="text/html" id="tmpl-wpinv-tax-rate-row">
85
-    <?php wpinv_tax_rate_callback( $dummy_rate, 0, true ); ?>
85
+    <?php wpinv_tax_rate_callback($dummy_rate, 0, true); ?>
86 86
 </script>
87 87
 
Please login to merge, or discard this patch.
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
Indentation   +415 added lines, -415 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,44 +157,44 @@  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'     => __( '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
-		}
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'     => __( '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 190
 }
191 191
 
192
-	$profile_id = $sub->get_profile_id();
193
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
-		unset( $fields['profile_id'] );
195
-	}
192
+    $profile_id = $sub->get_profile_id();
193
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
+        unset( $fields['profile_id'] );
195
+    }
196 196
 
197
-	?>
197
+    ?>
198 198
 
199 199
 		<table class="table table-borderless" style="font-size: 14px;">
200 200
 			<tbody>
@@ -228,20 +228,20 @@  discard block
 block discarded – undo
228 228
  */
229 229
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
230 230
 
231
-	$username = __( '(Missing User)', 'invoicing' );
231
+    $username = __( '(Missing User)', 'invoicing' );
232 232
 
233
-	$user = get_userdata( $subscription->get_customer_id() );
234
-	if ( $user ) {
233
+    $user = get_userdata( $subscription->get_customer_id() );
234
+    if ( $user ) {
235 235
 
236
-		$username = sprintf(
237
-			'<a href="user-edit.php?user_id=%s">%s</a>',
238
-			absint( $user->ID ),
239
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
240
-		);
236
+        $username = sprintf(
237
+            '<a href="user-edit.php?user_id=%s">%s</a>',
238
+            absint( $user->ID ),
239
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
240
+        );
241 241
 
242
-	}
242
+    }
243 243
 
244
-	echo wp_kses_post( $username );
244
+    echo wp_kses_post( $username );
245 245
 }
246 246
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
247 247
 
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
  * @param WPInv_Subscription $subscription
252 252
  */
253 253
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
254
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
255
-	echo wp_kses_post( "<span>$amount</span>" );
254
+    $amount    = getpaid_get_formatted_subscription_amount( $subscription );
255
+    echo wp_kses_post( "<span>$amount</span>" );
256 256
 }
257 257
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
258 258
 
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
265 265
 
266
-	printf(
267
-		'<a href="%s">#%s</a>',
268
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
269
-		absint( $subscription->get_id() )
270
-	);
266
+    printf(
267
+        '<a href="%s">#%s</a>',
268
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
269
+        absint( $subscription->get_id() )
270
+    );
271 271
 
272 272
 }
273 273
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
  * @param WPInv_Subscription $subscription
279 279
  */
280 280
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
281
-	echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
281
+    echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
282 282
 }
283 283
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
284 284
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
  * @param WPInv_Subscription $subscription
289 289
  */
290 290
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
291
-	echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
291
+    echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
292 292
 }
293 293
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
294 294
 
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
  * @param WPInv_Subscription $subscription
299 299
  */
300 300
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
301
-	$max_bills = $subscription->get_bill_times();
302
-	echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
301
+    $max_bills = $subscription->get_bill_times();
302
+    echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
303 303
 }
304 304
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
305 305
 /**
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
  */
311 311
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
312 312
 
313
-	if ( empty( $subscription_group ) ) {
314
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
315
-		return;
316
-	}
313
+    if ( empty( $subscription_group ) ) {
314
+        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
315
+        return;
316
+    }
317 317
 
318
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
319
-	echo wp_kses_post( implode( ' | ', $markup ) );
318
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
319
+    echo wp_kses_post( implode( ' | ', $markup ) );
320 320
 
321 321
 }
322 322
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
330 330
 
331
-	$gateway = $subscription->get_gateway();
331
+    $gateway = $subscription->get_gateway();
332 332
 
333
-	if ( ! empty( $gateway ) ) {
334
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
335
-	} else {
336
-		echo '&mdash;';
337
-	}
333
+    if ( ! empty( $gateway ) ) {
334
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
335
+    } else {
336
+        echo '&mdash;';
337
+    }
338 338
 
339 339
 }
340 340
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
  * @param WPInv_Subscription $subscription
346 346
  */
347 347
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
348
-	echo wp_kses_post( $subscription->get_status_label_html() );
348
+    echo wp_kses_post( $subscription->get_status_label_html() );
349 349
 }
350 350
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
351 351
 
@@ -356,27 +356,27 @@  discard block
 block discarded – undo
356 356
  */
357 357
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
358 358
 
359
-	$profile_id = $subscription->get_profile_id();
360
-
361
-	aui()->input(
362
-		array(
363
-			'type'              => 'text',
364
-			'id'                => 'wpinv_subscription_profile_id',
365
-			'name'              => 'wpinv_subscription_profile_id',
366
-			'label'             => __( 'Profile Id', 'invoicing' ),
367
-			'label_type'        => 'hidden',
368
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
-			'value'             => esc_attr( $profile_id ),
370
-			'input_group_right' => '',
371
-			'no_wrap'           => true,
372
-		),
373
-		true
374
-	);
375
-
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		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>';
379
-	}
359
+    $profile_id = $subscription->get_profile_id();
360
+
361
+    aui()->input(
362
+        array(
363
+            'type'              => 'text',
364
+            'id'                => 'wpinv_subscription_profile_id',
365
+            'name'              => 'wpinv_subscription_profile_id',
366
+            'label'             => __( 'Profile Id', 'invoicing' ),
367
+            'label_type'        => 'hidden',
368
+            'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
+            'value'             => esc_attr( $profile_id ),
370
+            'input_group_right' => '',
371
+            'no_wrap'           => true,
372
+        ),
373
+        true
374
+    );
375
+
376
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
+    if ( ! empty( $url ) ) {
378
+        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>';
379
+    }
380 380
 
381 381
 }
382 382
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -388,40 +388,40 @@  discard block
 block discarded – undo
388 388
  */
389 389
 function getpaid_admin_subscription_update_metabox( $subscription ) {
390 390
 
391
-	?>
391
+    ?>
392 392
 	<div class="mt-3">
393 393
 
394 394
 		<?php
395
-			aui()->select(
396
-				array(
397
-					'options'   => getpaid_get_subscription_statuses(),
398
-					'name'      => 'subscription_status',
399
-					'id'        => 'subscription_status_update_select',
400
-					'required'  => true,
401
-					'no_wrap'   => false,
402
-					'label'     => __( 'Subscription Status', 'invoicing' ),
403
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
404
-					'select2'   => true,
405
-					'value'     => $subscription->get_status( 'edit' ),
406
-				),
407
-				true
408
-			);
409
-		?>
395
+            aui()->select(
396
+                array(
397
+                    'options'   => getpaid_get_subscription_statuses(),
398
+                    'name'      => 'subscription_status',
399
+                    'id'        => 'subscription_status_update_select',
400
+                    'required'  => true,
401
+                    'no_wrap'   => false,
402
+                    'label'     => __( 'Subscription Status', 'invoicing' ),
403
+                    'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
404
+                    'select2'   => true,
405
+                    'value'     => $subscription->get_status( 'edit' ),
406
+                ),
407
+                true
408
+            );
409
+        ?>
410 410
 
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
415 415
 
416
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$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' );
416
+            $url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
417
+            $anchor = __( 'Renew Subscription', 'invoicing' );
418
+            $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' );
419 419
 
420
-			if ( $subscription->is_active() ) {
421
-			echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
422
-			}
420
+            if ( $subscription->is_active() ) {
421
+            echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
422
+            }
423 423
 
424
-	echo '</div></div>';
424
+    echo '</div></div>';
425 425
 }
426 426
 
427 427
 /**
@@ -432,33 +432,33 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
434 434
 
435
-	$columns = apply_filters(
436
-		'getpaid_subscription_related_invoices_columns',
437
-		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
443
-		),
444
-		$subscription
445
-	);
446
-
447
-	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
449
-	$parent   = $subscription->get_parent_invoice();
450
-
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
453
-	}
454
-
455
-	$table_class = 'w-100 bg-white';
456
-
457
-	if ( ! is_admin() ) {
458
-		$table_class = 'table table-bordered';
459
-	}
460
-
461
-	?>
435
+    $columns = apply_filters(
436
+        'getpaid_subscription_related_invoices_columns',
437
+        array(
438
+            'invoice'      => __( 'Invoice', 'invoicing' ),
439
+            'relationship' => __( 'Relationship', 'invoicing' ),
440
+            'date'         => __( 'Date', 'invoicing' ),
441
+            'status'       => __( 'Status', 'invoicing' ),
442
+            'total'        => __( 'Total', 'invoicing' ),
443
+        ),
444
+        $subscription
445
+    );
446
+
447
+    // Prepare the invoices.
448
+    $payments = $subscription->get_child_payments( ! is_admin() );
449
+    $parent   = $subscription->get_parent_invoice();
450
+
451
+    if ( $parent->exists() ) {
452
+        $payments = array_merge( array( $parent ), $payments );
453
+    }
454
+
455
+    $table_class = 'w-100 bg-white';
456
+
457
+    if ( ! is_admin() ) {
458
+        $table_class = 'table table-bordered';
459
+    }
460
+
461
+    ?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464 464
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
471
-							}
472
-						?>
469
+                            foreach ( $columns as $key => $label ) {
470
+                            echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
471
+                            }
472
+                        ?>
473 473
 					</tr>
474 474
 				</thead>
475 475
 
@@ -485,72 +485,72 @@  discard block
 block discarded – undo
485 485
 
486 486
 					<?php
487 487
 
488
-						foreach ( $payments as $payment ) :
488
+                        foreach ( $payments as $payment ) :
489 489
 
490
-						// Ensure that we have an invoice.
491
-						$payment = new WPInv_Invoice( $payment );
490
+                        // Ensure that we have an invoice.
491
+                        $payment = new WPInv_Invoice( $payment );
492 492
 
493
-						// Abort if the invoice is invalid...
494
-						if ( ! $payment->exists() ) {
495
-							continue;
496
-							}
493
+                        // Abort if the invoice is invalid...
494
+                        if ( ! $payment->exists() ) {
495
+                            continue;
496
+                            }
497 497
 
498
-						// ... or belongs to a different subscription.
499
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
500
-							continue;
501
-							}
498
+                        // ... or belongs to a different subscription.
499
+                        if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
500
+                            continue;
501
+                            }
502 502
 
503
-						echo '<tr>';
503
+                        echo '<tr>';
504 504
 
505
-						foreach ( array_keys( $columns ) as $key ) {
505
+                        foreach ( array_keys( $columns ) as $key ) {
506 506
 
507
-							echo "<td class='p-2 text-left'>";
507
+                            echo "<td class='p-2 text-left'>";
508 508
 
509
-								switch ( $key ) {
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;
511
+                                case 'total':
512
+                                        echo '<strong>';
513
+                                        wpinv_the_price( $payment->get_total(), $payment->get_currency() );
514
+                                        echo '</strong>';
515
+                                    break;
516 516
 
517
-								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
-									break;
517
+                                case 'relationship':
518
+                                        echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
519
+                                    break;
520 520
 
521
-								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
-									break;
521
+                                case 'date':
522
+                                    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
523
+                                    break;
524 524
 
525
-								case 'status':
526
-										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
528
-										$status = $payment->get_status_label_html();
529
-										}
525
+                                case 'status':
526
+                                        $status = $payment->get_status_nicename();
527
+                                        if ( is_admin() ) {
528
+                                        $status = $payment->get_status_label_html();
529
+                                        }
530 530
 
531
-										echo wp_kses_post( $status );
532
-									break;
531
+                                        echo wp_kses_post( $status );
532
+                                    break;
533 533
 
534
-								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
534
+                                case 'invoice':
535
+                                        $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
536 536
 
537
-										if ( ! is_admin() ) {
538
-										$link = esc_url( $payment->get_view_url() );
539
-										}
537
+                                        if ( ! is_admin() ) {
538
+                                        $link = esc_url( $payment->get_view_url() );
539
+                                        }
540 540
 
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
-									break;
544
-										}
541
+                                        $invoice = esc_html( $payment->get_number() );
542
+                                        echo wp_kses_post( "<a href='$link'>$invoice</a>" );
543
+                                    break;
544
+                                        }
545 545
 
546
-								echo '</td>';
546
+                                echo '</td>';
547 547
 
548
-							}
548
+                            }
549 549
 
550
-						echo '</tr>';
550
+                        echo '</tr>';
551 551
 
552
-						endforeach;
553
-					?>
552
+                        endforeach;
553
+                    ?>
554 554
 
555 555
 				</tbody>
556 556
 
@@ -568,42 +568,42 @@  discard block
 block discarded – undo
568 568
  */
569 569
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
570 570
 
571
-	// Fetch the subscription group.
572
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
571
+    // Fetch the subscription group.
572
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
573 573
 
574
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
575
-		return;
576
-	}
574
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
575
+        return;
576
+    }
577 577
 
578
-	// Prepare table columns.
579
-	$columns = apply_filters(
580
-		'getpaid_subscription_item_details_columns',
581
-		array(
582
-			'item_name' => __( 'Item', 'invoicing' ),
583
-			'price'     => __( 'Price', 'invoicing' ),
584
-			'tax'       => __( 'Tax', 'invoicing' ),
585
-			'discount'  => __( 'Discount', 'invoicing' ),
586
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
587
-			'recurring' => __( 'Subtotal', 'invoicing' ),
588
-		),
589
-		$subscription
590
-	);
578
+    // Prepare table columns.
579
+    $columns = apply_filters(
580
+        'getpaid_subscription_item_details_columns',
581
+        array(
582
+            'item_name' => __( 'Item', 'invoicing' ),
583
+            'price'     => __( 'Price', 'invoicing' ),
584
+            'tax'       => __( 'Tax', 'invoicing' ),
585
+            'discount'  => __( 'Discount', 'invoicing' ),
586
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
587
+            'recurring' => __( 'Subtotal', 'invoicing' ),
588
+        ),
589
+        $subscription
590
+    );
591 591
 
592
-	// Prepare the invoices.
592
+    // Prepare the invoices.
593 593
 
594
-	$invoice = $subscription->get_parent_invoice();
594
+    $invoice = $subscription->get_parent_invoice();
595 595
 
596
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
-		unset( $columns['tax'] );
598
-	}
596
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
+        unset( $columns['tax'] );
598
+    }
599 599
 
600
-	$table_class = 'w-100 bg-white';
600
+    $table_class = 'w-100 bg-white';
601 601
 
602
-	if ( ! is_admin() ) {
603
-		$table_class = 'table table-bordered';
604
-	}
602
+    if ( ! is_admin() ) {
603
+        $table_class = 'table table-bordered';
604
+    }
605 605
 
606
-	?>
606
+    ?>
607 607
 		<div class="m-0" style="overflow: auto;">
608 608
 
609 609
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
 					<tr>
613 613
 						<?php
614 614
 
615
-							foreach ( $columns as $key => $label ) {
616
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
617
-							}
618
-						?>
615
+                            foreach ( $columns as $key => $label ) {
616
+                            echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
617
+                            }
618
+                        ?>
619 619
 					</tr>
620 620
 				</thead>
621 621
 
@@ -623,106 +623,106 @@  discard block
 block discarded – undo
623 623
 
624 624
 					<?php
625 625
 
626
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
626
+                        foreach ( $subscription_group['items'] as $subscription_group_item ) :
627 627
 
628
-						echo '<tr>';
628
+                        echo '<tr>';
629 629
 
630
-						foreach ( array_keys( $columns ) as $key ) {
630
+                        foreach ( array_keys( $columns ) as $key ) {
631 631
 
632
-							$class = 'text-left';
632
+                            $class = 'text-left';
633 633
 
634
-							echo "<td class='p-2 text-left'>";
634
+                            echo "<td class='p-2 text-left'>";
635 635
 
636
-								switch ( $key ) {
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
 
672
-								echo '</td>';
672
+                                echo '</td>';
673 673
 
674
-							}
674
+                            }
675 675
 
676
-						echo '</tr>';
676
+                        echo '</tr>';
677 677
 
678
-						endforeach;
678
+                        endforeach;
679 679
 
680
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
680
+                        foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
681 681
 
682
-						echo '<tr>';
682
+                        echo '<tr>';
683 683
 
684
-						foreach ( array_keys( $columns ) as $key ) {
684
+                        foreach ( array_keys( $columns ) as $key ) {
685 685
 
686
-							$class = 'text-left';
686
+                            $class = 'text-left';
687 687
 
688
-							echo "<td class='p-2 text-left'>";
688
+                            echo "<td class='p-2 text-left'>";
689 689
 
690
-								switch ( $key ) {
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
 
718
-								echo '</td>';
718
+                                echo '</td>';
719 719
 
720
-							}
720
+                            }
721 721
 
722
-						echo '</tr>';
722
+                        echo '</tr>';
723 723
 
724
-						endforeach;
725
-					?>
724
+                        endforeach;
725
+                    ?>
726 726
 
727 727
 				</tbody>
728 728
 
@@ -741,38 +741,38 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
743 743
 
744
-	// Fetch the subscription groups.
745
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
746
-
747
-	if ( empty( $subscription_groups ) ) {
748
-		return;
749
-	}
750
-
751
-	// Prepare table columns.
752
-	$columns = apply_filters(
753
-		'getpaid_subscription_related_subscriptions_columns',
754
-		array(
755
-			'subscription' => __( 'Subscription', 'invoicing' ),
756
-			'start_date'   => __( 'Start Date', 'invoicing' ),
757
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
758
-			'renewals'     => __( 'Payments', 'invoicing' ),
759
-			'item'         => __( 'Items', 'invoicing' ),
760
-			'status'       => __( 'Status', 'invoicing' ),
761
-		),
762
-		$subscription
763
-	);
764
-
765
-	if ( $subscription->get_status() == 'pending' ) {
766
-		unset( $columns['start_date'], $columns['renewal_date'] );
767
-	}
768
-
769
-	$table_class = 'w-100 bg-white';
770
-
771
-	if ( ! is_admin() ) {
772
-		$table_class = 'table table-bordered';
773
-	}
774
-
775
-	?>
744
+    // Fetch the subscription groups.
745
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
746
+
747
+    if ( empty( $subscription_groups ) ) {
748
+        return;
749
+    }
750
+
751
+    // Prepare table columns.
752
+    $columns = apply_filters(
753
+        'getpaid_subscription_related_subscriptions_columns',
754
+        array(
755
+            'subscription' => __( 'Subscription', 'invoicing' ),
756
+            'start_date'   => __( 'Start Date', 'invoicing' ),
757
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
758
+            'renewals'     => __( 'Payments', 'invoicing' ),
759
+            'item'         => __( 'Items', 'invoicing' ),
760
+            'status'       => __( 'Status', 'invoicing' ),
761
+        ),
762
+        $subscription
763
+    );
764
+
765
+    if ( $subscription->get_status() == 'pending' ) {
766
+        unset( $columns['start_date'], $columns['renewal_date'] );
767
+    }
768
+
769
+    $table_class = 'w-100 bg-white';
770
+
771
+    if ( ! is_admin() ) {
772
+        $table_class = 'table table-bordered';
773
+    }
774
+
775
+    ?>
776 776
 		<div class="m-0" style="overflow: auto;">
777 777
 
778 778
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -781,10 +781,10 @@  discard block
 block discarded – undo
781 781
 					<tr>
782 782
 						<?php
783 783
 
784
-							foreach ( $columns as $key => $label ) {
785
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
786
-							}
787
-						?>
784
+                            foreach ( $columns as $key => $label ) {
785
+                            echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
786
+                            }
787
+                        ?>
788 788
 					</tr>
789 789
 				</thead>
790 790
 
@@ -792,74 +792,74 @@  discard block
 block discarded – undo
792 792
 
793 793
 					<?php
794 794
 
795
-						foreach ( $subscription_groups as $subscription_group ) :
795
+                        foreach ( $subscription_groups as $subscription_group ) :
796 796
 
797
-						// Do not list current subscription.
798
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
799
-							continue;
800
-							}
797
+                        // Do not list current subscription.
798
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
799
+                            continue;
800
+                            }
801 801
 
802
-						// Ensure the subscription exists.
803
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
802
+                        // Ensure the subscription exists.
803
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
804 804
 
805
-						if ( ! $_suscription->exists() ) {
806
-							continue;
807
-							}
805
+                        if ( ! $_suscription->exists() ) {
806
+                            continue;
807
+                            }
808 808
 
809
-						echo '<tr>';
809
+                        echo '<tr>';
810 810
 
811
-						foreach ( array_keys( $columns ) as $key ) {
811
+                        foreach ( array_keys( $columns ) as $key ) {
812 812
 
813
-							$class = 'text-left';
813
+                            $class = 'text-left';
814 814
 
815
-							echo "<td class='p-2 text-left'>";
815
+                            echo "<td class='p-2 text-left'>";
816 816
 
817
-								switch ( $key ) {
817
+                                switch ( $key ) {
818 818
 
819
-								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
821
-									break;
819
+                                case 'status':
820
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
821
+                                    break;
822 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;
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 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;
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 832
 
833
-								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
-									break;
833
+                                case 'renewal_date':
834
+                                        echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
835
+                                    break;
836 836
 
837
-								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
-									break;
837
+                                case 'start_date':
838
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
839
+                                    break;
840 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(
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 844
                                             '%1$s#%2$s%3$s',
845 845
                                             '<a href="' . esc_url( $url ) . '">',
846 846
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
847
-											'</a>'
847
+                                            '</a>'
848 848
                                         );
849 849
 
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
-									break;
850
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
851
+                                    break;
852 852
 
853
-										}
853
+                                        }
854 854
 
855
-								echo '</td>';
855
+                                echo '</td>';
856 856
 
857
-							}
857
+                            }
858 858
 
859
-						echo '</tr>';
859
+                        echo '</tr>';
860 860
 
861
-						endforeach;
862
-					?>
861
+                        endforeach;
862
+                    ?>
863 863
 
864 864
 				</tbody>
865 865
 
Please login to merge, or discard this patch.
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.
Spacing   +203 added lines, -203 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,43 +155,43 @@  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'     => __( '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'     => __('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 190
 }
191 191
 
192 192
 	$profile_id = $sub->get_profile_id();
193
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
194
-		unset( $fields['profile_id'] );
193
+	if (empty($profile_id) && isset($fields['profile_id'])) {
194
+		unset($fields['profile_id']);
195 195
 	}
196 196
 
197 197
 	?>
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 		<table class="table table-borderless" style="font-size: 14px;">
200 200
 			<tbody>
201 201
 
202
-				<?php foreach ( $fields as $key => $label ) : ?>
202
+				<?php foreach ($fields as $key => $label) : ?>
203 203
 
204
-					<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
204
+					<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
205 205
 
206 206
 						<th class="w-25" style="font-weight: 500;">
207
-							<?php echo esc_html( $label ); ?>
207
+							<?php echo esc_html($label); ?>
208 208
 						</th>
209 209
 
210 210
 						<td class="w-75 text-muted">
211
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
211
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
212 212
 						</td>
213 213
 
214 214
 					</tr>
@@ -226,135 +226,135 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @param WPInv_Subscription $subscription
228 228
  */
229
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
229
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
230 230
 
231
-	$username = __( '(Missing User)', 'invoicing' );
231
+	$username = __('(Missing User)', 'invoicing');
232 232
 
233
-	$user = get_userdata( $subscription->get_customer_id() );
234
-	if ( $user ) {
233
+	$user = get_userdata($subscription->get_customer_id());
234
+	if ($user) {
235 235
 
236 236
 		$username = sprintf(
237 237
 			'<a href="user-edit.php?user_id=%s">%s</a>',
238
-			absint( $user->ID ),
239
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
238
+			absint($user->ID),
239
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
240 240
 		);
241 241
 
242 242
 	}
243 243
 
244
-	echo wp_kses_post( $username );
244
+	echo wp_kses_post($username);
245 245
 }
246
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
246
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
247 247
 
248 248
 /**
249 249
  * Displays the subscription amount.
250 250
  *
251 251
  * @param WPInv_Subscription $subscription
252 252
  */
253
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
254
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
255
-	echo wp_kses_post( "<span>$amount</span>" );
253
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
254
+	$amount = getpaid_get_formatted_subscription_amount($subscription);
255
+	echo wp_kses_post("<span>$amount</span>");
256 256
 }
257
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
257
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
258 258
 
259 259
 /**
260 260
  * Displays the subscription id.
261 261
  *
262 262
  * @param WPInv_Subscription $subscription
263 263
  */
264
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
264
+function getpaid_admin_subscription_metabox_display_id($subscription) {
265 265
 
266 266
 	printf(
267 267
 		'<a href="%s">#%s</a>',
268
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
269
-		absint( $subscription->get_id() )
268
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
269
+		absint($subscription->get_id())
270 270
 	);
271 271
 
272 272
 }
273
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
273
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
274 274
 
275 275
 /**
276 276
  * Displays the subscription renewal date.
277 277
  *
278 278
  * @param WPInv_Subscription $subscription
279 279
  */
280
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
281
-	echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
280
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
281
+	echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
282 282
 }
283
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
283
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
284 284
 
285 285
 /**
286 286
  * Displays the subscription renewal date.
287 287
  *
288 288
  * @param WPInv_Subscription $subscription
289 289
  */
290
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
291
-	echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
290
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
291
+	echo esc_html(getpaid_format_date_value($subscription->get_expiration()));
292 292
 }
293
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
293
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
294 294
 
295 295
 /**
296 296
  * Displays the subscription renewal count.
297 297
  *
298 298
  * @param WPInv_Subscription $subscription
299 299
  */
300
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
300
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
301 301
 	$max_bills = $subscription->get_bill_times();
302
-	echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
302
+	echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
303 303
 }
304
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
304
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
305 305
 /**
306 306
  * Displays the subscription item.
307 307
  *
308 308
  * @param WPInv_Subscription $subscription
309 309
  * @param false|array $subscription_group
310 310
  */
311
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
311
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
312 312
 
313
-	if ( empty( $subscription_group ) ) {
314
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
313
+	if (empty($subscription_group)) {
314
+		echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
315 315
 		return;
316 316
 	}
317 317
 
318
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
319
-	echo wp_kses_post( implode( ' | ', $markup ) );
318
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
319
+	echo wp_kses_post(implode(' | ', $markup));
320 320
 
321 321
 }
322
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
322
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
323 323
 
324 324
 /**
325 325
  * Displays the subscription gateway.
326 326
  *
327 327
  * @param WPInv_Subscription $subscription
328 328
  */
329
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
329
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
330 330
 
331 331
 	$gateway = $subscription->get_gateway();
332 332
 
333
-	if ( ! empty( $gateway ) ) {
334
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
333
+	if (!empty($gateway)) {
334
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
335 335
 	} else {
336 336
 		echo '&mdash;';
337 337
 	}
338 338
 
339 339
 }
340
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
340
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
341 341
 
342 342
 /**
343 343
  * Displays the subscription status.
344 344
  *
345 345
  * @param WPInv_Subscription $subscription
346 346
  */
347
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
348
-	echo wp_kses_post( $subscription->get_status_label_html() );
347
+function getpaid_admin_subscription_metabox_display_status($subscription) {
348
+	echo wp_kses_post($subscription->get_status_label_html());
349 349
 }
350
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
350
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
351 351
 
352 352
 /**
353 353
  * Displays the subscription profile id.
354 354
  *
355 355
  * @param WPInv_Subscription $subscription
356 356
  */
357
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
357
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
358 358
 
359 359
 	$profile_id = $subscription->get_profile_id();
360 360
 
@@ -363,30 +363,30 @@  discard block
 block discarded – undo
363 363
 			'type'              => 'text',
364 364
 			'id'                => 'wpinv_subscription_profile_id',
365 365
 			'name'              => 'wpinv_subscription_profile_id',
366
-			'label'             => __( 'Profile Id', 'invoicing' ),
366
+			'label'             => __('Profile Id', 'invoicing'),
367 367
 			'label_type'        => 'hidden',
368
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
369
-			'value'             => esc_attr( $profile_id ),
368
+			'placeholder'       => __('Profile Id', 'invoicing'),
369
+			'value'             => esc_attr($profile_id),
370 370
 			'input_group_right' => '',
371 371
 			'no_wrap'           => true,
372 372
 		),
373 373
 		true
374 374
 	);
375 375
 
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		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>';
376
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
377
+	if (!empty($url)) {
378
+		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>';
379 379
 	}
380 380
 
381 381
 }
382
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
382
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
383 383
 
384 384
 /**
385 385
  * Displays the subscriptions update metabox.
386 386
  *
387 387
  * @param WPInv_Subscription $subscription
388 388
  */
389
-function getpaid_admin_subscription_update_metabox( $subscription ) {
389
+function getpaid_admin_subscription_update_metabox($subscription) {
390 390
 
391 391
 	?>
392 392
 	<div class="mt-3">
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 					'id'        => 'subscription_status_update_select',
400 400
 					'required'  => true,
401 401
 					'no_wrap'   => false,
402
-					'label'     => __( 'Subscription Status', 'invoicing' ),
403
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
402
+					'label'     => __('Subscription Status', 'invoicing'),
403
+					'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'),
404 404
 					'select2'   => true,
405
-					'value'     => $subscription->get_status( 'edit' ),
405
+					'value'     => $subscription->get_status('edit'),
406 406
 				),
407 407
 				true
408 408
 			);
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
415 415
 
416
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$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' );
416
+			$url    = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce');
417
+			$anchor = __('Renew Subscription', 'invoicing');
418
+			$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');
419 419
 
420
-			if ( $subscription->is_active() ) {
421
-			echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>";
420
+			if ($subscription->is_active()) {
421
+			echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>";
422 422
 			}
423 423
 
424 424
 	echo '</div></div>';
@@ -430,44 +430,44 @@  discard block
 block discarded – undo
430 430
  * @param WPInv_Subscription $subscription
431 431
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
432 432
  */
433
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
433
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
434 434
 
435 435
 	$columns = apply_filters(
436 436
 		'getpaid_subscription_related_invoices_columns',
437 437
 		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
438
+			'invoice'      => __('Invoice', 'invoicing'),
439
+			'relationship' => __('Relationship', 'invoicing'),
440
+			'date'         => __('Date', 'invoicing'),
441
+			'status'       => __('Status', 'invoicing'),
442
+			'total'        => __('Total', 'invoicing'),
443 443
 		),
444 444
 		$subscription
445 445
 	);
446 446
 
447 447
 	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
448
+	$payments = $subscription->get_child_payments(!is_admin());
449 449
 	$parent   = $subscription->get_parent_invoice();
450 450
 
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
451
+	if ($parent->exists()) {
452
+		$payments = array_merge(array($parent), $payments);
453 453
 	}
454 454
 
455 455
 	$table_class = 'w-100 bg-white';
456 456
 
457
-	if ( ! is_admin() ) {
457
+	if (!is_admin()) {
458 458
 		$table_class = 'table table-bordered';
459 459
 	}
460 460
 
461 461
 	?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464
-			<table class="<?php echo esc_attr( $table_class ); ?>">
464
+			<table class="<?php echo esc_attr($table_class); ?>">
465 465
 
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
469
+							foreach ($columns as $key => $label) {
470
+							echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
471 471
 							}
472 472
 						?>
473 473
 					</tr>
@@ -475,71 +475,71 @@  discard block
 block discarded – undo
475 475
 
476 476
 				<tbody>
477 477
 
478
-					<?php if ( empty( $payments ) ) : ?>
478
+					<?php if (empty($payments)) : ?>
479 479
 						<tr>
480
-							<td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted">
481
-								<?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?>
480
+							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
481
+								<?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?>
482 482
 							</td>
483 483
 						</tr>
484 484
 					<?php endif; ?>
485 485
 
486 486
 					<?php
487 487
 
488
-						foreach ( $payments as $payment ) :
488
+						foreach ($payments as $payment) :
489 489
 
490 490
 						// Ensure that we have an invoice.
491
-						$payment = new WPInv_Invoice( $payment );
491
+						$payment = new WPInv_Invoice($payment);
492 492
 
493 493
 						// Abort if the invoice is invalid...
494
-						if ( ! $payment->exists() ) {
494
+						if (!$payment->exists()) {
495 495
 							continue;
496 496
 							}
497 497
 
498 498
 						// ... or belongs to a different subscription.
499
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
499
+						if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
500 500
 							continue;
501 501
 							}
502 502
 
503 503
 						echo '<tr>';
504 504
 
505
-						foreach ( array_keys( $columns ) as $key ) {
505
+						foreach (array_keys($columns) as $key) {
506 506
 
507 507
 							echo "<td class='p-2 text-left'>";
508 508
 
509
-								switch ( $key ) {
509
+								switch ($key) {
510 510
 
511 511
 								case 'total':
512 512
 										echo '<strong>';
513
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
513
+										wpinv_the_price($payment->get_total(), $payment->get_currency());
514 514
 										echo '</strong>';
515 515
 									break;
516 516
 
517 517
 								case 'relationship':
518
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
518
+										echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing');
519 519
 									break;
520 520
 
521 521
 								case 'date':
522
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
522
+									echo esc_html(getpaid_format_date_value($payment->get_date_created()));
523 523
 									break;
524 524
 
525 525
 								case 'status':
526 526
 										$status = $payment->get_status_nicename();
527
-										if ( is_admin() ) {
527
+										if (is_admin()) {
528 528
 										$status = $payment->get_status_label_html();
529 529
 										}
530 530
 
531
-										echo wp_kses_post( $status );
531
+										echo wp_kses_post($status);
532 532
 									break;
533 533
 
534 534
 								case 'invoice':
535
-										$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
535
+										$link = esc_url(get_edit_post_link($payment->get_id()));
536 536
 
537
-										if ( ! is_admin() ) {
538
-										$link = esc_url( $payment->get_view_url() );
537
+										if (!is_admin()) {
538
+										$link = esc_url($payment->get_view_url());
539 539
 										}
540 540
 
541
-										$invoice = esc_html( $payment->get_number() );
542
-										echo wp_kses_post( "<a href='$link'>$invoice</a>" );
541
+										$invoice = esc_html($payment->get_number());
542
+										echo wp_kses_post("<a href='$link'>$invoice</a>");
543 543
 									break;
544 544
 										}
545 545
 
@@ -566,12 +566,12 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @param WPInv_Subscription $subscription
568 568
  */
569
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
569
+function getpaid_admin_subscription_item_details_metabox($subscription) {
570 570
 
571 571
 	// Fetch the subscription group.
572
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
572
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
573 573
 
574
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
574
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
575 575
 		return;
576 576
 	}
577 577
 
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
 	$columns = apply_filters(
580 580
 		'getpaid_subscription_item_details_columns',
581 581
 		array(
582
-			'item_name' => __( 'Item', 'invoicing' ),
583
-			'price'     => __( 'Price', 'invoicing' ),
584
-			'tax'       => __( 'Tax', 'invoicing' ),
585
-			'discount'  => __( 'Discount', 'invoicing' ),
582
+			'item_name' => __('Item', 'invoicing'),
583
+			'price'     => __('Price', 'invoicing'),
584
+			'tax'       => __('Tax', 'invoicing'),
585
+			'discount'  => __('Discount', 'invoicing'),
586 586
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
587
-			'recurring' => __( 'Subtotal', 'invoicing' ),
587
+			'recurring' => __('Subtotal', 'invoicing'),
588 588
 		),
589 589
 		$subscription
590 590
 	);
@@ -593,27 +593,27 @@  discard block
 block discarded – undo
593 593
 
594 594
 	$invoice = $subscription->get_parent_invoice();
595 595
 
596
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
597
-		unset( $columns['tax'] );
596
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
597
+		unset($columns['tax']);
598 598
 	}
599 599
 
600 600
 	$table_class = 'w-100 bg-white';
601 601
 
602
-	if ( ! is_admin() ) {
602
+	if (!is_admin()) {
603 603
 		$table_class = 'table table-bordered';
604 604
 	}
605 605
 
606 606
 	?>
607 607
 		<div class="m-0" style="overflow: auto;">
608 608
 
609
-			<table class="<?php echo esc_attr( $table_class ); ?>">
609
+			<table class="<?php echo esc_attr($table_class); ?>">
610 610
 
611 611
 				<thead>
612 612
 					<tr>
613 613
 						<?php
614 614
 
615
-							foreach ( $columns as $key => $label ) {
616
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
615
+							foreach ($columns as $key => $label) {
616
+							echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
617 617
 							}
618 618
 						?>
619 619
 					</tr>
@@ -623,48 +623,48 @@  discard block
 block discarded – undo
623 623
 
624 624
 					<?php
625 625
 
626
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
626
+						foreach ($subscription_group['items'] as $subscription_group_item) :
627 627
 
628 628
 						echo '<tr>';
629 629
 
630
-						foreach ( array_keys( $columns ) as $key ) {
630
+						foreach (array_keys($columns) as $key) {
631 631
 
632 632
 							$class = 'text-left';
633 633
 
634 634
 							echo "<td class='p-2 text-left'>";
635 635
 
636
-								switch ( $key ) {
636
+								switch ($key) {
637 637
 
638 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;
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 );
642
+										if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
643
+										echo esc_html($item_name);
644 644
 										} else {
645
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
645
+										printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
646 646
 											}
647 647
 
648 648
 									break;
649 649
 
650 650
 								case 'price':
651
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
651
+									wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency());
652 652
 									break;
653 653
 
654 654
 								case 'tax':
655
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
655
+									wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency());
656 656
 									break;
657 657
 
658 658
 								case 'discount':
659
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
659
+									wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency());
660 660
 									break;
661 661
 
662 662
 								case 'initial':
663
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
663
+									wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
664 664
 									break;
665 665
 
666 666
 								case 'recurring':
667
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
667
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>');
668 668
 									break;
669 669
 
670 670
 										}
@@ -677,24 +677,24 @@  discard block
 block discarded – undo
677 677
 
678 678
 						endforeach;
679 679
 
680
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
680
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
681 681
 
682 682
 						echo '<tr>';
683 683
 
684
-						foreach ( array_keys( $columns ) as $key ) {
684
+						foreach (array_keys($columns) as $key) {
685 685
 
686 686
 							$class = 'text-left';
687 687
 
688 688
 							echo "<td class='p-2 text-left'>";
689 689
 
690
-								switch ( $key ) {
690
+								switch ($key) {
691 691
 
692 692
 								case 'item_name':
693
-										echo esc_html( $subscription_group_fee['name'] );
693
+										echo esc_html($subscription_group_fee['name']);
694 694
 									break;
695 695
 
696 696
 								case 'price':
697
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
697
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
698 698
 									break;
699 699
 
700 700
 								case 'tax':
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 									break;
707 707
 
708 708
 								case 'initial':
709
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
709
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
710 710
 									break;
711 711
 
712 712
 								case 'recurring':
713
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
713
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>');
714 714
 									break;
715 715
 
716 716
 										}
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
  * @param WPInv_Subscription $subscription
740 740
  * @param bool $skip_current
741 741
  */
742
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
742
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
743 743
 
744 744
 	// Fetch the subscription groups.
745
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
745
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
746 746
 
747
-	if ( empty( $subscription_groups ) ) {
747
+	if (empty($subscription_groups)) {
748 748
 		return;
749 749
 	}
750 750
 
@@ -752,37 +752,37 @@  discard block
 block discarded – undo
752 752
 	$columns = apply_filters(
753 753
 		'getpaid_subscription_related_subscriptions_columns',
754 754
 		array(
755
-			'subscription' => __( 'Subscription', 'invoicing' ),
756
-			'start_date'   => __( 'Start Date', 'invoicing' ),
757
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
758
-			'renewals'     => __( 'Payments', 'invoicing' ),
759
-			'item'         => __( 'Items', 'invoicing' ),
760
-			'status'       => __( 'Status', 'invoicing' ),
755
+			'subscription' => __('Subscription', 'invoicing'),
756
+			'start_date'   => __('Start Date', 'invoicing'),
757
+			'renewal_date' => __('Next Payment', 'invoicing'),
758
+			'renewals'     => __('Payments', 'invoicing'),
759
+			'item'         => __('Items', 'invoicing'),
760
+			'status'       => __('Status', 'invoicing'),
761 761
 		),
762 762
 		$subscription
763 763
 	);
764 764
 
765
-	if ( $subscription->get_status() == 'pending' ) {
766
-		unset( $columns['start_date'], $columns['renewal_date'] );
765
+	if ($subscription->get_status() == 'pending') {
766
+		unset($columns['start_date'], $columns['renewal_date']);
767 767
 	}
768 768
 
769 769
 	$table_class = 'w-100 bg-white';
770 770
 
771
-	if ( ! is_admin() ) {
771
+	if (!is_admin()) {
772 772
 		$table_class = 'table table-bordered';
773 773
 	}
774 774
 
775 775
 	?>
776 776
 		<div class="m-0" style="overflow: auto;">
777 777
 
778
-			<table class="<?php echo esc_attr( $table_class ); ?>">
778
+			<table class="<?php echo esc_attr($table_class); ?>">
779 779
 
780 780
 				<thead>
781 781
 					<tr>
782 782
 						<?php
783 783
 
784
-							foreach ( $columns as $key => $label ) {
785
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
784
+							foreach ($columns as $key => $label) {
785
+							echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
786 786
 							}
787 787
 						?>
788 788
 					</tr>
@@ -792,62 +792,62 @@  discard block
 block discarded – undo
792 792
 
793 793
 					<?php
794 794
 
795
-						foreach ( $subscription_groups as $subscription_group ) :
795
+						foreach ($subscription_groups as $subscription_group) :
796 796
 
797 797
 						// Do not list current subscription.
798
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
798
+						if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
799 799
 							continue;
800 800
 							}
801 801
 
802 802
 						// Ensure the subscription exists.
803
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
803
+						$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
804 804
 
805
-						if ( ! $_suscription->exists() ) {
805
+						if (!$_suscription->exists()) {
806 806
 							continue;
807 807
 							}
808 808
 
809 809
 						echo '<tr>';
810 810
 
811
-						foreach ( array_keys( $columns ) as $key ) {
811
+						foreach (array_keys($columns) as $key) {
812 812
 
813 813
 							$class = 'text-left';
814 814
 
815 815
 							echo "<td class='p-2 text-left'>";
816 816
 
817
-								switch ( $key ) {
817
+								switch ($key) {
818 818
 
819 819
 								case 'status':
820
-										echo wp_kses_post( $_suscription->get_status_label_html() );
820
+										echo wp_kses_post($_suscription->get_status_label_html());
821 821
 									break;
822 822
 
823 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 ) );
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 826
 									break;
827 827
 
828 828
 								case 'renewals':
829 829
 									$max_bills = $_suscription->get_bill_times();
830
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
830
+									echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
831 831
 									break;
832 832
 
833 833
 								case 'renewal_date':
834
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
834
+										echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '&mdash;';
835 835
 									break;
836 836
 
837 837
 								case 'start_date':
838
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
838
+										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html(getpaid_format_date_value($_suscription->get_date_created()));
839 839
 									break;
840 840
 
841 841
 								case 'subscription':
842
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
842
+										$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
843 843
 										printf(
844 844
                                             '%1$s#%2$s%3$s',
845
-                                            '<a href="' . esc_url( $url ) . '">',
846
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
845
+                                            '<a href="' . esc_url($url) . '">',
846
+                                            '<strong>' . intval($_suscription->get_id()) . '</strong>',
847 847
 											'</a>'
848 848
                                         );
849 849
 
850
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
850
+											echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription));
851 851
 									break;
852 852
 
853 853
 										}
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   +39 added lines, -39 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
 /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
  * @return array
65 65
  */
66 66
 function wpinv_get_errors() {
67
-    $errors = getpaid_session()->get( 'wpinv_errors' );
68
-    return is_array( $errors ) ? $errors : array();
67
+    $errors = getpaid_session()->get('wpinv_errors');
68
+    return is_array($errors) ? $errors : array();
69 69
 }
70 70
 
71 71
 /**
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
  * @param string $error_message The error message.
76 76
  * @param string $type Either error, info, warning, primary, dark, light or success.
77 77
  */
78
-function wpinv_set_error( $error_id, $error_message, $type = 'error' ) {
78
+function wpinv_set_error($error_id, $error_message, $type = 'error') {
79 79
 
80 80
     $errors              = wpinv_get_errors();
81
-    $errors[ $error_id ] = array(
81
+    $errors[$error_id] = array(
82 82
         'type' => $type,
83 83
         'text' => $error_message,
84 84
     );
85 85
 
86
-    getpaid_session()->set( 'wpinv_errors', $errors );
86
+    getpaid_session()->set('wpinv_errors', $errors);
87 87
 }
88 88
 
89 89
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  *
92 92
  */
93 93
 function wpinv_has_errors() {
94
-    return count( wpinv_get_errors() ) > 0;
94
+    return count(wpinv_get_errors()) > 0;
95 95
 }
96 96
 
97 97
 /**
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
  *
100 100
  */
101 101
 function wpinv_clear_errors() {
102
-    getpaid_session()->set( 'wpinv_errors', null );
102
+    getpaid_session()->set('wpinv_errors', null);
103 103
 }
104 104
 
105 105
 /**
106 106
  * Clears a single error.
107 107
  *
108 108
  */
109
-function wpinv_unset_error( $error_id ) {
109
+function wpinv_unset_error($error_id) {
110 110
     $errors = wpinv_get_errors();
111 111
 
112
-    if ( isset( $errors[ $error_id ] ) ) {
113
-        unset( $errors[ $error_id ] );
112
+    if (isset($errors[$error_id])) {
113
+        unset($errors[$error_id]);
114 114
     }
115 115
 
116
-    getpaid_session()->set( 'wpinv_errors', $errors );
116
+    getpaid_session()->set('wpinv_errors', $errors);
117 117
 }
118 118
 
119 119
 /**
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
  * @param string $message Message to log.
125 125
  * @param string $version Version the message was added in.
126 126
  */
127
-function getpaid_doing_it_wrong( $function, $message, $version ) {
127
+function getpaid_doing_it_wrong($function, $message, $version) {
128 128
 
129 129
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
130 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}." );
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 134
 	} else {
135
-		_doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) );
135
+		_doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version));
136 136
 	}
137 137
 
138 138
 }
@@ -146,41 +146,41 @@  discard block
 block discarded – undo
146 146
  * @param string $line The line that contains the error.
147 147
  * @param bool $exit Whether or not to exit function execution.
148 148
  */
149
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
149
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
150 150
 
151
-    if ( true === apply_filters( 'wpinv_log_errors', true ) ) {
151
+    if (true === apply_filters('wpinv_log_errors', true)) {
152 152
 
153 153
         // Ensure the log is a scalar.
154
-        if ( ! is_scalar( $log ) ) {
155
-            $log = print_r( $log, true );
154
+        if (!is_scalar($log)) {
155
+            $log = print_r($log, true);
156 156
         }
157 157
 
158 158
         // Add title.
159
-        if ( ! empty( $title ) ) {
160
-            $log  = $title . ' ' . trim( $log );
159
+        if (!empty($title)) {
160
+            $log = $title . ' ' . trim($log);
161 161
         }
162 162
 
163 163
         // Add the file to the label.
164
-        if ( ! empty( $file ) ) {
164
+        if (!empty($file)) {
165 165
             $log .= ' in ' . $file;
166 166
         }
167 167
 
168 168
         // Add the line number to the label.
169
-        if ( ! empty( $line ) ) {
169
+        if (!empty($line)) {
170 170
             $log .= ' on line ' . $line;
171 171
         }
172 172
 
173 173
         // Log the message.
174
-        error_log( trim( $log ) );
174
+        error_log(trim($log));
175 175
 
176 176
         // ... and a backtrace.
177
-        if ( false !== $title && false !== $file ) {
178
-            error_log( 'Backtrace ' . wp_debug_backtrace_summary() );
177
+        if (false !== $title && false !== $file) {
178
+            error_log('Backtrace ' . wp_debug_backtrace_summary());
179 179
         }
180 180
 }
181 181
 
182 182
     // Maybe exit.
183
-    if ( $exit ) {
183
+    if ($exit) {
184 184
         exit;
185 185
     }
186 186
 
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.
includes/admin/html-admin-page-addons.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if ( $current_tab == 'membership' ) {
26
+        if ( $current_tab == 'membership' ) {
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' );
40
-						echo wp_kses_post( $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ) );
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' );
40
+                        echo wp_kses_post( $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ) );
41
+                        ?>
42 42
 					</p>
43 43
 				<?php } ?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ( $addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ( $addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,26 +126,26 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		} else {
130
-			$installed_plugins = get_plugins();
129
+        } else {
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ( $addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				//print_r($addons);
134
-				?>
132
+            if ( $addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                //print_r($addons);
134
+                ?>
135 135
 				<ul class="wpi-products">
136 136
                 <?php
137 137
                 foreach ( $addons as $addon ) :
138 138
                         if ( 965 == $addon->info->id ) {
139 139
 continue;}// don't show quote add on
140
-						?>
140
+                        ?>
141 141
                         <li class="wpi-product">
142 142
 								<div class="wpi-product-title">
143 143
 									<h3>
144 144
                                     <?php
145
-										if ( ! empty( $addon->info->excerpt ) ) {
146
-										wpi_help_tip( $addon->info->excerpt, false, false, true );
147
-										}
148
-										echo esc_html( $addon->info->title );
145
+                                        if ( ! empty( $addon->info->excerpt ) ) {
146
+                                        wpi_help_tip( $addon->info->excerpt, false, false, true );
147
+                                        }
148
+                                        echo esc_html( $addon->info->title );
149 149
                                         ?>
150 150
                                         </h3>
151 151
 								</div>
@@ -156,32 +156,32 @@  discard block
 block discarded – undo
156 156
 									<?php
157 157
                                     endif;
158 158
 
159
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
160
-										$addon->info->slug = 'getpaid-stripe-payments';
161
-										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
162
-									}
163
-
164
-									if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) {
165
-										echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
166
-										echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
167
-										echo '</a>';
168
-									} elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) {
169
-										if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
170
-											$url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' );
171
-										} else {
172
-											// if installed show activation link
173
-											if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) {
174
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
175
-											} else {
176
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
177
-											}
178
-										}
179
-										echo '<a href="' . esc_url( $url ) . '" class="thickbox">';
180
-										echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
181
-										echo '</a>';
182
-									}
183
-
184
-									?>
159
+                                    if ( 'stripe-payment-gateway' == $addon->info->slug ) {
160
+                                        $addon->info->slug = 'getpaid-stripe-payments';
161
+                                        $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
162
+                                    }
163
+
164
+                                    if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) {
165
+                                        echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
166
+                                        echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
167
+                                        echo '</a>';
168
+                                    } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) {
169
+                                        if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
170
+                                            $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' );
171
+                                        } else {
172
+                                            // if installed show activation link
173
+                                            if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) {
174
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
175
+                                            } else {
176
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
177
+                                            }
178
+                                        }
179
+                                        echo '<a href="' . esc_url( $url ) . '" class="thickbox">';
180
+                                        echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
181
+                                        echo '</a>';
182
+                                    }
183
+
184
+                                    ?>
185 185
 
186 186
 								</span>
187 187
 
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 								<span class="wpi-product-button">
190 190
 									<?php
191 191
                                     $addon_obj->output_button( $addon );
192
-									?>
192
+                                    ?>
193 193
 								</span>
194 194
 
195 195
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
196 196
 			<?php
197 197
             endif;
198
-		}
198
+        }
199 199
 }
200
-	?>
200
+    ?>
201 201
 
202 202
 
203 203
 	<div class="clearfix" ></div>
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 			<input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button>
217 217
 			<br>
218 218
 			<?php
219
-			printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' );
220
-			?>
219
+            printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' );
220
+            ?>
221 221
 		</span>
222 222
 	</div>
223 223
 
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -3,27 +3,27 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
11 11
 <div class="wrap wpi_addons_wrap">
12
-	<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
12
+	<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
13 13
 
14
-	<?php if ( $tabs ) { ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if ( $current_tab == 'membership' ) {
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?>
36
-					<h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?>
36
+					<h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' );
40
-						echo wp_kses_post( $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ) );
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo wp_kses_post($wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php } ?>
44 44
 
45 45
 				<div class="membership-cta-contet">
46 46
 					<div class="main-cta">
47
-							<h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2>
47
+							<h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2>
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51 51
 									$addon_obj = new WPInv_Admin_Addons();
52
-									if ( $addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
52
+									if ($addons = $addon_obj->get_section_data('addons')) {
53
+										foreach ($addons as $addon) {
54
+											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
55 55
 										}
56 56
 									}
57 57
 									?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
61
-										<h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3>
61
+										<h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3>
62 62
 										<h4>$99</h4>
63
-										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a>
63
+										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a>
64 64
 									</div>
65
-									<h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3>
65
+									<h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>';
68
+										if ($addons = $addon_obj->get_section_data('gateways')) {
69
+											foreach ($addons as $addon) {
70
+												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
71 71
 											}
72 72
 										}
73 73
 										?>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > ';
84
+									echo '<img src="' . esc_url(plugins_url('images/t-image2.png', dirname(__FILE__))) . '" > ';
85 85
 								?>
86 86
 							</div>
87 87
 							<div class="t-content">
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > ';
104
+									echo '<img src="' . esc_url(plugins_url('images/t-image1.png', dirname(__FILE__))) . '" > ';
105 105
 								?>
106 106
 							</div>
107 107
 							<div class="t-content">
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 						</div>
118 118
 					</div>
119 119
 					<div class="member-footer">
120
-						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a>
121
-						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a>
120
+						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a>
121
+						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a>
122 122
 					</div>
123 123
 				</div>
124 124
 
@@ -129,55 +129,55 @@  discard block
 block discarded – undo
129 129
 		} else {
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ( $addons = $addon_obj->get_section_data( $current_tab ) ) :
132
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
133 133
 				//print_r($addons);
134 134
 				?>
135 135
 				<ul class="wpi-products">
136 136
                 <?php
137
-                foreach ( $addons as $addon ) :
138
-                        if ( 965 == $addon->info->id ) {
139
-continue;}// don't show quote add on
137
+                foreach ($addons as $addon) :
138
+                        if (965 == $addon->info->id) {
139
+continue; }// don't show quote add on
140 140
 						?>
141 141
                         <li class="wpi-product">
142 142
 								<div class="wpi-product-title">
143 143
 									<h3>
144 144
                                     <?php
145
-										if ( ! empty( $addon->info->excerpt ) ) {
146
-										wpi_help_tip( $addon->info->excerpt, false, false, true );
145
+										if (!empty($addon->info->excerpt)) {
146
+										wpi_help_tip($addon->info->excerpt, false, false, true);
147 147
 										}
148
-										echo esc_html( $addon->info->title );
148
+										echo esc_html($addon->info->title);
149 149
                                         ?>
150 150
                                         </h3>
151 151
 								</div>
152 152
 
153 153
 								<span class="wpi-product-image">
154
-									<?php if ( ! empty( $addon->info->thumbnail ) ) : ?>
155
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
154
+									<?php if (!empty($addon->info->thumbnail)) : ?>
155
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
156 156
 									<?php
157 157
                                     endif;
158 158
 
159
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
159
+									if ('stripe-payment-gateway' == $addon->info->slug) {
160 160
 										$addon->info->slug = 'getpaid-stripe-payments';
161 161
 										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
162 162
 									}
163 163
 
164
-									if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) {
165
-										echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
166
-										echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
164
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') {
165
+										echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
166
+										echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>';
167 167
 										echo '</a>';
168
-									} elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) {
169
-										if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
170
-											$url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' );
168
+									} elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) {
169
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
170
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true');
171 171
 										} else {
172 172
 											// if installed show activation link
173
-											if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) {
173
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
174 174
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
175 175
 											} else {
176 176
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
177 177
 											}
178 178
 										}
179
-										echo '<a href="' . esc_url( $url ) . '" class="thickbox">';
180
-										echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>';
179
+										echo '<a href="' . esc_url($url) . '" class="thickbox">';
180
+										echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>';
181 181
 										echo '</a>';
182 182
 									}
183 183
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
 								<span class="wpi-product-button">
190 190
 									<?php
191
-                                    $addon_obj->output_button( $addon );
191
+                                    $addon_obj->output_button($addon);
192 192
 									?>
193 193
 								</span>
194 194
 
@@ -202,21 +202,21 @@  discard block
 block discarded – undo
202 202
 
203 203
 	<div class="clearfix" ></div>
204 204
 
205
-	<?php if ( $current_tab == 'addons' ) { ?>
206
-	<p><?php printf(  esc_attr__( 'All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/addons/">','</a>' ); ?></p>
207
-	<?php } if ( $current_tab == 'gateways' ) { ?>
208
-    <p><?php printf( esc_attr__( 'All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/gateways/">','</a>'  ); ?></p>
205
+	<?php if ($current_tab == 'addons') { ?>
206
+	<p><?php printf(esc_attr__('All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/addons/">', '</a>'); ?></p>
207
+	<?php } if ($current_tab == 'gateways') { ?>
208
+    <p><?php printf(esc_attr__('All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/gateways/">', '</a>'); ?></p>
209 209
     <?php } ?>
210 210
 
211
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(  sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ) ); ?></span></div>
212
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ) ); ?></span></div>
211
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'))); ?></span></div>
212
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true'))); ?></span></div>
213 213
 	<div id="wpeu-licence-popup" style="display:none;">
214 214
 		<span class="wpi-notification noti-white">
215
-			<h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3>
216
-			<input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button>
215
+			<h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3>
216
+			<input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button>
217 217
 			<br>
218 218
 			<?php
219
-			printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' );
219
+			printf(esc_html__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
220 220
 			?>
221 221
 		</span>
222 222
 	</div>
Please login to merge, or discard this patch.