Passed
Push — master ( 3cea45...1efd62 )
by Brian
04:26
created
templates/invoice/invoice-meta.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$class = ! is_singular( 'page' ) ? 'px-1' : '';
12
+$class = !is_singular('page') ? 'px-1' : '';
13 13
 ?>
14 14
 
15
-        <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?>
15
+        <?php do_action('getpaid_before_invoice_meta', $invoice); ?>
16 16
         <div class="getpaid-invoice-meta-data">
17 17
 
18
-            <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?>
18
+            <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?>
19 19
             <table class="table table-bordered">
20 20
                 <tbody>
21 21
 
22
-                    <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?>
23
-                    <?php foreach ( $meta as $key => $data ) : ?>
22
+                    <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?>
23
+                    <?php foreach ($meta as $key => $data) : ?>
24 24
 
25
-                        <?php if ( ! empty( $data['value'] ) ) : ?>
25
+                        <?php if (!empty($data['value'])) : ?>
26 26
 
27
-                            <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?>
27
+                            <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?>
28 28
 
29
-                            <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>">
29
+                            <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>">
30 30
 
31 31
                                 <th class="<?php echo $class; ?>">
32
-                                    <?php echo sanitize_text_field( $data['label'] ); ?>
32
+                                    <?php echo sanitize_text_field($data['label']); ?>
33 33
                                 </th>
34 34
 
35 35
                                 <td class="<?php echo $class; ?>">
36
-                                    <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span>
36
+                                    <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span>
37 37
                                 </td>
38 38
 
39 39
                             </tr>
40 40
 
41
-                            <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?>
41
+                            <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?>
42 42
 
43 43
                         <?php endif; ?>
44 44
                     
45 45
                     <?php endforeach; ?>
46
-                    <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?>
46
+                    <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?>
47 47
 
48 48
                 </tbody>
49 49
             </table>
50
-            <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?>
50
+            <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?>
51 51
 
52 52
 
53 53
         </div>
54
-        <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?>
54
+        <?php do_action('getpaid_after_invoice_meta', $invoice); ?>
55 55
 
56 56
 <?php
Please login to merge, or discard this patch.
templates/invoice/header-left-actions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
8 8
  * @var WPInv_Invoice $invoice
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 ?>
14 14
 
15 15
         <div class="getpaid-header-left-actions">
16 16
 
17
-            <?php if ( $invoice->is_type( 'invoice' ) && $invoice->needs_payment() && ! $invoice->is_held() ): ?>
18
-                <a class="btn btn-sm btn-primary invoice-action-pay" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>">
19
-                    <?php _e( 'Pay For Invoice', 'invoicing' ); ?>
17
+            <?php if ($invoice->is_type('invoice') && $invoice->needs_payment() && !$invoice->is_held()): ?>
18
+                <a class="btn btn-sm btn-primary invoice-action-pay" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>">
19
+                    <?php _e('Pay For Invoice', 'invoicing'); ?>
20 20
                 </a>
21 21
             <?php endif; ?>
22 22
 
23
-            <?php if ( $invoice->is_type( 'invoice' ) && $invoice->is_paid() ): ?>
24
-                <a class="btn btn-sm btn-info invoice-action-receipt" href="<?php echo esc_url( $invoice->get_receipt_url() ); ?>">
25
-                    <?php _e( 'View Receipt', 'invoicing' ); ?>
23
+            <?php if ($invoice->is_type('invoice') && $invoice->is_paid()): ?>
24
+                <a class="btn btn-sm btn-info invoice-action-receipt" href="<?php echo esc_url($invoice->get_receipt_url()); ?>">
25
+                    <?php _e('View Receipt', 'invoicing'); ?>
26 26
                 </a>
27 27
             <?php endif; ?>
28 28
 
29
-            <?php do_action( 'wpinv_invoice_display_left_actions', $invoice ); ?>
29
+            <?php do_action('wpinv_invoice_display_left_actions', $invoice); ?>
30 30
 
31 31
         </div>
32 32
 
Please login to merge, or discard this patch.
templates/wpinv-invoice-print.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Fetch the invoice.
13
-$invoice = new WPInv_Invoice( $GLOBALS['post'] );
13
+$invoice = new WPInv_Invoice($GLOBALS['post']);
14 14
 
15 15
 // Abort if it does not exist.
16
-if ( $invoice->get_id() == 0 ) {
16
+if ($invoice->get_id() == 0) {
17 17
     exit;
18 18
 }
19 19
 
20 20
 // Fires before printing an invoice.
21
-do_action( 'wpinv_invoice_print_before_display', $invoice );
21
+do_action('wpinv_invoice_print_before_display', $invoice);
22 22
 
23 23
 ?><!DOCTYPE html>
24 24
 
@@ -27,24 +27,24 @@  discard block
 block discarded – undo
27 27
 
28 28
     <head>
29 29
 
30
-		<meta charset="<?php bloginfo( 'charset' ); ?>">
30
+		<meta charset="<?php bloginfo('charset'); ?>">
31 31
         <meta name="viewport" content="width=device-width, initial-scale=1.0" >
32 32
 
33 33
         <meta name="robots" content="noindex,nofollow">
34 34
 
35 35
 		<link rel="profile" href="https://gmpg.org/xfn/11">
36 36
 
37
-        <title>#<?php echo sanitize_text_field( $invoice->get_number() ); ?></title>
37
+        <title>#<?php echo sanitize_text_field($invoice->get_number()); ?></title>
38 38
 
39
-        <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
39
+        <?php do_action('wpinv_invoice_print_head', $invoice); ?>
40 40
 
41 41
     </head>
42 42
     
43 43
 
44 44
     <body class="body wpinv wpinv-print" style="font-weight: 400;">
45 45
 
46
-        <?php do_action( 'getpaid_invoice', $invoice ); ?>
47
-        <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?>
46
+        <?php do_action('getpaid_invoice', $invoice); ?>
47
+        <?php do_action('wpinv_invoice_print_body_end', $invoice); ?>
48 48
 
49 49
     </body>
50 50
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +619 added lines, -619 removed lines patch added patch discarded remove patch
@@ -13,604 +13,604 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-
29
-		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
32
-
33
-		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
40
-
41
-		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
-
46
-		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
49
-
50
-		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
53
-	}
54
-
55
-	/**
56
-	 * Post updated messages.
57
-	 */
58
-	public static function post_updated_messages( $messages ) {
59
-		global $post;
60
-
61
-		$messages['wpi_discount'] = array(
62
-			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
73
-		);
74
-
75
-		$messages['wpi_payment_form'] = array(
76
-			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
87
-		);
88
-
89
-		return $messages;
90
-
91
-	}
92
-
93
-	/**
94
-	 * Post row actions.
95
-	 */
96
-	public static function post_row_actions( $actions, $post ) {
97
-
98
-		$post = get_post( $post );
99
-
100
-		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
104
-		}
105
-
106
-		return $actions;
107
-	}
108
-
109
-	/**
110
-	 * Returns an array of invoice table columns.
111
-	 */
112
-	public static function invoice_columns( $columns ) {
113
-
114
-		$columns = array(
115
-			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
123
-		);
124
-
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
126
-	}
127
-
128
-	/**
129
-	 * Displays invoice table columns.
130
-	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
132
-
133
-		$invoice = new WPInv_Invoice( $post_id );
134
-
135
-		switch ( $column_name ) {
136
-
137
-			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
140
-				echo "<span title='$date_time'>$date</span>";
141
-				break;
142
-
143
-			case 'amount' :
144
-
145
-				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
147
-
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
150
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151
-				} else {
152
-
153
-					$discount = $invoice->get_total_discount();
154
-
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
157
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158
-					} else {
159
-						echo $formated_amount;
160
-					}
161
-
162
-				}
163
-
164
-				break;
165
-
166
-			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
169
-
170
-				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
174 19
 
175
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176
-				} else {
177
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
178
-				}
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
179 22
 
180
-				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
182 25
 
183
-					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
186
-					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
188
-					}
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
189 28
 
190
-					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
192
-						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
29
+        // Invoice table columns.
30
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
194 32
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
197
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198
-						}
199
-					}
33
+        // Items table columns.
34
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
200 40
 
201
-				}
41
+        // Payment forms columns.
42
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
202 45
 
203
-				break;
46
+        // Discount table columns.
47
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
204 49
 
205
-			case 'recurring':
50
+        // Deleting posts.
51
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
53
+    }
206 54
 
207
-				if ( $invoice->is_recurring() ) {
208
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209
-				} else {
210
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
211
-				}
212
-				break;
55
+    /**
56
+     * Post updated messages.
57
+     */
58
+    public static function post_updated_messages( $messages ) {
59
+        global $post;
60
+
61
+        $messages['wpi_discount'] = array(
62
+            0   => '',
63
+            1   => __( 'Discount updated.', 'invoicing' ),
64
+            2   => __( 'Custom field updated.', 'invoicing' ),
65
+            3   => __( 'Custom field deleted.', 'invoicing' ),
66
+            4   => __( 'Discount updated.', 'invoicing' ),
67
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
+            6   => __( 'Discount updated.', 'invoicing' ),
69
+            7   => __( 'Discount saved.', 'invoicing' ),
70
+            8   => __( 'Discount submitted.', 'invoicing' ),
71
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
+            10  => __( 'Discount draft updated.', 'invoicing' ),
73
+        );
74
+
75
+        $messages['wpi_payment_form'] = array(
76
+            0   => '',
77
+            1   => __( 'Payment Form updated.', 'invoicing' ),
78
+            2   => __( 'Custom field updated.', 'invoicing' ),
79
+            3   => __( 'Custom field deleted.', 'invoicing' ),
80
+            4   => __( 'Payment Form updated.', 'invoicing' ),
81
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
+            6   => __( 'Payment Form updated.', 'invoicing' ),
83
+            7   => __( 'Payment Form saved.', 'invoicing' ),
84
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
85
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
87
+        );
88
+
89
+        return $messages;
90
+
91
+    }
92
+
93
+    /**
94
+     * Post row actions.
95
+     */
96
+    public static function post_row_actions( $actions, $post ) {
97
+
98
+        $post = get_post( $post );
99
+
100
+        // We do not want to edit the default payment form.
101
+        if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
+            unset( $actions['trash'] );
103
+            unset( $actions['inline hide-if-no-js'] );
104
+        }
105
+
106
+        return $actions;
107
+    }
108
+
109
+    /**
110
+     * Returns an array of invoice table columns.
111
+     */
112
+    public static function invoice_columns( $columns ) {
113
+
114
+        $columns = array(
115
+            'cb'                => $columns['cb'],
116
+            'number'            => __( 'Invoice', 'invoicing' ),
117
+            'customer'          => __( 'Customer', 'invoicing' ),
118
+            'invoice_date'      => __( 'Date', 'invoicing' ),
119
+            'amount'            => __( 'Amount', 'invoicing' ),
120
+            'recurring'         => __( 'Recurring', 'invoicing' ),
121
+            'status'            => __( 'Status', 'invoicing' ),
122
+            'wpi_actions'       => __( 'Actions', 'invoicing' ),
123
+        );
124
+
125
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
126
+    }
127
+
128
+    /**
129
+     * Displays invoice table columns.
130
+     */
131
+    public static function display_invoice_columns( $column_name, $post_id ) {
132
+
133
+        $invoice = new WPInv_Invoice( $post_id );
134
+
135
+        switch ( $column_name ) {
136
+
137
+            case 'invoice_date' :
138
+                $date_time = esc_attr( $invoice->get_created_date() );
139
+                $date      = getpaid_format_date_value( $date_time );
140
+                echo "<span title='$date_time'>$date</span>";
141
+                break;
142
+
143
+            case 'amount' :
144
+
145
+                $amount = $invoice->get_total();
146
+                $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
147
+
148
+                if ( $invoice->is_refunded() ) {
149
+                    $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
150
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151
+                } else {
152
+
153
+                    $discount = $invoice->get_total_discount();
154
+
155
+                    if ( ! empty( $discount ) ) {
156
+                        $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
157
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158
+                    } else {
159
+                        echo $formated_amount;
160
+                    }
161
+
162
+                }
163
+
164
+                break;
165
+
166
+            case 'status' :
167
+                $status       = sanitize_text_field( $invoice->get_status() );
168
+                $status_label = sanitize_text_field( $invoice->get_status_nicename() );
169
+
170
+                // If it is paid, show the gateway title.
171
+                if ( $invoice->is_paid() ) {
172
+                    $gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
174
+
175
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176
+                } else {
177
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
178
+                }
179
+
180
+                // If it is not paid, display the overdue and view status.
181
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
213 182
 
214
-			case 'number' :
183
+                    // Invoice view status.
184
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
186
+                    } else {
187
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
188
+                    }
215 189
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
190
+                    // Display the overview status.
191
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
192
+                        $due_date = $invoice->get_due_date();
193
+                        $fomatted = getpaid_format_date( $due_date );
219 194
 
220
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
195
+                        if ( ! empty( $fomatted ) ) {
196
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
197
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198
+                        }
199
+                    }
221 200
 
222
-				break;
201
+                }
223 202
 
224
-			case 'customer' :
203
+                break;
204
+
205
+            case 'recurring':
206
+
207
+                if ( $invoice->is_recurring() ) {
208
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209
+                } else {
210
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
211
+                }
212
+                break;
213
+
214
+            case 'number' :
215
+
216
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
+                $invoice_number  = sanitize_text_field( $invoice->get_number() );
218
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
219
+
220
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221
+
222
+                break;
223
+
224
+            case 'customer' :
225 225
 	
226
-				$customer_name = $invoice->get_user_full_name();
226
+                $customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
229
-					$customer_name = $invoice->get_email();
230
-				}
228
+                if ( empty( $customer_name ) ) {
229
+                    $customer_name = $invoice->get_email();
230
+                }
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
235
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236
-				} else {
237
-					echo '<div>&mdash;</div>';
238
-				}
232
+                if ( ! empty( $customer_name ) ) {
233
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
235
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236
+                } else {
237
+                    echo '<div>&mdash;</div>';
238
+                }
239
+
240
+                break;
241
+
242
+            case 'wpi_actions' :
243
+
244
+                if ( $invoice->is_draft() ) {
245
+                    return;
246
+                }
247
+
248
+                $url    = esc_url( $invoice->get_view_url() );
249
+                $print  = esc_attr__( 'Print invoice', 'invoicing' );
250
+                echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251
+
252
+                $url    = esc_url(
253
+                    wp_nonce_url(
254
+                        add_query_arg(
255
+                            array(
256
+                                'getpaid-admin-action' => 'send_invoice',
257
+                                'invoice_id'           => $invoice->get_id()
258
+                            )
259
+                        ),
260
+                        'getpaid-nonce',
261
+                        'getpaid-nonce'
262
+                    )
263
+                );
264
+
265
+                $send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
266
+                echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267
+
268
+                break;
269
+        }
239 270
 
240
-				break;
271
+    }
241 272
 
242
-			case 'wpi_actions' :
243
-
244
-				if ( $invoice->is_draft() ) {
245
-					return;
246
-				}
247
-
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
250
-				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
273
+    /**
274
+     * Returns an array of payment forms table columns.
275
+     */
276
+    public static function payment_form_columns( $columns ) {
251 277
 
252
-				$url    = esc_url(
253
-					wp_nonce_url(
254
-						add_query_arg(
255
-							array(
256
-								'getpaid-admin-action' => 'send_invoice',
257
-								'invoice_id'           => $invoice->get_id()
258
-							)
259
-						),
260
-						'getpaid-nonce',
261
-						'getpaid-nonce'
262
-					)
263
-				);
278
+        $columns = array(
279
+            'cb'                => $columns['cb'],
280
+            'title'             => __( 'Name', 'invoicing' ),
281
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
+            'earnings'          => __( 'Revenue', 'invoicing' ),
283
+            'refunds'           => __( 'Refunded', 'invoicing' ),
284
+            'items'             => __( 'Items', 'invoicing' ),
285
+            'date'              => __( 'Date', 'invoicing' ),
286
+        );
264 287
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
266
-				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
288
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
267 289
 
268
-				break;
269
-		}
290
+    }
270 291
 
271
-	}
292
+    /**
293
+     * Displays payment form table columns.
294
+     */
295
+    public static function display_payment_form_columns( $column_name, $post_id ) {
272 296
 
273
-	/**
274
-	 * Returns an array of payment forms table columns.
275
-	 */
276
-	public static function payment_form_columns( $columns ) {
297
+        // Retrieve the payment form.
298
+        $form = new GetPaid_Payment_Form( $post_id );
277 299
 
278
-		$columns = array(
279
-			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
286
-		);
300
+        switch ( $column_name ) {
287 301
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
302
+            case 'earnings' :
303
+                echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
304
+                break;
289 305
 
290
-	}
306
+            case 'refunds' :
307
+                echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
308
+                break;
291 309
 
292
-	/**
293
-	 * Displays payment form table columns.
294
-	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
310
+            case 'refunds' :
311
+                echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
312
+                break;
296 313
 
297
-		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
314
+            case 'shortcode' :
299 315
 
300
-		switch ( $column_name ) {
316
+                if ( $form->is_default() ) {
317
+                    echo '&mdash;';
318
+                } else {
319
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
320
+                }
301 321
 
302
-			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
304
-				break;
322
+                break;
305 323
 
306
-			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
308
-				break;
324
+            case 'items' :
309 325
 
310
-			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
312
-				break;
326
+                $items = $form->get_items();
313 327
 
314
-			case 'shortcode' :
328
+                if ( $form->is_default() || empty( $items ) ) {
329
+                    echo '&mdash;';
330
+                    return;
331
+                }
315 332
 
316
-				if ( $form->is_default() ) {
317
-					echo '&mdash;';
318
-				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
320
-				}
333
+                $_items = array();
321 334
 
322
-				break;
335
+                foreach ( $items as $item ) {
336
+                    $url = $item->get_edit_url();
323 337
 
324
-			case 'items' :
338
+                    if ( empty( $url ) ) {
339
+                        $_items[] = sanitize_text_field( $item->get_name() );
340
+                    } else {
341
+                        $_items[] = sprintf(
342
+                            '<a href="%s">%s</a>',
343
+                            esc_url( $url ),
344
+                            sanitize_text_field( $item->get_name() )
345
+                        );
346
+                    }
325 347
 
326
-				$items = $form->get_items();
348
+                }
327 349
 
328
-				if ( $form->is_default() || empty( $items ) ) {
329
-					echo '&mdash;';
330
-					return;
331
-				}
350
+                echo implode( '<br>', $_items );
332 351
 
333
-				$_items = array();
352
+                break;
334 353
 
335
-				foreach ( $items as $item ) {
336
-					$url = $item->get_edit_url();
354
+        }
337 355
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
340
-					} else {
341
-						$_items[] = sprintf(
342
-							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
345
-						);
346
-					}
356
+    }
347 357
 
348
-				}
358
+    /**
359
+     * Filters post states.
360
+     */
361
+    public static function filter_payment_form_state( $post_states, $post ) {
349 362
 
350
-				echo implode( '<br>', $_items );
363
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
365
+        }
366
+	
367
+        return $post_states;
368
+
369
+    }
370
+
371
+    /**
372
+     * Returns an array of coupon table columns.
373
+     */
374
+    public static function discount_columns( $columns ) {
375
+
376
+        $columns = array(
377
+            'cb'                => $columns['cb'],
378
+            'title'             => __( 'Name', 'invoicing' ),
379
+            'code'              => __( 'Code', 'invoicing' ),
380
+            'amount'            => __( 'Amount', 'invoicing' ),
381
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
+            'start_date'        => __( 'Start Date', 'invoicing' ),
383
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
384
+        );
385
+
386
+        return apply_filters( 'wpi_discount_table_columns', $columns );
387
+    }
351 388
 
352
-				break;
389
+    /**
390
+     * Filters post states.
391
+     */
392
+    public static function filter_discount_state( $post_states, $post ) {
353 393
 
354
-		}
394
+        if ( 'wpi_discount' == $post->post_type ) {
355 395
 
356
-	}
396
+            $discount = new WPInv_Discount( $post );
357 397
 
358
-	/**
359
-	 * Filters post states.
360
-	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
398
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
362 399
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
365
-		}
366
-	
367
-		return $post_states;
368
-
369
-	}
370
-
371
-	/**
372
-	 * Returns an array of coupon table columns.
373
-	 */
374
-	public static function discount_columns( $columns ) {
375
-
376
-		$columns = array(
377
-			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
384
-		);
385
-
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
387
-	}
388
-
389
-	/**
390
-	 * Filters post states.
391
-	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
393
-
394
-		if ( 'wpi_discount' == $post->post_type ) {
395
-
396
-			$discount = new WPInv_Discount( $post );
397
-
398
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
399
-
400
-			if ( $status != 'publish' ) {
401
-				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
403
-				);
404
-			}
405
-
406
-			return array();
407
-
408
-		}
409
-
410
-		return $post_states;
411
-
412
-	}
413
-
414
-	/**
415
-	 * Returns an array of items table columns.
416
-	 */
417
-	public static function item_columns( $columns ) {
418
-
419
-		$columns = array(
420
-			'cb'                => $columns['cb'],
421
-			'title'             => __( 'Name', 'invoicing' ),
422
-			'price'             => __( 'Price', 'invoicing' ),
423
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
424
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
425
-			'type'              => __( 'Type', 'invoicing' ),
426
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
427
-		);
428
-
429
-		if ( ! wpinv_use_taxes() ) {
430
-			unset( $columns['vat_rule'] );
431
-			unset( $columns['vat_class'] );
432
-		}
433
-
434
-		return apply_filters( 'wpi_item_table_columns', $columns );
435
-	}
436
-
437
-	/**
438
-	 * Returns an array of sortable items table columns.
439
-	 */
440
-	public static function sortable_item_columns( $columns ) {
441
-
442
-		return array_merge(
443
-			$columns,
444
-			array(
445
-				'price'     => 'price',
446
-				'vat_rule'  => 'vat_rule',
447
-				'vat_class' => 'vat_class',
448
-				'type'      => 'type',
449
-			)
450
-		);
451
-
452
-	}
453
-
454
-	/**
455
-	 * Displays items table columns.
456
-	 */
457
-	public static function display_item_columns( $column_name, $post_id ) {
400
+            if ( $status != 'publish' ) {
401
+                return array(
402
+                    'discount_status' => wpinv_discount_status( $status ),
403
+                );
404
+            }
405
+
406
+            return array();
407
+
408
+        }
409
+
410
+        return $post_states;
411
+
412
+    }
413
+
414
+    /**
415
+     * Returns an array of items table columns.
416
+     */
417
+    public static function item_columns( $columns ) {
418
+
419
+        $columns = array(
420
+            'cb'                => $columns['cb'],
421
+            'title'             => __( 'Name', 'invoicing' ),
422
+            'price'             => __( 'Price', 'invoicing' ),
423
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
424
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
425
+            'type'              => __( 'Type', 'invoicing' ),
426
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
427
+        );
428
+
429
+        if ( ! wpinv_use_taxes() ) {
430
+            unset( $columns['vat_rule'] );
431
+            unset( $columns['vat_class'] );
432
+        }
433
+
434
+        return apply_filters( 'wpi_item_table_columns', $columns );
435
+    }
436
+
437
+    /**
438
+     * Returns an array of sortable items table columns.
439
+     */
440
+    public static function sortable_item_columns( $columns ) {
441
+
442
+        return array_merge(
443
+            $columns,
444
+            array(
445
+                'price'     => 'price',
446
+                'vat_rule'  => 'vat_rule',
447
+                'vat_class' => 'vat_class',
448
+                'type'      => 'type',
449
+            )
450
+        );
451
+
452
+    }
453
+
454
+    /**
455
+     * Displays items table columns.
456
+     */
457
+    public static function display_item_columns( $column_name, $post_id ) {
458 458
  
459
-		$item = new WPInv_Item( $post_id );
459
+        $item = new WPInv_Item( $post_id );
460 460
 
461
-		switch ( $column_name ) {
461
+        switch ( $column_name ) {
462 462
 
463
-			case 'price' :
463
+            case 'price' :
464 464
 
465
-				if ( ! $item->is_recurring() ) {
466
-					echo $item->get_the_price();
467
-					break;
468
-				}
465
+                if ( ! $item->is_recurring() ) {
466
+                    echo $item->get_the_price();
467
+                    break;
468
+                }
469 469
 
470
-				$price = wp_sprintf(
471
-					__( '%s / %s', 'invoicing' ),
472
-					$item->get_the_price(),
473
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
474
-				);
470
+                $price = wp_sprintf(
471
+                    __( '%s / %s', 'invoicing' ),
472
+                    $item->get_the_price(),
473
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
474
+                );
475 475
 
476
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
477
-					echo $price;
478
-					break;
479
-				}
476
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
477
+                    echo $price;
478
+                    break;
479
+                }
480 480
 
481
-				echo $item->get_the_initial_price();
481
+                echo $item->get_the_initial_price();
482 482
 
483
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
484
-				break;
483
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
484
+                break;
485 485
 
486
-			case 'vat_rule' :
487
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
488
-				break;
486
+            case 'vat_rule' :
487
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
488
+                break;
489 489
 
490
-			case 'vat_class' :
491
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
492
-				break;
490
+            case 'vat_class' :
491
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
492
+                break;
493 493
 
494
-			case 'shortcode' :
495
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
496
-				break;
494
+            case 'shortcode' :
495
+                echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
496
+                break;
497 497
 
498
-			case 'type' :
499
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
500
-				break;
498
+            case 'type' :
499
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
500
+                break;
501 501
 
502
-		}
502
+        }
503 503
 
504
-	}
504
+    }
505 505
 
506
-	/**
507
-	 * Lets users filter items using taxes.
508
-	 */
509
-	public static function add_item_filters( $post_type ) {
506
+    /**
507
+     * Lets users filter items using taxes.
508
+     */
509
+    public static function add_item_filters( $post_type ) {
510 510
 
511
-		// Abort if we're not dealing with items.
512
-		if ( $post_type != 'wpi_item' ) {
513
-			return;
514
-		}
511
+        // Abort if we're not dealing with items.
512
+        if ( $post_type != 'wpi_item' ) {
513
+            return;
514
+        }
515 515
 
516
-		// Filter by vat rules.
517
-		if ( wpinv_use_taxes() ) {
516
+        // Filter by vat rules.
517
+        if ( wpinv_use_taxes() ) {
518 518
 	
519
-			// Sanitize selected vat rule.
520
-			$vat_rule   = '';
521
-			$vat_rules  = getpaid_get_tax_rules();
522
-			if ( isset( $_GET['vat_rule'] ) ) {
523
-				$vat_rule   =  $_GET['vat_rule'];
524
-			}
525
-
526
-			// Filter by VAT rule.
527
-			echo wpinv_html_select(
528
-				array(
529
-					'options'          => array_merge(
530
-						array(
531
-							'' => __( 'All VAT rules', 'invoicing' )
532
-						),
533
-						$vat_rules
534
-					),
535
-					'name'             => 'vat_rule',
536
-					'id'               => 'vat_rule',
537
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
538
-					'show_option_all'  => false,
539
-					'show_option_none' => false,
540
-				)
541
-			);
542
-
543
-			// Filter by VAT class.
519
+            // Sanitize selected vat rule.
520
+            $vat_rule   = '';
521
+            $vat_rules  = getpaid_get_tax_rules();
522
+            if ( isset( $_GET['vat_rule'] ) ) {
523
+                $vat_rule   =  $_GET['vat_rule'];
524
+            }
525
+
526
+            // Filter by VAT rule.
527
+            echo wpinv_html_select(
528
+                array(
529
+                    'options'          => array_merge(
530
+                        array(
531
+                            '' => __( 'All VAT rules', 'invoicing' )
532
+                        ),
533
+                        $vat_rules
534
+                    ),
535
+                    'name'             => 'vat_rule',
536
+                    'id'               => 'vat_rule',
537
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
538
+                    'show_option_all'  => false,
539
+                    'show_option_none' => false,
540
+                )
541
+            );
542
+
543
+            // Filter by VAT class.
544 544
 	
545
-			// Sanitize selected vat rule.
546
-			$vat_class   = '';
547
-			$vat_classes = getpaid_get_tax_classes();
548
-			if ( isset( $_GET['vat_class'] ) ) {
549
-				$vat_class   =  $_GET['vat_class'];
550
-			}
551
-
552
-			echo wpinv_html_select(
553
-				array(
554
-					'options'          => array_merge(
555
-						array(
556
-							'' => __( 'All VAT classes', 'invoicing' )
557
-						),
558
-						$vat_classes
559
-					),
560
-					'name'             => 'vat_class',
561
-					'id'               => 'vat_class',
562
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
563
-					'show_option_all'  => false,
564
-					'show_option_none' => false,
565
-				)
566
-			);
567
-
568
-		}
569
-
570
-		// Filter by item type.
571
-		$type   = '';
572
-		if ( isset( $_GET['type'] ) ) {
573
-			$type   =  $_GET['type'];
574
-		}
575
-
576
-		echo wpinv_html_select(
577
-			array(
578
-				'options'          => array_merge(
579
-					array(
580
-						'' => __( 'All item types', 'invoicing' )
581
-					),
582
-					wpinv_get_item_types()
583
-				),
584
-				'name'             => 'type',
585
-				'id'               => 'type',
586
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
587
-				'show_option_all'  => false,
588
-				'show_option_none' => false,
589
-			)
590
-		);
591
-
592
-	}
593
-
594
-	/**
595
-	 * Filters the item query.
596
-	 */
597
-	public static function filter_item_query( $query ) {
598
-
599
-		// modify the query only if it admin and main query.
600
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
601
-			return $query;
602
-		}
603
-
604
-		// we want to modify the query for our items.
605
-		if ( 'wpi_item' != $query->query['post_type'] ){
606
-			return $query;
607
-		}
608
-
609
-		if ( empty( $query->query_vars['meta_query'] ) ) {
610
-			$query->query_vars['meta_query'] = array();
611
-		}
612
-
613
-		// Filter vat rule type
545
+            // Sanitize selected vat rule.
546
+            $vat_class   = '';
547
+            $vat_classes = getpaid_get_tax_classes();
548
+            if ( isset( $_GET['vat_class'] ) ) {
549
+                $vat_class   =  $_GET['vat_class'];
550
+            }
551
+
552
+            echo wpinv_html_select(
553
+                array(
554
+                    'options'          => array_merge(
555
+                        array(
556
+                            '' => __( 'All VAT classes', 'invoicing' )
557
+                        ),
558
+                        $vat_classes
559
+                    ),
560
+                    'name'             => 'vat_class',
561
+                    'id'               => 'vat_class',
562
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
563
+                    'show_option_all'  => false,
564
+                    'show_option_none' => false,
565
+                )
566
+            );
567
+
568
+        }
569
+
570
+        // Filter by item type.
571
+        $type   = '';
572
+        if ( isset( $_GET['type'] ) ) {
573
+            $type   =  $_GET['type'];
574
+        }
575
+
576
+        echo wpinv_html_select(
577
+            array(
578
+                'options'          => array_merge(
579
+                    array(
580
+                        '' => __( 'All item types', 'invoicing' )
581
+                    ),
582
+                    wpinv_get_item_types()
583
+                ),
584
+                'name'             => 'type',
585
+                'id'               => 'type',
586
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
587
+                'show_option_all'  => false,
588
+                'show_option_none' => false,
589
+            )
590
+        );
591
+
592
+    }
593
+
594
+    /**
595
+     * Filters the item query.
596
+     */
597
+    public static function filter_item_query( $query ) {
598
+
599
+        // modify the query only if it admin and main query.
600
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
601
+            return $query;
602
+        }
603
+
604
+        // we want to modify the query for our items.
605
+        if ( 'wpi_item' != $query->query['post_type'] ){
606
+            return $query;
607
+        }
608
+
609
+        if ( empty( $query->query_vars['meta_query'] ) ) {
610
+            $query->query_vars['meta_query'] = array();
611
+        }
612
+
613
+        // Filter vat rule type
614 614
         if ( ! empty( $_GET['vat_rule'] ) ) {
615 615
             $query->query_vars['meta_query'][] = array(
616 616
                 'key'     => '_wpinv_vat_rule',
@@ -635,94 +635,94 @@  discard block
 block discarded – undo
635 635
                 'value'   => sanitize_text_field( $_GET['type'] ),
636 636
                 'compare' => '='
637 637
             );
638
-		}
639
-
640
-	}
641
-
642
-	/**
643
-	 * Reorders items.
644
-	 */
645
-	public static function reorder_items( $vars ) {
646
-		global $typenow;
647
-
648
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
649
-			return $vars;
650
-		}
651
-
652
-		// By item type.
653
-		if ( 'type' == $vars['orderby'] ) {
654
-			return array_merge(
655
-				$vars,
656
-				array(
657
-					'meta_key' => '_wpinv_type',
658
-					'orderby'  => 'meta_value'
659
-				)
660
-			);
661
-		}
662
-
663
-		// By vat class.
664
-		if ( 'vat_class' == $vars['orderby'] ) {
665
-			return array_merge(
666
-				$vars,
667
-				array(
668
-					'meta_key' => '_wpinv_vat_class',
669
-					'orderby'  => 'meta_value'
670
-				)
671
-			);
672
-		}
673
-
674
-		// By vat rule.
675
-		if ( 'vat_rule' == $vars['orderby'] ) {
676
-			return array_merge(
677
-				$vars,
678
-				array(
679
-					'meta_key' => '_wpinv_vat_rule',
680
-					'orderby'  => 'meta_value'
681
-				)
682
-			);
683
-		}
684
-
685
-		// By price.
686
-		if ( 'price' == $vars['orderby'] ) {
687
-			return array_merge(
688
-				$vars,
689
-				array(
690
-					'meta_key' => '_wpinv_price',
691
-					'orderby'  => 'meta_value_num'
692
-				)
693
-			);
694
-		}
695
-
696
-		return $vars;
697
-
698
-	}
699
-
700
-	/**
701
-	 * Fired when deleting a post.
702
-	 */
703
-	public static function delete_post( $post_id ) {
704
-
705
-		switch ( get_post_type( $post_id ) ) {
706
-
707
-			case 'wpi_item' :
708
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
709
-				break;
710
-
711
-			case 'wpi_payment_form' :
712
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
713
-				break;
714
-
715
-			case 'wpi_discount' :
716
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
717
-				break;
718
-
719
-			case 'wpi_invoice' :
720
-				$invoice = new WPInv_Invoice( $post_id );
721
-				do_action( "getpaid_before_delete_invoice", $invoice );
722
-				$invoice->get_data_store()->delete_items( $invoice );
723
-				$invoice->get_data_store()->delete_special_fields( $invoice );
724
-				break;
725
-		}
726
-	}
638
+        }
639
+
640
+    }
641
+
642
+    /**
643
+     * Reorders items.
644
+     */
645
+    public static function reorder_items( $vars ) {
646
+        global $typenow;
647
+
648
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
649
+            return $vars;
650
+        }
651
+
652
+        // By item type.
653
+        if ( 'type' == $vars['orderby'] ) {
654
+            return array_merge(
655
+                $vars,
656
+                array(
657
+                    'meta_key' => '_wpinv_type',
658
+                    'orderby'  => 'meta_value'
659
+                )
660
+            );
661
+        }
662
+
663
+        // By vat class.
664
+        if ( 'vat_class' == $vars['orderby'] ) {
665
+            return array_merge(
666
+                $vars,
667
+                array(
668
+                    'meta_key' => '_wpinv_vat_class',
669
+                    'orderby'  => 'meta_value'
670
+                )
671
+            );
672
+        }
673
+
674
+        // By vat rule.
675
+        if ( 'vat_rule' == $vars['orderby'] ) {
676
+            return array_merge(
677
+                $vars,
678
+                array(
679
+                    'meta_key' => '_wpinv_vat_rule',
680
+                    'orderby'  => 'meta_value'
681
+                )
682
+            );
683
+        }
684
+
685
+        // By price.
686
+        if ( 'price' == $vars['orderby'] ) {
687
+            return array_merge(
688
+                $vars,
689
+                array(
690
+                    'meta_key' => '_wpinv_price',
691
+                    'orderby'  => 'meta_value_num'
692
+                )
693
+            );
694
+        }
695
+
696
+        return $vars;
697
+
698
+    }
699
+
700
+    /**
701
+     * Fired when deleting a post.
702
+     */
703
+    public static function delete_post( $post_id ) {
704
+
705
+        switch ( get_post_type( $post_id ) ) {
706
+
707
+            case 'wpi_item' :
708
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
709
+                break;
710
+
711
+            case 'wpi_payment_form' :
712
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
713
+                break;
714
+
715
+            case 'wpi_discount' :
716
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
717
+                break;
718
+
719
+            case 'wpi_invoice' :
720
+                $invoice = new WPInv_Invoice( $post_id );
721
+                do_action( "getpaid_before_delete_invoice", $invoice );
722
+                $invoice->get_data_store()->delete_items( $invoice );
723
+                $invoice->get_data_store()->delete_special_fields( $invoice );
724
+                break;
725
+        }
726
+    }
727 727
 
728 728
 }
Please login to merge, or discard this patch.
Spacing   +192 added lines, -192 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
 /**
10 10
  * Post types Admin Class
@@ -21,69 +21,69 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28 28
 
29 29
 		// Invoice table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
30
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
31
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
32 32
 
33 33
 		// Items table columns.
34
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
35
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
36
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
37
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
38
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
39
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
34
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
35
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
36
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
37
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
38
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
39
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
40 40
 
41 41
 		// Payment forms columns.
42
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
43
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
44
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
42
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
43
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
44
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
45 45
 
46 46
 		// Discount table columns.
47
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
48
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
47
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
48
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
49 49
 
50 50
 		// Deleting posts.
51
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
52
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
51
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
52
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * Post updated messages.
57 57
 	 */
58
-	public static function post_updated_messages( $messages ) {
58
+	public static function post_updated_messages($messages) {
59 59
 		global $post;
60 60
 
61 61
 		$messages['wpi_discount'] = array(
62 62
 			0   => '',
63
-			1   => __( 'Discount updated.', 'invoicing' ),
64
-			2   => __( 'Custom field updated.', 'invoicing' ),
65
-			3   => __( 'Custom field deleted.', 'invoicing' ),
66
-			4   => __( 'Discount updated.', 'invoicing' ),
67
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
68
-			6   => __( 'Discount updated.', 'invoicing' ),
69
-			7   => __( 'Discount saved.', 'invoicing' ),
70
-			8   => __( 'Discount submitted.', 'invoicing' ),
71
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
72
-			10  => __( 'Discount draft updated.', 'invoicing' ),
63
+			1   => __('Discount updated.', 'invoicing'),
64
+			2   => __('Custom field updated.', 'invoicing'),
65
+			3   => __('Custom field deleted.', 'invoicing'),
66
+			4   => __('Discount updated.', 'invoicing'),
67
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
68
+			6   => __('Discount updated.', 'invoicing'),
69
+			7   => __('Discount saved.', 'invoicing'),
70
+			8   => __('Discount submitted.', 'invoicing'),
71
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
72
+			10  => __('Discount draft updated.', 'invoicing'),
73 73
 		);
74 74
 
75 75
 		$messages['wpi_payment_form'] = array(
76 76
 			0   => '',
77
-			1   => __( 'Payment Form updated.', 'invoicing' ),
78
-			2   => __( 'Custom field updated.', 'invoicing' ),
79
-			3   => __( 'Custom field deleted.', 'invoicing' ),
80
-			4   => __( 'Payment Form updated.', 'invoicing' ),
81
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
82
-			6   => __( 'Payment Form updated.', 'invoicing' ),
83
-			7   => __( 'Payment Form saved.', 'invoicing' ),
84
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
85
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
86
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
77
+			1   => __('Payment Form updated.', 'invoicing'),
78
+			2   => __('Custom field updated.', 'invoicing'),
79
+			3   => __('Custom field deleted.', 'invoicing'),
80
+			4   => __('Payment Form updated.', 'invoicing'),
81
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
82
+			6   => __('Payment Form updated.', 'invoicing'),
83
+			7   => __('Payment Form saved.', 'invoicing'),
84
+			8   => __('Payment Form submitted.', 'invoicing'),
85
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
86
+			10  => __('Payment Form draft updated.', 'invoicing'),
87 87
 		);
88 88
 
89 89
 		return $messages;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * Post row actions.
95 95
 	 */
96
-	public static function post_row_actions( $actions, $post ) {
96
+	public static function post_row_actions($actions, $post) {
97 97
 
98
-		$post = get_post( $post );
98
+		$post = get_post($post);
99 99
 
100 100
 		// We do not want to edit the default payment form.
101
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
102
-			unset( $actions['trash'] );
103
-			unset( $actions['inline hide-if-no-js'] );
101
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
102
+			unset($actions['trash']);
103
+			unset($actions['inline hide-if-no-js']);
104 104
 		}
105 105
 
106 106
 		return $actions;
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Returns an array of invoice table columns.
111 111
 	 */
112
-	public static function invoice_columns( $columns ) {
112
+	public static function invoice_columns($columns) {
113 113
 
114 114
 		$columns = array(
115 115
 			'cb'                => $columns['cb'],
116
-			'number'            => __( 'Invoice', 'invoicing' ),
117
-			'customer'          => __( 'Customer', 'invoicing' ),
118
-			'invoice_date'      => __( 'Date', 'invoicing' ),
119
-			'amount'            => __( 'Amount', 'invoicing' ),
120
-			'recurring'         => __( 'Recurring', 'invoicing' ),
121
-			'status'            => __( 'Status', 'invoicing' ),
122
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
116
+			'number'            => __('Invoice', 'invoicing'),
117
+			'customer'          => __('Customer', 'invoicing'),
118
+			'invoice_date'      => __('Date', 'invoicing'),
119
+			'amount'            => __('Amount', 'invoicing'),
120
+			'recurring'         => __('Recurring', 'invoicing'),
121
+			'status'            => __('Status', 'invoicing'),
122
+			'wpi_actions'       => __('Actions', 'invoicing'),
123 123
 		);
124 124
 
125
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
125
+		return apply_filters('wpi_invoice_table_columns', $columns);
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * Displays invoice table columns.
130 130
 	 */
131
-	public static function display_invoice_columns( $column_name, $post_id ) {
131
+	public static function display_invoice_columns($column_name, $post_id) {
132 132
 
133
-		$invoice = new WPInv_Invoice( $post_id );
133
+		$invoice = new WPInv_Invoice($post_id);
134 134
 
135
-		switch ( $column_name ) {
135
+		switch ($column_name) {
136 136
 
137 137
 			case 'invoice_date' :
138
-				$date_time = esc_attr( $invoice->get_created_date() );
139
-				$date      = getpaid_format_date_value( $date_time );
138
+				$date_time = esc_attr($invoice->get_created_date());
139
+				$date      = getpaid_format_date_value($date_time);
140 140
 				echo "<span title='$date_time'>$date</span>";
141 141
 				break;
142 142
 
143 143
 			case 'amount' :
144 144
 
145 145
 				$amount = $invoice->get_total();
146
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
146
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
147 147
 
148
-				if ( $invoice->is_refunded() ) {
149
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
148
+				if ($invoice->is_refunded()) {
149
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
150 150
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
151 151
 				} else {
152 152
 
153 153
 					$discount = $invoice->get_total_discount();
154 154
 
155
-					if ( ! empty( $discount ) ) {
156
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
155
+					if (!empty($discount)) {
156
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
157 157
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
158 158
 					} else {
159 159
 						echo $formated_amount;
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				break;
165 165
 
166 166
 			case 'status' :
167
-				$status       = sanitize_text_field( $invoice->get_status() );
168
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
167
+				$status       = sanitize_text_field($invoice->get_status());
168
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
169 169
 
170 170
 				// If it is paid, show the gateway title.
171
-				if ( $invoice->is_paid() ) {
172
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
173
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
171
+				if ($invoice->is_paid()) {
172
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
173
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
174 174
 
175 175
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
176 176
 				} else {
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
 				}
179 179
 
180 180
 				// If it is not paid, display the overdue and view status.
181
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
181
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
182 182
 
183 183
 					// Invoice view status.
184
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
185
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
184
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
185
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
186 186
 					} else {
187
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
187
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
188 188
 					}
189 189
 
190 190
 					// Display the overview status.
191
-					if ( wpinv_get_option( 'overdue_active' ) ) {
191
+					if (wpinv_get_option('overdue_active')) {
192 192
 						$due_date = $invoice->get_due_date();
193
-						$fomatted = getpaid_format_date( $due_date );
193
+						$fomatted = getpaid_format_date($due_date);
194 194
 
195
-						if ( ! empty( $fomatted ) ) {
196
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
195
+						if (!empty($fomatted)) {
196
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
197 197
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
198 198
 						}
199 199
 					}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 			case 'recurring':
206 206
 
207
-				if ( $invoice->is_recurring() ) {
207
+				if ($invoice->is_recurring()) {
208 208
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
209 209
 				} else {
210 210
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 
214 214
 			case 'number' :
215 215
 
216
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
217
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
218
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
216
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
217
+				$invoice_number  = sanitize_text_field($invoice->get_number());
218
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
219 219
 
220 220
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
221 221
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 	
226 226
 				$customer_name = $invoice->get_user_full_name();
227 227
 	
228
-				if ( empty( $customer_name ) ) {
228
+				if (empty($customer_name)) {
229 229
 					$customer_name = $invoice->get_email();
230 230
 				}
231 231
 	
232
-				if ( ! empty( $customer_name ) ) {
233
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
234
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
232
+				if (!empty($customer_name)) {
233
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
234
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
235 235
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
236 236
 				} else {
237 237
 					echo '<div>&mdash;</div>';
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
 			case 'wpi_actions' :
243 243
 
244
-				if ( $invoice->is_draft() ) {
244
+				if ($invoice->is_draft()) {
245 245
 					return;
246 246
 				}
247 247
 
248
-				$url    = esc_url( $invoice->get_view_url() );
249
-				$print  = esc_attr__( 'Print invoice', 'invoicing' );
248
+				$url    = esc_url($invoice->get_view_url());
249
+				$print  = esc_attr__('Print invoice', 'invoicing');
250 250
 				echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
251 251
 
252 252
 				$url    = esc_url(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 					)
263 263
 				);
264 264
 
265
-				$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
265
+				$send = esc_attr__('Send invoice to customer', 'invoicing');
266 266
 				echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
267 267
 
268 268
 				break;
@@ -273,50 +273,50 @@  discard block
 block discarded – undo
273 273
 	/**
274 274
 	 * Returns an array of payment forms table columns.
275 275
 	 */
276
-	public static function payment_form_columns( $columns ) {
276
+	public static function payment_form_columns($columns) {
277 277
 
278 278
 		$columns = array(
279 279
 			'cb'                => $columns['cb'],
280
-			'title'             => __( 'Name', 'invoicing' ),
281
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
282
-			'earnings'          => __( 'Revenue', 'invoicing' ),
283
-			'refunds'           => __( 'Refunded', 'invoicing' ),
284
-			'items'             => __( 'Items', 'invoicing' ),
285
-			'date'              => __( 'Date', 'invoicing' ),
280
+			'title'             => __('Name', 'invoicing'),
281
+			'shortcode'         => __('Shortcode', 'invoicing'),
282
+			'earnings'          => __('Revenue', 'invoicing'),
283
+			'refunds'           => __('Refunded', 'invoicing'),
284
+			'items'             => __('Items', 'invoicing'),
285
+			'date'              => __('Date', 'invoicing'),
286 286
 		);
287 287
 
288
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
288
+		return apply_filters('wpi_payment_form_table_columns', $columns);
289 289
 
290 290
 	}
291 291
 
292 292
 	/**
293 293
 	 * Displays payment form table columns.
294 294
 	 */
295
-	public static function display_payment_form_columns( $column_name, $post_id ) {
295
+	public static function display_payment_form_columns($column_name, $post_id) {
296 296
 
297 297
 		// Retrieve the payment form.
298
-		$form = new GetPaid_Payment_Form( $post_id );
298
+		$form = new GetPaid_Payment_Form($post_id);
299 299
 
300
-		switch ( $column_name ) {
300
+		switch ($column_name) {
301 301
 
302 302
 			case 'earnings' :
303
-				echo wpinv_price( wpinv_format_amount( $form->get_earned() ) );
303
+				echo wpinv_price(wpinv_format_amount($form->get_earned()));
304 304
 				break;
305 305
 
306 306
 			case 'refunds' :
307
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
307
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
308 308
 				break;
309 309
 
310 310
 			case 'refunds' :
311
-				echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) );
311
+				echo wpinv_price(wpinv_format_amount($form->get_refunded()));
312 312
 				break;
313 313
 
314 314
 			case 'shortcode' :
315 315
 
316
-				if ( $form->is_default() ) {
316
+				if ($form->is_default()) {
317 317
 					echo '&mdash;';
318 318
 				} else {
319
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
319
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
320 320
 				}
321 321
 
322 322
 				break;
@@ -325,29 +325,29 @@  discard block
 block discarded – undo
325 325
 
326 326
 				$items = $form->get_items();
327 327
 
328
-				if ( $form->is_default() || empty( $items ) ) {
328
+				if ($form->is_default() || empty($items)) {
329 329
 					echo '&mdash;';
330 330
 					return;
331 331
 				}
332 332
 
333 333
 				$_items = array();
334 334
 
335
-				foreach ( $items as $item ) {
335
+				foreach ($items as $item) {
336 336
 					$url = $item->get_edit_url();
337 337
 
338
-					if ( empty( $url ) ) {
339
-						$_items[] = sanitize_text_field( $item->get_name() );
338
+					if (empty($url)) {
339
+						$_items[] = sanitize_text_field($item->get_name());
340 340
 					} else {
341 341
 						$_items[] = sprintf(
342 342
 							'<a href="%s">%s</a>',
343
-							esc_url( $url ),
344
-							sanitize_text_field( $item->get_name() )
343
+							esc_url($url),
344
+							sanitize_text_field($item->get_name())
345 345
 						);
346 346
 					}
347 347
 
348 348
 				}
349 349
 
350
-				echo implode( '<br>', $_items );
350
+				echo implode('<br>', $_items);
351 351
 
352 352
 				break;
353 353
 
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 	/**
359 359
 	 * Filters post states.
360 360
 	 */
361
-	public static function filter_payment_form_state( $post_states, $post ) {
361
+	public static function filter_payment_form_state($post_states, $post) {
362 362
 
363
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
364
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
363
+		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) {
364
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
365 365
 		}
366 366
 	
367 367
 		return $post_states;
@@ -371,35 +371,35 @@  discard block
 block discarded – undo
371 371
 	/**
372 372
 	 * Returns an array of coupon table columns.
373 373
 	 */
374
-	public static function discount_columns( $columns ) {
374
+	public static function discount_columns($columns) {
375 375
 
376 376
 		$columns = array(
377 377
 			'cb'                => $columns['cb'],
378
-			'title'             => __( 'Name', 'invoicing' ),
379
-			'code'              => __( 'Code', 'invoicing' ),
380
-			'amount'            => __( 'Amount', 'invoicing' ),
381
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
382
-			'start_date'        => __( 'Start Date', 'invoicing' ),
383
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
378
+			'title'             => __('Name', 'invoicing'),
379
+			'code'              => __('Code', 'invoicing'),
380
+			'amount'            => __('Amount', 'invoicing'),
381
+			'usage'             => __('Usage / Limit', 'invoicing'),
382
+			'start_date'        => __('Start Date', 'invoicing'),
383
+			'expiry_date'       => __('Expiry Date', 'invoicing'),
384 384
 		);
385 385
 
386
-		return apply_filters( 'wpi_discount_table_columns', $columns );
386
+		return apply_filters('wpi_discount_table_columns', $columns);
387 387
 	}
388 388
 
389 389
 	/**
390 390
 	 * Filters post states.
391 391
 	 */
392
-	public static function filter_discount_state( $post_states, $post ) {
392
+	public static function filter_discount_state($post_states, $post) {
393 393
 
394
-		if ( 'wpi_discount' == $post->post_type ) {
394
+		if ('wpi_discount' == $post->post_type) {
395 395
 
396
-			$discount = new WPInv_Discount( $post );
396
+			$discount = new WPInv_Discount($post);
397 397
 
398 398
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
399 399
 
400
-			if ( $status != 'publish' ) {
400
+			if ($status != 'publish') {
401 401
 				return array(
402
-					'discount_status' => wpinv_discount_status( $status ),
402
+					'discount_status' => wpinv_discount_status($status),
403 403
 				);
404 404
 			}
405 405
 
@@ -414,30 +414,30 @@  discard block
 block discarded – undo
414 414
 	/**
415 415
 	 * Returns an array of items table columns.
416 416
 	 */
417
-	public static function item_columns( $columns ) {
417
+	public static function item_columns($columns) {
418 418
 
419 419
 		$columns = array(
420 420
 			'cb'                => $columns['cb'],
421
-			'title'             => __( 'Name', 'invoicing' ),
422
-			'price'             => __( 'Price', 'invoicing' ),
423
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
424
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
425
-			'type'              => __( 'Type', 'invoicing' ),
426
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
421
+			'title'             => __('Name', 'invoicing'),
422
+			'price'             => __('Price', 'invoicing'),
423
+			'vat_rule'          => __('VAT rule', 'invoicing'),
424
+			'vat_class'         => __('VAT class', 'invoicing'),
425
+			'type'              => __('Type', 'invoicing'),
426
+			'shortcode'         => __('Shortcode', 'invoicing'),
427 427
 		);
428 428
 
429
-		if ( ! wpinv_use_taxes() ) {
430
-			unset( $columns['vat_rule'] );
431
-			unset( $columns['vat_class'] );
429
+		if (!wpinv_use_taxes()) {
430
+			unset($columns['vat_rule']);
431
+			unset($columns['vat_class']);
432 432
 		}
433 433
 
434
-		return apply_filters( 'wpi_item_table_columns', $columns );
434
+		return apply_filters('wpi_item_table_columns', $columns);
435 435
 	}
436 436
 
437 437
 	/**
438 438
 	 * Returns an array of sortable items table columns.
439 439
 	 */
440
-	public static function sortable_item_columns( $columns ) {
440
+	public static function sortable_item_columns($columns) {
441 441
 
442 442
 		return array_merge(
443 443
 			$columns,
@@ -454,49 +454,49 @@  discard block
 block discarded – undo
454 454
 	/**
455 455
 	 * Displays items table columns.
456 456
 	 */
457
-	public static function display_item_columns( $column_name, $post_id ) {
457
+	public static function display_item_columns($column_name, $post_id) {
458 458
  
459
-		$item = new WPInv_Item( $post_id );
459
+		$item = new WPInv_Item($post_id);
460 460
 
461
-		switch ( $column_name ) {
461
+		switch ($column_name) {
462 462
 
463 463
 			case 'price' :
464 464
 
465
-				if ( ! $item->is_recurring() ) {
465
+				if (!$item->is_recurring()) {
466 466
 					echo $item->get_the_price();
467 467
 					break;
468 468
 				}
469 469
 
470 470
 				$price = wp_sprintf(
471
-					__( '%s / %s', 'invoicing' ),
471
+					__('%s / %s', 'invoicing'),
472 472
 					$item->get_the_price(),
473
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
473
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
474 474
 				);
475 475
 
476
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
476
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
477 477
 					echo $price;
478 478
 					break;
479 479
 				}
480 480
 
481 481
 				echo $item->get_the_initial_price();
482 482
 
483
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
483
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
484 484
 				break;
485 485
 
486 486
 			case 'vat_rule' :
487
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
487
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
488 488
 				break;
489 489
 
490 490
 			case 'vat_class' :
491
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
491
+				echo getpaid_get_tax_class_label($item->get_vat_class());
492 492
 				break;
493 493
 
494 494
 			case 'shortcode' :
495
-				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
495
+				echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
496 496
 				break;
497 497
 
498 498
 			case 'type' :
499
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
499
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
500 500
 				break;
501 501
 
502 502
 		}
@@ -506,21 +506,21 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 * Lets users filter items using taxes.
508 508
 	 */
509
-	public static function add_item_filters( $post_type ) {
509
+	public static function add_item_filters($post_type) {
510 510
 
511 511
 		// Abort if we're not dealing with items.
512
-		if ( $post_type != 'wpi_item' ) {
512
+		if ($post_type != 'wpi_item') {
513 513
 			return;
514 514
 		}
515 515
 
516 516
 		// Filter by vat rules.
517
-		if ( wpinv_use_taxes() ) {
517
+		if (wpinv_use_taxes()) {
518 518
 	
519 519
 			// Sanitize selected vat rule.
520 520
 			$vat_rule   = '';
521 521
 			$vat_rules  = getpaid_get_tax_rules();
522
-			if ( isset( $_GET['vat_rule'] ) ) {
523
-				$vat_rule   =  $_GET['vat_rule'];
522
+			if (isset($_GET['vat_rule'])) {
523
+				$vat_rule = $_GET['vat_rule'];
524 524
 			}
525 525
 
526 526
 			// Filter by VAT rule.
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 				array(
529 529
 					'options'          => array_merge(
530 530
 						array(
531
-							'' => __( 'All VAT rules', 'invoicing' )
531
+							'' => __('All VAT rules', 'invoicing')
532 532
 						),
533 533
 						$vat_rules
534 534
 					),
535 535
 					'name'             => 'vat_rule',
536 536
 					'id'               => 'vat_rule',
537
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
537
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
538 538
 					'show_option_all'  => false,
539 539
 					'show_option_none' => false,
540 540
 				)
@@ -545,21 +545,21 @@  discard block
 block discarded – undo
545 545
 			// Sanitize selected vat rule.
546 546
 			$vat_class   = '';
547 547
 			$vat_classes = getpaid_get_tax_classes();
548
-			if ( isset( $_GET['vat_class'] ) ) {
549
-				$vat_class   =  $_GET['vat_class'];
548
+			if (isset($_GET['vat_class'])) {
549
+				$vat_class = $_GET['vat_class'];
550 550
 			}
551 551
 
552 552
 			echo wpinv_html_select(
553 553
 				array(
554 554
 					'options'          => array_merge(
555 555
 						array(
556
-							'' => __( 'All VAT classes', 'invoicing' )
556
+							'' => __('All VAT classes', 'invoicing')
557 557
 						),
558 558
 						$vat_classes
559 559
 					),
560 560
 					'name'             => 'vat_class',
561 561
 					'id'               => 'vat_class',
562
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
562
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
563 563
 					'show_option_all'  => false,
564 564
 					'show_option_none' => false,
565 565
 				)
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 
570 570
 		// Filter by item type.
571
-		$type   = '';
572
-		if ( isset( $_GET['type'] ) ) {
573
-			$type   =  $_GET['type'];
571
+		$type = '';
572
+		if (isset($_GET['type'])) {
573
+			$type = $_GET['type'];
574 574
 		}
575 575
 
576 576
 		echo wpinv_html_select(
577 577
 			array(
578 578
 				'options'          => array_merge(
579 579
 					array(
580
-						'' => __( 'All item types', 'invoicing' )
580
+						'' => __('All item types', 'invoicing')
581 581
 					),
582 582
 					wpinv_get_item_types()
583 583
 				),
584 584
 				'name'             => 'type',
585 585
 				'id'               => 'type',
586
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
586
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
587 587
 				'show_option_all'  => false,
588 588
 				'show_option_none' => false,
589 589
 			)
@@ -594,45 +594,45 @@  discard block
 block discarded – undo
594 594
 	/**
595 595
 	 * Filters the item query.
596 596
 	 */
597
-	public static function filter_item_query( $query ) {
597
+	public static function filter_item_query($query) {
598 598
 
599 599
 		// modify the query only if it admin and main query.
600
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
600
+		if (!(is_admin() && $query->is_main_query())) { 
601 601
 			return $query;
602 602
 		}
603 603
 
604 604
 		// we want to modify the query for our items.
605
-		if ( 'wpi_item' != $query->query['post_type'] ){
605
+		if ('wpi_item' != $query->query['post_type']) {
606 606
 			return $query;
607 607
 		}
608 608
 
609
-		if ( empty( $query->query_vars['meta_query'] ) ) {
609
+		if (empty($query->query_vars['meta_query'])) {
610 610
 			$query->query_vars['meta_query'] = array();
611 611
 		}
612 612
 
613 613
 		// Filter vat rule type
614
-        if ( ! empty( $_GET['vat_rule'] ) ) {
614
+        if (!empty($_GET['vat_rule'])) {
615 615
             $query->query_vars['meta_query'][] = array(
616 616
                 'key'     => '_wpinv_vat_rule',
617
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
617
+                'value'   => sanitize_text_field($_GET['vat_rule']),
618 618
                 'compare' => '='
619 619
             );
620 620
         }
621 621
 
622 622
         // Filter vat class
623
-        if ( ! empty( $_GET['vat_class'] ) ) {
623
+        if (!empty($_GET['vat_class'])) {
624 624
             $query->query_vars['meta_query'][] = array(
625 625
                 'key'     => '_wpinv_vat_class',
626
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
626
+                'value'   => sanitize_text_field($_GET['vat_class']),
627 627
                 'compare' => '='
628 628
             );
629 629
         }
630 630
 
631 631
         // Filter item type
632
-        if ( ! empty( $_GET['type'] ) ) {
632
+        if (!empty($_GET['type'])) {
633 633
             $query->query_vars['meta_query'][] = array(
634 634
                 'key'     => '_wpinv_type',
635
-                'value'   => sanitize_text_field( $_GET['type'] ),
635
+                'value'   => sanitize_text_field($_GET['type']),
636 636
                 'compare' => '='
637 637
             );
638 638
 		}
@@ -642,15 +642,15 @@  discard block
 block discarded – undo
642 642
 	/**
643 643
 	 * Reorders items.
644 644
 	 */
645
-	public static function reorder_items( $vars ) {
645
+	public static function reorder_items($vars) {
646 646
 		global $typenow;
647 647
 
648
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
648
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
649 649
 			return $vars;
650 650
 		}
651 651
 
652 652
 		// By item type.
653
-		if ( 'type' == $vars['orderby'] ) {
653
+		if ('type' == $vars['orderby']) {
654 654
 			return array_merge(
655 655
 				$vars,
656 656
 				array(
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 
663 663
 		// By vat class.
664
-		if ( 'vat_class' == $vars['orderby'] ) {
664
+		if ('vat_class' == $vars['orderby']) {
665 665
 			return array_merge(
666 666
 				$vars,
667 667
 				array(
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 		}
673 673
 
674 674
 		// By vat rule.
675
-		if ( 'vat_rule' == $vars['orderby'] ) {
675
+		if ('vat_rule' == $vars['orderby']) {
676 676
 			return array_merge(
677 677
 				$vars,
678 678
 				array(
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 		}
684 684
 
685 685
 		// By price.
686
-		if ( 'price' == $vars['orderby'] ) {
686
+		if ('price' == $vars['orderby']) {
687 687
 			return array_merge(
688 688
 				$vars,
689 689
 				array(
@@ -700,27 +700,27 @@  discard block
 block discarded – undo
700 700
 	/**
701 701
 	 * Fired when deleting a post.
702 702
 	 */
703
-	public static function delete_post( $post_id ) {
703
+	public static function delete_post($post_id) {
704 704
 
705
-		switch ( get_post_type( $post_id ) ) {
705
+		switch (get_post_type($post_id)) {
706 706
 
707 707
 			case 'wpi_item' :
708
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
708
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
709 709
 				break;
710 710
 
711 711
 			case 'wpi_payment_form' :
712
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
712
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
713 713
 				break;
714 714
 
715 715
 			case 'wpi_discount' :
716
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
716
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
717 717
 				break;
718 718
 
719 719
 			case 'wpi_invoice' :
720
-				$invoice = new WPInv_Invoice( $post_id );
721
-				do_action( "getpaid_before_delete_invoice", $invoice );
722
-				$invoice->get_data_store()->delete_items( $invoice );
723
-				$invoice->get_data_store()->delete_special_fields( $invoice );
720
+				$invoice = new WPInv_Invoice($post_id);
721
+				do_action("getpaid_before_delete_invoice", $invoice);
722
+				$invoice->get_data_store()->delete_items($invoice);
723
+				$invoice->get_data_store()->delete_special_fields($invoice);
724 724
 				break;
725 725
 		}
726 726
 	}
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +129 added lines, -129 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
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
65
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
66
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
65
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
66
+		do_action('getpaid_init_admin_hooks', $this);
67 67
 
68 68
     }
69 69
 
@@ -74,44 +74,44 @@  discard block
 block discarded – undo
74 74
 	public function enqeue_scripts() {
75 75
         global $current_screen, $pagenow;
76 76
 
77
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
77
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
78 78
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
79 79
 
80
-        if ( ! empty( $current_screen->post_type ) ) {
80
+        if (!empty($current_screen->post_type)) {
81 81
 			$page = $current_screen->post_type;
82 82
         }
83 83
 
84 84
         // General styles.
85
-        if ( false !== stripos( $page, 'wpi' ) ) {
85
+        if (false !== stripos($page, 'wpi')) {
86 86
 
87 87
             // Styles.
88
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
89
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
90
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
91
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
88
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
89
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
90
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
91
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
92 92
 
93 93
             // Scripts.
94
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
95
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
94
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
95
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
96 96
 
97
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
98
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
99
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
97
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
98
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
99
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
100 100
 
101 101
         }
102 102
 
103 103
         // Payment form scripts.
104
-		if ( 'wpi_payment_form' == $page && $editing ) {
104
+		if ('wpi_payment_form' == $page && $editing) {
105 105
             $this->load_payment_form_scripts();
106 106
         }
107 107
 
108
-        if ( $page == 'wpinv-subscriptions' ) {
109
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
110
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
108
+        if ($page == 'wpinv-subscriptions') {
109
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
110
+			wp_enqueue_script('wpinv-sub-admin-script');
111 111
 		}
112 112
 
113
-		if ( $page == 'wpinv-subscriptions' ) {
114
-			wp_enqueue_script( 'postbox' );
113
+		if ($page == 'wpinv-subscriptions') {
114
+			wp_enqueue_script('postbox');
115 115
 		}
116 116
 
117 117
     }
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
         global $post;
125 125
 
126 126
         $i18n = array(
127
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
128
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
129
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
130
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
131
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
132
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
133
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
127
+            'ajax_url'                  => admin_url('admin-ajax.php'),
128
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
129
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
130
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
131
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
132
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
133
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
134 134
             'tax'                       => wpinv_tax_amount(),
135 135
             'discount'                  => 0,
136 136
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -138,35 +138,35 @@  discard block
 block discarded – undo
138 138
             'thousand_sep'              => wpinv_thousands_separator(),
139 139
             'decimal_sep'               => wpinv_decimal_separator(),
140 140
             'decimals'                  => wpinv_decimals(),
141
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
142
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
143
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
144
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
145
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
146
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
147
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
148
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
149
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
150
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
151
-            'action_edit'               => __( 'Edit', 'invoicing' ),
152
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
153
-            'item_description'          => __( 'Item Description', 'invoicing' ),
154
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
155
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
156
-            'searching'                 => __( 'Searching', 'invoicing' ),
141
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
142
+            'status_publish'            => wpinv_status_nicename('publish'),
143
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
144
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
145
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
146
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
147
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
148
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
149
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
150
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
151
+            'action_edit'               => __('Edit', 'invoicing'),
152
+            'action_cancel'             => __('Cancel', 'invoicing'),
153
+            'item_description'          => __('Item Description', 'invoicing'),
154
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
155
+            'discount_description'      => __('Discount Description', 'invoicing'),
156
+            'searching'                 => __('Searching', 'invoicing'),
157 157
         );
158 158
 
159
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
159
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
160 160
 
161
-			$invoice              = new WPInv_Invoice( $post );
161
+			$invoice              = new WPInv_Invoice($post);
162 162
 			$i18n['save_invoice'] = sprintf(
163
-				__( 'Save %s', 'invoicing' ),
164
-				ucfirst( $invoice->get_type() )
163
+				__('Save %s', 'invoicing'),
164
+				ucfirst($invoice->get_type())
165 165
 			);
166 166
 
167 167
 			$i18n['invoice_description'] = sprintf(
168
-				__( '%s Description', 'invoicing' ),
169
-				ucfirst( $invoice->get_type() )
168
+				__('%s Description', 'invoicing'),
169
+				ucfirst($invoice->get_type())
170 170
 			);
171 171
 
172 172
 		}
@@ -180,30 +180,30 @@  discard block
 block discarded – undo
180 180
 	protected function load_payment_form_scripts() {
181 181
         global $post;
182 182
 
183
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
184
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
185
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
183
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
184
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
185
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
186 186
 
187
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
188
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
187
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
188
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
189 189
 
190 190
 		wp_localize_script(
191 191
             'wpinv-admin-payment-form-script',
192 192
             'wpinvPaymentFormAdmin',
193 193
             array(
194
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
195
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
194
+				'elements'      => wpinv_get_data('payment-form-elements'),
195
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
196 196
 				'currency'      => wpinv_currency_symbol(),
197 197
 				'position'      => wpinv_currency_position(),
198 198
 				'decimals'      => (int) wpinv_decimals(),
199 199
 				'thousands_sep' => wpinv_thousands_separator(),
200 200
 				'decimals_sep'  => wpinv_decimal_separator(),
201
-				'form_items'    => gepaid_get_form_items( $post->ID ),
201
+				'form_items'    => gepaid_get_form_items($post->ID),
202 202
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
203 203
             )
204 204
         );
205 205
 
206
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
206
+        wp_enqueue_script('wpinv-admin-payment-form-script');
207 207
 
208 208
     }
209 209
 
@@ -214,25 +214,25 @@  discard block
 block discarded – undo
214 214
      * @return string
215 215
 	 *
216 216
 	 */
217
-    public function admin_body_class( $classes ) {
217
+    public function admin_body_class($classes) {
218 218
 		global $pagenow, $post, $current_screen;
219 219
 
220 220
 
221
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
222 222
 
223
-        if ( ! empty( $current_screen->post_type ) ) {
223
+        if (!empty($current_screen->post_type)) {
224 224
 			$page = $current_screen->post_type;
225 225
         }
226 226
 
227
-        if ( false !== stripos( $page, 'wpi' ) ) {
228
-            $classes .= ' wpi-' . sanitize_key( $page );
227
+        if (false !== stripos($page, 'wpi')) {
228
+            $classes .= ' wpi-' . sanitize_key($page);
229 229
         }
230 230
 
231
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
231
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
232 232
             $classes .= ' wpinv-cpt wpinv';
233 233
 		}
234 234
 		
235
-		if ( getpaid_is_invoice_post_type( $page ) ) {
235
+		if (getpaid_is_invoice_post_type($page)) {
236 236
             $classes .= ' getpaid-is-invoice-cpt';
237 237
         }
238 238
 
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
     /**
243 243
 	 * Maybe show the AyeCode Connect Notice.
244 244
 	 */
245
-	public function init_ayecode_connect_helper(){
245
+	public function init_ayecode_connect_helper() {
246 246
 
247 247
         new AyeCode_Connect_Helper(
248 248
             array(
249
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
250
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
251
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
252
-				'connect_button'    => __("Connect Site","invoicing"),
253
-				'connecting_button'    => __("Connecting...","invoicing"),
254
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
255
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
249
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
250
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
251
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
252
+				'connect_button'    => __("Connect Site", "invoicing"),
253
+				'connecting_button'    => __("Connecting...", "invoicing"),
254
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
255
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
256 256
             ),
257
-            array( 'wpi-addons' )
257
+            array('wpi-addons')
258 258
         );
259 259
 
260 260
     }
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
     public function activation_redirect() {
266 266
 
267 267
 		// Bail if no activation redirect.
268
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
268
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
269 269
 			return;
270 270
 		}
271 271
 
272 272
 		// Delete the redirect transient.
273
-		delete_transient( '_wpinv_activation_redirect' );
273
+		delete_transient('_wpinv_activation_redirect');
274 274
 
275 275
 		// Bail if activating from network, or bulk
276
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
276
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
280
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
281 281
 		exit;
282 282
     }
283 283
 
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
      */
287 287
     public function maybe_do_admin_action() {
288 288
 
289
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
290
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
291
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
289
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
290
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
291
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
292 292
         }
293 293
 
294 294
     }
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 	 * 
299 299
 	 * @param array $args
300 300
      */
301
-    public function send_customer_invoice( $args ) {
302
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
301
+    public function send_customer_invoice($args) {
302
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
303 303
 
304
-		if ( $sent ) {
305
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
304
+		if ($sent) {
305
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
306 306
 		} else {
307
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
307
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
308 308
 		}
309 309
 
310
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
310
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
311 311
 		exit;
312 312
 	}
313 313
 
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 	 * 
317 317
 	 * @param array $args
318 318
      */
319
-    public function send_customer_payment_reminder( $args ) {
320
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
319
+    public function send_customer_payment_reminder($args) {
320
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
321 321
 
322
-		if ( $sent ) {
323
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
322
+		if ($sent) {
323
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
324 324
 		} else {
325
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
325
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
326 326
 		}
327 327
 
328
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
328
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
329 329
 		exit;
330 330
 	}
331 331
 
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function admin_reset_tax_rates() {
337 337
 
338
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
339
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
338
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
339
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
340 340
 		exit;
341 341
 
342 342
 	}
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
      * @return array
349 349
 	 */
350 350
 	public function get_notices() {
351
-		$notices = get_option( 'wpinv_admin_notices' );
352
-        return is_array( $notices ) ? $notices : array();
351
+		$notices = get_option('wpinv_admin_notices');
352
+        return is_array($notices) ? $notices : array();
353 353
 	}
354 354
 
355 355
 	/**
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @since       1.0.19
360 360
 	 */
361 361
 	public function clear_notices() {
362
-		delete_option( 'wpinv_admin_notices' );
362
+		delete_option('wpinv_admin_notices');
363 363
 	}
364 364
 
365 365
 	/**
@@ -368,16 +368,16 @@  discard block
 block discarded – undo
368 368
 	 * @access      public
369 369
 	 * @since       1.0.19
370 370
 	 */
371
-	public function save_notice( $type, $message ) {
371
+	public function save_notice($type, $message) {
372 372
 		$notices = $this->get_notices();
373 373
 
374
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
375
-			$notices[ $type ] = array();
374
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
375
+			$notices[$type] = array();
376 376
 		}
377 377
 
378
-		$notices[ $type ][] = $message;
378
+		$notices[$type][] = $message;
379 379
 
380
-		update_option( 'wpinv_admin_notices', $notices );
380
+		update_option('wpinv_admin_notices', $notices);
381 381
 	}
382 382
 
383 383
 	/**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @access      public
388 388
 	 * @since       1.0.19
389 389
 	 */
390
-	public function show_success( $msg ) {
391
-		$this->save_notice( 'success', $msg );
390
+	public function show_success($msg) {
391
+		$this->save_notice('success', $msg);
392 392
 	}
393 393
 
394 394
 	/**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param       string $msg The message to qeue.
399 399
 	 * @since       1.0.19
400 400
 	 */
401
-	public function show_error( $msg ) {
402
-		$this->save_notice( 'error', $msg );
401
+	public function show_error($msg) {
402
+		$this->save_notice('error', $msg);
403 403
 	}
404 404
 
405 405
 	/**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param       string $msg The message to qeue.
410 410
 	 * @since       1.0.19
411 411
 	 */
412
-	public function show_warning( $msg ) {
413
-		$this->save_notice( 'warning', $msg );
412
+	public function show_warning($msg) {
413
+		$this->save_notice('warning', $msg);
414 414
 	}
415 415
 
416 416
 	/**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param       string $msg The message to qeue.
421 421
 	 * @since       1.0.19
422 422
 	 */
423
-	public function show_info( $msg ) {
424
-		$this->save_notice( 'info', $msg );
423
+	public function show_info($msg) {
424
+		$this->save_notice('info', $msg);
425 425
 	}
426 426
 
427 427
 	/**
@@ -435,15 +435,15 @@  discard block
 block discarded – undo
435 435
         $notices = $this->get_notices();
436 436
         $this->clear_notices();
437 437
 
438
-		foreach ( $notices as $type => $messages ) {
438
+		foreach ($notices as $type => $messages) {
439 439
 
440
-			if ( ! is_array( $messages ) ) {
440
+			if (!is_array($messages)) {
441 441
 				continue;
442 442
 			}
443 443
 
444
-            $type  = sanitize_key( $type );
445
-			foreach ( $messages as $message ) {
446
-                $message = wp_kses_post( $message );
444
+            $type = sanitize_key($type);
445
+			foreach ($messages as $message) {
446
+                $message = wp_kses_post($message);
447 447
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
448 448
             }
449 449
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-details.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;
30
+        wp_nonce_field('wpinv_details', 'wpinv_details_nonce');
31 31
 
32 32
 
33 33
         ?>
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
                 <div class="bsui" style="margin-top: 1.5rem">
48 48
 
49
-                    <?php if ( ! $invoice->is_draft() ) : ?>
49
+                    <?php if (!$invoice->is_draft()) : ?>
50 50
                         <div class="form-group">
51
-                            <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong>
52
-                            <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?>
51
+                            <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong>
52
+                            <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?>
53 53
                         </div>
54 54
                     <?php endif; ?>
55 55
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
                         // Date created.
59 59
                         $label = sprintf(
60
-                            __( '%s Date:', 'invoicing' ),
61
-                            ucfirst( $invoice->get_type() )
60
+                            __('%s Date:', 'invoicing'),
61
+                            ucfirst($invoice->get_type())
62 62
                         );
63 63
 
64
-                        $info  = sprintf(
65
-                            __( 'The date this %s was created.', 'invoicing' ),
66
-                            strtolower( $invoice->get_type() )
64
+                        $info = sprintf(
65
+                            __('The date this %s was created.', 'invoicing'),
66
+                            strtolower($invoice->get_type())
67 67
                         );
68 68
 
69 69
                         echo aui()->input(
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
                                 'type'        => 'datepicker',
72 72
                                 'id'          => 'wpinv_date_created',
73 73
                                 'name'        => 'date_created',
74
-                                'label'       => $label . getpaid_get_help_tip( $info ),
74
+                                'label'       => $label . getpaid_get_help_tip($info),
75 75
                                 'label_type'  => 'vertical',
76 76
                                 'placeholder' => 'YYYY-MM-DD 00:00',
77 77
                                 'class'       => 'form-control-sm',
78
-                                'value'       => $invoice->get_date_created( 'edit' ),
78
+                                'value'       => $invoice->get_date_created('edit'),
79 79
                                 'extra_attributes' => array(
80 80
                                     'data-enable-time' => 'true',
81 81
                                     'data-time_24hr'   => 'true',
@@ -86,30 +86,30 @@  discard block
 block discarded – undo
86 86
                         );
87 87
 
88 88
                         // Due date.
89
-                        if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) {
89
+                        if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) {
90 90
 
91 91
                             echo aui()->input(
92 92
                                 array(
93 93
                                     'type'        => 'text',
94 94
                                     'id'          => 'wpinv_due_date',
95 95
                                     'name'        => 'wpinv_due_date',
96
-                                    'label'       => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ),
96
+                                    'label'       => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')),
97 97
                                     'label_type'  => 'vertical',
98
-                                    'placeholder' => __( 'No due date', 'invoicing' ),
98
+                                    'placeholder' => __('No due date', 'invoicing'),
99 99
                                     'class'       => 'form-control-sm',
100
-                                    'value'       => $invoice->get_due_date( 'edit' ),
100
+                                    'value'       => $invoice->get_due_date('edit'),
101 101
                                 )
102 102
                             );
103 103
 
104 104
                         }
105 105
 
106
-                        do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() );
107
-                        do_action( 'getpaid_metabox_after_due_date', $invoice );
106
+                        do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id());
107
+                        do_action('getpaid_metabox_after_due_date', $invoice);
108 108
 
109 109
                         // Status.
110 110
                         $label = sprintf(
111
-                            __( '%s Status:', 'invoicing' ),
112
-                            ucfirst( $invoice->get_type() )
111
+                            __('%s Status:', 'invoicing'),
112
+                            ucfirst($invoice->get_type())
113 113
                         );
114 114
 
115 115
                         echo aui()->select(
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
                                 'name'             => 'wpinv_status',
119 119
                                 'label'            => $label,
120 120
                                 'label_type'       => 'vertical',
121
-                                'placeholder'      => __( 'Select Status', 'invoicing' ),
122
-                                'value'            => $invoice->get_status( 'edit' ),
121
+                                'placeholder'      => __('Select Status', 'invoicing'),
122
+                                'value'            => $invoice->get_status('edit'),
123 123
                                 'select2'          => true,
124 124
                                 'data-allow-clear' => 'false',
125
-                                'options'          => wpinv_get_invoice_statuses( true, false, $invoice )
125
+                                'options'          => wpinv_get_invoice_statuses(true, false, $invoice)
126 126
                             )
127 127
                         );
128 128
 
129 129
                         // Invoice number.
130 130
                         $label = sprintf(
131
-                            __( '%s Number:', 'invoicing' ),
132
-                            ucfirst( $invoice->get_type() )
131
+                            __('%s Number:', 'invoicing'),
132
+                            ucfirst($invoice->get_type())
133 133
                         );
134 134
 
135
-                        $info  = sprintf(
136
-                            __( 'Each %s number must be unique.', 'invoicing' ),
137
-                            strtolower( $invoice->get_type() )
135
+                        $info = sprintf(
136
+                            __('Each %s number must be unique.', 'invoicing'),
137
+                            strtolower($invoice->get_type())
138 138
                         );
139 139
 
140 140
                         echo aui()->input(
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
                                 'type'        => 'text',
143 143
                                 'id'          => 'wpinv_number',
144 144
                                 'name'        => 'wpinv_number',
145
-                                'label'       => $label . getpaid_get_help_tip( $info ),
145
+                                'label'       => $label . getpaid_get_help_tip($info),
146 146
                                 'label_type'  => 'vertical',
147
-                                'placeholder' => __( 'Autogenerate', 'invoicing' ),
147
+                                'placeholder' => __('Autogenerate', 'invoicing'),
148 148
                                 'class'       => 'form-control-sm',
149
-                                'value'       => $invoice->get_number( 'edit' ),
149
+                                'value'       => $invoice->get_number('edit'),
150 150
                             )
151 151
                         );
152 152
 
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
                                 'type'        => 'text',
157 157
                                 'id'          => 'wpinv_cc',
158 158
                                 'name'        => 'wpinv_cc',
159
-                                'label'       => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ),
159
+                                'label'       => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')),
160 160
                                 'label_type'  => 'vertical',
161
-                                'placeholder' => __( '[email protected], [email protected]', 'invoicing' ),
161
+                                'placeholder' => __('[email protected], [email protected]', 'invoicing'),
162 162
                                 'class'       => 'form-control-sm',
163
-                                'value'       => $invoice->get_email_cc( 'edit' ),
163
+                                'value'       => $invoice->get_email_cc('edit'),
164 164
                             )
165 165
                         );
166 166
 
167
-                        do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() );
167
+                        do_action('wpinv_meta_box_details_inner', $invoice->get_id());
168 168
 
169 169
                         // Disable taxes.
170
-                        if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) {
170
+                        if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) {
171 171
 
172 172
                             echo aui()->input(
173 173
                                 array(
174 174
                                     'id'          => 'wpinv_taxable',
175 175
                                     'name'        => 'disable_taxes',
176 176
                                     'type'        => 'checkbox',
177
-                                    'label'       => __( 'Disable taxes', 'invoicing' ),
177
+                                    'label'       => __('Disable taxes', 'invoicing'),
178 178
                                     'value'       => '1',
179 179
                                     'checked'     => (bool) $invoice->get_disable_taxes(),
180 180
                                 )
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
                         }
184 184
 
185 185
                         // Apply a discount.
186
-                        if ( $invoice->get_discount_code( 'edit' ) ) {
186
+                        if ($invoice->get_discount_code('edit')) {
187 187
 
188 188
                             echo aui()->input(
189 189
                                 array(
190 190
                                     'type'        => 'text',
191 191
                                     'id'          => 'wpinv_discount_code',
192 192
                                     'name'        => 'wpinv_discount_code',
193
-                                    'label'       => __( 'Discount Code:', 'invoicing' ),
193
+                                    'label'       => __('Discount Code:', 'invoicing'),
194 194
                                     'label_type'  => 'vertical',
195 195
                                     'class'       => 'form-control-sm',
196
-                                    'value'       => $invoice->get_discount_code( 'edit' ),
196
+                                    'value'       => $invoice->get_discount_code('edit'),
197 197
                                     'extra_attributes' => array(
198 198
                                         'onclick'  => 'this.select();',
199 199
                                         'readonly' => 'true',
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = sanitize_text_field( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = sanitize_text_field($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = esc_html( $value );
30
+            $value = esc_html($value);
31 31
             echo "<div class='col-6 form-group'><strong>$key:</strong></div><div class='col-6 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +472 added lines, -472 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,127 +228,127 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
298
-    $current     = date( 'Y' );
299
-    $start_year  = $current - absint( $years_before );
300
-    $end_year    = $current + absint( $years_after );
301
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
297
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
298
+    $current     = date('Y');
299
+    $start_year  = $current - absint($years_before);
300
+    $end_year    = $current + absint($years_after);
301
+    $selected    = empty($selected) ? date('Y') : $selected;
302 302
     $options     = array();
303 303
 
304
-    while ( $start_year <= $end_year ) {
305
-        $options[ absint( $start_year ) ] = $start_year;
304
+    while ($start_year <= $end_year) {
305
+        $options[absint($start_year)] = $start_year;
306 306
         $start_year++;
307 307
     }
308 308
 
309
-    $output = wpinv_html_select( array(
309
+    $output = wpinv_html_select(array(
310 310
         'name'             => $name,
311 311
         'selected'         => $selected,
312 312
         'options'          => $options,
313 313
         'show_option_all'  => false,
314 314
         'show_option_none' => false
315
-    ) );
315
+    ));
316 316
 
317 317
     return $output;
318 318
 }
319 319
 
320
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
320
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
321 321
 
322 322
     $options = array(
323
-        '1'  => __( 'January', 'invoicing' ),
324
-        '2'  => __( 'February', 'invoicing' ),
325
-        '3'  => __( 'March', 'invoicing' ),
326
-        '4'  => __( 'April', 'invoicing' ),
327
-        '5'  => __( 'May', 'invoicing' ),
328
-        '6'  => __( 'June', 'invoicing' ),
329
-        '7'  => __( 'July', 'invoicing' ),
330
-        '8'  => __( 'August', 'invoicing' ),
331
-        '9'  => __( 'September', 'invoicing' ),
332
-        '10' => __( 'October', 'invoicing' ),
333
-        '11' => __( 'November', 'invoicing' ),
334
-        '12' => __( 'December', 'invoicing' ),
323
+        '1'  => __('January', 'invoicing'),
324
+        '2'  => __('February', 'invoicing'),
325
+        '3'  => __('March', 'invoicing'),
326
+        '4'  => __('April', 'invoicing'),
327
+        '5'  => __('May', 'invoicing'),
328
+        '6'  => __('June', 'invoicing'),
329
+        '7'  => __('July', 'invoicing'),
330
+        '8'  => __('August', 'invoicing'),
331
+        '9'  => __('September', 'invoicing'),
332
+        '10' => __('October', 'invoicing'),
333
+        '11' => __('November', 'invoicing'),
334
+        '12' => __('December', 'invoicing'),
335 335
     );
336 336
 
337 337
     // If no month is selected, default to the current month
338
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
338
+    $selected = empty($selected) ? date('n') : $selected;
339 339
 
340
-    $output = wpinv_html_select( array(
340
+    $output = wpinv_html_select(array(
341 341
         'name'             => $name,
342 342
         'selected'         => $selected,
343 343
         'options'          => $options,
344 344
         'show_option_all'  => false,
345 345
         'show_option_none' => false
346
-    ) );
346
+    ));
347 347
 
348 348
     return $output;
349 349
 }
350 350
 
351
-function wpinv_html_select( $args = array() ) {
351
+function wpinv_html_select($args = array()) {
352 352
     $defaults = array(
353 353
         'options'          => array(),
354 354
         'name'             => null,
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
         'selected'         => 0,
358 358
         'placeholder'      => null,
359 359
         'multiple'         => false,
360
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
361
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
360
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
361
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
362 362
         'data'             => array(),
363 363
         'onchange'         => null,
364 364
         'required'         => false,
@@ -366,74 +366,74 @@  discard block
 block discarded – undo
366 366
         'readonly'         => false,
367 367
     );
368 368
 
369
-    $args = wp_parse_args( $args, $defaults );
369
+    $args = wp_parse_args($args, $defaults);
370 370
 
371 371
     $data_elements = '';
372
-    foreach ( $args['data'] as $key => $value ) {
373
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
372
+    foreach ($args['data'] as $key => $value) {
373
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
374 374
     }
375 375
 
376
-    if( $args['multiple'] ) {
376
+    if ($args['multiple']) {
377 377
         $multiple = ' MULTIPLE';
378 378
     } else {
379 379
         $multiple = '';
380 380
     }
381 381
 
382
-    if( $args['placeholder'] ) {
382
+    if ($args['placeholder']) {
383 383
         $placeholder = $args['placeholder'];
384 384
     } else {
385 385
         $placeholder = '';
386 386
     }
387 387
     
388 388
     $options = '';
389
-    if( !empty( $args['onchange'] ) ) {
390
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
389
+    if (!empty($args['onchange'])) {
390
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
391 391
     }
392 392
     
393
-    if( !empty( $args['required'] ) ) {
393
+    if (!empty($args['required'])) {
394 394
         $options .= ' required="required"';
395 395
     }
396 396
     
397
-    if( !empty( $args['disabled'] ) ) {
397
+    if (!empty($args['disabled'])) {
398 398
         $options .= ' disabled';
399 399
     }
400 400
     
401
-    if( !empty( $args['readonly'] ) ) {
401
+    if (!empty($args['readonly'])) {
402 402
         $options .= ' readonly';
403 403
     }
404 404
 
405
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
406
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
405
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
406
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
407 407
 
408
-    if ( $args['show_option_all'] ) {
409
-        if( $args['multiple'] ) {
410
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
408
+    if ($args['show_option_all']) {
409
+        if ($args['multiple']) {
410
+            $selected = selected(true, in_array(0, $args['selected']), false);
411 411
         } else {
412
-            $selected = selected( $args['selected'], 0, false );
412
+            $selected = selected($args['selected'], 0, false);
413 413
         }
414
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
414
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
415 415
     }
416 416
 
417
-    if ( !empty( $args['options'] ) ) {
417
+    if (!empty($args['options'])) {
418 418
 
419
-        if ( $args['show_option_none'] ) {
420
-            if( $args['multiple'] ) {
421
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
419
+        if ($args['show_option_none']) {
420
+            if ($args['multiple']) {
421
+                $selected = selected(true, in_array("", $args['selected']), false);
422 422
             } else {
423
-                $selected = selected( $args['selected'] === "", true, false );
423
+                $selected = selected($args['selected'] === "", true, false);
424 424
             }
425
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
425
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
426 426
         }
427 427
 
428
-        foreach( $args['options'] as $key => $option ) {
428
+        foreach ($args['options'] as $key => $option) {
429 429
 
430
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
431
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
430
+            if ($args['multiple'] && is_array($args['selected'])) {
431
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
432 432
             } else {
433
-                $selected = selected( $args['selected'], $key, false );
433
+                $selected = selected($args['selected'], $key, false);
434 434
             }
435 435
 
436
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
436
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
437 437
         }
438 438
     }
439 439
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     return $output;
443 443
 }
444 444
 
445
-function wpinv_item_dropdown( $args = array() ) {
445
+function wpinv_item_dropdown($args = array()) {
446 446
     $defaults = array(
447 447
         'name'              => 'wpi_item',
448 448
         'id'                => 'wpi_item',
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
         'multiple'          => false,
451 451
         'selected'          => 0,
452 452
         'number'            => 100,
453
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
454
-        'data'              => array( 'search-type' => 'item' ),
453
+        'placeholder'       => __('Choose a item', 'invoicing'),
454
+        'data'              => array('search-type' => 'item'),
455 455
         'show_option_all'   => false,
456 456
         'show_option_none'  => false,
457 457
         'show_recurring'    => false,
458 458
     );
459 459
 
460
-    $args = wp_parse_args( $args, $defaults );
460
+    $args = wp_parse_args($args, $defaults);
461 461
 
462 462
     $item_args = array(
463 463
         'post_type'      => 'wpi_item',
@@ -466,44 +466,44 @@  discard block
 block discarded – undo
466 466
         'posts_per_page' => $args['number']
467 467
     );
468 468
 
469
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
469
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
470 470
 
471
-    $items      = get_posts( $item_args );
471
+    $items      = get_posts($item_args);
472 472
     $options    = array();
473
-    if ( $items ) {
474
-        foreach ( $items as $item ) {
475
-            $title = esc_html( $item->post_title );
473
+    if ($items) {
474
+        foreach ($items as $item) {
475
+            $title = esc_html($item->post_title);
476 476
             
477
-            if ( !empty( $args['show_recurring'] ) ) {
478
-                $title .= wpinv_get_item_suffix( $item->ID, false );
477
+            if (!empty($args['show_recurring'])) {
478
+                $title .= wpinv_get_item_suffix($item->ID, false);
479 479
             }
480 480
             
481
-            $options[ absint( $item->ID ) ] = $title;
481
+            $options[absint($item->ID)] = $title;
482 482
         }
483 483
     }
484 484
 
485 485
     // This ensures that any selected items are included in the drop down
486
-    if( is_array( $args['selected'] ) ) {
487
-        foreach( $args['selected'] as $item ) {
488
-            if( ! in_array( $item, $options ) ) {
489
-                $title = get_the_title( $item );
490
-                if ( !empty( $args['show_recurring'] ) ) {
491
-                    $title .= wpinv_get_item_suffix( $item, false );
486
+    if (is_array($args['selected'])) {
487
+        foreach ($args['selected'] as $item) {
488
+            if (!in_array($item, $options)) {
489
+                $title = get_the_title($item);
490
+                if (!empty($args['show_recurring'])) {
491
+                    $title .= wpinv_get_item_suffix($item, false);
492 492
                 }
493 493
                 $options[$item] = $title;
494 494
             }
495 495
         }
496
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
497
-        if ( ! in_array( $args['selected'], $options ) ) {
498
-            $title = get_the_title( $args['selected'] );
499
-            if ( !empty( $args['show_recurring'] ) ) {
500
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
496
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
497
+        if (!in_array($args['selected'], $options)) {
498
+            $title = get_the_title($args['selected']);
499
+            if (!empty($args['show_recurring'])) {
500
+                $title .= wpinv_get_item_suffix($args['selected'], false);
501 501
             }
502
-            $options[$args['selected']] = get_the_title( $args['selected'] );
502
+            $options[$args['selected']] = get_the_title($args['selected']);
503 503
         }
504 504
     }
505 505
 
506
-    $output = wpinv_html_select( array(
506
+    $output = wpinv_html_select(array(
507 507
         'name'             => $args['name'],
508 508
         'selected'         => $args['selected'],
509 509
         'id'               => $args['id'],
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         'show_option_all'  => $args['show_option_all'],
515 515
         'show_option_none' => $args['show_option_none'],
516 516
         'data'             => $args['data'],
517
-    ) );
517
+    ));
518 518
 
519 519
     return $output;
520 520
 }
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
     );
535 535
 
536 536
     $options = array();
537
-    if ( $items ) {
538
-        foreach ( $items as $item ) {
539
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
537
+    if ($items) {
538
+        foreach ($items as $item) {
539
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
540 540
         }
541 541
     }
542 542
 
543 543
     return $options;
544 544
 }
545 545
 
546
-function wpinv_html_checkbox( $args = array() ) {
546
+function wpinv_html_checkbox($args = array()) {
547 547
     $defaults = array(
548 548
         'name'     => null,
549 549
         'current'  => null,
@@ -554,17 +554,17 @@  discard block
 block discarded – undo
554 554
         )
555 555
     );
556 556
 
557
-    $args = wp_parse_args( $args, $defaults );
557
+    $args = wp_parse_args($args, $defaults);
558 558
 
559
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
559
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
560 560
     $options = '';
561
-    if ( ! empty( $args['options']['disabled'] ) ) {
561
+    if (!empty($args['options']['disabled'])) {
562 562
         $options .= ' disabled="disabled"';
563
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
563
+    } elseif (!empty($args['options']['readonly'])) {
564 564
         $options .= ' readonly';
565 565
     }
566 566
 
567
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
567
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
568 568
 
569 569
     return $output;
570 570
 }
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 /**
573 573
  * Displays a hidden field.
574 574
  */
575
-function getpaid_hidden_field( $name, $value ) {
576
-    $name  = sanitize_text_field( $name );
577
-    $value = esc_attr( $value );
575
+function getpaid_hidden_field($name, $value) {
576
+    $name  = sanitize_text_field($name);
577
+    $value = esc_attr($value);
578 578
 
579 579
     echo "<input type='hidden' name='$name' value='$value' />";
580 580
 }
@@ -582,31 +582,31 @@  discard block
 block discarded – undo
582 582
 /**
583 583
  * Displays a submit field.
584 584
  */
585
-function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) {
586
-    $name  = sanitize_text_field( $name );
587
-    $value = esc_attr( $value );
588
-    $class = esc_attr( $class );
585
+function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') {
586
+    $name  = sanitize_text_field($name);
587
+    $value = esc_attr($value);
588
+    $class = esc_attr($class);
589 589
 
590 590
     echo "<input type='submit' name='$name' value='$value' class='btn $class' />";
591 591
 }
592 592
 
593
-function wpinv_html_text( $args = array() ) {
593
+function wpinv_html_text($args = array()) {
594 594
     // Backwards compatibility
595
-    if ( func_num_args() > 1 ) {
595
+    if (func_num_args() > 1) {
596 596
         $args = func_get_args();
597 597
 
598 598
         $name  = $args[0];
599
-        $value = isset( $args[1] ) ? $args[1] : '';
600
-        $label = isset( $args[2] ) ? $args[2] : '';
601
-        $desc  = isset( $args[3] ) ? $args[3] : '';
599
+        $value = isset($args[1]) ? $args[1] : '';
600
+        $label = isset($args[2]) ? $args[2] : '';
601
+        $desc  = isset($args[3]) ? $args[3] : '';
602 602
     }
603 603
 
604 604
     $defaults = array(
605 605
         'id'           => '',
606
-        'name'         => isset( $name )  ? $name  : 'text',
607
-        'value'        => isset( $value ) ? $value : null,
608
-        'label'        => isset( $label ) ? $label : null,
609
-        'desc'         => isset( $desc )  ? $desc  : null,
606
+        'name'         => isset($name) ? $name : 'text',
607
+        'value'        => isset($value) ? $value : null,
608
+        'label'        => isset($label) ? $label : null,
609
+        'desc'         => isset($desc) ? $desc : null,
610 610
         'placeholder'  => '',
611 611
         'class'        => 'regular-text',
612 612
         'disabled'     => false,
@@ -616,41 +616,41 @@  discard block
 block discarded – undo
616 616
         'data'         => false
617 617
     );
618 618
 
619
-    $args = wp_parse_args( $args, $defaults );
619
+    $args = wp_parse_args($args, $defaults);
620 620
 
621
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
621
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
622 622
     $options = '';
623
-    if( $args['required'] ) {
623
+    if ($args['required']) {
624 624
         $options .= ' required="required"';
625 625
     }
626
-    if( $args['readonly'] ) {
626
+    if ($args['readonly']) {
627 627
         $options .= ' readonly';
628 628
     }
629
-    if( $args['readonly'] ) {
629
+    if ($args['readonly']) {
630 630
         $options .= ' readonly';
631 631
     }
632 632
 
633 633
     $data = '';
634
-    if ( !empty( $args['data'] ) ) {
635
-        foreach ( $args['data'] as $key => $value ) {
636
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
634
+    if (!empty($args['data'])) {
635
+        foreach ($args['data'] as $key => $value) {
636
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
637 637
         }
638 638
     }
639 639
 
640
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
641
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
642
-    if ( ! empty( $args['desc'] ) ) {
643
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
640
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
641
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
642
+    if (!empty($args['desc'])) {
643
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
644 644
     }
645 645
 
646
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
646
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
647 647
 
648 648
     $output .= '</span>';
649 649
 
650 650
     return $output;
651 651
 }
652 652
 
653
-function wpinv_html_textarea( $args = array() ) {
653
+function wpinv_html_textarea($args = array()) {
654 654
     $defaults = array(
655 655
         'name'        => 'textarea',
656 656
         'value'       => null,
@@ -661,31 +661,31 @@  discard block
 block discarded – undo
661 661
         'placeholder' => '',
662 662
     );
663 663
 
664
-    $args = wp_parse_args( $args, $defaults );
664
+    $args = wp_parse_args($args, $defaults);
665 665
 
666
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
666
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
667 667
     $disabled = '';
668
-    if( $args['disabled'] ) {
668
+    if ($args['disabled']) {
669 669
         $disabled = ' disabled="disabled"';
670 670
     }
671 671
 
672
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
673
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
674
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
672
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
673
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
674
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
675 675
 
676
-    if ( ! empty( $args['desc'] ) ) {
677
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
676
+    if (!empty($args['desc'])) {
677
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
678 678
     }
679 679
     $output .= '</span>';
680 680
 
681 681
     return $output;
682 682
 }
683 683
 
684
-function wpinv_html_ajax_user_search( $args = array() ) {
684
+function wpinv_html_ajax_user_search($args = array()) {
685 685
     $defaults = array(
686 686
         'name'        => 'user_id',
687 687
         'value'       => null,
688
-        'placeholder' => __( 'Enter username', 'invoicing' ),
688
+        'placeholder' => __('Enter username', 'invoicing'),
689 689
         'label'       => null,
690 690
         'desc'        => null,
691 691
         'class'       => '',
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
         'data'        => false
695 695
     );
696 696
 
697
-    $args = wp_parse_args( $args, $defaults );
697
+    $args = wp_parse_args($args, $defaults);
698 698
 
699 699
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
700 700
 
701 701
     $output  = '<span class="wpinv_user_search_wrap">';
702
-        $output .= wpinv_html_text( $args );
703
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
702
+        $output .= wpinv_html_text($args);
703
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
704 704
     $output .= '</span>';
705 705
 
706 706
     return $output;
@@ -711,20 +711,20 @@  discard block
 block discarded – undo
711 711
  * 
712 712
  * @param string $template the template that is currently being used.
713 713
  */
714
-function wpinv_template( $template ) {
714
+function wpinv_template($template) {
715 715
     global $post;
716 716
 
717
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
717
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
718 718
 
719 719
         // If the user can view this invoice, display it.
720
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
720
+        if (wpinv_user_can_view_invoice($post->ID)) {
721 721
 
722
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
722
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
723 723
 
724 724
         // Else display an error message.
725 725
         } else {
726 726
 
727
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
727
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
728 728
 
729 729
         }
730 730
 
@@ -732,46 +732,46 @@  discard block
 block discarded – undo
732 732
 
733 733
     return $template;
734 734
 }
735
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
735
+add_filter('template_include', 'wpinv_template', 10, 1);
736 736
 
737 737
 function wpinv_get_business_address() {
738 738
     $business_address   = wpinv_store_address();
739
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
739
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
740 740
     
741 741
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
742 742
     
743
-    return apply_filters( 'wpinv_get_business_address', $business_address );
743
+    return apply_filters('wpinv_get_business_address', $business_address);
744 744
 }
745 745
 
746 746
 /**
747 747
  * Displays the company address.
748 748
  */
749 749
 function wpinv_display_from_address() {
750
-    wpinv_get_template( 'invoice/company-address.php' );
750
+    wpinv_get_template('invoice/company-address.php');
751 751
 }
752
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
752
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
753 753
 
754
-function wpinv_watermark( $id = 0 ) {
755
-    $output = wpinv_get_watermark( $id );
756
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
754
+function wpinv_watermark($id = 0) {
755
+    $output = wpinv_get_watermark($id);
756
+    return apply_filters('wpinv_get_watermark', $output, $id);
757 757
 }
758 758
 
759
-function wpinv_get_watermark( $id ) {
760
-    if ( !$id > 0 ) {
759
+function wpinv_get_watermark($id) {
760
+    if (!$id > 0) {
761 761
         return NULL;
762 762
     }
763 763
 
764
-    $invoice = wpinv_get_invoice( $id );
764
+    $invoice = wpinv_get_invoice($id);
765 765
     
766
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
767
-        if ( $invoice->is_paid() ) {
768
-            return __( 'Paid', 'invoicing' );
766
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
767
+        if ($invoice->is_paid()) {
768
+            return __('Paid', 'invoicing');
769 769
         }
770
-        if ( $invoice->is_refunded() ) {
771
-            return __( 'Refunded', 'invoicing' );
770
+        if ($invoice->is_refunded()) {
771
+            return __('Refunded', 'invoicing');
772 772
         }
773
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
774
-            return __( 'Cancelled', 'invoicing' );
773
+        if ($invoice->has_status(array('wpi-cancelled'))) {
774
+            return __('Cancelled', 'invoicing');
775 775
         }
776 776
     }
777 777
     
@@ -781,30 +781,30 @@  discard block
 block discarded – undo
781 781
 /**
782 782
  * @deprecated
783 783
  */
784
-function wpinv_display_invoice_details( $invoice ) {
785
-    return getpaid_invoice_meta( $invoice );
784
+function wpinv_display_invoice_details($invoice) {
785
+    return getpaid_invoice_meta($invoice);
786 786
 }
787 787
 
788 788
 /**
789 789
  * Displays invoice meta.
790 790
  */
791
-function getpaid_invoice_meta( $invoice ) {
791
+function getpaid_invoice_meta($invoice) {
792 792
 
793
-    $invoice = new WPInv_Invoice( $invoice );
793
+    $invoice = new WPInv_Invoice($invoice);
794 794
 
795 795
     // Ensure that we have an invoice.
796
-    if ( 0 == $invoice->get_id() ) {
796
+    if (0 == $invoice->get_id()) {
797 797
         return;
798 798
     }
799 799
 
800 800
     // Get the invoice meta.
801
-    $meta = getpaid_get_invoice_meta( $invoice );
801
+    $meta = getpaid_get_invoice_meta($invoice);
802 802
 
803 803
     // Display the meta.
804
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
804
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
805 805
 
806 806
 }
807
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
807
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
808 808
 
809 809
 /**
810 810
  * Retrieves the address markup to use on Invoices.
@@ -816,29 +816,29 @@  discard block
 block discarded – undo
816 816
  * @param  string $separator How to separate address lines.
817 817
  * @return string
818 818
  */
819
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
819
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
820 820
 
821 821
     // Retrieve the address markup...
822
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
823
-    $format = wpinv_get_full_address_format( $country );
822
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
823
+    $format = wpinv_get_full_address_format($country);
824 824
 
825 825
     // ... and the replacements.
826
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
826
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
827 827
 
828
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
828
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
829 829
     
830 830
 	// Remove unavailable tags.
831
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
831
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
832 832
 
833 833
     // Clean up white space.
834
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
835
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
834
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
835
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
836 836
     
837 837
     // Break newlines apart and remove empty lines/trim commas and white space.
838
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
838
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
839 839
 
840 840
     // Add html breaks.
841
-	$formatted_address = implode( $separator, $formatted_address );
841
+	$formatted_address = implode($separator, $formatted_address);
842 842
 
843 843
 	// We're done!
844 844
 	return $formatted_address;
@@ -850,88 +850,88 @@  discard block
 block discarded – undo
850 850
  * 
851 851
  * @param WPInv_Invoice $invoice
852 852
  */
853
-function wpinv_display_to_address( $invoice = 0 ) {
854
-    if ( ! empty( $invoice ) ) {
855
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
853
+function wpinv_display_to_address($invoice = 0) {
854
+    if (!empty($invoice)) {
855
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
856 856
     }
857 857
 }
858
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
858
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
859 859
 
860 860
 
861 861
 /**
862 862
  * Displays invoice line items.
863 863
  */
864
-function wpinv_display_line_items( $invoice_id = 0 ) {
864
+function wpinv_display_line_items($invoice_id = 0) {
865 865
 
866 866
     // Prepare the invoice.
867
-    $invoice = new WPInv_Invoice( $invoice_id );
867
+    $invoice = new WPInv_Invoice($invoice_id);
868 868
 
869 869
     // Abort if there is no invoice.
870
-    if ( 0 == $invoice->get_id() ) {
870
+    if (0 == $invoice->get_id()) {
871 871
         return;
872 872
     }
873 873
 
874 874
     // Line item columns.
875
-    $columns = getpaid_invoice_item_columns( $invoice );
876
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
875
+    $columns = getpaid_invoice_item_columns($invoice);
876
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
877 877
 
878
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
878
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
879 879
 }
880
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
880
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
881 881
 
882 882
 /**
883 883
  * Displays invoice notices on invoices.
884 884
  */
885 885
 function wpinv_display_invoice_notice() {
886 886
 
887
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
888
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
887
+    $label  = wpinv_get_option('vat_invoice_notice_label');
888
+    $notice = wpinv_get_option('vat_invoice_notice');
889 889
 
890
-    if ( empty( $label ) && empty( $notice ) ) {
890
+    if (empty($label) && empty($notice)) {
891 891
         return;
892 892
     }
893 893
 
894 894
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
895 895
 
896
-    if ( ! empty( $label ) ) {
897
-        $label = sanitize_text_field( $label );
896
+    if (!empty($label)) {
897
+        $label = sanitize_text_field($label);
898 898
         echo "<h5>$label</h5>";
899 899
     }
900 900
 
901
-    if ( ! empty( $notice ) ) {
902
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
901
+    if (!empty($notice)) {
902
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
903 903
     }
904 904
 
905 905
     echo '</div>';
906 906
 }
907
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
907
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
908 908
 
909 909
 /**
910 910
  * @param WPInv_Invoice $invoice
911 911
  */
912
-function wpinv_display_invoice_notes( $invoice ) {
912
+function wpinv_display_invoice_notes($invoice) {
913 913
 
914 914
     // Retrieve the notes.
915
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
915
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
916 916
 
917 917
     // Abort if we have non.
918
-    if ( empty( $notes ) ) {
918
+    if (empty($notes)) {
919 919
         return;
920 920
     }
921 921
 
922 922
     // Echo the note.
923 923
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
924
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
924
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
925 925
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
926 926
 
927
-    foreach( $notes as $note ) {
928
-        wpinv_get_invoice_note_line_item( $note );
927
+    foreach ($notes as $note) {
928
+        wpinv_get_invoice_note_line_item($note);
929 929
     }
930 930
 
931 931
     echo '</ul>';
932 932
     echo '</div>';
933 933
 }
934
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
934
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
935 935
 
936 936
 /**
937 937
  * Loads scripts on our invoice templates.
@@ -939,31 +939,31 @@  discard block
 block discarded – undo
939 939
 function wpinv_display_style() {
940 940
 
941 941
     // Make sure that all scripts have been loaded.
942
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
943
-        do_action( 'wp_enqueue_scripts' );
942
+    if (!did_action('wp_enqueue_scripts')) {
943
+        do_action('wp_enqueue_scripts');
944 944
     }
945 945
 
946 946
     // Register the invoices style.
947
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
947
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
948 948
 
949 949
     // Load required styles
950
-    wp_print_styles( 'wpinv-single-style' );
951
-    wp_print_styles( 'ayecode-ui' );
950
+    wp_print_styles('wpinv-single-style');
951
+    wp_print_styles('ayecode-ui');
952 952
 
953 953
     // Maybe load custom css.
954
-    $custom_css = wpinv_get_option( 'template_custom_css' );
954
+    $custom_css = wpinv_get_option('template_custom_css');
955 955
 
956
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
957
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
958
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
956
+    if (isset($custom_css) && !empty($custom_css)) {
957
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
958
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
959 959
         echo '<style type="text/css">';
960 960
         echo $custom_css;
961 961
         echo '</style>';
962 962
     }
963 963
 
964 964
 }
965
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
966
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
965
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
966
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
967 967
 
968 968
 
969 969
 /**
@@ -975,41 +975,41 @@  discard block
 block discarded – undo
975 975
     // Retrieve the current invoice.
976 976
     $invoice_id = getpaid_get_current_invoice_id();
977 977
 
978
-    if ( empty( $invoice_id ) ) {
978
+    if (empty($invoice_id)) {
979 979
 
980 980
         return aui()->alert(
981 981
             array(
982 982
                 'type'    => 'warning',
983
-                'content' => __( 'Invalid invoice', 'invoicing' ),
983
+                'content' => __('Invalid invoice', 'invoicing'),
984 984
             )
985 985
         );
986 986
 
987 987
     }
988 988
 
989 989
     // Can the user view this invoice?
990
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
990
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
991 991
 
992 992
         return aui()->alert(
993 993
             array(
994 994
                 'type'    => 'warning',
995
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
995
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
996 996
             )
997 997
         );
998 998
 
999 999
     }
1000 1000
 
1001 1001
     // Ensure that it is not yet paid for.
1002
-    $invoice = new WPInv_Invoice( $invoice_id );
1002
+    $invoice = new WPInv_Invoice($invoice_id);
1003 1003
 
1004 1004
     // Maybe mark it as viewed.
1005
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1005
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1006 1006
 
1007
-    if ( $invoice->is_paid() ) {
1007
+    if ($invoice->is_paid()) {
1008 1008
 
1009 1009
         return aui()->alert(
1010 1010
             array(
1011 1011
                 'type'    => 'success',
1012
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1012
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1013 1013
             )
1014 1014
         );
1015 1015
 
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
     $wpi_checkout_id = $invoice_id;
1020 1020
 
1021 1021
     // We'll display this invoice via the default form.
1022
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1022
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1023 1023
 
1024
-    if ( 0 == $form->get_id() ) {
1024
+    if (0 == $form->get_id()) {
1025 1025
 
1026 1026
         return aui()->alert(
1027 1027
             array(
1028 1028
                 'type'    => 'warning',
1029
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1029
+                'content' => __('Error loading the payment form', 'invoicing'),
1030 1030
             )
1031 1031
         );
1032 1032
 
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
     // Set the invoice.
1036 1036
     $form->invoice = $invoice;
1037
-    $form->set_items( $invoice->get_items() );
1037
+    $form->set_items($invoice->get_items());
1038 1038
 
1039 1039
     // Generate the html.
1040 1040
     return $form->get_html();
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 }
1043 1043
 
1044 1044
 function wpinv_empty_cart_message() {
1045
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1045
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1059,38 +1059,38 @@  discard block
 block discarded – undo
1059 1059
         )
1060 1060
     );
1061 1061
 }
1062
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1062
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1063 1063
 
1064
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1065
-    $invoice = wpinv_get_invoice( $invoice_id );
1064
+function wpinv_receipt_billing_address($invoice_id = 0) {
1065
+    $invoice = wpinv_get_invoice($invoice_id);
1066 1066
 
1067
-    if ( empty( $invoice ) ) {
1067
+    if (empty($invoice)) {
1068 1068
         return NULL;
1069 1069
     }
1070 1070
 
1071 1071
     $billing_details = $invoice->get_user_info();
1072
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1072
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1073 1073
 
1074 1074
     ob_start();
1075 1075
     ?>
1076 1076
     <table class="table table-bordered table-sm wpi-billing-details">
1077 1077
         <tbody>
1078 1078
             <tr class="wpi-receipt-name">
1079
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1080
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1079
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1080
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1081 1081
             </tr>
1082 1082
             <tr class="wpi-receipt-email">
1083
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1084
-                <td><?php echo $billing_details['email'] ;?></td>
1083
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1084
+                <td><?php echo $billing_details['email']; ?></td>
1085 1085
             </tr>
1086 1086
             <tr class="wpi-receipt-address">
1087
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1088
-                <td><?php echo $address_row ;?></td>
1087
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1088
+                <td><?php echo $address_row; ?></td>
1089 1089
             </tr>
1090
-            <?php if ( $billing_details['phone'] ) { ?>
1090
+            <?php if ($billing_details['phone']) { ?>
1091 1091
             <tr class="wpi-receipt-phone">
1092
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1093
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1092
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1093
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1094 1094
             </tr>
1095 1095
             <?php } ?>
1096 1096
         </tbody>
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
     <?php
1099 1099
     $output = ob_get_clean();
1100 1100
     
1101
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1101
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1102 1102
 
1103 1103
     echo $output;
1104 1104
 }
@@ -1106,66 +1106,66 @@  discard block
 block discarded – undo
1106 1106
 /**
1107 1107
  * Filters the receipt page.
1108 1108
  */
1109
-function wpinv_filter_success_page_content( $content ) {
1109
+function wpinv_filter_success_page_content($content) {
1110 1110
 
1111 1111
     // Ensure this is our page.
1112
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1112
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1113 1113
 
1114
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1115
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1114
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1115
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1116 1116
 
1117 1117
     }
1118 1118
 
1119 1119
     return $content;
1120 1120
 }
1121
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1121
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1122 1122
 
1123
-function wpinv_invoice_link( $invoice_id ) {
1124
-    $invoice = wpinv_get_invoice( $invoice_id );
1123
+function wpinv_invoice_link($invoice_id) {
1124
+    $invoice = wpinv_get_invoice($invoice_id);
1125 1125
 
1126
-    if ( empty( $invoice ) ) {
1126
+    if (empty($invoice)) {
1127 1127
         return NULL;
1128 1128
     }
1129 1129
 
1130
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1130
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1131 1131
 
1132
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1132
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1133 1133
 }
1134 1134
 
1135
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1136
-    if ( empty( $note ) ) {
1135
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1136
+    if (empty($note)) {
1137 1137
         return NULL;
1138 1138
     }
1139 1139
 
1140
-    if ( is_int( $note ) ) {
1141
-        $note = get_comment( $note );
1140
+    if (is_int($note)) {
1141
+        $note = get_comment($note);
1142 1142
     }
1143 1143
 
1144
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1144
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1145 1145
         return NULL;
1146 1146
     }
1147 1147
 
1148
-    $note_classes   = array( 'note' );
1149
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1148
+    $note_classes   = array('note');
1149
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1150 1150
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1151
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1152
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1151
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1152
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1153 1153
 
1154 1154
     ob_start();
1155 1155
     ?>
1156
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1156
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1157 1157
         <div class="note_content bg-light border position-relative p-4">
1158 1158
 
1159
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1159
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1160 1160
 
1161
-            <?php if ( ! is_admin() ) : ?>
1161
+            <?php if (!is_admin()) : ?>
1162 1162
                 <em class="meta position-absolute form-text">
1163 1163
                     <?php
1164 1164
                         printf(
1165
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1165
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1166 1166
                             $note->comment_author,
1167
-                            getpaid_format_date_value( $note->comment_date ),
1168
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1167
+                            getpaid_format_date_value($note->comment_date),
1168
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1169 1169
                         );
1170 1170
                     ?>
1171 1171
                 </em>
@@ -1173,21 +1173,21 @@  discard block
 block discarded – undo
1173 1173
 
1174 1174
         </div>
1175 1175
 
1176
-        <?php if ( is_admin() ) : ?>
1176
+        <?php if (is_admin()) : ?>
1177 1177
 
1178 1178
             <p class="meta px-4 py-2">
1179
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1179
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1180 1180
                     <?php
1181 1181
                         printf(
1182
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1182
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1183 1183
                             $note->comment_author,
1184
-                            getpaid_format_date_value( $note->comment_date ),
1185
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1184
+                            getpaid_format_date_value($note->comment_date),
1185
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1186 1186
                         );
1187 1187
                     ?>
1188 1188
                 </abbr>&nbsp;&nbsp;
1189
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1190
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1189
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1190
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1191 1191
                 <?php } ?>
1192 1192
             </p>
1193 1193
 
@@ -1196,9 +1196,9 @@  discard block
 block discarded – undo
1196 1196
     </li>
1197 1197
     <?php
1198 1198
     $note_content = ob_get_clean();
1199
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1199
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1200 1200
 
1201
-    if ( $echo ) {
1201
+    if ($echo) {
1202 1202
         echo $note_content;
1203 1203
     } else {
1204 1204
         return $note_content;
@@ -1208,36 +1208,36 @@  discard block
 block discarded – undo
1208 1208
 function wpinv_invalid_invoice_content() {
1209 1209
     global $post;
1210 1210
 
1211
-    $invoice = wpinv_get_invoice( $post->ID );
1211
+    $invoice = wpinv_get_invoice($post->ID);
1212 1212
 
1213
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1214
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1215
-        if ( is_user_logged_in() ) {
1216
-            if ( wpinv_require_login_to_checkout() ) {
1217
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1218
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1213
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1214
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1215
+        if (is_user_logged_in()) {
1216
+            if (wpinv_require_login_to_checkout()) {
1217
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1218
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1219 1219
                 }
1220 1220
             }
1221 1221
         } else {
1222
-            if ( wpinv_require_login_to_checkout() ) {
1223
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1224
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1222
+            if (wpinv_require_login_to_checkout()) {
1223
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1224
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1225 1225
                 }
1226 1226
             }
1227 1227
         }
1228 1228
     } else {
1229
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1229
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1230 1230
     }
1231 1231
     ?>
1232 1232
     <div class="row wpinv-row-invalid">
1233 1233
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1234
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1234
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1235 1235
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1236 1236
         </div>
1237 1237
     </div>
1238 1238
     <?php
1239 1239
 }
1240
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1240
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1241 1241
 
1242 1242
 /**
1243 1243
  * Function to get privacy policy text.
@@ -1246,21 +1246,21 @@  discard block
 block discarded – undo
1246 1246
  * @return string
1247 1247
  */
1248 1248
 function wpinv_get_policy_text() {
1249
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1249
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1250 1250
 
1251
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1251
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1252 1252
 
1253
-    if(!$privacy_page_id){
1254
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1253
+    if (!$privacy_page_id) {
1254
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1255 1255
     }
1256 1256
 
1257
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1257
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1258 1258
 
1259 1259
     $find_replace = array(
1260 1260
         '[wpinv_privacy_policy]' => $privacy_link,
1261 1261
     );
1262 1262
 
1263
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1263
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1264 1264
 
1265 1265
     return wp_kses_post(wpautop($privacy_text));
1266 1266
 }
@@ -1268,21 +1268,21 @@  discard block
 block discarded – undo
1268 1268
 function wpinv_oxygen_fix_conflict() {
1269 1269
     global $ct_ignore_post_types;
1270 1270
 
1271
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1271
+    if (!is_array($ct_ignore_post_types)) {
1272 1272
         $ct_ignore_post_types = array();
1273 1273
     }
1274 1274
 
1275
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1275
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1276 1276
 
1277
-    foreach ( $post_types as $post_type ) {
1277
+    foreach ($post_types as $post_type) {
1278 1278
         $ct_ignore_post_types[] = $post_type;
1279 1279
 
1280 1280
         // Ignore post type
1281
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1281
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1282 1282
     }
1283 1283
 
1284
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1285
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1284
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1285
+    add_filter('template_include', 'wpinv_template', 999, 1);
1286 1286
 }
1287 1287
 
1288 1288
 /**
@@ -1290,10 +1290,10 @@  discard block
 block discarded – undo
1290 1290
  * 
1291 1291
  * @param GetPaid_Payment_Form $form
1292 1292
  */
1293
-function getpaid_display_payment_form( $form ) {
1293
+function getpaid_display_payment_form($form) {
1294 1294
 
1295
-    if ( is_numeric( $form ) ) {
1296
-        $form = new GetPaid_Payment_Form( $form );
1295
+    if (is_numeric($form)) {
1296
+        $form = new GetPaid_Payment_Form($form);
1297 1297
     }
1298 1298
 
1299 1299
     $form->display();
@@ -1303,55 +1303,55 @@  discard block
 block discarded – undo
1303 1303
 /**
1304 1304
  * Helper function to display a item payment form on the frontend.
1305 1305
  */
1306
-function getpaid_display_item_payment_form( $items ) {
1306
+function getpaid_display_item_payment_form($items) {
1307 1307
 
1308
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1309
-    $form->set_items( $items );
1308
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1309
+    $form->set_items($items);
1310 1310
 
1311
-    if ( 0 == count( $form->get_items() ) ) {
1311
+    if (0 == count($form->get_items())) {
1312 1312
         echo aui()->alert(
1313 1313
 			array(
1314 1314
 				'type'    => 'warning',
1315
-				'content' => __( 'No published items found', 'invoicing' ),
1315
+				'content' => __('No published items found', 'invoicing'),
1316 1316
 			)
1317 1317
         );
1318 1318
         return;
1319 1319
     }
1320 1320
 
1321
-    $form_items = esc_attr( getpaid_convert_items_to_string( $items ) );
1321
+    $form_items = esc_attr(getpaid_convert_items_to_string($items));
1322 1322
     $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />";
1323
-    $form->display( $form_items );
1323
+    $form->display($form_items);
1324 1324
 }
1325 1325
 
1326 1326
 /**
1327 1327
  * Helper function to display an invoice payment form on the frontend.
1328 1328
  */
1329
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1329
+function getpaid_display_invoice_payment_form($invoice_id) {
1330 1330
 
1331
-    $invoice = wpinv_get_invoice( $invoice_id );
1331
+    $invoice = wpinv_get_invoice($invoice_id);
1332 1332
 
1333
-    if ( empty( $invoice ) ) {
1333
+    if (empty($invoice)) {
1334 1334
 		echo aui()->alert(
1335 1335
 			array(
1336 1336
 				'type'    => 'warning',
1337
-				'content' => __( 'Invoice not found', 'invoicing' ),
1337
+				'content' => __('Invoice not found', 'invoicing'),
1338 1338
 			)
1339 1339
         );
1340 1340
         return;
1341 1341
     }
1342 1342
 
1343
-    if ( $invoice->is_paid() ) {
1343
+    if ($invoice->is_paid()) {
1344 1344
 		echo aui()->alert(
1345 1345
 			array(
1346 1346
 				'type'    => 'warning',
1347
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1347
+				'content' => __('Invoice has already been paid', 'invoicing'),
1348 1348
 			)
1349 1349
         );
1350 1350
         return;
1351 1351
     }
1352 1352
 
1353
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1354
-    $form->set_items( $invoice->get_items() );
1353
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1354
+    $form->set_items($invoice->get_items());
1355 1355
 
1356 1356
     $form->display();
1357 1357
 }
@@ -1359,23 +1359,23 @@  discard block
 block discarded – undo
1359 1359
 /**
1360 1360
  * Helper function to convert item string to array.
1361 1361
  */
1362
-function getpaid_convert_items_to_array( $items ) {
1363
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1362
+function getpaid_convert_items_to_array($items) {
1363
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1364 1364
     $prepared = array();
1365 1365
 
1366
-    foreach ( $items as $item ) {
1367
-        $data = array_map( 'trim', explode( '|', $item ) );
1366
+    foreach ($items as $item) {
1367
+        $data = array_map('trim', explode('|', $item));
1368 1368
 
1369
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1369
+        if (empty($data[0]) || !is_numeric($data[0])) {
1370 1370
             continue;
1371 1371
         }
1372 1372
 
1373 1373
         $quantity = 1;
1374
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1374
+        if (isset($data[1]) && is_numeric($data[1])) {
1375 1375
             $quantity = (int) $data[1];
1376 1376
         }
1377 1377
 
1378
-        $prepared[ $data[0] ] = $quantity;
1378
+        $prepared[$data[0]] = $quantity;
1379 1379
 
1380 1380
     }
1381 1381
 
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 /**
1386 1386
  * Helper function to convert item array to string.
1387 1387
  */
1388
-function getpaid_convert_items_to_string( $items ) {
1388
+function getpaid_convert_items_to_string($items) {
1389 1389
     $prepared = array();
1390 1390
 
1391
-    foreach ( $items as $item => $quantity ) {
1391
+    foreach ($items as $item => $quantity) {
1392 1392
         $prepared[] = "$item|$quantity";
1393 1393
     }
1394
-    return implode( ',', $prepared );
1394
+    return implode(',', $prepared);
1395 1395
 }
1396 1396
 
1397 1397
 /**
@@ -1399,21 +1399,21 @@  discard block
 block discarded – undo
1399 1399
  * 
1400 1400
  * Provide a label and one of $form, $items or $invoice.
1401 1401
  */
1402
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1403
-    $label = sanitize_text_field( $label );
1402
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1403
+    $label = sanitize_text_field($label);
1404 1404
 
1405
-    if ( ! empty( $form ) ) {
1406
-        $form  = esc_attr( $form );
1405
+    if (!empty($form)) {
1406
+        $form = esc_attr($form);
1407 1407
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; 
1408 1408
     }
1409 1409
 	
1410
-	if ( ! empty( $items ) ) {
1411
-        $items  = esc_attr( $items );
1410
+	if (!empty($items)) {
1411
+        $items = esc_attr($items);
1412 1412
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; 
1413 1413
     }
1414 1414
     
1415
-    if ( ! empty( $invoice ) ) {
1416
-        $invoice  = esc_attr( $invoice );
1415
+    if (!empty($invoice)) {
1416
+        $invoice = esc_attr($invoice);
1417 1417
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; 
1418 1418
     }
1419 1419
 
@@ -1424,17 +1424,17 @@  discard block
 block discarded – undo
1424 1424
  *
1425 1425
  * @param WPInv_Invoice $invoice
1426 1426
  */
1427
-function getpaid_the_invoice_description( $invoice ) {
1427
+function getpaid_the_invoice_description($invoice) {
1428 1428
     $description = $invoice->get_description();
1429 1429
 
1430
-    if ( empty( $description ) ) {
1430
+    if (empty($description)) {
1431 1431
         return;
1432 1432
     }
1433 1433
 
1434
-    $description = wp_kses_post( $description );
1434
+    $description = wp_kses_post($description);
1435 1435
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1436 1436
 }
1437
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1437
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1438 1438
 
1439 1439
 /**
1440 1440
  * Render element on a form.
@@ -1442,60 +1442,60 @@  discard block
 block discarded – undo
1442 1442
  * @param array $element
1443 1443
  * @param GetPaid_Payment_Form $form
1444 1444
  */
1445
-function getpaid_payment_form_element( $element, $form ) {
1445
+function getpaid_payment_form_element($element, $form) {
1446 1446
 
1447 1447
     // Set up the args.
1448
-    $element_type    = trim( $element['type'] );
1448
+    $element_type    = trim($element['type']);
1449 1449
     $element['form'] = $form;
1450
-    extract( $element );
1450
+    extract($element);
1451 1451
 
1452 1452
     // Try to locate the appropriate template.
1453
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1453
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1454 1454
     
1455 1455
     // Abort if this is not our element.
1456
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1456
+    if (empty($located) || !file_exists($located)) {
1457 1457
         return;
1458 1458
     }
1459 1459
 
1460 1460
     // Generate the class and id of the element.
1461
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1462
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1461
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1462
+    $id            = isset($id) ? $id : uniqid('gp');
1463 1463
 
1464 1464
     // Echo the opening wrapper.
1465 1465
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1466 1466
 
1467 1467
     // Fires before displaying a given element type's content.
1468
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1468
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1469 1469
 
1470 1470
     // Include the template for the element.
1471 1471
     include $located;
1472 1472
 
1473 1473
     // Fires after displaying a given element type's content.
1474
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1474
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1475 1475
 
1476 1476
     // Echo the closing wrapper.
1477 1477
     echo '</div>';
1478 1478
 }
1479
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1479
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1480 1480
 
1481 1481
 /**
1482 1482
  * Render an element's edit page.
1483 1483
  *
1484 1484
  * @param WP_Post $post
1485 1485
  */
1486
-function getpaid_payment_form_edit_element_template( $post ) {
1486
+function getpaid_payment_form_edit_element_template($post) {
1487 1487
 
1488 1488
     // Retrieve all elements.
1489
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1489
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1490 1490
 
1491
-    foreach ( $all_elements as $element ) {
1491
+    foreach ($all_elements as $element) {
1492 1492
 
1493 1493
         // Try to locate the appropriate template.
1494
-        $element = sanitize_key( $element );
1495
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1494
+        $element = sanitize_key($element);
1495
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1496 1496
 
1497 1497
         // Continue if this is not our element.
1498
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1498
+        if (empty($located) || !file_exists($located)) {
1499 1499
             continue;
1500 1500
         }
1501 1501
 
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
     }
1507 1507
 
1508 1508
 }
1509
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1509
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1510 1510
 
1511 1511
 /**
1512 1512
  * Render an element's preview.
@@ -1515,16 +1515,16 @@  discard block
 block discarded – undo
1515 1515
 function getpaid_payment_form_render_element_preview_template() {
1516 1516
 
1517 1517
     // Retrieve all elements.
1518
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1518
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1519 1519
 
1520
-    foreach ( $all_elements as $element ) {
1520
+    foreach ($all_elements as $element) {
1521 1521
 
1522 1522
         // Try to locate the appropriate template.
1523
-        $element = sanitize_key( $element );
1524
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1523
+        $element = sanitize_key($element);
1524
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1525 1525
 
1526 1526
         // Continue if this is not our element.
1527
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1527
+        if (empty($located) || !file_exists($located)) {
1528 1528
             continue;
1529 1529
         }
1530 1530
 
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
     }
1536 1536
 
1537 1537
 }
1538
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1538
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1539 1539
 
1540 1540
 /**
1541 1541
  * Shows a list of gateways that support recurring payments.
@@ -1543,17 +1543,17 @@  discard block
 block discarded – undo
1543 1543
 function wpinv_get_recurring_gateways_text() {
1544 1544
     $gateways = array();
1545 1545
 
1546
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1547
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1548
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1546
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1547
+        if (wpinv_gateway_support_subscription($key)) {
1548
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1549 1549
         }
1550 1550
     }
1551 1551
 
1552
-    if ( empty( $gateways ) ) {
1553
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1552
+    if (empty($gateways)) {
1553
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1554 1554
     }
1555 1555
 
1556
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1556
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1557 1557
 
1558 1558
 }
1559 1559
 
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
  * @return GetPaid_Template
1564 1564
  */
1565 1565
 function getpaid_template() {
1566
-    return getpaid()->get( 'template' );
1566
+    return getpaid()->get('template');
1567 1567
 }
1568 1568
 
1569 1569
 /**
@@ -1572,23 +1572,23 @@  discard block
 block discarded – undo
1572 1572
  * @param array args
1573 1573
  * @return string
1574 1574
  */
1575
-function getpaid_paginate_links( $args ) {
1575
+function getpaid_paginate_links($args) {
1576 1576
 
1577 1577
     $args['type']     = 'array';
1578 1578
     $args['mid_size'] = 1;
1579
-    $pages        = paginate_links( $args );
1579
+    $pages = paginate_links($args);
1580 1580
 
1581
-    if ( ! is_array( $pages ) ) {
1581
+    if (!is_array($pages)) {
1582 1582
         return '';
1583 1583
     }
1584 1584
 
1585 1585
     $_pages = array();
1586
-    foreach ( $pages as $page ) {
1587
-        $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page );
1586
+    foreach ($pages as $page) {
1587
+        $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page);
1588 1588
     }
1589 1589
 
1590 1590
     $links  = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>";
1591
-    $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages );
1591
+    $links .= join("</li>\n\t\t<li class='page-item'>", $_pages);
1592 1592
     $links .= "</li>\n\t</ul>\n</nav>\n";
1593 1593
 
1594 1594
     return $links;
@@ -1601,21 +1601,21 @@  discard block
 block discarded – undo
1601 1601
  * @param string state
1602 1602
  * @return string
1603 1603
  */
1604
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) {
1604
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') {
1605 1605
 
1606
-    $states = wpinv_get_country_states( $country );
1607
-    $uniqid = uniqid( '_' );
1606
+    $states = wpinv_get_country_states($country);
1607
+    $uniqid = uniqid('_');
1608 1608
 
1609
-    if ( ! empty( $states ) ) {
1609
+    if (!empty($states)) {
1610 1610
 
1611
-        return aui()->select( array(
1611
+        return aui()->select(array(
1612 1612
             'options'          => $states,
1613
-            'name'             => esc_attr( $field_name ),
1614
-            'id'               => sanitize_html_class( $field_name ) . $uniqid,
1615
-            'value'            => sanitize_text_field( $state ),
1613
+            'name'             => esc_attr($field_name),
1614
+            'id'               => sanitize_html_class($field_name) . $uniqid,
1615
+            'value'            => sanitize_text_field($state),
1616 1616
             'placeholder'      => $placeholder,
1617 1617
             'required'         => $required,
1618
-            'label'            => wp_kses_post( $label ),
1618
+            'label'            => wp_kses_post($label),
1619 1619
             'label_type'       => 'vertical',
1620 1620
             'help_text'        => $help_text,
1621 1621
             'class'            => 'getpaid-address-field wpinv_state',
@@ -1627,14 +1627,14 @@  discard block
 block discarded – undo
1627 1627
 
1628 1628
     return aui()->input(
1629 1629
         array(
1630
-            'name'        => esc_attr( $field_name ),
1631
-            'id'          => sanitize_html_class( $field_name ) . $uniqid,
1630
+            'name'        => esc_attr($field_name),
1631
+            'id'          => sanitize_html_class($field_name) . $uniqid,
1632 1632
             'placeholder' => $placeholder,
1633 1633
             'required'    => $required,
1634
-            'label'       => wp_kses_post( $label ),
1634
+            'label'       => wp_kses_post($label),
1635 1635
             'label_type'  => 'vertical',
1636 1636
             'help_text'   => $help_text,
1637
-            'value'       => sanitize_text_field( $state ),
1637
+            'value'       => sanitize_text_field($state),
1638 1638
             'class'       => 'getpaid-address-field wpinv_state',
1639 1639
             'wrap_class'  => "$wrapper_class getpaid-address-field-wrapper__state",
1640 1640
             'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1649,16 +1649,16 @@  discard block
 block discarded – undo
1649 1649
  * @param array $element
1650 1650
  * @return string
1651 1651
  */
1652
-function getpaid_get_form_element_grid_class( $element ) {
1652
+function getpaid_get_form_element_grid_class($element) {
1653 1653
 
1654 1654
     $class = "col-12";
1655
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1655
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1656 1656
 
1657
-    if ( $width == 'half' ) {
1657
+    if ($width == 'half') {
1658 1658
         $class = "col-12 col-md-6";
1659 1659
     }
1660 1660
 
1661
-    if ( $width == 'third' ) {
1661
+    if ($width == 'third') {
1662 1662
         $class = "col-12 col-md-4";
1663 1663
     }
1664 1664
 
Please login to merge, or discard this patch.