Completed
Push — master ( b6ca0b...43d636 )
by Brian
31s queued 16s
created
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -7,245 +7,245 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Created Date', 'invoicing' ),
21
-        'payment_date'      => __( 'Payment Date', 'invoicing' ),
22
-        'status'            => __( 'Status', 'invoicing' ),
23
-        'ID'                => __( 'ID', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Created Date', 'invoicing'),
21
+        'payment_date'      => __('Payment Date', 'invoicing'),
22
+        'status'            => __('Status', 'invoicing'),
23
+        'ID'                => __('ID', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
39
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
40 40
 
41
-function wpinv_sortable_columns( $columns ) {
41
+function wpinv_sortable_columns($columns) {
42 42
     $columns = array(
43
-        'ID'            => array( 'ID', true ),
44
-        'number'        => array( 'number', false ),
45
-        'amount'        => array( 'amount', false ),
46
-        'invoice_date'  => array( 'date', false ),
47
-        'payment_date'  => array( 'payment_date', true ),
48
-        'customer'      => array( 'customer', false ),
49
-        'status'        => array( 'status', false ),
43
+        'ID'            => array('ID', true),
44
+        'number'        => array('number', false),
45
+        'amount'        => array('amount', false),
46
+        'invoice_date'  => array('date', false),
47
+        'payment_date'  => array('payment_date', true),
48
+        'customer'      => array('customer', false),
49
+        'status'        => array('status', false),
50 50
     );
51 51
     
52
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
52
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
53 53
 }
54
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
54
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
55 55
 
56
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
56
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
58 58
     global $post, $wpi_invoice;
59 59
     
60
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
61
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
60
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
61
+        $wpi_invoice = new WPInv_Invoice($post->ID);
62 62
     }
63 63
 
64 64
     $value = NULL;
65 65
     
66
-    switch ( $column_name ) {
66
+    switch ($column_name) {
67 67
         case 'email' :
68
-            $value   = $wpi_invoice->get_email();
68
+            $value = $wpi_invoice->get_email();
69 69
             break;
70 70
         case 'customer' :
71 71
             $customer_name = $wpi_invoice->get_user_full_name();
72
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
73
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
74
-            if ( $email = $wpi_invoice->get_email() ) {
72
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
73
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
74
+            if ($email = $wpi_invoice->get_email()) {
75 75
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
76 76
             }
77 77
             break;
78 78
         case 'amount' :
79
-            echo $wpi_invoice->get_total( true );
79
+            echo $wpi_invoice->get_total(true);
80 80
             break;
81 81
         case 'invoice_date' :
82
-            $date_format = get_option( 'date_format' );
82
+            $date_format = get_option('date_format');
83 83
             
84 84
             $m_time = $post->post_date;
85
-            $h_time = mysql2date( $date_format, $m_time );
85
+            $h_time = mysql2date($date_format, $m_time);
86 86
             
87
-            $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
87
+            $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
88 88
             break;
89 89
         case 'payment_date' :
90
-            if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) {
91
-                $date_format = get_option( 'date_format' );
90
+            if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) {
91
+                $date_format = get_option('date_format');
92 92
                 
93 93
                 $m_time = $date_completed;
94
-                $h_time = mysql2date( $date_format, $m_time );
94
+                $h_time = mysql2date($date_format, $m_time);
95 95
                 
96
-                $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
96
+                $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
97 97
             } else {
98 98
                 $value = '-';
99 99
             }
100 100
             break;
101 101
         case 'status' :
102
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
103
-            $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
104
-	        $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() );
102
+            $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
103
+            $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID);
104
+	        $gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway());
105 105
 	        $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod'));
106 106
 	        $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false;
107 107
 
108
-            if ( 1 == $is_viewed ) {
109
-                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
108
+            if (1 == $is_viewed) {
109
+                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>';
110 110
             }
111
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment ) && ( isset( $gateway_title ) ) ) {
112
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
111
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment) && (isset($gateway_title))) {
112
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
113 113
             }
114 114
             break;
115 115
         case 'number' :
116
-            $edit_link = get_edit_post_link( $post->ID );
117
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
116
+            $edit_link = get_edit_post_link($post->ID);
117
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
118 118
             break;
119 119
         case 'wpi_actions' :
120 120
             $value = '';
121
-            if ( !empty( $post->post_name ) ) {
122
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
121
+            if (!empty($post->post_name)) {
122
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
123 123
             }
124 124
             
125
-            if ( $email = $wpi_invoice->get_email() ) {
126
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
125
+            if ($email = $wpi_invoice->get_email()) {
126
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
127 127
             }
128 128
             
129 129
             break;
130 130
         default:
131
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
131
+            $value = isset($post->$column_name) ? $post->$column_name : '';
132 132
             break;
133 133
 
134 134
     }
135
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
135
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
136 136
     
137
-    if ( $value !== NULL ) {
137
+    if ($value !== NULL) {
138 138
         echo $value;
139 139
     }
140 140
 }
141 141
 
142
-function wpinv_admin_post_id( $id = 0 ) {
142
+function wpinv_admin_post_id($id = 0) {
143 143
     global $post;
144 144
 
145
-    if ( isset( $id ) && ! empty( $id ) ) {
146
-        return (int)$id;
147
-    } else if ( get_the_ID() ) {
145
+    if (isset($id) && !empty($id)) {
146
+        return (int) $id;
147
+    } else if (get_the_ID()) {
148 148
         return (int) get_the_ID();
149
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
149
+    } else if (isset($post->ID) && !empty($post->ID)) {
150 150
         return (int) $post->ID;
151
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
151
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
152 152
         return (int) $_GET['post'];
153
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
153
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
154 154
         return (int) $_GET['id'];
155
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
155
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
156 156
         return (int) $_POST['id'];
157 157
     } 
158 158
 
159 159
     return null;
160 160
 }
161 161
     
162
-function wpinv_admin_post_type( $id = 0 ) {
163
-    if ( !$id ) {
162
+function wpinv_admin_post_type($id = 0) {
163
+    if (!$id) {
164 164
         $id = wpinv_admin_post_id();
165 165
     }
166 166
     
167
-    $type = get_post_type( $id );
167
+    $type = get_post_type($id);
168 168
     
169
-    if ( !$type ) {
170
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
169
+    if (!$type) {
170
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
171 171
     }
172 172
     
173
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
173
+    return apply_filters('wpinv_admin_post_type', $type, $id);
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177 177
 	global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
179
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
180
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
181 181
 	}
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
183
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
184
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
185 185
 	}
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
187
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
188
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
189 189
 	}
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
191
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
192
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
193 193
 	}
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
195
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
196
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
197 197
 	}
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
199
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
200
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
201 201
 	}
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
203
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
204
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
205 205
 	}
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
208
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
209 209
     }
210 210
     
211
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
211
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
212
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
213 213
     }
214 214
 
215
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
216
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
215
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
216
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
219
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
220
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
221 221
 	}
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
223
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
224
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
225 225
 	}
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
227
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
228
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
229 229
 	}
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
232
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
234
+		if (!empty($message)) {
235
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
236 236
 		}
237 237
 	}
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+	settings_errors('wpinv-notices');
240 240
 }
241
-add_action( 'admin_notices', 'wpinv_admin_messages' );
241
+add_action('admin_notices', 'wpinv_admin_messages');
242 242
 
243
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
244
-function wpinv_show_test_payment_gateway_notice(){
245
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
243
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
244
+function wpinv_show_test_payment_gateway_notice() {
245
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
246 246
 }
247 247
 
248
-function wpinv_test_payment_gateway_messages(){
248
+function wpinv_test_payment_gateway_messages() {
249 249
     $gateways = wpinv_get_enabled_payment_gateways();
250 250
     $name = array(); $test_gateways = '';
251 251
     if ($gateways) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         }
257 257
         $test_gateways = implode(', ', $name);
258 258
     }
259
-    if(isset($test_gateways) && !empty($test_gateways)){
259
+    if (isset($test_gateways) && !empty($test_gateways)) {
260 260
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
261
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
261
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
262 262
         ?>
263 263
         <div class="notice notice-warning is-dismissible">
264 264
             <p><?php echo $notice; ?></p>
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
     }
268 268
 }
269 269
 
270
-function wpinv_items_columns( $existing_columns ) {
270
+function wpinv_items_columns($existing_columns) {
271 271
     global $wpinv_euvat;
272 272
     
273 273
     $columns                = array();
274 274
     $columns['cb']          = $existing_columns['cb'];
275
-    $columns['title']       = __( 'Title', 'invoicing' );
276
-    $columns['price']       = __( 'Price', 'invoicing' );
277
-    if ( $wpinv_euvat->allow_vat_rules() ) {
278
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
275
+    $columns['title']       = __('Title', 'invoicing');
276
+    $columns['price']       = __('Price', 'invoicing');
277
+    if ($wpinv_euvat->allow_vat_rules()) {
278
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
279 279
     }
280
-    if ( $wpinv_euvat->allow_vat_classes() ) {
281
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
280
+    if ($wpinv_euvat->allow_vat_classes()) {
281
+        $columns['vat_class']   = __('VAT class', 'invoicing');
282 282
     }
283
-    $columns['type']        = __( 'Type', 'invoicing' );
284
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
285
-    $columns['date']        = __( 'Date', 'invoicing' );
286
-    $columns['id']          = __( 'ID', 'invoicing' );
283
+    $columns['type']        = __('Type', 'invoicing');
284
+    $columns['recurring']   = __('Recurring', 'invoicing');
285
+    $columns['date']        = __('Date', 'invoicing');
286
+    $columns['id']          = __('ID', 'invoicing');
287 287
 
288
-    return apply_filters( 'wpinv_items_columns', $columns );
288
+    return apply_filters('wpinv_items_columns', $columns);
289 289
 }
290
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
290
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
291 291
 
292
-function wpinv_items_sortable_columns( $columns ) {
292
+function wpinv_items_sortable_columns($columns) {
293 293
     $columns['price']       = 'price';
294 294
     $columns['vat_rule']    = 'vat_rule';
295 295
     $columns['vat_class']   = 'vat_class';
@@ -299,175 +299,175 @@  discard block
 block discarded – undo
299 299
 
300 300
     return $columns;
301 301
 }
302
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
302
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
303 303
 
304
-function wpinv_items_table_custom_column( $column ) {
304
+function wpinv_items_table_custom_column($column) {
305 305
     global $wpinv_euvat, $post, $wpi_item;
306 306
     
307
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
308
-        $wpi_item = new WPInv_Item( $post->ID );
307
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
308
+        $wpi_item = new WPInv_Item($post->ID);
309 309
     }
310 310
 
311
-    switch ( $column ) {
311
+    switch ($column) {
312 312
         case 'price' :
313
-            echo wpinv_item_price( $post->ID );
313
+            echo wpinv_item_price($post->ID);
314 314
         break;
315 315
         case 'vat_rule' :
316
-            echo $wpinv_euvat->item_rule_label( $post->ID );
316
+            echo $wpinv_euvat->item_rule_label($post->ID);
317 317
         break;
318 318
         case 'vat_class' :
319
-            echo $wpinv_euvat->item_class_label( $post->ID );
319
+            echo $wpinv_euvat->item_class_label($post->ID);
320 320
         break;
321 321
         case 'type' :
322
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
322
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
323 323
         break;
324 324
         case 'recurring' :
325
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
325
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
326 326
         break;
327 327
         case 'id' :
328 328
            echo $post->ID;
329 329
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
330
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
331
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
332
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
330
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
331
+                    if ($wpinv_euvat->allow_vat_rules()) {
332
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
333 333
                     }
334
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
335
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
334
+                    if ($wpinv_euvat->allow_vat_classes()) {
335
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
336 336
                     }
337
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
337
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
338 338
                 </div>';
339 339
         break;
340 340
     }
341 341
     
342
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
342
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
343 343
 }
344
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
344
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
345 345
 
346 346
 function wpinv_add_items_filters() {
347 347
     global $wpinv_euvat, $typenow;
348 348
 
349 349
     // Checks if the current post type is 'item'
350
-    if ( $typenow == 'wpi_item') {
351
-        if ( $wpinv_euvat->allow_vat_rules() ) {
350
+    if ($typenow == 'wpi_item') {
351
+        if ($wpinv_euvat->allow_vat_rules()) {
352 352
 
353 353
             // Sanitize selected vat rule.
354
-            $vat_rule   = '';
355
-            if( isset( $_GET['vat_rule'] ) && array_key_exists(  $_GET['type'], $wpinv_euvat->get_rules() ) ) {
356
-                $class   =  $_GET['type'];
354
+            $vat_rule = '';
355
+            if (isset($_GET['vat_rule']) && array_key_exists($_GET['type'], $wpinv_euvat->get_rules())) {
356
+                $class = $_GET['type'];
357 357
             }
358 358
 
359
-            echo wpinv_html_select( array(
360
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
359
+            echo wpinv_html_select(array(
360
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
361 361
                     'name'             => 'vat_rule',
362 362
                     'id'               => 'vat_rule',
363
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
363
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
364 364
                     'show_option_all'  => false,
365 365
                     'show_option_none' => false,
366 366
                     'class'            => 'gdmbx2-text-medium wpi_select2',
367
-                    'placeholder'      => __( 'Select VAT rule', 'invoicing' ),
368
-                ) );
367
+                    'placeholder'      => __('Select VAT rule', 'invoicing'),
368
+                ));
369 369
         }
370 370
 
371
-        if ( $wpinv_euvat->allow_vat_classes() ) {
371
+        if ($wpinv_euvat->allow_vat_classes()) {
372 372
 
373 373
             $classes = $wpinv_euvat->get_all_classes();
374 374
 
375 375
             // Sanitize selected vat class.
376 376
             $class   = '';
377
-            if( isset( $_GET['vat_class'] ) && array_key_exists(  $_GET['vat_class'], $classes ) ) {
378
-                $class   =  $_GET['vat_class'];
377
+            if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $classes)) {
378
+                $class = $_GET['vat_class'];
379 379
             }
380 380
 
381
-            echo wpinv_html_select( array(
382
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $classes ),
381
+            echo wpinv_html_select(array(
382
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $classes),
383 383
                     'name'             => 'vat_class',
384 384
                     'id'               => 'vat_class',
385 385
                     'selected'         => $class,
386 386
                     'show_option_all'  => false,
387 387
                     'show_option_none' => false,
388 388
                     'class'            => 'gdmbx2-text-medium wpi_select2',
389
-                    'placeholder'      => __( 'Select VAT class', 'invoicing' ),
390
-                ) );
389
+                    'placeholder'      => __('Select VAT class', 'invoicing'),
390
+                ));
391 391
         }
392 392
         
393 393
         // Sanitize selected item type.
394
-        $type   = '';
395
-        if( isset( $_GET['type'] ) && array_key_exists(  $_GET['type'], wpinv_get_item_types() ) ) {
396
-            $class   =  $_GET['type'];
394
+        $type = '';
395
+        if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) {
396
+            $class = $_GET['type'];
397 397
         }
398 398
 
399
-        echo wpinv_html_select( array(
400
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
399
+        echo wpinv_html_select(array(
400
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
401 401
                 'name'             => 'type',
402 402
                 'id'               => 'type',
403 403
                 'selected'         => $type,
404 404
                 'show_option_all'  => false,
405 405
                 'show_option_none' => false,
406 406
                 'class'            => 'gdmbx2-text-medium',
407
-            ) );
407
+            ));
408 408
 
409
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
409
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
410 410
             echo '<input type="hidden" name="all_posts" value="1" />';
411 411
         }
412 412
     }
413 413
 }
414
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
414
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
415 415
 
416
-function wpinv_send_invoice_after_save( $invoice ) {
417
-    if ( empty( $_POST['wpi_save_send'] ) ) {
416
+function wpinv_send_invoice_after_save($invoice) {
417
+    if (empty($_POST['wpi_save_send'])) {
418 418
         return;
419 419
     }
420 420
     
421
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
422
-        wpinv_user_invoice_notification( $invoice->ID );
421
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
422
+        wpinv_user_invoice_notification($invoice->ID);
423 423
     }
424 424
 }
425
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
425
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
426 426
 
427
-function wpinv_send_register_new_user( $data, $postarr ) {
428
-    if ( wpinv_current_user_can_manage_invoicing() && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
429
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
430
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
427
+function wpinv_send_register_new_user($data, $postarr) {
428
+    if (wpinv_current_user_can_manage_invoicing() && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
429
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
430
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
431 431
         
432
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
433
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
434
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
435
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
436
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
437
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
432
+        if ($is_new_user && $email && !email_exists($email)) {
433
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
434
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
435
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
436
+            $user_nicename = $display_name ? trim($display_name) : $email;
437
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
438 438
             
439
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
440
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
439
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
440
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
441 441
                 $new_user_login = strstr($email, '@', true);
442
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
443
-                    $user_login = sanitize_user($new_user_login, true );
442
+                if (validate_username($user_login) && username_exists($user_login)) {
443
+                    $user_login = sanitize_user($new_user_login, true);
444 444
                 }
445
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
446
-                    $user_append_text = rand(10,1000);
447
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
445
+                if (validate_username($user_login) && username_exists($user_login)) {
446
+                    $user_append_text = rand(10, 1000);
447
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
448 448
                 }
449 449
                 
450
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
450
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
451 451
                     $user_login = $email;
452 452
                 }
453 453
             }
454 454
             
455 455
             $userdata = array(
456 456
                 'user_login' => $user_login,
457
-                'user_pass' => wp_generate_password( 12, false ),
458
-                'user_email' => sanitize_text_field( $email ),
457
+                'user_pass' => wp_generate_password(12, false),
458
+                'user_email' => sanitize_text_field($email),
459 459
                 'first_name' => $first_name,
460 460
                 'last_name' => $last_name,
461
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
461
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
462 462
                 'nickname' => $display_name,
463 463
                 'display_name' => $display_name,
464 464
             );
465 465
 
466
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
466
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
467 467
             
468
-            $new_user_id = wp_insert_user( $userdata );
468
+            $new_user_id = wp_insert_user($userdata);
469 469
             
470
-            if ( !is_wp_error( $new_user_id ) ) {
470
+            if (!is_wp_error($new_user_id)) {
471 471
                 $data['post_author'] = $new_user_id;
472 472
                 $_POST['post_author'] = $new_user_id;
473 473
                 $_POST['post_author_override'] = $new_user_id;
@@ -488,86 +488,86 @@  discard block
 block discarded – undo
488 488
                 
489 489
                 $meta = array();
490 490
                 ///$meta['_wpinv_user_id'] = $new_user_id;
491
-                foreach ( $meta_fields as $field ) {
492
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
491
+                foreach ($meta_fields as $field) {
492
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
493 493
                 }
494 494
                 
495
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
495
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
496 496
 
497 497
                 // Update user meta.
498
-                foreach ( $meta as $key => $value ) {
499
-                    update_user_meta( $new_user_id, $key, $value );
498
+                foreach ($meta as $key => $value) {
499
+                    update_user_meta($new_user_id, $key, $value);
500 500
                 }
501 501
                 
502
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
502
+                if (function_exists('wp_send_new_user_notifications')) {
503 503
                     // Send email notifications related to the creation of new user.
504
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
504
+                    wp_send_new_user_notifications($new_user_id, 'user');
505 505
                 }
506 506
             } else {
507
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
507
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
508 508
             }
509 509
         }
510 510
     }
511 511
     
512 512
     return $data;
513 513
 }
514
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
514
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
515 515
 
516
-function wpinv_show_recurring_supported_gateways( $item_ID ) {
516
+function wpinv_show_recurring_supported_gateways($item_ID) {
517 517
     $all_gateways = wpinv_get_payment_gateways();
518 518
 
519
-    if ( !empty( $all_gateways ) ) {
519
+    if (!empty($all_gateways)) {
520 520
         $gateways = array();
521 521
 
522
-        foreach ( $all_gateways as $key => $gateway ) {
523
-            if ( wpinv_gateway_support_subscription( $key ) ) {
522
+        foreach ($all_gateways as $key => $gateway) {
523
+            if (wpinv_gateway_support_subscription($key)) {
524 524
                 $gateways[] = $gateway['admin_label'];
525 525
             }
526 526
         }
527 527
 
528
-        if ( !empty( $gateways ) ) {
528
+        if (!empty($gateways)) {
529 529
             ?>
530
-            <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span>
530
+            <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span>
531 531
             <?php
532 532
         }
533 533
     }
534 534
 }
535
-add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 );
535
+add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1);
536 536
 
537
-function wpinv_post_updated_messages( $messages ) {
537
+function wpinv_post_updated_messages($messages) {
538 538
     global $post, $post_ID;
539 539
 
540 540
     $messages['wpi_discount'] = array(
541 541
         0   => '',
542
-        1   => __( 'Discount updated.', 'invoicing' ),
543
-        2   => __( 'Custom field updated.', 'invoicing' ),
544
-        3   => __( 'Custom field deleted.', 'invoicing' ),
545
-        4   => __( 'Discount updated.', 'invoicing' ),
546
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
547
-        6   => __( 'Discount updated.', 'invoicing' ),
548
-        7   => __( 'Discount saved.', 'invoicing' ),
549
-        8   => __( 'Discount submitted.', 'invoicing' ),
550
-        9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
551
-        10  => __( 'Discount draft updated.', 'invoicing' ),
542
+        1   => __('Discount updated.', 'invoicing'),
543
+        2   => __('Custom field updated.', 'invoicing'),
544
+        3   => __('Custom field deleted.', 'invoicing'),
545
+        4   => __('Discount updated.', 'invoicing'),
546
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
547
+        6   => __('Discount updated.', 'invoicing'),
548
+        7   => __('Discount saved.', 'invoicing'),
549
+        8   => __('Discount submitted.', 'invoicing'),
550
+        9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
551
+        10  => __('Discount draft updated.', 'invoicing'),
552 552
     );
553 553
 
554 554
     $messages['wpi_payment_form'] = array(
555 555
         0   => '',
556
-        1   => __( 'Payment Form updated.', 'invoicing' ),
557
-        2   => __( 'Custom field updated.', 'invoicing' ),
558
-        3   => __( 'Custom field deleted.', 'invoicing' ),
559
-        4   => __( 'Payment Form updated.', 'invoicing' ),
560
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
561
-        6   => __( 'Payment Form updated.', 'invoicing' ),
562
-        7   => __( 'Payment Form saved.', 'invoicing' ),
563
-        8   => __( 'Payment Form submitted.', 'invoicing' ),
564
-        9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
565
-        10  => __( 'Payment Form draft updated.', 'invoicing' ),
556
+        1   => __('Payment Form updated.', 'invoicing'),
557
+        2   => __('Custom field updated.', 'invoicing'),
558
+        3   => __('Custom field deleted.', 'invoicing'),
559
+        4   => __('Payment Form updated.', 'invoicing'),
560
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
561
+        6   => __('Payment Form updated.', 'invoicing'),
562
+        7   => __('Payment Form saved.', 'invoicing'),
563
+        8   => __('Payment Form submitted.', 'invoicing'),
564
+        9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
565
+        10  => __('Payment Form draft updated.', 'invoicing'),
566 566
     );
567 567
 
568 568
     return $messages;
569 569
 }
570
-add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 );
570
+add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1);
571 571
 
572 572
 add_action('admin_init', 'admin_init_example_type');
573 573
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 function admin_init_example_type() {
578 578
     global $typenow;
579 579
 
580
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
580
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
581 581
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
582 582
     }
583 583
 }
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
     global $wpdb;
593 593
 
594 594
     if ($query->is_main_query() && !empty($query->query['s'])) {
595
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
596
-        if ( ! empty( $search ) ) {
597
-            $search = preg_replace( '/^ AND /', '', $search );
595
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
596
+        if (!empty($search)) {
597
+            $search = preg_replace('/^ AND /', '', $search);
598 598
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
599 599
         } else {
600 600
             $search = " AND ( {$conditions_str} )";
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
     return $search;
605 605
 }
606 606
 
607
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
608
-function wpinv_reset_invoice_count(){
609
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
607
+add_action('admin_init', 'wpinv_reset_invoice_count');
608
+function wpinv_reset_invoice_count() {
609
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
610 610
         wpinv_update_option('invoice_sequence_start', 1);
611 611
         delete_option('wpinv_last_invoice_number');
612 612
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 }
618 618
 
619 619
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
620
-function wpinv_invoice_count_reset_message(){
621
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
620
+function wpinv_invoice_count_reset_message() {
621
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
622 622
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
623 623
         ?>
624 624
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +51 added lines, -51 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="gdmbx2-wrap form-table"> <div class="gdmbx2-metabox gdmbx-field-list">';
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
 
32 32
             echo "<div class='gdmbx-row gdmbx-type-select'>";
33 33
             echo "<div class='gdmbx-th'><label>$key:</label></div>";
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @param WP_Post $post
45 45
      */
46
-    public static function output_shortcode( $post ) {
46
+    public static function output_shortcode($post) {
47 47
 
48
-        if ( ! is_numeric( $post ) ) {
48
+        if (!is_numeric($post)) {
49 49
             $post = $post->ID;
50 50
         }
51 51
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @param WP_Post $post
59 59
      */
60
-    public static function output ( $post ) {
61
-        $success_page        = get_post_meta( $post->ID, 'wpinv_success_page', true );
62
-        $success_page        = empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page
60
+    public static function output($post) {
61
+        $success_page        = get_post_meta($post->ID, 'wpinv_success_page', true);
62
+        $success_page        = empty($success_page) ? wpinv_get_success_page_uri() : $success_page
63 63
         ?>
64 64
 
65 65
         <div id="wpinv-form-builder" style="display: flex; flex-flow: wrap;">
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
             <div class="wpinv-form-builder-left bsui" style="flex: 0 0 320px;">
68 68
                 <ul class="wpinv-form-builder-tabs  nav nav-tabs">
69 69
                     <li class='nav-item' v-if="active_tab!='new_item'">
70
-                        <a @click.prevent="active_tab='new_item'" class="nav-link p-3" :class="{ 'active': active_tab=='new_item' }" href="#"><?php _e( 'Add new element', 'invoicing' ); ?></a>
70
+                        <a @click.prevent="active_tab='new_item'" class="nav-link p-3" :class="{ 'active': active_tab=='new_item' }" href="#"><?php _e('Add new element', 'invoicing'); ?></a>
71 71
                     </li>
72 72
                     <li class='nav-item' v-if='false'>
73
-                        <a @click.prevent="active_tab='edit_item'" class="nav-link p-3" :class="{ 'active': active_tab=='edit_item' }" href="#"><?php _e( 'Edit element', 'invoicing' ); ?></a>
73
+                        <a @click.prevent="active_tab='edit_item'" class="nav-link p-3" :class="{ 'active': active_tab=='edit_item' }" href="#"><?php _e('Edit element', 'invoicing'); ?></a>
74 74
                     </li>
75 75
                     <li class='nav-item' v-if='false'>
76
-                        <a @click.prevent="active_tab='settings'" class="nav-link p-3" :class="{ 'active': active_tab=='settings' }" href="#"><?php _e( 'Settings', 'invoicing' ); ?></a>
76
+                        <a @click.prevent="active_tab='settings'" class="nav-link p-3" :class="{ 'active': active_tab=='settings' }" href="#"><?php _e('Settings', 'invoicing'); ?></a>
77 77
                     </li>
78 78
                 </ul>
79 79
 
80 80
                 <div class="wpinv-form-builder-tab-content bsui" style="margin-top: 16px;">
81 81
                     <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
82 82
                         <div class="wpinv-form-builder-add-field-types">
83
-                            <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
83
+                            <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
84 84
                             <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
85 85
                                 <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
86 86
                                     <button class="button btn">
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 
96 96
                     <div class="wpinv-form-builder-tab-pane bsui" v-if="active_tab=='edit_item'" style="font-size: 16px;">
97 97
                         <div class="wpinv-form-builder-edit-field-wrapper">
98
-                            <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
98
+                            <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
99 99
                             <div>
100
-                                <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Field', 'invoicing' ); ?></button>
100
+                                <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Field', 'invoicing'); ?></button>
101 101
                             </div>
102 102
                         </div>
103 103
                     </div>
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
                         <div class="wpinv-form-builder-settings-wrapper">
107 107
                         
108 108
                             <div class='form-group'>
109
-                                <label for="wpi-success-page"><?php _e( 'Success Page', 'invoicing' ); ?></label>
110
-                                <input  placeholder="https://" id='wpi-success-page' value="<?php echo esc_url( $success_page ); ?>" class='form-control' type='text'>
111
-                                <small class='form-text text-muted'><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></small>
109
+                                <label for="wpi-success-page"><?php _e('Success Page', 'invoicing'); ?></label>
110
+                                <input  placeholder="https://" id='wpi-success-page' value="<?php echo esc_url($success_page); ?>" class='form-control' type='text'>
111
+                                <small class='form-text text-muted'><?php _e('Where should we redirect users after successfuly completing their payment?', 'invoicing'); ?></small>
112 112
                             </div>
113 113
 
114 114
                         </div>
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 
120 120
             <div class="wpinv-form-builder-right" style="flex: 1; padding-top: 40px;border-left: 1px solid #ddd;padding-left: 20px;min-height: 520px;margin-left: 10px;">
121 121
 
122
-                <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
123
-                <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
122
+                <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
123
+                <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
124 124
 
125 125
                 <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;">
126 126
                     <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="{ active: active_form_element==form_element &&  active_tab=='edit_item' }" @click="active_tab = 'edit_item'; active_form_element = form_element">
127
-                        <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
127
+                        <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
128 128
                     </div>
129 129
                 </draggable>
130 130
             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             <textarea style="display:none;" name="wpinv_form_items" v-model="itemString"></textarea>
134 134
         </div>
135 135
         
136
-        <?php wp_nonce_field( 'wpinv_save_payment_form', 'wpinv_save_payment_form' ) ;?>
136
+        <?php wp_nonce_field('wpinv_save_payment_form', 'wpinv_save_payment_form'); ?>
137 137
 
138 138
         <?php
139 139
     }
@@ -141,83 +141,83 @@  discard block
 block discarded – undo
141 141
     /**
142 142
      * Saves our payment forms.
143 143
      */
144
-    public static function save( $post_id, $post ) {
144
+    public static function save($post_id, $post) {
145 145
 
146
-        remove_action( 'save_post', 'WPInv_Meta_Box_Payment_Form::save' );
146
+        remove_action('save_post', 'WPInv_Meta_Box_Payment_Form::save');
147 147
 
148 148
         // $post_id and $post are required.
149
-        if ( empty( $post_id ) || empty( $post ) ) {
149
+        if (empty($post_id) || empty($post)) {
150 150
             return;
151 151
         }
152 152
         
153 153
         // Ensure that this user can edit the post.
154
-        if ( ! current_user_can( 'edit_post', $post_id ) ) {
154
+        if (!current_user_can('edit_post', $post_id)) {
155 155
             return;
156 156
         }
157 157
 
158 158
         // Dont' save meta boxes for revisions or autosaves
159
-        if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
159
+        if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
160 160
             return;
161 161
         }
162 162
 
163 163
         // Do not save for ajax requests.
164
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
164
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
165 165
             return;
166 166
         }
167 167
 
168 168
         // Confirm the security nonce.
169
-        if ( empty( $_POST['wpinv_save_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_save_payment_form'], 'wpinv_save_payment_form' ) ) {
169
+        if (empty($_POST['wpinv_save_payment_form']) || !wp_verify_nonce($_POST['wpinv_save_payment_form'], 'wpinv_save_payment_form')) {
170 170
             return;
171 171
         }
172 172
 
173 173
         // Save form items.
174
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
174
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
175 175
 
176
-        if ( empty( $form_items ) ) {
176
+        if (empty($form_items)) {
177 177
             $form_items = array();
178 178
         }
179 179
 
180
-        update_post_meta( $post_id, 'wpinv_form_items', self::maybe_save_items( $form_items ) );
180
+        update_post_meta($post_id, 'wpinv_form_items', self::maybe_save_items($form_items));
181 181
 
182 182
         // Save form elements.
183
-        $wpinv_form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
184
-        if ( empty( $wpinv_form_elements ) ) {
183
+        $wpinv_form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
184
+        if (empty($wpinv_form_elements)) {
185 185
             $wpinv_form_elements = array();
186 186
         }
187 187
 
188
-        update_post_meta( $post_id, 'wpinv_form_elements', $wpinv_form_elements );
188
+        update_post_meta($post_id, 'wpinv_form_elements', $wpinv_form_elements);
189 189
     }
190 190
 
191 191
     /**
192 192
      * Saves unsaved form items.
193 193
      */
194
-    public static function maybe_save_items( $items ) {
194
+    public static function maybe_save_items($items) {
195 195
 
196 196
         $saved = array();
197 197
 
198
-        foreach( $items as $item ) {
198
+        foreach ($items as $item) {
199 199
 
200
-            if ( is_numeric( $item['id'] ) ) {
200
+            if (is_numeric($item['id'])) {
201 201
                 $saved[] = $item;
202 202
                 continue;
203 203
             }
204 204
 
205 205
             $data = array(
206
-                'post_title'   => sanitize_text_field( $item['title'] ),
207
-                'post_excerpt' => wp_kses_post( $item['description'] ),
206
+                'post_title'   => sanitize_text_field($item['title']),
207
+                'post_excerpt' => wp_kses_post($item['description']),
208 208
                 'post_status'  => 'publish',
209 209
                 'meta'         => array(
210 210
                     'type'      => 'custom',
211
-                    'price'     => wpinv_sanitize_amount( $item['price'] ),
211
+                    'price'     => wpinv_sanitize_amount($item['price']),
212 212
                     'vat_rule'  => 'digital',
213 213
                     'vat_class' => '_standard',
214 214
                 )
215 215
             );
216 216
             
217
-            $new_item  = new WPInv_Item();
218
-            $new_item->create( $data );
217
+            $new_item = new WPInv_Item();
218
+            $new_item->create($data);
219 219
     
220
-            if ( ! empty( $new_item ) ) {
220
+            if (!empty($new_item)) {
221 221
                 $item['id'] = $new_item->ID;
222 222
                 $saved[] = $item;
223 223
             }
@@ -230,5 +230,5 @@  discard block
 block discarded – undo
230 230
 
231 231
 }
232 232
 
233
-add_action( 'save_post_wpi_payment_form', 'WPInv_Meta_Box_Payment_Form::save', 10, 2 );
233
+add_action('save_post_wpi_payment_form', 'WPInv_Meta_Box_Payment_Form::save', 10, 2);
234 234
 
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23
-            if ( method_exists( $this, "edit_{$element}_template" ) ) {
24
-                add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 );
23
+            if (method_exists($this, "edit_{$element}_template")) {
24
+                add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2);
25 25
             }
26 26
 
27
-            if ( method_exists( $this, "frontend_render_{$element}_template" ) ) {
28
-                add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 );
27
+            if (method_exists($this, "frontend_render_{$element}_template")) {
28
+                add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3);
29 29
             }
30 30
 
31 31
         }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function get_elements() {
39 39
 
40
-        if ( ! empty( $this->elements ) ) {
40
+        if (!empty($this->elements)) {
41 41
             return $this->elements;
42 42
         }
43 43
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
 
46 46
             array(
47 47
                 'type'     => 'heading',
48
-                'name'     => __( 'Heading', 'invoicing' ),
48
+                'name'     => __('Heading', 'invoicing'),
49 49
                 'defaults' => array(
50 50
                     'level' => 'h2',
51
-                    'text'  => __( 'Heading', 'invoicing' ),
51
+                    'text'  => __('Heading', 'invoicing'),
52 52
                 )
53 53
             ),
54 54
 
55 55
             array(
56 56
                 'type' => 'paragraph',
57
-                'name' => __( 'Paragraph', 'invoicing' ),
57
+                'name' => __('Paragraph', 'invoicing'),
58 58
                 'defaults'  => array(
59
-                    'text'  => __( 'Paragraph text', 'invoicing' ),
59
+                    'text'  => __('Paragraph text', 'invoicing'),
60 60
                 )
61 61
             ),
62 62
 
63 63
             array( 
64 64
                 'type' => 'alert',
65
-                'name' => __( 'Alert', 'invoicing' ),
65
+                'name' => __('Alert', 'invoicing'),
66 66
                 'defaults'  => array(
67 67
                     'value'        => '',
68 68
                     'class'        => 'alert-warning',
69
-                    'text'         => __( 'Alert', 'invoicing' ),
69
+                    'text'         => __('Alert', 'invoicing'),
70 70
                     'dismissible'  => false,
71 71
                 )
72 72
             ),
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
             array(
84 84
                 'type' => 'text',
85
-                'name' => __( 'Text Input', 'invoicing' ),
85
+                'name' => __('Text Input', 'invoicing'),
86 86
                 'defaults'  => array(
87
-                    'placeholder'  => __( 'Enter some text', 'invoicing' ),
87
+                    'placeholder'  => __('Enter some text', 'invoicing'),
88 88
                     'value'        => '',
89
-                    'label'        => __( 'Field Label', 'invoicing' ),
89
+                    'label'        => __('Field Label', 'invoicing'),
90 90
                     'description'  => '',
91 91
                     'required'     => false,
92 92
                 )
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 
95 95
             array(
96 96
                 'type' => 'textarea',
97
-                'name' => __( 'Textarea', 'invoicing' ),
97
+                'name' => __('Textarea', 'invoicing'),
98 98
                 'defaults'         => array(
99
-                    'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
99
+                    'placeholder'  => __('Enter your text hear', 'invoicing'),
100 100
                     'value'        => '',
101
-                    'label'        => __( 'Textarea Label', 'invoicing' ),
101
+                    'label'        => __('Textarea Label', 'invoicing'),
102 102
                     'description'  => '',
103 103
                     'required'     => false,
104 104
                 )
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
 
107 107
             array(
108 108
                 'type' => 'select',
109
-                'name' => __( 'Dropdown', 'invoicing' ),
109
+                'name' => __('Dropdown', 'invoicing'),
110 110
                 'defaults'         => array(
111
-                    'placeholder'  => __( 'Select a value', 'invoicing' ),
111
+                    'placeholder'  => __('Select a value', 'invoicing'),
112 112
                     'value'        => '',
113
-                    'label'        => __( 'Dropdown Label', 'invoicing' ),
113
+                    'label'        => __('Dropdown Label', 'invoicing'),
114 114
                     'description'  => '',
115 115
                     'required'     => false,
116 116
                     'options'      => array(
117
-                        esc_attr__( 'Option One', 'invoicing' ),
118
-                        esc_attr__( 'Option Two', 'invoicing' ),
119
-                        esc_attr__( 'Option Three', 'invoicing' )
117
+                        esc_attr__('Option One', 'invoicing'),
118
+                        esc_attr__('Option Two', 'invoicing'),
119
+                        esc_attr__('Option Three', 'invoicing')
120 120
                     ),
121 121
                 )
122 122
             ),
123 123
 
124 124
             array(
125 125
                 'type' => 'checkbox',
126
-                'name' => __( 'Checkbox', 'invoicing' ),
126
+                'name' => __('Checkbox', 'invoicing'),
127 127
                 'defaults'         => array(
128 128
                     'value'        => '',
129
-                    'label'        => __( 'Checkbox Label', 'invoicing' ),
129
+                    'label'        => __('Checkbox Label', 'invoicing'),
130 130
                     'description'  => '',
131 131
                     'required'     => false,
132 132
                 )
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
 
135 135
             array( 
136 136
                 'type' => 'radio',
137
-                'name' => __( 'Multiple Choice', 'invoicing' ),
137
+                'name' => __('Multiple Choice', 'invoicing'),
138 138
                 'defaults'     => array(
139
-                    'label'    => __( 'Select one choice', 'invoicing' ),
139
+                    'label'    => __('Select one choice', 'invoicing'),
140 140
                     'options'  => array(
141
-                        esc_attr__( 'Choice One', 'invoicing' ),
142
-                        esc_attr__( 'Choice Two', 'invoicing' ),
143
-                        esc_attr__( 'Choice Three', 'invoicing' )
141
+                        esc_attr__('Choice One', 'invoicing'),
142
+                        esc_attr__('Choice Two', 'invoicing'),
143
+                        esc_attr__('Choice Three', 'invoicing')
144 144
                     ),
145 145
                 )
146 146
             ),
147 147
 
148 148
             array( 
149 149
                 'type' => 'date',
150
-                'name' => __( 'Date', 'invoicing' ),
150
+                'name' => __('Date', 'invoicing'),
151 151
                 'defaults' => array(
152 152
                     'value'        => '',
153
-                    'label'        => __( 'Date', 'invoicing' ),
153
+                    'label'        => __('Date', 'invoicing'),
154 154
                     'description'  => '',
155 155
                     'required'     => false,
156 156
                 )
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 
159 159
             array( 
160 160
                 'type' => 'time',
161
-                'name' => __( 'Time', 'invoicing' ),
161
+                'name' => __('Time', 'invoicing'),
162 162
                 'defaults' => array(
163 163
                     'value'        => '',
164
-                    'label'        => __( 'Time', 'invoicing' ),
164
+                    'label'        => __('Time', 'invoicing'),
165 165
                     'description'  => '',
166 166
                     'required'     => false,
167 167
                 )
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 
170 170
             array( 
171 171
                 'type' => 'number',
172
-                'name' => __( 'Number', 'invoicing' ),
172
+                'name' => __('Number', 'invoicing'),
173 173
                 'defaults' => array(
174 174
                     'placeholder'  => '',
175 175
                     'value'        => '',
176
-                    'label'        => __( 'Number', 'invoicing' ),
176
+                    'label'        => __('Number', 'invoicing'),
177 177
                     'description'  => '',
178 178
                     'required'     => false,
179 179
                 )
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 
182 182
             array( 
183 183
                 'type' => 'website',
184
-                'name' => __( 'Website', 'invoicing' ),
184
+                'name' => __('Website', 'invoicing'),
185 185
                 'defaults' => array(
186 186
                     'placeholder'  => 'http://example.com',
187 187
                     'value'        => '',
188
-                    'label'        => __( 'Website', 'invoicing' ),
188
+                    'label'        => __('Website', 'invoicing'),
189 189
                     'description'  => '',
190 190
                     'required'     => false,
191 191
                 )
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 
194 194
             array( 
195 195
                 'type' => 'email',
196
-                'name' => __( 'Email', 'invoicing' ),
196
+                'name' => __('Email', 'invoicing'),
197 197
                 'defaults'  => array(
198 198
                     'placeholder'  => '[email protected]',
199 199
                     'value'        => '',
200
-                    'label'        => __( 'Email Address', 'invoicing' ),
200
+                    'label'        => __('Email Address', 'invoicing'),
201 201
                     'description'  => '',
202 202
                     'required'     => false,
203 203
                 )
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 
206 206
             array( 
207 207
                 'type' => 'address',
208
-                'name' => __( 'Address', 'invoicing' ),
208
+                'name' => __('Address', 'invoicing'),
209 209
                 'defaults'  => array(
210 210
 
211 211
                     'fields' => array(
212 212
                         array(
213 213
                             'placeholder'  => 'Jon',
214 214
                             'value'        => '',
215
-                            'label'        => __( 'First Name', 'invoicing' ),
215
+                            'label'        => __('First Name', 'invoicing'),
216 216
                             'description'  => '',
217 217
                             'required'     => false,
218 218
                             'visible'      => true,
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         array(
223 223
                             'placeholder'  => 'Snow',
224 224
                             'value'        => '',
225
-                            'label'        => __( 'Last Name', 'invoicing' ),
225
+                            'label'        => __('Last Name', 'invoicing'),
226 226
                             'description'  => '',
227 227
                             'required'     => false,
228 228
                             'visible'      => true,
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                         array(
233 233
                             'placeholder'  => '',
234 234
                             'value'        => '',
235
-                            'label'        => __( 'Address', 'invoicing' ),
235
+                            'label'        => __('Address', 'invoicing'),
236 236
                             'description'  => '',
237 237
                             'required'     => false,
238 238
                             'visible'      => true,
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                         array(
243 243
                             'placeholder'  => '',
244 244
                             'value'        => '',
245
-                            'label'        => __( 'City', 'invoicing' ),
245
+                            'label'        => __('City', 'invoicing'),
246 246
                             'description'  => '',
247 247
                             'required'     => false,
248 248
                             'visible'      => true,
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
                         ),
251 251
 
252 252
                         array(
253
-                            'placeholder'  => __( 'Select your country' ),
253
+                            'placeholder'  => __('Select your country'),
254 254
                             'value'        => '',
255
-                            'label'        => __( 'Country', 'invoicing' ),
255
+                            'label'        => __('Country', 'invoicing'),
256 256
                             'description'  => '',
257 257
                             'required'     => false,
258 258
                             'visible'      => true,
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                         ),
261 261
 
262 262
                         array(
263
-                            'placeholder'  => __( 'Choose a state', 'invoicing' ),
263
+                            'placeholder'  => __('Choose a state', 'invoicing'),
264 264
                             'value'        => '',
265
-                            'label'        => __( 'State / Province', 'invoicing' ),
265
+                            'label'        => __('State / Province', 'invoicing'),
266 266
                             'description'  => '',
267 267
                             'required'     => false,
268 268
                             'visible'      => true,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                         array(
273 273
                             'placeholder'  => '',
274 274
                             'value'        => '',
275
-                            'label'        => __( 'ZIP / Postcode', 'invoicing' ),
275
+                            'label'        => __('ZIP / Postcode', 'invoicing'),
276 276
                             'description'  => '',
277 277
                             'required'     => false,
278 278
                             'visible'      => true,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                         array(
283 283
                             'placeholder'  => '',
284 284
                             'value'        => '',
285
-                            'label'        => __( 'Phone', 'invoicing' ),
285
+                            'label'        => __('Phone', 'invoicing'),
286 286
                             'description'  => '',
287 287
                             'required'     => false,
288 288
                             'visible'      => true,
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 
295 295
             array( 
296 296
                 'type' => 'billing_email',
297
-                'name' => __( 'Billing Email', 'invoicing' ),
297
+                'name' => __('Billing Email', 'invoicing'),
298 298
                 'defaults'  => array(
299 299
                     'placeholder'  => '[email protected]',
300 300
                     'value'        => '',
301
-                    'label'        => __( 'Billing Email', 'invoicing' ),
301
+                    'label'        => __('Billing Email', 'invoicing'),
302 302
                     'description'  => '',
303 303
                     'premade'      => true,
304 304
                 )
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
             array( 
319 319
                 'type' => 'items',
320
-                'name' => __( 'Items', 'invoicing' ),
320
+                'name' => __('Items', 'invoicing'),
321 321
                 'defaults'  => array(
322 322
                     'value'        => '',
323 323
                     'items_type'   => 'total',
@@ -328,25 +328,25 @@  discard block
 block discarded – undo
328 328
 
329 329
             array( 
330 330
                 'type'       => 'pay_button',
331
-                'name'       => __( 'Payment Button', 'invoicing' ),
331
+                'name'       => __('Payment Button', 'invoicing'),
332 332
                 'defaults'   => array(
333 333
                     'value'        => '',
334 334
                     'class'        => 'btn-primary',
335
-                    'label'        => __( 'Pay Now »', 'invoicing' ),
336
-                    'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
335
+                    'label'        => __('Pay Now »', 'invoicing'),
336
+                    'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
337 337
                     'premade'      => true,
338 338
                 )
339 339
             )
340 340
         );
341 341
 
342
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
342
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
343 343
         return $this->elements;
344 344
     }
345 345
 
346 346
     /**
347 347
      * Returns the restrict markup.
348 348
      */
349
-    public function get_restrict_markup( $field, $field_type ) {
349
+    public function get_restrict_markup($field, $field_type) {
350 350
         $restrict = "$field.type=='$field_type'";
351 351
         return "v-if=\"$restrict\"";
352 352
     }
@@ -354,15 +354,15 @@  discard block
 block discarded – undo
354 354
     /**
355 355
      * Renders the title element template.
356 356
      */
357
-    public function render_heading_template( $field ) {
358
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
357
+    public function render_heading_template($field) {
358
+        $restrict = $this->get_restrict_markup($field, 'heading');
359 359
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
360 360
     }
361 361
 
362 362
     /**
363 363
      * Renders the title element on the frontend.
364 364
      */
365
-    public function frontend_render_heading_template( $field ) {
365
+    public function frontend_render_heading_template($field) {
366 366
         $tag = $field['level'];
367 367
         echo "<$tag>{$field['text']}</$tag>";
368 368
     }
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
     /**
371 371
      * Renders the edit title element template.
372 372
      */
373
-    public function edit_heading_template( $field ) {
374
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
375
-        $label    = __( 'Heading', 'invoicing' );
376
-        $label2   = __( 'Select Heading Level', 'invoicing' );
373
+    public function edit_heading_template($field) {
374
+        $restrict = $this->get_restrict_markup($field, 'heading');
375
+        $label    = __('Heading', 'invoicing');
376
+        $label2   = __('Select Heading Level', 'invoicing');
377 377
         $id       = $field . '.id + "_edit"';
378 378
         $id2      = $field . '.id + "_edit2"';
379 379
 
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
     /**
406 406
      * Renders a paragraph element template.
407 407
      */
408
-    public function render_paragraph_template( $field ) {
409
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
408
+    public function render_paragraph_template($field) {
409
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
410 410
         $label    = "$field.text";
411 411
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
412 412
     }
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
     /**
415 415
      * Renders the paragraph element on the frontend.
416 416
      */
417
-    public function frontend_render_paragraph_template( $field ) {
417
+    public function frontend_render_paragraph_template($field) {
418 418
         echo "<p>{$field['text']}</p>";
419 419
     }
420 420
 
421 421
     /**
422 422
      * Renders the edit paragraph element template.
423 423
      */
424
-    public function edit_paragraph_template( $field ) {
425
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
426
-        $label    = __( 'Enter your text', 'invoicing' );
424
+    public function edit_paragraph_template($field) {
425
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
426
+        $label    = __('Enter your text', 'invoicing');
427 427
         $id       = $field . '.id + "_edit"';
428 428
         echo "
429 429
             <div $restrict>
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
     /**
440 440
      * Renders the text element template.
441 441
      */
442
-    public function render_text_template( $field ) {
443
-        $restrict = $this->get_restrict_markup( $field, 'text' );
442
+    public function render_text_template($field) {
443
+        $restrict = $this->get_restrict_markup($field, 'text');
444 444
         $label    = "$field.label";
445 445
         echo "
446 446
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
     /**
456 456
      * Renders the text element on the frontend.
457 457
      */
458
-    public function frontend_render_text_template( $field ) {
458
+    public function frontend_render_text_template($field) {
459 459
         
460 460
         echo "<div class='form-group'>";
461 461
 
462 462
         echo aui()->input(
463 463
             array(
464
-                'name'       => esc_attr( $field['id'] ),
465
-                'id'         => esc_attr( $field['id'] ),
466
-                'placeholder'=> esc_attr( $field['placeholder'] ),
464
+                'name'       => esc_attr($field['id']),
465
+                'id'         => esc_attr($field['id']),
466
+                'placeholder'=> esc_attr($field['placeholder']),
467 467
                 'required'   => (bool) $field['required'],
468
-                'label'      => wp_kses_post( $field['label'] ),
468
+                'label'      => wp_kses_post($field['label']),
469 469
                 'no_wrap'    => true,
470 470
             )
471 471
         );
472 472
 
473
-        if ( ! empty( $field['description'] ) ) {
474
-            $description = wp_kses_post( $field['description'] );
473
+        if (!empty($field['description'])) {
474
+            $description = wp_kses_post($field['description']);
475 475
             echo "<small class='form-text text-muted'>$description</small>";
476 476
         }
477 477
 
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
     /**
483 483
      * Renders the edit text element template.
484 484
      */
485
-    public function edit_text_template( $field ) {
486
-        $restrict = $this->get_restrict_markup( $field, 'text' );
487
-        $label    = __( 'Field Label', 'invoicing' );
485
+    public function edit_text_template($field) {
486
+        $restrict = $this->get_restrict_markup($field, 'text');
487
+        $label    = __('Field Label', 'invoicing');
488 488
         $id       = $field . '.id + "_edit"';
489
-        $label2   = __( 'Placeholder text', 'invoicing' );
489
+        $label2   = __('Placeholder text', 'invoicing');
490 490
         $id2      = $field . '.id + "_edit2"';
491
-        $label3   = __( 'Help text', 'invoicing' );
492
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
491
+        $label3   = __('Help text', 'invoicing');
492
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
493 493
         $id3      = $field . '.id + "_edit3"';
494
-        $label5   = __( 'Is this field required?', 'invoicing' );
494
+        $label5   = __('Is this field required?', 'invoicing');
495 495
         $id4      = $field . '.id + "_edit4"';
496 496
         echo "
497 497
             <div $restrict>
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
     /**
520 520
      * Renders the textarea element template.
521 521
      */
522
-    public function render_textarea_template( $field ) {
523
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
522
+    public function render_textarea_template($field) {
523
+        $restrict = $this->get_restrict_markup($field, 'textarea');
524 524
         $label    = "$field.label";
525 525
         echo "
526 526
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -535,24 +535,24 @@  discard block
 block discarded – undo
535 535
     /**
536 536
      * Renders the textarea element on the frontend.
537 537
      */
538
-    public function frontend_render_textarea_template( $field ) {
538
+    public function frontend_render_textarea_template($field) {
539 539
         
540 540
         echo "<div class='form-group'>";
541 541
 
542 542
         echo aui()->textarea(
543 543
             array(
544
-                'name'       => esc_attr( $field['id'] ),
545
-                'id'         => esc_attr( $field['id'] ),
546
-                'placeholder'=> esc_attr( $field['placeholder'] ),
544
+                'name'       => esc_attr($field['id']),
545
+                'id'         => esc_attr($field['id']),
546
+                'placeholder'=> esc_attr($field['placeholder']),
547 547
                 'required'   => (bool) $field['required'],
548
-                'label'      => wp_kses_post( $field['label'] ),
548
+                'label'      => wp_kses_post($field['label']),
549 549
                 'no_wrap'    => true,
550 550
                 'rows'       => 3,
551 551
             )
552 552
         );
553 553
 
554
-        if ( ! empty( $field['description'] ) ) {
555
-            $description = wp_kses_post( $field['description'] );
554
+        if (!empty($field['description'])) {
555
+            $description = wp_kses_post($field['description']);
556 556
             echo "<small class='form-text text-muted'>$description</small>";
557 557
         }
558 558
 
@@ -563,16 +563,16 @@  discard block
 block discarded – undo
563 563
     /**
564 564
      * Renders the edit textarea element template.
565 565
      */
566
-    public function edit_textarea_template( $field ) {
567
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
568
-        $label    = __( 'Field Label', 'invoicing' );
566
+    public function edit_textarea_template($field) {
567
+        $restrict = $this->get_restrict_markup($field, 'textarea');
568
+        $label    = __('Field Label', 'invoicing');
569 569
         $id       = $field . '.id + "_edit"';
570
-        $label2   = __( 'Placeholder text', 'invoicing' );
570
+        $label2   = __('Placeholder text', 'invoicing');
571 571
         $id2      = $field . '.id + "_edit2"';
572
-        $label3   = __( 'Help text', 'invoicing' );
573
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
572
+        $label3   = __('Help text', 'invoicing');
573
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
574 574
         $id3      = $field . '.id + "_edit3"';
575
-        $label5   = __( 'Is this field required?', 'invoicing' );
575
+        $label5   = __('Is this field required?', 'invoicing');
576 576
         $id4      = $field . '.id + "_edit4"';
577 577
         echo "
578 578
             <div $restrict>
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
     /**
601 601
      * Renders the select element template.
602 602
      */
603
-    public function render_select_template( $field ) {
604
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
603
+    public function render_select_template($field) {
604
+        $restrict    = $this->get_restrict_markup($field, 'select');
605 605
         $label       = "$field.label";
606 606
         $placeholder = "$field.placeholder";
607 607
         $id          = $field . '.id';
@@ -621,24 +621,24 @@  discard block
 block discarded – undo
621 621
     /**
622 622
      * Renders the select element on the frontend.
623 623
      */
624
-    public function frontend_render_select_template( $field ) {
624
+    public function frontend_render_select_template($field) {
625 625
         
626 626
         echo "<div class='form-group'>";
627 627
 
628 628
         echo aui()->select(
629 629
             array(
630
-                'name'       => esc_attr( $field['id'] ),
631
-                'id'         => esc_attr( $field['id'] ),
632
-                'placeholder'=> esc_attr( $field['placeholder'] ),
630
+                'name'       => esc_attr($field['id']),
631
+                'id'         => esc_attr($field['id']),
632
+                'placeholder'=> esc_attr($field['placeholder']),
633 633
                 'required'   => (bool) $field['required'],
634
-                'label'      => wp_kses_post( $field['label'] ),
634
+                'label'      => wp_kses_post($field['label']),
635 635
                 'no_wrap'    => true,
636
-                'options'    => array_combine( $field['options'], $field['options'] ),
636
+                'options'    => array_combine($field['options'], $field['options']),
637 637
             )
638 638
         );
639 639
 
640
-        if ( ! empty( $field['description'] ) ) {
641
-            $description = wp_kses_post( $field['description'] );
640
+        if (!empty($field['description'])) {
641
+            $description = wp_kses_post($field['description']);
642 642
             echo "<small class='form-text text-muted'>$description</small>";
643 643
         }
644 644
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
     /**
650 650
      * Renders the edit select element template.
651 651
      */
652
-    public function edit_select_template( $field ) {
653
-        $restrict = $this->get_restrict_markup( $field, 'select' );
654
-        $label    = __( 'Field Label', 'invoicing' );
652
+    public function edit_select_template($field) {
653
+        $restrict = $this->get_restrict_markup($field, 'select');
654
+        $label    = __('Field Label', 'invoicing');
655 655
         $id       = $field . '.id + "_edit"';
656
-        $label2   = __( 'Placeholder text', 'invoicing' );
656
+        $label2   = __('Placeholder text', 'invoicing');
657 657
         $id2      = $field . '.id + "_edit2"';
658
-        $label3   = __( 'Help text', 'invoicing' );
659
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
658
+        $label3   = __('Help text', 'invoicing');
659
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
660 660
         $id3      = $field . '.id + "_edit3"';
661
-        $label5   = __( 'Is this field required?', 'invoicing' );
661
+        $label5   = __('Is this field required?', 'invoicing');
662 662
         $id4      = $field . '.id + "_edit4"';
663
-        $label6   = __( 'Available Options', 'invoicing' );
663
+        $label6   = __('Available Options', 'invoicing');
664 664
         echo "
665 665
             <div $restrict>
666 666
                 <div class='form-group'>
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
     /**
699 699
      * Renders the checkbox element template.
700 700
      */
701
-    public function render_checkbox_template( $field ) {
702
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
701
+    public function render_checkbox_template($field) {
702
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
703 703
         $label    = "$field.label";
704 704
         echo "
705 705
             <div class='form-check' $restrict>
@@ -714,24 +714,24 @@  discard block
 block discarded – undo
714 714
     /**
715 715
      * Renders the checkbox element on the frontend.
716 716
      */
717
-    public function frontend_render_checkbox_template( $field ) {
717
+    public function frontend_render_checkbox_template($field) {
718 718
         
719 719
         echo "<div class='form-group'>";
720 720
 
721 721
         echo aui()->input(
722 722
             array(
723
-                'name'       => esc_attr( $field['id'] ),
724
-                'id'         => esc_attr( $field['id'] ),
723
+                'name'       => esc_attr($field['id']),
724
+                'id'         => esc_attr($field['id']),
725 725
                 'required'   => (bool) $field['required'],
726
-                'label'      => wp_kses_post( $field['label'] ),
726
+                'label'      => wp_kses_post($field['label']),
727 727
                 'no_wrap'    => true,
728
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
728
+                'value'      => esc_attr__('Yes', 'invoicing'),
729 729
                 'type'       => 'checkbox',
730 730
             )
731 731
         );
732 732
 
733
-        if ( ! empty( $field['description'] ) ) {
734
-            $description = wp_kses_post( $field['description'] );
733
+        if (!empty($field['description'])) {
734
+            $description = wp_kses_post($field['description']);
735 735
             echo "<small class='form-text text-muted'>$description</small>";
736 736
         }
737 737
 
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
     /**
743 743
      * Renders the edit checkbox element template.
744 744
      */
745
-    public function edit_checkbox_template( $field ) {
746
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
747
-        $label    = __( 'Field Label', 'invoicing' );
745
+    public function edit_checkbox_template($field) {
746
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
747
+        $label    = __('Field Label', 'invoicing');
748 748
         $id       = $field . '.id + "_edit"';
749
-        $label2   = __( 'Help text', 'invoicing' );
750
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
749
+        $label2   = __('Help text', 'invoicing');
750
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
751 751
         $id2      = $field . '.id + "_edit2"';
752
-        $label4   = __( 'Is this field required?', 'invoicing' );
752
+        $label4   = __('Is this field required?', 'invoicing');
753 753
         $id3      = $field . '.id + "_edit3"';
754 754
         echo "
755 755
             <div $restrict>
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
     /**
774 774
      * Renders the radio element template.
775 775
      */
776
-    public function render_radio_template( $field ) {
777
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
776
+    public function render_radio_template($field) {
777
+        $restrict    = $this->get_restrict_markup($field, 'radio');
778 778
         $label       = "$field.label";
779 779
         $id          = $field . '.id';
780 780
         echo "
@@ -793,20 +793,20 @@  discard block
 block discarded – undo
793 793
     /**
794 794
      * Renders the radio element on the frontend.
795 795
      */
796
-    public function frontend_render_radio_template( $field ) {
796
+    public function frontend_render_radio_template($field) {
797 797
         
798 798
         echo "<div class='form-group'>";
799 799
 
800
-        if ( ! empty( $field['label'] ) ) {
801
-            $label = wp_kses_post( $field['label'] );
800
+        if (!empty($field['label'])) {
801
+            $label = wp_kses_post($field['label']);
802 802
             echo "<legend class='col-form-label'>$label</legend>";
803 803
         }
804 804
 
805
-        foreach( $field['options'] as $index => $option ) {
805
+        foreach ($field['options'] as $index => $option) {
806 806
             $id    = $field['id'] . $index;
807 807
             $name  = $field['id'];
808
-            $value = esc_attr( $option );
809
-            $label = wp_kses_post( $option );
808
+            $value = esc_attr($option);
809
+            $label = wp_kses_post($option);
810 810
 
811 811
             echo "
812 812
                 <div class='form-check'>
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
             ";
817 817
         }
818 818
 
819
-        if ( ! empty( $field['description'] ) ) {
820
-            $description = wp_kses_post( $field['description'] );
819
+        if (!empty($field['description'])) {
820
+            $description = wp_kses_post($field['description']);
821 821
             echo "<small class='form-text text-muted'>$description</small>";
822 822
         }
823 823
 
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
     /**
829 829
      * Renders the edit radio element template.
830 830
      */
831
-    public function edit_radio_template( $field ) {
832
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
833
-        $label    = __( 'Field Label', 'invoicing' );
831
+    public function edit_radio_template($field) {
832
+        $restrict = $this->get_restrict_markup($field, 'radio');
833
+        $label    = __('Field Label', 'invoicing');
834 834
         $id       = $field . '.id + "_edit"';
835
-        $label2   = __( 'Help text', 'invoicing' );
836
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
835
+        $label2   = __('Help text', 'invoicing');
836
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
837 837
         $id2      = $field . '.id + "_edit3"';
838
-        $label4   = __( 'Is this field required?', 'invoicing' );
838
+        $label4   = __('Is this field required?', 'invoicing');
839 839
         $id3      = $field . '.id + "_edit4"';
840
-        $label5   = __( 'Available Options', 'invoicing' );
840
+        $label5   = __('Available Options', 'invoicing');
841 841
         echo "
842 842
             <div $restrict>
843 843
                 <div class='form-group'>
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
     /**
872 872
      * Renders the address element template.
873 873
      */
874
-    public function render_address_template( $field ) {
875
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
874
+    public function render_address_template($field) {
875
+        $restrict = $this->get_restrict_markup($field, 'address');
876 876
 
877 877
         echo "
878 878
             <div class='wpinv-address-wrapper' $restrict>
@@ -894,55 +894,55 @@  discard block
 block discarded – undo
894 894
     /**
895 895
      * Renders the address element on the frontend.
896 896
      */
897
-    public function frontend_render_address_template( $field ) {
897
+    public function frontend_render_address_template($field) {
898 898
         
899 899
         echo "<div class='wpinv-address-fields'>";
900 900
 
901
-        foreach( $field['fields'] as $address_field ) {
901
+        foreach ($field['fields'] as $address_field) {
902 902
 
903
-            if ( empty( $address_field['visible'] ) ) {
903
+            if (empty($address_field['visible'])) {
904 904
                 continue;
905 905
             }
906 906
 
907
-            $class = esc_attr( $address_field['name'] );
907
+            $class = esc_attr($address_field['name']);
908 908
             echo "<div class='form-group $class'>";
909 909
 
910 910
             $label = $address_field['label'];
911 911
 
912
-            if ( ! empty( $address_field['required'] ) ) {
912
+            if (!empty($address_field['required'])) {
913 913
                 $label .= "<span class='text-danger'> *</span>";
914 914
             }
915 915
 
916
-            if ( 'wpinv_country' == $address_field['name'] ) {
916
+            if ('wpinv_country' == $address_field['name']) {
917 917
 
918
-                echo aui()->select( array(
918
+                echo aui()->select(array(
919 919
                     'options'          => wpinv_get_country_list(),
920
-                    'name'             => esc_attr( $address_field['name'] ),
921
-                    'id'               => esc_attr( $address_field['name'] ),
920
+                    'name'             => esc_attr($address_field['name']),
921
+                    'id'               => esc_attr($address_field['name']),
922 922
                     'value'            => wpinv_get_default_country(),
923
-                    'placeholder'      => esc_attr( $address_field['placeholder'] ),
923
+                    'placeholder'      => esc_attr($address_field['placeholder']),
924 924
                     'required'         => (bool) $address_field['required'],
925 925
                     'no_wrap'          => true,
926
-                    'label'            => wp_kses_post( $label ),
926
+                    'label'            => wp_kses_post($label),
927 927
                     'select2'          => false,
928 928
                 ));
929 929
     
930
-            } else if ( 'wpinv_state' == $address_field['name'] ) {
930
+            } else if ('wpinv_state' == $address_field['name']) {
931 931
 
932
-                $states = wpinv_get_country_states( wpinv_get_default_country() );
932
+                $states = wpinv_get_country_states(wpinv_get_default_country());
933 933
                 $state  = wpinv_get_default_state();
934 934
 
935
-                if ( ! empty( $states ) ) {
935
+                if (!empty($states)) {
936 936
 
937
-                    echo aui()->select( array(
937
+                    echo aui()->select(array(
938 938
                         'options'          => $states,
939
-                        'name'             => esc_attr( $address_field['name'] ),
940
-                        'id'               => esc_attr( $address_field['name'] ),
939
+                        'name'             => esc_attr($address_field['name']),
940
+                        'id'               => esc_attr($address_field['name']),
941 941
                         'value'            => $state,
942
-                        'placeholder'      => esc_attr( $address_field['placeholder'] ),
942
+                        'placeholder'      => esc_attr($address_field['placeholder']),
943 943
                         'required'         => (bool) $address_field['required'],
944 944
                         'no_wrap'          => true,
945
-                        'label'            => wp_kses_post( $label ),
945
+                        'label'            => wp_kses_post($label),
946 946
                         'select2'          => false,
947 947
                     ));
948 948
 
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 
951 951
                     echo aui()->input(
952 952
                         array(
953
-                            'name'       => esc_attr( $address_field['name'] ),
954
-                            'id'         => esc_attr( $address_field['name'] ),
953
+                            'name'       => esc_attr($address_field['name']),
954
+                            'id'         => esc_attr($address_field['name']),
955 955
                             'required'   => (bool) $address_field['required'],
956
-                            'label'      => wp_kses_post( $label ),
956
+                            'label'      => wp_kses_post($label),
957 957
                             'no_wrap'    => true,
958 958
                             'type'       => 'text',
959 959
                         )
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 
966 966
                 echo aui()->input(
967 967
                     array(
968
-                        'name'       => esc_attr( $address_field['name'] ),
969
-                        'id'         => esc_attr( $address_field['name'] ),
968
+                        'name'       => esc_attr($address_field['name']),
969
+                        'id'         => esc_attr($address_field['name']),
970 970
                         'required'   => (bool) $address_field['required'],
971
-                        'label'      => wp_kses_post( $label ),
971
+                        'label'      => wp_kses_post($label),
972 972
                         'no_wrap'    => true,
973
-                        'placeholder' => esc_attr( $address_field['placeholder'] ),
973
+                        'placeholder' => esc_attr($address_field['placeholder']),
974 974
                         'type'       => 'text',
975 975
                     )
976 976
                 );
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
             }
979 979
             
980 980
 
981
-            if ( ! empty( $address_field['description'] ) ) {
982
-                $description = wp_kses_post( $address_field['description'] );
981
+            if (!empty($address_field['description'])) {
982
+                $description = wp_kses_post($address_field['description']);
983 983
                 echo "<small class='form-text text-muted'>$description</small>";
984 984
             }
985 985
     
@@ -994,13 +994,13 @@  discard block
 block discarded – undo
994 994
     /**
995 995
      * Renders the edit address element template.
996 996
      */
997
-    public function edit_address_template( $field ) {
998
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
999
-        $label     = __( 'Field Label', 'invoicing' );
1000
-        $label2    = __( 'Placeholder', 'invoicing' );
1001
-        $label3    = __( 'Description', 'invoicing' );
1002
-        $label4    = __( 'Is required', 'invoicing' );
1003
-        $label5    = __( 'Is visible', 'invoicing' );
997
+    public function edit_address_template($field) {
998
+        $restrict  = $this->get_restrict_markup($field, 'address');
999
+        $label     = __('Field Label', 'invoicing');
1000
+        $label2    = __('Placeholder', 'invoicing');
1001
+        $label3    = __('Description', 'invoicing');
1002
+        $label4    = __('Is required', 'invoicing');
1003
+        $label5    = __('Is visible', 'invoicing');
1004 1004
         $id        = $field . '.id + "_edit_label"';
1005 1005
         $id2       = $field . '.id + "_edit_placeholder"';
1006 1006
         $id3       = $field . '.id + "_edit_description"';
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
     /**
1069 1069
      * Renders the email element template.
1070 1070
      */
1071
-    public function render_email_template( $field ) {
1072
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1071
+    public function render_email_template($field) {
1072
+        $restrict = $this->get_restrict_markup($field, 'email');
1073 1073
         $label    = "$field.label";
1074 1074
         echo "
1075 1075
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
     /**
1085 1085
      * Renders the billing_email element template.
1086 1086
      */
1087
-    public function render_billing_email_template( $field ) {
1088
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1087
+    public function render_billing_email_template($field) {
1088
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1089 1089
         $label    = "$field.label";
1090 1090
         echo "
1091 1091
             <div $restrict>
@@ -1099,24 +1099,24 @@  discard block
 block discarded – undo
1099 1099
     /**
1100 1100
      * Renders the email element on the frontend.
1101 1101
      */
1102
-    public function frontend_render_email_template( $field ) {
1102
+    public function frontend_render_email_template($field) {
1103 1103
         
1104 1104
         echo "<div class='form-group'>";
1105 1105
 
1106 1106
         echo aui()->input(
1107 1107
             array(
1108
-                'name'       => esc_attr( $field['id'] ),
1109
-                'id'         => esc_attr( $field['id'] ),
1108
+                'name'       => esc_attr($field['id']),
1109
+                'id'         => esc_attr($field['id']),
1110 1110
                 'required'   => (bool) $field['required'],
1111
-                'label'      => wp_kses_post( $field['label'] ),
1111
+                'label'      => wp_kses_post($field['label']),
1112 1112
                 'no_wrap'    => true,
1113
-                'placeholder' => esc_attr( $field['placeholder'] ),
1113
+                'placeholder' => esc_attr($field['placeholder']),
1114 1114
                 'type'       => 'email',
1115 1115
             )
1116 1116
         );
1117 1117
 
1118
-        if ( ! empty( $field['description'] ) ) {
1119
-            $description = wp_kses_post( $field['description'] );
1118
+        if (!empty($field['description'])) {
1119
+            $description = wp_kses_post($field['description']);
1120 1120
             echo "<small class='form-text text-muted'>$description</small>";
1121 1121
         }
1122 1122
 
@@ -1127,30 +1127,30 @@  discard block
 block discarded – undo
1127 1127
     /**
1128 1128
      * Renders the billing email element on the frontend.
1129 1129
      */
1130
-    public function frontend_render_billing_email_template( $field ) {
1130
+    public function frontend_render_billing_email_template($field) {
1131 1131
         
1132 1132
         echo "<div class='form-group'>";
1133 1133
         $value = '';
1134 1134
 
1135
-        if ( is_user_logged_in() ) {
1135
+        if (is_user_logged_in()) {
1136 1136
             $user  = wp_get_current_user();
1137
-            $value = sanitize_email( $user->user_email );
1137
+            $value = sanitize_email($user->user_email);
1138 1138
         }
1139 1139
         echo aui()->input(
1140 1140
             array(
1141 1141
                 'name'       => 'billing_email',
1142 1142
                 'value'      => $value,
1143
-                'id'         => esc_attr( $field['id'] ),
1143
+                'id'         => esc_attr($field['id']),
1144 1144
                 'required'   => true,
1145
-                'label'      => wp_kses_post( $field['label'] ),
1145
+                'label'      => wp_kses_post($field['label']),
1146 1146
                 'no_wrap'    => true,
1147
-                'placeholder' => esc_attr( $field['placeholder'] ),
1147
+                'placeholder' => esc_attr($field['placeholder']),
1148 1148
                 'type'       => 'email',
1149 1149
             )
1150 1150
         );
1151 1151
 
1152
-        if ( ! empty( $field['description'] ) ) {
1153
-            $description = wp_kses_post( $field['description'] );
1152
+        if (!empty($field['description'])) {
1153
+            $description = wp_kses_post($field['description']);
1154 1154
             echo "<small class='form-text text-muted'>$description</small>";
1155 1155
         }
1156 1156
 
@@ -1161,16 +1161,16 @@  discard block
 block discarded – undo
1161 1161
     /**
1162 1162
      * Renders the edit email element template.
1163 1163
      */
1164
-    public function edit_email_template( $field ) {
1165
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1166
-        $label    = __( 'Field Label', 'invoicing' );
1164
+    public function edit_email_template($field) {
1165
+        $restrict = $this->get_restrict_markup($field, 'email');
1166
+        $label    = __('Field Label', 'invoicing');
1167 1167
         $id       = $field . '.id + "_edit"';
1168
-        $label2   = __( 'Placeholder text', 'invoicing' );
1168
+        $label2   = __('Placeholder text', 'invoicing');
1169 1169
         $id2      = $field . '.id + "_edit2"';
1170
-        $label3   = __( 'Help text', 'invoicing' );
1171
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1170
+        $label3   = __('Help text', 'invoicing');
1171
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1172 1172
         $id3      = $field . '.id + "_edit3"';
1173
-        $label5   = __( 'Is this field required?', 'invoicing' );
1173
+        $label5   = __('Is this field required?', 'invoicing');
1174 1174
         $id4      = $field . '.id + "_edit4"';
1175 1175
         echo "
1176 1176
             <div $restrict>
@@ -1198,16 +1198,16 @@  discard block
 block discarded – undo
1198 1198
     /**
1199 1199
      * Renders the edit billing_email element template.
1200 1200
      */
1201
-    public function edit_billing_email_template( $field ) {
1202
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1203
-        $label    = __( 'Field Label', 'invoicing' );
1201
+    public function edit_billing_email_template($field) {
1202
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1203
+        $label    = __('Field Label', 'invoicing');
1204 1204
         $id       = $field . '.id + "_edit"';
1205
-        $label2   = __( 'Placeholder text', 'invoicing' );
1205
+        $label2   = __('Placeholder text', 'invoicing');
1206 1206
         $id2      = $field . '.id + "_edit2"';
1207
-        $label3   = __( 'Help text', 'invoicing' );
1208
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1207
+        $label3   = __('Help text', 'invoicing');
1208
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1209 1209
         $id3      = $field . '.id + "_edit3"';
1210
-        $label5   = __( 'Is this field required?', 'invoicing' );
1210
+        $label5   = __('Is this field required?', 'invoicing');
1211 1211
         $id4      = $field . '.id + "_edit4"';
1212 1212
         echo "
1213 1213
             <div $restrict>
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
     /**
1232 1232
      * Renders the website element template.
1233 1233
      */
1234
-    public function render_website_template( $field ) {
1235
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1234
+    public function render_website_template($field) {
1235
+        $restrict = $this->get_restrict_markup($field, 'website');
1236 1236
         $label    = "$field.label";
1237 1237
         echo "
1238 1238
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1247,24 +1247,24 @@  discard block
 block discarded – undo
1247 1247
     /**
1248 1248
      * Renders the website element on the frontend.
1249 1249
      */
1250
-    public function frontend_render_website_template( $field ) {
1250
+    public function frontend_render_website_template($field) {
1251 1251
         
1252 1252
         echo "<div class='form-group'>";
1253 1253
 
1254 1254
         echo aui()->input(
1255 1255
             array(
1256
-                'name'       => esc_attr( $field['id'] ),
1257
-                'id'         => esc_attr( $field['id'] ),
1256
+                'name'       => esc_attr($field['id']),
1257
+                'id'         => esc_attr($field['id']),
1258 1258
                 'required'   => (bool) $field['required'],
1259
-                'label'      => wp_kses_post( $field['label'] ),
1259
+                'label'      => wp_kses_post($field['label']),
1260 1260
                 'no_wrap'    => true,
1261
-                'placeholder' => esc_attr( $field['placeholder'] ),
1261
+                'placeholder' => esc_attr($field['placeholder']),
1262 1262
                 'type'       => 'url',
1263 1263
             )
1264 1264
         );
1265 1265
 
1266
-        if ( ! empty( $field['description'] ) ) {
1267
-            $description = wp_kses_post( $field['description'] );
1266
+        if (!empty($field['description'])) {
1267
+            $description = wp_kses_post($field['description']);
1268 1268
             echo "<small class='form-text text-muted'>$description</small>";
1269 1269
         }
1270 1270
 
@@ -1275,16 +1275,16 @@  discard block
 block discarded – undo
1275 1275
     /**
1276 1276
      * Renders the edit website element template.
1277 1277
      */
1278
-    public function edit_website_template( $field ) {
1279
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1280
-        $label    = __( 'Field Label', 'invoicing' );
1278
+    public function edit_website_template($field) {
1279
+        $restrict = $this->get_restrict_markup($field, 'website');
1280
+        $label    = __('Field Label', 'invoicing');
1281 1281
         $id       = $field . '.id + "_edit"';
1282
-        $label2   = __( 'Placeholder text', 'invoicing' );
1282
+        $label2   = __('Placeholder text', 'invoicing');
1283 1283
         $id2      = $field . '.id + "_edit2"';
1284
-        $label3   = __( 'Help text', 'invoicing' );
1285
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1284
+        $label3   = __('Help text', 'invoicing');
1285
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1286 1286
         $id3      = $field . '.id + "_edit3"';
1287
-        $label5   = __( 'Is this field required?', 'invoicing' );
1287
+        $label5   = __('Is this field required?', 'invoicing');
1288 1288
         $id4      = $field . '.id + "_edit4"';
1289 1289
         echo "
1290 1290
             <div $restrict>
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
     /**
1313 1313
      * Renders the date element template.
1314 1314
      */
1315
-    public function render_date_template( $field ) {
1316
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1315
+    public function render_date_template($field) {
1316
+        $restrict = $this->get_restrict_markup($field, 'date');
1317 1317
         $label    = "$field.label";
1318 1318
         echo "
1319 1319
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1328,23 +1328,23 @@  discard block
 block discarded – undo
1328 1328
     /**
1329 1329
      * Renders the date element on the frontend.
1330 1330
      */
1331
-    public function frontend_render_date_template( $field ) {
1331
+    public function frontend_render_date_template($field) {
1332 1332
         
1333 1333
         echo "<div class='form-group'>";
1334 1334
 
1335 1335
         echo aui()->input(
1336 1336
             array(
1337
-                'name'       => esc_attr( $field['id'] ),
1338
-                'id'         => esc_attr( $field['id'] ),
1337
+                'name'       => esc_attr($field['id']),
1338
+                'id'         => esc_attr($field['id']),
1339 1339
                 'required'   => (bool) $field['required'],
1340
-                'label'      => wp_kses_post( $field['label'] ),
1340
+                'label'      => wp_kses_post($field['label']),
1341 1341
                 'no_wrap'    => true,
1342 1342
                 'type'       => 'date',
1343 1343
             )
1344 1344
         );
1345 1345
 
1346
-        if ( ! empty( $field['description'] ) ) {
1347
-            $description = wp_kses_post( $field['description'] );
1346
+        if (!empty($field['description'])) {
1347
+            $description = wp_kses_post($field['description']);
1348 1348
             echo "<small class='form-text text-muted'>$description</small>";
1349 1349
         }
1350 1350
 
@@ -1355,14 +1355,14 @@  discard block
 block discarded – undo
1355 1355
     /**
1356 1356
      * Renders the edit date element template.
1357 1357
      */
1358
-    public function edit_date_template( $field ) {
1359
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1360
-        $label    = __( 'Field Label', 'invoicing' );
1358
+    public function edit_date_template($field) {
1359
+        $restrict = $this->get_restrict_markup($field, 'date');
1360
+        $label    = __('Field Label', 'invoicing');
1361 1361
         $id       = $field . '.id + "_edit"';
1362
-        $label3   = __( 'Help text', 'invoicing' );
1363
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1362
+        $label3   = __('Help text', 'invoicing');
1363
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1364 1364
         $id3      = $field . '.id + "_edit3"';
1365
-        $label5   = __( 'Is this field required?', 'invoicing' );
1365
+        $label5   = __('Is this field required?', 'invoicing');
1366 1366
         $id4      = $field . '.id + "_edit4"';
1367 1367
         echo "
1368 1368
             <div $restrict>
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
     /**
1387 1387
      * Renders the time element template.
1388 1388
      */
1389
-    public function render_time_template( $field ) {
1390
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1389
+    public function render_time_template($field) {
1390
+        $restrict = $this->get_restrict_markup($field, 'time');
1391 1391
         $label    = "$field.label";
1392 1392
         echo "
1393 1393
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1402,23 +1402,23 @@  discard block
 block discarded – undo
1402 1402
     /**
1403 1403
      * Renders the time element on the frontend.
1404 1404
      */
1405
-    public function frontend_render_time_template( $field ) {
1405
+    public function frontend_render_time_template($field) {
1406 1406
         
1407 1407
         echo "<div class='form-group'>";
1408 1408
 
1409 1409
         echo aui()->input(
1410 1410
             array(
1411
-                'name'       => esc_attr( $field['id'] ),
1412
-                'id'         => esc_attr( $field['id'] ),
1411
+                'name'       => esc_attr($field['id']),
1412
+                'id'         => esc_attr($field['id']),
1413 1413
                 'required'   => (bool) $field['required'],
1414
-                'label'      => wp_kses_post( $field['label'] ),
1414
+                'label'      => wp_kses_post($field['label']),
1415 1415
                 'no_wrap'    => true,
1416 1416
                 'type'       => 'time',
1417 1417
             )
1418 1418
         );
1419 1419
 
1420
-        if ( ! empty( $field['description'] ) ) {
1421
-            $description = wp_kses_post( $field['description'] );
1420
+        if (!empty($field['description'])) {
1421
+            $description = wp_kses_post($field['description']);
1422 1422
             echo "<small class='form-text text-muted'>$description</small>";
1423 1423
         }
1424 1424
 
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
     /**
1430 1430
      * Renders the edit time element template.
1431 1431
      */
1432
-    public function edit_time_template( $field ) {
1433
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1434
-        $label    = __( 'Field Label', 'invoicing' );
1432
+    public function edit_time_template($field) {
1433
+        $restrict = $this->get_restrict_markup($field, 'time');
1434
+        $label    = __('Field Label', 'invoicing');
1435 1435
         $id       = $field . '.id + "_edit"';
1436
-        $label3   = __( 'Help text', 'invoicing' );
1437
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1436
+        $label3   = __('Help text', 'invoicing');
1437
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1438 1438
         $id3      = $field . '.id + "_edit3"';
1439
-        $label5   = __( 'Is this field required?', 'invoicing' );
1439
+        $label5   = __('Is this field required?', 'invoicing');
1440 1440
         $id4      = $field . '.id + "_edit4"';
1441 1441
         echo "
1442 1442
             <div $restrict>
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
     /**
1461 1461
      * Renders the number element template.
1462 1462
      */
1463
-    public function render_number_template( $field ) {
1464
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1463
+    public function render_number_template($field) {
1464
+        $restrict = $this->get_restrict_markup($field, 'number');
1465 1465
         $label    = "$field.label";
1466 1466
         echo "
1467 1467
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1476,24 +1476,24 @@  discard block
 block discarded – undo
1476 1476
     /**
1477 1477
      * Renders the number element on the frontend.
1478 1478
      */
1479
-    public function frontend_render_number_template( $field ) {
1479
+    public function frontend_render_number_template($field) {
1480 1480
         
1481 1481
         echo "<div class='form-group'>";
1482 1482
 
1483 1483
         echo aui()->input(
1484 1484
             array(
1485
-                'name'       => esc_attr( $field['id'] ),
1486
-                'id'         => esc_attr( $field['id'] ),
1485
+                'name'       => esc_attr($field['id']),
1486
+                'id'         => esc_attr($field['id']),
1487 1487
                 'required'   => (bool) $field['required'],
1488
-                'label'      => wp_kses_post( $field['label'] ),
1489
-                'placeholder' => esc_attr( $field['placeholder'] ),
1488
+                'label'      => wp_kses_post($field['label']),
1489
+                'placeholder' => esc_attr($field['placeholder']),
1490 1490
                 'no_wrap'    => true,
1491 1491
                 'type'       => 'number',
1492 1492
             )
1493 1493
         );
1494 1494
 
1495
-        if ( ! empty( $field['description'] ) ) {
1496
-            $description = wp_kses_post( $field['description'] );
1495
+        if (!empty($field['description'])) {
1496
+            $description = wp_kses_post($field['description']);
1497 1497
             echo "<small class='form-text text-muted'>$description</small>";
1498 1498
         }
1499 1499
 
@@ -1504,16 +1504,16 @@  discard block
 block discarded – undo
1504 1504
     /**
1505 1505
      * Renders the edit number element template.
1506 1506
      */
1507
-    public function edit_number_template( $field ) {
1508
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1509
-        $label    = __( 'Field Label', 'invoicing' );
1507
+    public function edit_number_template($field) {
1508
+        $restrict = $this->get_restrict_markup($field, 'number');
1509
+        $label    = __('Field Label', 'invoicing');
1510 1510
         $id       = $field . '.id + "_edit"';
1511
-        $label2   = __( 'Placeholder text', 'invoicing' );
1511
+        $label2   = __('Placeholder text', 'invoicing');
1512 1512
         $id2      = $field . '.id + "_edit2"';
1513
-        $label3   = __( 'Help text', 'invoicing' );
1514
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1513
+        $label3   = __('Help text', 'invoicing');
1514
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1515 1515
         $id3      = $field . '.id + "_edit3"';
1516
-        $label5   = __( 'Is this field required?', 'invoicing' );
1516
+        $label5   = __('Is this field required?', 'invoicing');
1517 1517
         $id4      = $field . '.id + "_edit4"';
1518 1518
         echo "
1519 1519
             <div $restrict>
@@ -1541,23 +1541,23 @@  discard block
 block discarded – undo
1541 1541
     /**
1542 1542
      * Renders the separator element template.
1543 1543
      */
1544
-    public function render_separator_template( $field ) {
1545
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1544
+    public function render_separator_template($field) {
1545
+        $restrict = $this->get_restrict_markup($field, 'separator');
1546 1546
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1547 1547
     }
1548 1548
 
1549 1549
     /**
1550 1550
      * Renders the separator element on the frontend.
1551 1551
      */
1552
-    public function frontend_render_separator_template( $field ) {
1552
+    public function frontend_render_separator_template($field) {
1553 1553
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1554 1554
     }
1555 1555
 
1556 1556
     /**
1557 1557
      * Renders the pay button element template.
1558 1558
      */
1559
-    public function render_pay_button_template( $field ) {
1560
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1559
+    public function render_pay_button_template($field) {
1560
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1561 1561
         $label    = "$field.label";
1562 1562
         echo "
1563 1563
             <div $restrict>
@@ -1570,28 +1570,28 @@  discard block
 block discarded – undo
1570 1570
     /**
1571 1571
      * Renders the pay_button element on the frontend.
1572 1572
      */
1573
-    public function frontend_render_pay_button_template( $field ) {
1573
+    public function frontend_render_pay_button_template($field) {
1574 1574
 
1575 1575
         echo "<div class='mt-4 mb-4'>";
1576
-            do_action( 'wpinv_payment_mode_select' );
1576
+            do_action('wpinv_payment_mode_select');
1577 1577
         echo "</div>";
1578 1578
 
1579 1579
         echo "<div class='form-group'>";
1580 1580
 
1581
-        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1581
+        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class($field['class']);
1582 1582
         echo aui()->input(
1583 1583
             array(
1584
-                'name'       => esc_attr( $field['id'] ),
1585
-                'id'         => esc_attr( $field['id'] ),
1586
-                'value'      => esc_attr( $field['label'] ),
1584
+                'name'       => esc_attr($field['id']),
1585
+                'id'         => esc_attr($field['id']),
1586
+                'value'      => esc_attr($field['label']),
1587 1587
                 'no_wrap'    => true,
1588 1588
                 'type'       => 'submit',
1589 1589
                 'class'      => $class,
1590 1590
             )
1591 1591
         );
1592 1592
 
1593
-        if ( ! empty( $field['description'] ) ) {
1594
-            $description = wp_kses_post( $field['description'] );
1593
+        if (!empty($field['description'])) {
1594
+            $description = wp_kses_post($field['description']);
1595 1595
             echo "<small class='form-text text-muted'>$description</small>";
1596 1596
         }
1597 1597
 
@@ -1602,14 +1602,14 @@  discard block
 block discarded – undo
1602 1602
     /**
1603 1603
      * Renders the pay button element template.
1604 1604
      */
1605
-    public function edit_pay_button_template( $field ) {
1606
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1607
-        $label    = __( 'Button Text', 'invoicing' );
1605
+    public function edit_pay_button_template($field) {
1606
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1607
+        $label    = __('Button Text', 'invoicing');
1608 1608
         $id       = $field . '.id + "_edit"';
1609
-        $label2   = __( 'Help text', 'invoicing' );
1610
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1609
+        $label2   = __('Help text', 'invoicing');
1610
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1611 1611
         $id2      = $field . '.id + "_edit2"';
1612
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1612
+        $label4   = esc_attr__('Button Type', 'invoicing');
1613 1613
         $id3      = $field . '.id + "_edit3"';
1614 1614
         echo "
1615 1615
             <div $restrict>
@@ -1625,15 +1625,15 @@  discard block
 block discarded – undo
1625 1625
                     <label :for='$id3'>$label4</label>
1626 1626
 
1627 1627
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1628
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1629
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1630
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1631
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1632
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1633
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1634
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1635
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1636
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1628
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1629
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1630
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1631
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1632
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1633
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1634
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1635
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1636
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1637 1637
                     </select>
1638 1638
                 </div>
1639 1639
             </div>
@@ -1644,8 +1644,8 @@  discard block
 block discarded – undo
1644 1644
     /**
1645 1645
      * Renders the alert element template.
1646 1646
      */
1647
-    public function render_alert_template( $field ) {
1648
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1647
+    public function render_alert_template($field) {
1648
+        $restrict = $this->get_restrict_markup($field, 'alert');
1649 1649
         $text     = "$field.text";
1650 1650
         echo "
1651 1651
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
     /**
1661 1661
      * Renders the alert element on the frontend.
1662 1662
      */
1663
-    public function frontend_render_alert_template( $field ) {
1663
+    public function frontend_render_alert_template($field) {
1664 1664
         
1665 1665
         echo "<div class='form-group'>";
1666 1666
 
1667 1667
         echo aui()->alert(
1668 1668
             array(
1669
-                'content'     => wp_kses_post( $field['text'] ),
1669
+                'content'     => wp_kses_post($field['text']),
1670 1670
                 'dismissible' => $field['dismissible'],
1671
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1671
+                'type'        => str_replace('alert-', '', $field['class']),
1672 1672
             )
1673 1673
         );
1674 1674
 
@@ -1679,14 +1679,14 @@  discard block
 block discarded – undo
1679 1679
     /**
1680 1680
      * Renders the alert element template.
1681 1681
      */
1682
-    public function edit_alert_template( $field ) {
1683
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1684
-        $label    = __( 'Alert Text', 'invoicing' );
1685
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1682
+    public function edit_alert_template($field) {
1683
+        $restrict = $this->get_restrict_markup($field, 'alert');
1684
+        $label    = __('Alert Text', 'invoicing');
1685
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1686 1686
         $id       = $field . '.id + "_edit"';
1687
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1687
+        $label3   = __('Is Dismissible?', 'invoicing');
1688 1688
         $id2      = $field . '.id + "_edit2"';
1689
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1689
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1690 1690
         $id3      = $field . '.id + "_edit3"';
1691 1691
         echo "
1692 1692
             <div $restrict>
@@ -1702,14 +1702,14 @@  discard block
 block discarded – undo
1702 1702
                     <label :for='$id3'>$label4</label>
1703 1703
 
1704 1704
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1705
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1706
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1707
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1708
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1709
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1710
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1711
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1712
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1705
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1706
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1707
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1708
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1709
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1710
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1711
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1712
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1713 1713
                     </select>
1714 1714
                 </div>
1715 1715
             </div>
@@ -1720,8 +1720,8 @@  discard block
 block discarded – undo
1720 1720
     /**
1721 1721
      * Renders the discount element template.
1722 1722
      */
1723
-    public function render_discount_template( $field ) {
1724
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1723
+    public function render_discount_template($field) {
1724
+        $restrict = $this->get_restrict_markup($field, 'discount');
1725 1725
         ?>
1726 1726
 
1727 1727
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1738,13 +1738,13 @@  discard block
 block discarded – undo
1738 1738
     /**
1739 1739
      * Renders the discount element on the frontend.
1740 1740
      */
1741
-    public function frontend_render_discount_template( $field ) {
1741
+    public function frontend_render_discount_template($field) {
1742 1742
         
1743
-        $placeholder = esc_attr( $field['input_label'] );
1744
-        $label       = sanitize_text_field( $field['button_label'] );
1743
+        $placeholder = esc_attr($field['input_label']);
1744
+        $label       = sanitize_text_field($field['button_label']);
1745 1745
         $description = '';
1746 1746
 
1747
-        if ( ! empty( $field['description'] ) ) {
1747
+        if (!empty($field['description'])) {
1748 1748
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1749 1749
         }
1750 1750
 ?>
@@ -1765,12 +1765,12 @@  discard block
 block discarded – undo
1765 1765
     /**
1766 1766
      * Renders the discount element template.
1767 1767
      */
1768
-    public function edit_discount_template( $field ) {
1769
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1770
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1771
-        $label2   = __( 'Help Text', 'invoicing' );
1772
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1773
-        $label4   = __( 'Button Text', 'invoicing' );
1768
+    public function edit_discount_template($field) {
1769
+        $restrict = $this->get_restrict_markup($field, 'discount');
1770
+        $label    = __('Discount Input Placeholder', 'invoicing');
1771
+        $label2   = __('Help Text', 'invoicing');
1772
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1773
+        $label4   = __('Button Text', 'invoicing');
1774 1774
         $id       = $field . '.id + "_edit"';
1775 1775
         $id2      = $field . '.id + "_edit2"';
1776 1776
         $id3      = $field . '.id + "_edit3"';
@@ -1799,11 +1799,11 @@  discard block
 block discarded – undo
1799 1799
     /**
1800 1800
      * Renders the items element template.
1801 1801
      */
1802
-    public function render_items_template( $field ) {
1803
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1804
-        $label     = __( 'Item totals will appear here. Click to set items.', 'invoicing' );
1805
-        $label2    = __( 'Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing' );
1806
-        $label2   .= ' ' . __( 'To prevent this, limit customers to selecting a single item.', 'invoicing' );
1802
+    public function render_items_template($field) {
1803
+        $restrict  = $this->get_restrict_markup($field, 'items');
1804
+        $label     = __('Item totals will appear here. Click to set items.', 'invoicing');
1805
+        $label2    = __('Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing');
1806
+        $label2   .= ' ' . __('To prevent this, limit customers to selecting a single item.', 'invoicing');
1807 1807
         echo "
1808 1808
             <div $restrict class='item_totals text-center'>
1809 1809
                 <div v-if='canCheckoutSeveralSubscriptions($field)' class='p-4 bg-danger text-light'>$label2</div>
@@ -1815,12 +1815,12 @@  discard block
 block discarded – undo
1815 1815
     /**
1816 1816
      * Renders the items element on the frontend.
1817 1817
      */
1818
-    public function frontend_render_items_template( $field, $items ) {
1818
+    public function frontend_render_items_template($field, $items) {
1819 1819
         
1820 1820
         echo "<div class='form-group item_totals'>";
1821 1821
         
1822
-        $id = esc_attr( $field['id'] );
1823
-        if ( 'total' == $field[ 'items_type' ] ) {
1822
+        $id = esc_attr($field['id']);
1823
+        if ('total' == $field['items_type']) {
1824 1824
             $total     = 0;
1825 1825
             $tax       = 0;
1826 1826
             $sub_total = 0;
@@ -1829,16 +1829,16 @@  discard block
 block discarded – undo
1829 1829
             <div class="border item_totals_type_total">
1830 1830
 
1831 1831
                 <?php
1832
-                    foreach( $items as $item ) {
1832
+                    foreach ($items as $item) {
1833 1833
 
1834
-                        $amount = floatval( $item['price'] );
1834
+                        $amount = floatval($item['price']);
1835 1835
 
1836
-                        if ( wpinv_use_taxes() ) {
1836
+                        if (wpinv_use_taxes()) {
1837 1837
 
1838
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1838
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1839 1839
 
1840
-                            if ( wpinv_prices_include_tax() ) {
1841
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1840
+                            if (wpinv_prices_include_tax()) {
1841
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1842 1842
                                 $item_tax = $amount - $pre_tax;
1843 1843
                             } else {
1844 1844
                                 $pre_tax  = $amount;
@@ -1850,27 +1850,27 @@  discard block
 block discarded – undo
1850 1850
                             $total     = $sub_total + $tax;
1851 1851
 
1852 1852
                         } else {
1853
-                            $total  = $total + $amount;
1853
+                            $total = $total + $amount;
1854 1854
                         }
1855 1855
 
1856 1856
                         $class  = 'col-8';
1857 1857
                         $class2 = '';
1858 1858
 
1859
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1859
+                        if (!empty($item['allow_quantities'])) {
1860 1860
                             $class = 'col-6 pt-2';
1861 1861
                             $class2 = 'pt-2';
1862 1862
                         }
1863 1863
 
1864
-                        if ( ! empty( $item['custom_price'] ) ) {
1864
+                        if (!empty($item['custom_price'])) {
1865 1865
                             $class .= ' pt-2';
1866 1866
                         }
1867 1867
             
1868 1868
                 ?>
1869 1869
                     <div  class="item_totals_item">
1870 1870
                         <div class='row pl-2 pr-2 pt-2'>
1871
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1871
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1872 1872
 
1873
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1873
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1874 1874
 
1875 1875
                                 <div class='col-2'>
1876 1876
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -1878,11 +1878,11 @@  discard block
 block discarded – undo
1878 1878
 
1879 1879
                             <?php } else { ?>
1880 1880
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1881
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1881
+                            <?php } if (empty($item['custom_price'])) { ?>
1882 1882
 
1883 1883
                                 <div class='col-4 <?php echo $class2; ?>'>
1884
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1885
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1884
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1885
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1886 1886
                                 </div>
1887 1887
 
1888 1888
                             <?php } else {?>
@@ -1890,15 +1890,15 @@  discard block
 block discarded – undo
1890 1890
                                 <div class='col-4'>
1891 1891
                                     <div class='input-group'>
1892 1892
 
1893
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1893
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1894 1894
                                             <div class='input-group-prepend'>
1895 1895
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1896 1896
                                             </div>
1897 1897
                                         <?php } ?>
1898 1898
 
1899
-                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1899
+                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1900 1900
                                     
1901
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1901
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1902 1902
                                             <div class='input-group-append'>
1903 1903
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1904 1904
                                             </div>
@@ -1909,28 +1909,28 @@  discard block
 block discarded – undo
1909 1909
                             <?php } ?>
1910 1910
 
1911 1911
                         </div>
1912
-                        <?php if ( ! empty( $item['description'] )) { ?>
1913
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1912
+                        <?php if (!empty($item['description'])) { ?>
1913
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1914 1914
                         <?php } ?>
1915 1915
                     </div>
1916 1916
                 <?php } ?>
1917 1917
 
1918 1918
                 <div class='mt-4 border-top item_totals_total p-2'>
1919 1919
 
1920
-                    <?php if ( wpinv_use_taxes() ) { ?>
1920
+                    <?php if (wpinv_use_taxes()) { ?>
1921 1921
                         <div class='row'>
1922
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1923
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1922
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1923
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1924 1924
                         </div>
1925 1925
                         <div class='row'>
1926
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1927
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1926
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1927
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1928 1928
                         </div>
1929 1929
                     <?php } ?>
1930 1930
 
1931 1931
                     <div class='row'>
1932
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1933
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1932
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1933
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1934 1934
                     </div>
1935 1935
 
1936 1936
                 </div>
@@ -1938,22 +1938,22 @@  discard block
 block discarded – undo
1938 1938
             </div>
1939 1939
         <?php } ?>
1940 1940
 
1941
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1941
+        <?php if ('radio' == $field['items_type']) { ?>
1942 1942
             <div class="item_totals_type_radio">
1943 1943
 
1944 1944
                 <?php
1945
-                    foreach( $items as $index => $item ) {
1945
+                    foreach ($items as $index => $item) {
1946 1946
 
1947
-                        if ( ! empty( $item['required'] ) ) {
1947
+                        if (!empty($item['required'])) {
1948 1948
                             continue;
1949 1949
                         }
1950 1950
                 ?>
1951 1951
                     <div  class="form-check">
1952
-                        <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1953
-                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?>&nbsp;<strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) ); ?></strong></label>
1952
+                        <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1953
+                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?>&nbsp;<strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label>
1954 1954
                     </div>
1955
-                    <?php if ( ! empty( $item['description'] )) { ?>
1956
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1955
+                    <?php if (!empty($item['description'])) { ?>
1956
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1957 1957
                     <?php } ?>
1958 1958
                 <?php } ?>
1959 1959
 
@@ -1965,32 +1965,32 @@  discard block
 block discarded – undo
1965 1965
                         $tax       = 0;
1966 1966
                         $sub_total = 0;
1967 1967
 
1968
-                        foreach ( $items as $item ) {
1968
+                        foreach ($items as $item) {
1969 1969
 
1970 1970
                             $class  = 'col-8';
1971 1971
                             $class2 = '';
1972 1972
 
1973
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1973
+                            if (!empty($item['allow_quantities'])) {
1974 1974
                                 $class = 'col-6 pt-2';
1975 1975
                                 $class2 = 'pt-2';
1976 1976
                             }
1977 1977
 
1978
-                            if ( ! empty( $item['custom_price'] ) ) {
1978
+                            if (!empty($item['custom_price'])) {
1979 1979
                                 $class .= ' pt-2';
1980 1980
                             }
1981 1981
 
1982 1982
                             $class3 = 'd-none';
1983 1983
                             $name   = '';
1984
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1984
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1985 1985
 
1986
-                                $amount = floatval( $item['price'] );
1986
+                                $amount = floatval($item['price']);
1987 1987
 
1988
-                                if ( wpinv_use_taxes() ) {
1988
+                                if (wpinv_use_taxes()) {
1989 1989
 
1990
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1990
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1991 1991
 
1992
-                                    if ( wpinv_prices_include_tax() ) {
1993
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1992
+                                    if (wpinv_prices_include_tax()) {
1993
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1994 1994
                                         $item_tax = $amount - $pre_tax;
1995 1995
                                     } else {
1996 1996
                                         $pre_tax  = $amount;
@@ -2002,13 +2002,13 @@  discard block
 block discarded – undo
2002 2002
                                     $total     = $sub_total + $tax;
2003 2003
 
2004 2004
                                 } else {
2005
-                                    $total  = $total + $amount;
2005
+                                    $total = $total + $amount;
2006 2006
                                 }
2007 2007
 
2008 2008
                                 $class3 = '';
2009 2009
                                 $name   = "wpinv-items[{$item['id']}]";
2010 2010
 
2011
-                                if ( empty( $item['required'] ) ) {
2011
+                                if (empty($item['required'])) {
2012 2012
                                     $totals_selected_radio_item = 1;
2013 2013
                                 }
2014 2014
 
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
 
2021 2021
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2022 2022
                         <div class='row pl-2 pr-2 pt-2'>
2023
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2023
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2024 2024
 
2025
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2025
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2026 2026
 
2027 2027
                                 <div class='col-2'>
2028 2028
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2030,11 +2030,11 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
                             <?php } else { ?>
2032 2032
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2033
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2033
+                            <?php } if (empty($item['custom_price'])) { ?>
2034 2034
 
2035 2035
                                 <div class='col-4 <?php echo $class2; ?>'>
2036
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2037
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2036
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2037
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2038 2038
                                 </div>
2039 2039
 
2040 2040
                             <?php } else {?>
@@ -2042,15 +2042,15 @@  discard block
 block discarded – undo
2042 2042
                                 <div class='col-4'>
2043 2043
                                     <div class='input-group'>
2044 2044
 
2045
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2045
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2046 2046
                                             <div class='input-group-prepend'>
2047 2047
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2048 2048
                                             </div>
2049 2049
                                         <?php } ?>
2050 2050
 
2051
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2051
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2052 2052
                                     
2053
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2053
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2054 2054
                                             <div class='input-group-append'>
2055 2055
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2056 2056
                                             </div>
@@ -2061,27 +2061,27 @@  discard block
 block discarded – undo
2061 2061
                             <?php } ?>
2062 2062
 
2063 2063
                         </div>
2064
-                        <?php if ( ! empty( $item['description'] )) { ?>
2065
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2064
+                        <?php if (!empty($item['description'])) { ?>
2065
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2066 2066
                         <?php } ?>
2067 2067
                     </div>
2068 2068
                 <?php } ?>
2069 2069
 
2070 2070
                 <div class='mt-4 border-top item_totals_total p-2'>
2071
-                    <?php if ( wpinv_use_taxes() ) { ?>
2071
+                    <?php if (wpinv_use_taxes()) { ?>
2072 2072
                         <div class='row'>
2073
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2074
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2073
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2074
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2075 2075
                         </div>
2076 2076
                         <div class='row'>
2077
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2078
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2077
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2078
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2079 2079
                         </div>
2080 2080
                     <?php } ?>
2081 2081
 
2082 2082
                     <div class='row'>
2083
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2084
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2083
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2084
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2085 2085
                     </div>
2086 2086
                 </div>
2087 2087
 
@@ -2089,22 +2089,22 @@  discard block
 block discarded – undo
2089 2089
             </div>
2090 2090
         <?php } ?>
2091 2091
 
2092
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
2092
+        <?php if ('checkbox' == $field['items_type']) { ?>
2093 2093
 
2094 2094
             <div class="item_totals_type_checkbox">
2095 2095
 
2096 2096
                 <?php
2097
-                    foreach ( $items as $index => $item ) {
2097
+                    foreach ($items as $index => $item) {
2098 2098
 
2099
-                        if ( ! empty( $item['required'] ) ) {
2099
+                        if (!empty($item['required'])) {
2100 2100
                             continue;
2101 2101
                         }
2102 2102
 
2103
-                        $title = sanitize_text_field(  $item['title'] );
2104
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2105
-                        $item_id    = esc_attr( $id . "_$index" );
2106
-                        $value = esc_attr( $item['id'] );
2107
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
2103
+                        $title = sanitize_text_field($item['title']);
2104
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2105
+                        $item_id = esc_attr($id . "_$index");
2106
+                        $value = esc_attr($item['id']);
2107
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
2108 2108
                         $selected_checkbox_item = 1;
2109 2109
 
2110 2110
                         echo "
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
2114 2114
                             </div>";
2115 2115
 
2116
-                        if ( ! empty( $item['description'] ) ) {
2116
+                        if (!empty($item['description'])) {
2117 2117
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
2118 2118
                         }
2119 2119
                     }
@@ -2127,31 +2127,31 @@  discard block
 block discarded – undo
2127 2127
                         $tax       = 0;
2128 2128
                         $sub_total = 0;
2129 2129
 
2130
-                        foreach ( $items as $item ) {
2130
+                        foreach ($items as $item) {
2131 2131
 
2132 2132
                             $class  = 'col-8';
2133 2133
                             $class2 = '';
2134 2134
 
2135
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2135
+                            if (!empty($item['allow_quantities'])) {
2136 2136
                                 $class = 'col-6 pt-2';
2137 2137
                                 $class2 = 'pt-2';
2138 2138
                             }
2139 2139
 
2140
-                            if ( ! empty( $item['custom_price'] ) ) {
2140
+                            if (!empty($item['custom_price'])) {
2141 2141
                                 $class .= ' pt-2';
2142 2142
                             }
2143 2143
 
2144 2144
                             $class3 = 'd-none';
2145
-                            $name  = '';
2146
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
2145
+                            $name = '';
2146
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
2147 2147
 
2148
-                                $amount = floatval( $item['price'] );
2149
-                                if ( wpinv_use_taxes() ) {
2148
+                                $amount = floatval($item['price']);
2149
+                                if (wpinv_use_taxes()) {
2150 2150
 
2151
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2151
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2152 2152
 
2153
-                                    if ( wpinv_prices_include_tax() ) {
2154
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2153
+                                    if (wpinv_prices_include_tax()) {
2154
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2155 2155
                                         $item_tax = $amount - $pre_tax;
2156 2156
                                     } else {
2157 2157
                                         $pre_tax  = $amount;
@@ -2163,13 +2163,13 @@  discard block
 block discarded – undo
2163 2163
                                     $total     = $sub_total + $tax;
2164 2164
 
2165 2165
                                 } else {
2166
-                                    $total  = $total + $amount;
2166
+                                    $total = $total + $amount;
2167 2167
                                 }
2168 2168
 
2169 2169
                                 $class3 = '';
2170
-                                $name  = "wpinv-items[{$item['id']}]";
2170
+                                $name = "wpinv-items[{$item['id']}]";
2171 2171
 
2172
-                                if ( empty( $item['required'] ) ) {
2172
+                                if (empty($item['required'])) {
2173 2173
                                     $totals_selected_checkbox_item = 1;
2174 2174
                                 }
2175 2175
 
@@ -2181,9 +2181,9 @@  discard block
 block discarded – undo
2181 2181
 
2182 2182
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2183 2183
                         <div class='row pl-2 pr-2 pt-2'>
2184
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2184
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2185 2185
 
2186
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2186
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2187 2187
 
2188 2188
                                 <div class='col-2'>
2189 2189
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2191,11 +2191,11 @@  discard block
 block discarded – undo
2191 2191
 
2192 2192
                             <?php } else { ?>
2193 2193
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2194
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2194
+                            <?php } if (empty($item['custom_price'])) { ?>
2195 2195
 
2196 2196
                                 <div class='col-4 <?php echo $class2; ?>'>
2197
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2198
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2197
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2198
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2199 2199
                                 </div>
2200 2200
 
2201 2201
                             <?php } else {?>
@@ -2203,15 +2203,15 @@  discard block
 block discarded – undo
2203 2203
                                 <div class='col-4'>
2204 2204
                                     <div class='input-group'>
2205 2205
 
2206
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2206
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2207 2207
                                             <div class='input-group-prepend'>
2208 2208
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2209 2209
                                             </div>
2210 2210
                                         <?php } ?>
2211 2211
 
2212
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2212
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2213 2213
                                     
2214
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2214
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2215 2215
                                             <div class='input-group-append'>
2216 2216
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2217 2217
                                             </div>
@@ -2222,35 +2222,35 @@  discard block
 block discarded – undo
2222 2222
                             <?php } ?>
2223 2223
 
2224 2224
                         </div>
2225
-                        <?php if ( ! empty( $item['description'] )) { ?>
2226
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2225
+                        <?php if (!empty($item['description'])) { ?>
2226
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2227 2227
                         <?php } ?>
2228 2228
                     </div>
2229 2229
                 <?php } ?>
2230 2230
 
2231 2231
                 <div class='mt-4 border-top item_totals_total p-2'>
2232 2232
 
2233
-                    <?php if ( wpinv_use_taxes() ) { ?>
2233
+                    <?php if (wpinv_use_taxes()) { ?>
2234 2234
                         <div class='row'>
2235
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2236
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2235
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2236
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2237 2237
                         </div>
2238 2238
                         <div class='row'>
2239
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2240
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2239
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2240
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2241 2241
                         </div>
2242 2242
                     <?php } ?>
2243 2243
 
2244 2244
                     <div class='row'>
2245
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2246
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2245
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2246
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2247 2247
                     </div>
2248 2248
                 </div>
2249 2249
             </div>
2250 2250
             </div>
2251 2251
         <?php } ?>
2252 2252
 
2253
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
2253
+        <?php if ('select' == $field['items_type']) { ?>
2254 2254
 
2255 2255
             <div class="item_totals_type_select">
2256 2256
 
@@ -2258,17 +2258,17 @@  discard block
 block discarded – undo
2258 2258
 
2259 2259
                     $options  = array();
2260 2260
                     $selected = '';
2261
-                    foreach ( $items as $index => $item ) {
2261
+                    foreach ($items as $index => $item) {
2262 2262
 
2263
-                        if ( ! empty( $item['required'] ) ) {
2263
+                        if (!empty($item['required'])) {
2264 2264
                             continue;
2265 2265
                         }
2266 2266
 
2267
-                        $title = sanitize_text_field(  $item['title'] );
2268
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2269
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2267
+                        $title = sanitize_text_field($item['title']);
2268
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2269
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2270 2270
 
2271
-                        if ( ! isset( $selected_item ) ) {
2271
+                        if (!isset($selected_item)) {
2272 2272
                             $selected = $item['id'];
2273 2273
                             $selected_item = 1;
2274 2274
                         }
@@ -2279,7 +2279,7 @@  discard block
 block discarded – undo
2279 2279
                         array(
2280 2280
                                 'name'        => 'payment-form-items',
2281 2281
                                 'id'          => $id,
2282
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
2282
+                                'placeholder' => __('Select an item', 'invoicing'),
2283 2283
                                 'no_wrap'     => true,
2284 2284
                                 'options'     => $options,
2285 2285
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -2296,31 +2296,31 @@  discard block
 block discarded – undo
2296 2296
                         $tax       = 0;
2297 2297
                         $sub_total = 0;
2298 2298
 
2299
-                        foreach ( $items as $item ) {
2299
+                        foreach ($items as $item) {
2300 2300
 
2301 2301
                             $class  = 'col-8';
2302 2302
                             $class2 = '';
2303 2303
 
2304
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2304
+                            if (!empty($item['allow_quantities'])) {
2305 2305
                                 $class = 'col-6 pt-2';
2306 2306
                                 $class2 = 'pt-2';
2307 2307
                             }
2308 2308
 
2309
-                            if ( ! empty( $item['custom_price'] ) ) {
2309
+                            if (!empty($item['custom_price'])) {
2310 2310
                                 $class .= ' pt-2';
2311 2311
                             }
2312 2312
 
2313 2313
                             $class3 = 'd-none';
2314
-                            $name  = '';
2315
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2314
+                            $name = '';
2315
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2316 2316
 
2317
-                                $amount = floatval( $item['price'] );
2318
-                                if ( wpinv_use_taxes() ) {
2317
+                                $amount = floatval($item['price']);
2318
+                                if (wpinv_use_taxes()) {
2319 2319
 
2320
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2320
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2321 2321
 
2322
-                                    if ( wpinv_prices_include_tax() ) {
2323
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2322
+                                    if (wpinv_prices_include_tax()) {
2323
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2324 2324
                                         $item_tax = $amount - $pre_tax;
2325 2325
                                     } else {
2326 2326
                                         $pre_tax  = $amount;
@@ -2332,13 +2332,13 @@  discard block
 block discarded – undo
2332 2332
                                     $total     = $sub_total + $tax;
2333 2333
 
2334 2334
                                 } else {
2335
-                                    $total  = $total + $amount;
2335
+                                    $total = $total + $amount;
2336 2336
                                 }
2337 2337
 
2338 2338
                                 $class3 = '';
2339
-                                $name  = "wpinv-items[{$item['id']}]";
2339
+                                $name = "wpinv-items[{$item['id']}]";
2340 2340
 
2341
-                                if ( empty( $item['required'] ) ) {
2341
+                                if (empty($item['required'])) {
2342 2342
                                     $totals_selected_select_item = 1;
2343 2343
                                 }
2344 2344
 
@@ -2350,9 +2350,9 @@  discard block
 block discarded – undo
2350 2350
 
2351 2351
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2352 2352
                         <div class='row pl-2 pr-2 pt-2'>
2353
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2353
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2354 2354
 
2355
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2355
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2356 2356
 
2357 2357
                                 <div class='col-2'>
2358 2358
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2360,11 +2360,11 @@  discard block
 block discarded – undo
2360 2360
 
2361 2361
                             <?php } else { ?>
2362 2362
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2363
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2363
+                            <?php } if (empty($item['custom_price'])) { ?>
2364 2364
 
2365 2365
                                 <div class='col-4 <?php echo $class2; ?>'>
2366
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2367
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2366
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2367
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2368 2368
                                 </div>
2369 2369
 
2370 2370
                             <?php } else {?>
@@ -2372,15 +2372,15 @@  discard block
 block discarded – undo
2372 2372
                                 <div class='col-4'>
2373 2373
                                     <div class='input-group'>
2374 2374
 
2375
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2375
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2376 2376
                                             <div class='input-group-prepend'>
2377 2377
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2378 2378
                                             </div>
2379 2379
                                         <?php } ?>
2380 2380
 
2381
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2381
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2382 2382
                                     
2383
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2383
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2384 2384
                                             <div class='input-group-append'>
2385 2385
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2386 2386
                                             </div>
@@ -2391,34 +2391,34 @@  discard block
 block discarded – undo
2391 2391
                             <?php } ?>
2392 2392
 
2393 2393
                         </div>
2394
-                        <?php if ( ! empty( $item['description'] )) { ?>
2395
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2394
+                        <?php if (!empty($item['description'])) { ?>
2395
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2396 2396
                         <?php } ?>
2397 2397
                     </div>
2398 2398
                 <?php } ?>
2399 2399
 
2400 2400
                 <div class='mt-4 border-top item_totals_total p-2'>
2401 2401
 
2402
-                    <?php if ( wpinv_use_taxes() ) { ?>
2402
+                    <?php if (wpinv_use_taxes()) { ?>
2403 2403
                         <div class='row'>
2404
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2405
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2404
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2405
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2406 2406
                         </div>
2407 2407
                         <div class='row'>
2408
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2409
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2408
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2409
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2410 2410
                         </div>
2411 2411
                     <?php } ?>
2412 2412
                     <div class='row'>
2413
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2414
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2413
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2414
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2415 2415
                     </div>
2416 2416
                 </div>
2417 2417
 
2418 2418
             </div>
2419 2419
         <?php } ?>
2420 2420
 
2421
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
2421
+        <?php if ('multi_select' == $field['items_type']) { ?>
2422 2422
 
2423 2423
             <div class="item_totals_type_multi_select">
2424 2424
 
@@ -2427,18 +2427,18 @@  discard block
 block discarded – undo
2427 2427
                     $options  = array();
2428 2428
                     $selected = array();
2429 2429
 
2430
-                    foreach ( $items as $index => $item ) {
2430
+                    foreach ($items as $index => $item) {
2431 2431
 
2432
-                        if ( ! empty( $item['required'] ) ) {
2432
+                        if (!empty($item['required'])) {
2433 2433
                             continue;
2434 2434
                         }
2435 2435
 
2436
-                        $title = sanitize_text_field(  $item['title'] );
2437
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2438
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2436
+                        $title = sanitize_text_field($item['title']);
2437
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2438
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2439 2439
 
2440
-                        if ( ! isset( $selected_item ) ) {
2441
-                            $selected = array( $item['id'] );
2440
+                        if (!isset($selected_item)) {
2441
+                            $selected = array($item['id']);
2442 2442
                             $selected_item = 1;
2443 2443
                         }
2444 2444
 
@@ -2465,31 +2465,31 @@  discard block
 block discarded – undo
2465 2465
                         $tax       = 0;
2466 2466
                         $sub_total = 0;
2467 2467
 
2468
-                        foreach ( $items as $item ) {
2468
+                        foreach ($items as $item) {
2469 2469
 
2470 2470
                             $class  = 'col-8';
2471 2471
                             $class2 = '';
2472 2472
 
2473
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2473
+                            if (!empty($item['allow_quantities'])) {
2474 2474
                                 $class = 'col-6 pt-2';
2475 2475
                                 $class2 = 'pt-2';
2476 2476
                             }
2477 2477
 
2478
-                            if ( ! empty( $item['custom_price'] ) ) {
2478
+                            if (!empty($item['custom_price'])) {
2479 2479
                                 $class .= ' pt-2';
2480 2480
                             }
2481 2481
 
2482 2482
                             $class3 = 'd-none';
2483
-                            $name  = '';
2484
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2483
+                            $name = '';
2484
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2485 2485
 
2486
-                                $amount = floatval( $item['price'] );
2487
-                                if ( wpinv_use_taxes() ) {
2486
+                                $amount = floatval($item['price']);
2487
+                                if (wpinv_use_taxes()) {
2488 2488
 
2489
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2489
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2490 2490
 
2491
-                                    if ( wpinv_prices_include_tax() ) {
2492
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2491
+                                    if (wpinv_prices_include_tax()) {
2492
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2493 2493
                                         $item_tax = $amount - $pre_tax;
2494 2494
                                     } else {
2495 2495
                                         $pre_tax  = $amount;
@@ -2501,13 +2501,13 @@  discard block
 block discarded – undo
2501 2501
                                     $total     = $sub_total + $tax;
2502 2502
 
2503 2503
                                 } else {
2504
-                                    $total  = $total + $amount;
2504
+                                    $total = $total + $amount;
2505 2505
                                 }
2506 2506
 
2507 2507
                                 $class3 = '';
2508
-                                $name  = "wpinv-items[{$item['id']}]";
2508
+                                $name = "wpinv-items[{$item['id']}]";
2509 2509
 
2510
-                                if ( empty( $item['required'] ) ) {
2510
+                                if (empty($item['required'])) {
2511 2511
                                     $totals_selected_select_item = 1;
2512 2512
                                 }
2513 2513
 
@@ -2519,9 +2519,9 @@  discard block
 block discarded – undo
2519 2519
 
2520 2520
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2521 2521
                         <div class='row pl-2 pr-2 pt-2'>
2522
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2522
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2523 2523
 
2524
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2524
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2525 2525
 
2526 2526
                                 <div class='col-2'>
2527 2527
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2529,11 +2529,11 @@  discard block
 block discarded – undo
2529 2529
 
2530 2530
                             <?php } else { ?>
2531 2531
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2532
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2532
+                            <?php } if (empty($item['custom_price'])) { ?>
2533 2533
 
2534 2534
                                 <div class='col-4 <?php echo $class2; ?>'>
2535
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2536
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2535
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2536
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2537 2537
                                 </div>
2538 2538
 
2539 2539
                             <?php } else {?>
@@ -2541,15 +2541,15 @@  discard block
 block discarded – undo
2541 2541
                                 <div class='col-4'>
2542 2542
                                     <div class='input-group'>
2543 2543
 
2544
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2544
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2545 2545
                                             <div class='input-group-prepend'>
2546 2546
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2547 2547
                                             </div>
2548 2548
                                         <?php } ?>
2549 2549
 
2550
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2550
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2551 2551
                                     
2552
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2552
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2553 2553
                                             <div class='input-group-append'>
2554 2554
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2555 2555
                                             </div>
@@ -2560,35 +2560,35 @@  discard block
 block discarded – undo
2560 2560
                             <?php } ?>
2561 2561
 
2562 2562
                         </div>
2563
-                        <?php if ( ! empty( $item['description'] )) { ?>
2564
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2563
+                        <?php if (!empty($item['description'])) { ?>
2564
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2565 2565
                         <?php } ?>
2566 2566
                     </div>
2567 2567
                 <?php } ?>
2568 2568
 
2569 2569
                 <div class='mt-4 border-top item_totals_total p-2'>
2570 2570
 
2571
-                    <?php if ( wpinv_use_taxes() ) { ?>
2571
+                    <?php if (wpinv_use_taxes()) { ?>
2572 2572
                         <div class='row'>
2573
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2574
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2573
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2574
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2575 2575
                         </div>
2576 2576
                         <div class='row'>
2577
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2578
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2577
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2578
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2579 2579
                         </div>
2580 2580
                     <?php } ?>
2581 2581
 
2582 2582
                     <div class='row'>
2583
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2584
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2583
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2584
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2585 2585
                     </div>
2586 2586
                 </div>
2587 2587
 
2588 2588
             </div>
2589 2589
         <?php } ?>
2590
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2591
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2590
+        <?php if (!empty($field['description'])) { ?>
2591
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2592 2592
         <?php } ?>
2593 2593
         </div>
2594 2594
         <?php
@@ -2597,20 +2597,20 @@  discard block
 block discarded – undo
2597 2597
     /**
2598 2598
      * Renders the items element template.
2599 2599
      */
2600
-    public function edit_items_template( $field ) {
2601
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2602
-        $label    = __( 'Let customers...', 'invoicing' );
2603
-        $label2   = __( 'Available Items', 'invoicing' );
2604
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2600
+    public function edit_items_template($field) {
2601
+        $restrict = $this->get_restrict_markup($field, 'items');
2602
+        $label    = __('Let customers...', 'invoicing');
2603
+        $label2   = __('Available Items', 'invoicing');
2604
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2605 2605
         $id       = $field . '.id + "_edit"';
2606 2606
         $id2      = $field . '.id + "_edit2"';
2607 2607
         $id3      = $field . '.id + "_edit3"';
2608 2608
         $id4      = $field . '.id + "_edit4"';
2609
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2610
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2611
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2612
-        $label7   = esc_attr__( 'Allow users to buy several quantities', 'invoicing' );
2613
-        $label8   = esc_attr__( 'This item is required', 'invoicing' );
2609
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2610
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2611
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2612
+        $label7   = esc_attr__('Allow users to buy several quantities', 'invoicing');
2613
+        $label8   = esc_attr__('This item is required', 'invoicing');
2614 2614
         echo "<div $restrict>
2615 2615
 
2616 2616
                 <label>$label2</label>
@@ -2680,7 +2680,7 @@  discard block
 block discarded – undo
2680 2680
                 <div class='form-group mt-2'>
2681 2681
 
2682 2682
                     <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'>
2683
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2683
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2684 2684
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2685 2685
                     </select>
2686 2686
 
@@ -2695,11 +2695,11 @@  discard block
 block discarded – undo
2695 2695
                     <label :for='$id2'>$label</label>
2696 2696
 
2697 2697
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2698
-                        <option value='total' :disabled='canCheckoutSeveralSubscriptions($field)'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2699
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2700
-                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions($field)'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2701
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2702
-                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2698
+                        <option value='total' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Buy all items on the list', 'invoicing') . "</option>
2699
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2700
+                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Select one or more items on the list', 'invoicing') . "</option>
2701
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2702
+                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2703 2703
                     </select>
2704 2704
 
2705 2705
                 </div>
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
             'orderby'        => 'title',
2725 2725
             'order'          => 'ASC',
2726 2726
             'posts_per_page' => -1,
2727
-            'post_status'    => array( 'publish' ),
2727
+            'post_status'    => array('publish'),
2728 2728
             'meta_query'     => array(
2729 2729
                 array(
2730 2730
                     'key'       => '_wpinv_type',
@@ -2734,24 +2734,24 @@  discard block
 block discarded – undo
2734 2734
             )
2735 2735
         );
2736 2736
     
2737
-        $items = get_posts( apply_filters( 'wpinv_payment_form_item_dropdown_query_args', $item_args ) );
2737
+        $items = get_posts(apply_filters('wpinv_payment_form_item_dropdown_query_args', $item_args));
2738 2738
 
2739
-        if ( empty( $items ) ) {
2739
+        if (empty($items)) {
2740 2740
             return array();
2741 2741
         }
2742 2742
 
2743
-        $options    = array();
2744
-        foreach ( $items as $item ) {
2745
-            $title            = esc_html( $item->post_title );
2746
-            $title           .= wpinv_get_item_suffix( $item->ID, false );
2747
-            $id               = absint( $item->ID );
2748
-            $price            = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2749
-            $recurring        = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2743
+        $options = array();
2744
+        foreach ($items as $item) {
2745
+            $title            = esc_html($item->post_title);
2746
+            $title           .= wpinv_get_item_suffix($item->ID, false);
2747
+            $id               = absint($item->ID);
2748
+            $price            = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2749
+            $recurring        = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2750 2750
             $description      = $item->post_excerpt;
2751
-            $custom_price     = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2752
-            $minimum_price    = (float) get_post_meta( $id, '_minimum_price', true );
2751
+            $custom_price     = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2752
+            $minimum_price    = (float) get_post_meta($id, '_minimum_price', true);
2753 2753
             $allow_quantities = false;
2754
-            $options[]        = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' );
2754
+            $options[]        = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities');
2755 2755
 
2756 2756
         }
2757 2757
         return $options;
@@ -2761,47 +2761,47 @@  discard block
 block discarded – undo
2761 2761
     /**
2762 2762
      * Returns an array of items for the currently being edited form.
2763 2763
      */
2764
-    public function get_form_items( $id = false ) {
2764
+    public function get_form_items($id = false) {
2765 2765
         
2766
-        if ( empty( $id ) ) {
2767
-            return wpinv_get_data( 'sample-payment-form-items' );
2766
+        if (empty($id)) {
2767
+            return wpinv_get_data('sample-payment-form-items');
2768 2768
         }
2769 2769
         
2770
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2770
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2771 2771
 
2772
-        if ( is_array( $form_elements ) ) {
2772
+        if (is_array($form_elements)) {
2773 2773
             return $form_elements;
2774 2774
         }
2775 2775
 
2776
-        return wpinv_get_data( 'sample-payment-form-items' );
2776
+        return wpinv_get_data('sample-payment-form-items');
2777 2777
 
2778 2778
     }
2779 2779
 
2780 2780
     /**
2781 2781
      * Returns an array of elements for the currently being edited form.
2782 2782
      */
2783
-    public function get_form_elements( $id = false ) {
2783
+    public function get_form_elements($id = false) {
2784 2784
 
2785
-        if ( empty( $id ) ) {
2786
-            return wpinv_get_data( 'sample-payment-form' );
2785
+        if (empty($id)) {
2786
+            return wpinv_get_data('sample-payment-form');
2787 2787
         }
2788 2788
         
2789
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2789
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2790 2790
 
2791
-        if ( is_array( $form_elements ) ) {
2791
+        if (is_array($form_elements)) {
2792 2792
             return $form_elements;
2793 2793
         }
2794 2794
 
2795
-        return wpinv_get_data( 'sample-payment-form' );
2795
+        return wpinv_get_data('sample-payment-form');
2796 2796
     }
2797 2797
 
2798 2798
     /**
2799 2799
      * Sends a redrect response to payment details.
2800 2800
      *
2801 2801
      */
2802
-    public function send_redirect_response( $url ) {
2803
-        $url = urlencode( $url );
2804
-        wp_send_json_success( $url );
2802
+    public function send_redirect_response($url) {
2803
+        $url = urlencode($url);
2804
+        wp_send_json_success($url);
2805 2805
     }
2806 2806
 
2807 2807
     /**
@@ -2812,12 +2812,12 @@  discard block
 block discarded – undo
2812 2812
 
2813 2813
         $errors = wpinv_get_errors();
2814 2814
 
2815
-        if ( ! empty( $errors ) ) {
2815
+        if (!empty($errors)) {
2816 2816
             wpinv_print_errors();
2817 2817
             exit;
2818 2818
         }
2819 2819
 
2820
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
2820
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
2821 2821
         exit;
2822 2822
 
2823 2823
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  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_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat;
10 10
 
11 11
         $currency_symbol    = wpinv_currency_symbol();
12
-        $statuses           = wpinv_get_invoice_statuses( true );
12
+        $statuses           = wpinv_get_invoice_statuses(true);
13 13
 
14
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
15
-        $invoice            = new WPInv_Invoice( $post_id );
16
-        $status             = $invoice->get_status( false ); // Current status    
14
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
15
+        $invoice            = new WPInv_Invoice($post_id);
16
+        $status             = $invoice->get_status(false); // Current status    
17 17
         $discount           = $invoice->get_discount();
18 18
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
19 19
         $invoice_number     = $invoice->get_number();
20 20
         $taxable            = $invoice->is_taxable();
21 21
 
22 22
         $date_created       = $invoice->get_created_date();
23
-        $datetime_created   = strtotime( $date_created );
24
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
23
+        $datetime_created   = strtotime($date_created);
24
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
25 25
         $date_completed     = $invoice->get_completed_date();
26
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
27
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
28
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
29
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
26
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
27
+        $title['status'] = __('Invoice Status:', 'invoicing');
28
+        $title['number'] = __('Invoice Number:', 'invoicing');
29
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
30 30
 
31 31
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
32 32
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -37,39 +37,39 @@  discard block
 block discarded – undo
37 37
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
38 38
 
39 39
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-date-created table-layout">
40
-            <div class="gdmbx-th"><label for="wpinv_date_created"><?php _e( 'Date Created:', 'invoicing' );?></label></div>
40
+            <div class="gdmbx-th"><label for="wpinv_date_created"><?php _e('Date Created:', 'invoicing'); ?></label></div>
41 41
             <div class="gdmbx-td">
42
-                <input type="datetime-local" value="<?php echo esc_attr( date( 'Y-m-d\TH:i:s', $datetime_created ) );?>" id="wpinv_date_created" name="date_created" class="regular-text">
42
+                <input type="datetime-local" value="<?php echo esc_attr(date('Y-m-d\TH:i:s', $datetime_created)); ?>" id="wpinv_date_created" name="date_created" class="regular-text">
43 43
             </div>
44 44
         </div>
45 45
 
46
-        <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?>
46
+        <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?>
47 47
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
48
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
48
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
49 49
             <div class="gdmbx-td">
50
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
51
-                <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p>
50
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
51
+                <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p>
52 52
             </div>
53 53
         </div>
54 54
         <?php } ?>
55
-        <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?>
56
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
55
+        <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?>
56
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
57 57
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
58
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
59
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
58
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
59
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
60 60
         </div>
61 61
         <?php } ?>
62
-        <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?>
62
+        <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?>
63 63
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed">
64
-            <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div>
65
-            <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div>
64
+            <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div>
65
+            <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div>
66 66
         </div>
67 67
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
68 68
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
69 69
             <div class="gdmbx-td">
70 70
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select wpi_select2">
71
-                    <?php foreach ( $statuses as $value => $label ) { ?>
72
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
71
+                    <?php foreach ($statuses as $value => $label) { ?>
72
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
73 73
                     <?php } ?>
74 74
                 </select>
75 75
             </div>
@@ -78,129 +78,129 @@  discard block
 block discarded – undo
78 78
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
79 79
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
80 80
             <div class="gdmbx-td">
81
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
81
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
82 82
             </div>
83 83
         </div>
84
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id );
84
+        <?php do_action('wpinv_meta_box_details_inner', $post_id);
85 85
         $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id);
86 86
         ?>
87 87
 
88
-        <?php if ( $wpinv_euvat->allow_vat_rules() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
88
+        <?php if ($wpinv_euvat->allow_vat_rules() && !($invoice->is_paid() || $invoice->is_refunded())) { ?>
89 89
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-taxable">
90 90
             <div class="gdmbx-th">
91 91
                 <label for="wpinv_taxable">
92
-                    <input type="checkbox" name="disable_taxes" value="1" <?php checked( $taxable, false ); ?> id="wpinv_taxable">
93
-                    <?php _e( 'Disable taxes', 'invoicing' ); ?>
92
+                    <input type="checkbox" name="disable_taxes" value="1" <?php checked($taxable, false); ?> id="wpinv_taxable">
93
+                    <?php _e('Disable taxes', 'invoicing'); ?>
94 94
                 </label>
95 95
             </div>
96 96
         </div>
97 97
         <?php } ?>
98 98
 
99
-        <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?>
99
+        <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?>
100 100
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
101
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
101
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
102 102
             <div class="gdmbx-td">
103
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
103
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
104 104
             </div>
105 105
         </div>
106 106
         <?php } ?>
107 107
     </div>
108 108
 </div>
109 109
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
110
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
110
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
111 111
         <select id="wpi_save_send" name="wpi_save_send" class="wpi_select2">
112
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
113
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
112
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
113
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
114 114
         </select>
115 115
     </p>
116 116
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
117 117
 </div>
118
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
118
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
119 119
         <?php
120 120
     }
121 121
     
122
-    public static function resend_invoice( $post ) {
122
+    public static function resend_invoice($post) {
123 123
         global $wpi_mb_invoice;
124 124
         
125
-        if ( empty( $wpi_mb_invoice ) ) {
125
+        if (empty($wpi_mb_invoice)) {
126 126
             return;
127 127
         }
128 128
         
129 129
         $text = array(
130
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
131
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
130
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
131
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
132 132
         );
133 133
             
134 134
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
135
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
135
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
136 136
         
137
-        if ( $email = $wpi_mb_invoice->get_email() ) {
137
+        if ($email = $wpi_mb_invoice->get_email()) {
138 138
             $email_actions = array();
139
-            $email_actions['email_url']      = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) );
140
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
139
+            $email_actions['email_url']      = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)));
140
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
141 141
             
142
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
142
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
143 143
         ?>
144 144
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
145
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
146
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
147
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
145
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
146
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
147
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
148 148
         <?php } ?>
149 149
         <?php
150 150
         }
151 151
         
152
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
152
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
153 153
     }
154 154
     
155
-    public static function subscriptions( $post ) {
156
-        $invoice = wpinv_get_invoice( $post->ID );
155
+    public static function subscriptions($post) {
156
+        $invoice = wpinv_get_invoice($post->ID);
157 157
 
158
-        if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
159
-            $subscription = wpinv_get_subscription( $invoice );
158
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
159
+            $subscription = wpinv_get_subscription($invoice);
160 160
 
161
-            if ( empty( $subscription ) ) {
161
+            if (empty($subscription)) {
162 162
                 ?>
163
-                <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p>
163
+                <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p>
164 164
                 <?php
165 165
                 return;
166 166
             }
167
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
168
-            $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
169
-            $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
167
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
168
+            $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
169
+            $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
170 170
             $payments = $subscription->get_child_payments();
171 171
             ?>
172 172
             <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p>
173
-            <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?>
173
+            <?php if (!empty($subscription) && !empty($subscription->id)) { ?>
174 174
                 <p class="wpi-meta-row wpi-sub-id">
175
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
175
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
176 176
             <?php } ?>
177 177
             <p class="wpi-meta-row wpi-bill-cycle">
178
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?>
178
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?>
179 179
             </p>
180 180
             <p class="wpi-meta-row wpi-billed-times">
181
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
181
+                <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
182 182
             </p>
183 183
             <p class="wpi-meta-row wpi-start-date">
184
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
184
+                <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
185 185
             </p>
186 186
             <p class="wpi-meta-row wpi-end-date">
187
-                <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
187
+                <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
188 188
             </p>
189
-            <?php if ( $subscription->status ) { ?>
189
+            <?php if ($subscription->status) { ?>
190 190
                 <p class="wpi-meta-row wpi-sub-status">
191
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
191
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
192 192
                 </p>
193 193
             <?php } ?>
194
-            <?php if ( !empty( $payments ) ) { ?>
195
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
194
+            <?php if (!empty($payments)) { ?>
195
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
196 196
                 <ul id="wpi-sub-payments">
197
-                <?php foreach ( $payments as $payment ) {
197
+                <?php foreach ($payments as $payment) {
198 198
                     $invoice_id = $payment->ID;
199 199
                     ?>
200 200
                     <li>
201
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
202
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
203
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
201
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
202
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
203
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
204 204
                     </li>
205 205
                 <?php } ?>
206 206
                 </ul>
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
         }
209 209
     }
210 210
     
211
-    public static function renewals( $post ) {
212
-        $invoice = wpinv_get_invoice( $post->ID );
211
+    public static function renewals($post) {
212
+        $invoice = wpinv_get_invoice($post->ID);
213 213
         
214
-        if ( wpinv_is_subscription_payment( $invoice ) ) {
215
-            $parent_url = get_edit_post_link( $invoice->parent_invoice );
216
-            $parent_id  = wpinv_get_invoice_number( $invoice->parent_invoice );
217
-            $subscription = wpinv_get_subscription( $invoice );
214
+        if (wpinv_is_subscription_payment($invoice)) {
215
+            $parent_url = get_edit_post_link($invoice->parent_invoice);
216
+            $parent_id  = wpinv_get_invoice_number($invoice->parent_invoice);
217
+            $subscription = wpinv_get_subscription($invoice);
218 218
         ?>
219
-        <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
220
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
219
+        <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
220
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
221 221
         <?php
222 222
         }
223 223
     }
@@ -225,47 +225,47 @@  discard block
 block discarded – undo
225 225
     /**
226 226
      * Renders a metabox to edit a payment form.
227 227
      */
228
-    public static function payment_form( $post ) {
229
-        WPInv_Meta_Box_Form_Items::output_options( $post );
228
+    public static function payment_form($post) {
229
+        WPInv_Meta_Box_Form_Items::output_options($post);
230 230
     }
231 231
 
232 232
     /**
233 233
      * Renders a metabox to select items.
234 234
      */
235
-    public static function payment_form_items( $post ) {
236
-        WPInv_Meta_Box_Form_Items::output( $post );
235
+    public static function payment_form_items($post) {
236
+        WPInv_Meta_Box_Form_Items::output($post);
237 237
     }
238 238
     
239
-    public static function payment_meta( $post ) {
239
+    public static function payment_meta($post) {
240 240
         global $wpi_mb_invoice;
241 241
 
242
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
243
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) {
242
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
243
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) {
244 244
             $set_dateway = true;
245 245
         }
246 246
         
247 247
         ?>
248 248
         <p class="wpi-meta-row">
249
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
250
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
249
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
250
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
251 251
             <select required="required" id="wpinv_gateway" class="wpi_select2" name="wpinv_gateway">
252
-                <?php foreach ( $gateways as $name => $gateway ) {
253
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
252
+                <?php foreach ($gateways as $name => $gateway) {
253
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
254 254
                         continue;
255 255
                     }
256 256
                     ?>
257
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
257
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
258 258
                 <?php } ?>
259 259
             </select>
260 260
         <?php } else { 
261
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) );
261
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway));
262 262
         } ?>
263 263
         </p>
264
-        <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?>
265
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p>
264
+        <?php if ($key = $wpi_mb_invoice->get_key()) { ?>
265
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p>
266 266
         <?php } ?>
267
-        <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?>
268
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
267
+        <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?>
268
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
269 269
         <?php } ?>
270 270
         <?php
271 271
     }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -33,34 +33,34 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array(&$this, 'wpinv_actions'));
48 48
         
49
-        if ( class_exists( 'BuddyPress' ) ) {
50
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
49
+        if (class_exists('BuddyPress')) {
50
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
51 51
         }
52 52
 
53
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
55
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
53
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
54
+        add_action('widgets_init', array(&$this, 'register_widgets'));
55
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
56 56
 
57
-        if ( is_admin() ) {
58
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
59
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
60
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
57
+        if (is_admin()) {
58
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
59
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
60
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
61 61
 
62 62
         } else {
63
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
63
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
64 64
         }
65 65
         
66 66
         /**
@@ -70,28 +70,28 @@  discard block
 block discarded – undo
70 70
          *
71 71
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
72 72
          */
73
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
73
+        do_action_ref_array('wpinv_actions', array(&$this));
74 74
 
75
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
75
+        add_action('admin_init', array(&$this, 'activation_redirect'));
76 76
     }
77 77
 
78 78
     /**
79 79
      * Maybe show the AyeCode Connect Notice.
80 80
      */
81
-    public function init_ayecode_connect_helper(){
81
+    public function init_ayecode_connect_helper() {
82 82
         // AyeCode Connect notice
83
-        if ( is_admin() ){
83
+        if (is_admin()) {
84 84
             // set the strings so they can be translated
85 85
             $strings = array(
86
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
87
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
88
-                '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>" ),
89
-                'connect_button'    => __("Connect Site","invoicing"),
90
-                'connecting_button'    => __("Connecting...","invoicing"),
91
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
92
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
86
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
87
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
88
+                '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>"),
89
+                'connect_button'    => __("Connect Site", "invoicing"),
90
+                'connecting_button'    => __("Connecting...", "invoicing"),
91
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
92
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
93 93
             );
94
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
94
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
95 95
         }
96 96
     }
97 97
     
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
         /* Internationalize the text strings used. */
100 100
         $this->load_textdomain();
101 101
 
102
-        do_action( 'wpinv_loaded' );
102
+        do_action('wpinv_loaded');
103 103
 
104 104
         // Fix oxygen page builder conflict
105
-        if ( function_exists( 'ct_css_output' ) ) {
105
+        if (function_exists('ct_css_output')) {
106 106
             wpinv_oxygen_fix_conflict();
107 107
         }
108 108
     }
@@ -112,237 +112,237 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @since 1.0
114 114
      */
115
-    public function load_textdomain( $locale = NULL ) {
116
-        if ( empty( $locale ) ) {
117
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
115
+    public function load_textdomain($locale = NULL) {
116
+        if (empty($locale)) {
117
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
118 118
         }
119 119
 
120
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
120
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
121 121
         
122
-        unload_textdomain( 'invoicing' );
123
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
124
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
122
+        unload_textdomain('invoicing');
123
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
124
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
125 125
         
126 126
         /**
127 127
          * Define language constants.
128 128
          */
129
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
129
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
130 130
     }
131 131
         
132 132
     public function includes() {
133 133
         global $wpinv_options;
134 134
         
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
136 136
         $wpinv_options = wpinv_get_settings();
137 137
         
138
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
145
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
148
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
173
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
174
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
178
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
179
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'widgets/payment-form.php' );
181
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
182
-
183
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
184
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
138
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
145
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
148
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
173
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
174
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
175
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
176
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
177
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
178
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
179
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'widgets/payment-form.php');
181
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
182
+
183
+        if (!class_exists('WPInv_EUVat')) {
184
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
185 185
         }
186 186
         
187
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
188
-        if ( !empty( $gateways ) ) {
189
-            foreach ( $gateways as $gateway ) {
190
-                if ( $gateway == 'manual' ) {
187
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
188
+        if (!empty($gateways)) {
189
+            foreach ($gateways as $gateway) {
190
+                if ($gateway == 'manual') {
191 191
                     continue;
192 192
                 }
193 193
                 
194 194
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
195 195
                 
196
-                if ( file_exists( $gateway_file ) ) {
197
-                    require_once( $gateway_file );
196
+                if (file_exists($gateway_file)) {
197
+                    require_once($gateway_file);
198 198
                 }
199 199
             }
200 200
         }
201
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
201
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
202 202
         
203
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
204
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
205
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
206
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
203
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
204
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
205
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
206
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
207 207
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
208
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
212
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
213
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
214
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
215
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
208
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
212
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
213
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
214
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
215
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
216 216
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
217 217
             // load the user class only on the users.php page
218 218
             global $pagenow;
219
-            if($pagenow=='users.php'){
219
+            if ($pagenow == 'users.php') {
220 220
                 new WPInv_Admin_Users();
221 221
             }
222 222
         }
223 223
 
224 224
         // Register cli commands
225
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
226
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
227
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
225
+        if (defined('WP_CLI') && WP_CLI) {
226
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
227
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
228 228
         }
229 229
         
230 230
         // include css inliner
231
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
232
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
231
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
232
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
233 233
         }
234 234
         
235
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
235
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
236 236
     }
237 237
     
238 238
     public function init() {
239 239
     }
240 240
     
241 241
     public function admin_init() {
242
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
242
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
243 243
     }
244 244
 
245 245
     public function activation_redirect() {
246 246
         // Bail if no activation redirect
247
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
247
+        if (!get_transient('_wpinv_activation_redirect')) {
248 248
             return;
249 249
         }
250 250
 
251 251
         // Delete the redirect transient
252
-        delete_transient( '_wpinv_activation_redirect' );
252
+        delete_transient('_wpinv_activation_redirect');
253 253
 
254 254
         // Bail if activating from network, or bulk
255
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
255
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
256 256
             return;
257 257
         }
258 258
 
259
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
259
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
260 260
         exit;
261 261
     }
262 262
     
263 263
     public function enqueue_scripts() {
264
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
264
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
265 265
         
266
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
267
-        wp_enqueue_style( 'wpinv_front_style' );
266
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
267
+        wp_enqueue_style('wpinv_front_style');
268 268
                
269 269
         // Register scripts
270
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
271
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
270
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
271
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
272 272
 
273 273
         $localize                         = array();
274
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
275
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
274
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
275
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
276 276
         $localize['currency_symbol']      = wpinv_currency_symbol();
277 277
         $localize['currency_pos']         = wpinv_currency_position();
278 278
         $localize['thousand_sep']         = wpinv_thousands_separator();
279 279
         $localize['decimal_sep']          = wpinv_decimal_separator();
280 280
         $localize['decimals']             = wpinv_decimals();
281
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
281
+        $localize['txtComplete']          = __('Continue', 'invoicing');
282 282
         $localize['UseTaxes']             = wpinv_use_taxes();
283
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
283
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
284 284
 
285
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
285
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
286 286
         
287
-        wp_enqueue_script( 'jquery-blockui' );
287
+        wp_enqueue_script('jquery-blockui');
288 288
         $autofill_api = wpinv_get_option('address_autofill_api');
289 289
         $autofill_active = wpinv_get_option('address_autofill_active');
290
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
291
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
292
-                wp_dequeue_script( 'google-maps-api' );
290
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
291
+            if (wp_script_is('google-maps-api', 'enqueued')) {
292
+                wp_dequeue_script('google-maps-api');
293 293
             }
294
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
295
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
294
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
295
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
296 296
         }
297 297
 
298
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
299
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
298
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
299
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
300 300
 
301
-        wp_enqueue_script( 'wpinv-front-script' );
302
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
301
+        wp_enqueue_script('wpinv-front-script');
302
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
303 303
 
304
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
305
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
304
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
305
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
306 306
     }
307 307
 
308
-    public function admin_enqueue_scripts( $hook ) {
308
+    public function admin_enqueue_scripts($hook) {
309 309
         global $post, $pagenow;
310 310
         
311 311
         $post_type  = wpinv_admin_post_type();
312
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
313
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
312
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
313
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
314 314
 
315 315
         $jquery_ui_css = false;
316
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
316
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
317 317
             $jquery_ui_css = true;
318
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
318
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
319 319
             $jquery_ui_css = true;
320 320
         }
321
-        if ( $jquery_ui_css ) {
322
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
323
-            wp_enqueue_style( 'jquery-ui-css' );
321
+        if ($jquery_ui_css) {
322
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
323
+            wp_enqueue_style('jquery-ui-css');
324 324
         }
325 325
 
326
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
327
-        wp_enqueue_style( 'wpinv_meta_box_style' );
326
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
327
+        wp_enqueue_style('wpinv_meta_box_style');
328 328
         
329
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
330
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
331
-        wp_enqueue_style( 'wpinv_admin_style' );
329
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
330
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
331
+        wp_enqueue_style('wpinv_admin_style');
332 332
 
333
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
334
-        if ( $page == 'wpinv-subscriptions' ) {
335
-            wp_enqueue_script( 'jquery-ui-datepicker' );
333
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
334
+        if ($page == 'wpinv-subscriptions') {
335
+            wp_enqueue_script('jquery-ui-datepicker');
336 336
         }
337 337
         
338
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
339
-            wp_enqueue_script( 'jquery-ui-datepicker' );
338
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
339
+            wp_enqueue_script('jquery-ui-datepicker');
340 340
         }
341 341
 
342
-        wp_enqueue_style( 'wp-color-picker' );
343
-        wp_enqueue_script( 'wp-color-picker' );
342
+        wp_enqueue_style('wp-color-picker');
343
+        wp_enqueue_script('wp-color-picker');
344 344
         
345
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
345
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
346 346
 
347 347
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
348 348
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -353,21 +353,21 @@  discard block
 block discarded – undo
353 353
             }
354 354
         }
355 355
 
356
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
357
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
356
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
357
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
358 358
 
359
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
360
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
361
-        wp_enqueue_script( 'wpinv-admin-script' );
359
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
360
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
361
+        wp_enqueue_script('wpinv-admin-script');
362 362
         
363 363
         $localize                               = array();
364
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
365
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
366
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
367
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
368
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
369
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
370
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
364
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
365
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
366
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
367
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
368
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
369
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
370
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
371 371
         $localize['tax']                        = wpinv_tax_amount();
372 372
         $localize['discount']                   = wpinv_discount_amount();
373 373
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -375,95 +375,95 @@  discard block
 block discarded – undo
375 375
         $localize['thousand_sep']               = wpinv_thousands_separator();
376 376
         $localize['decimal_sep']                = wpinv_decimal_separator();
377 377
         $localize['decimals']                   = wpinv_decimals();
378
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
379
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
380
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
381
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
382
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
383
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
384
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
385
-        $localize['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' );
386
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
387
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
388
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
389
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
390
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
391
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
392
-
393
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
394
-
395
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
378
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
379
+        $localize['status_publish']             = wpinv_status_nicename('publish');
380
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
381
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
382
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
383
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
384
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
385
+        $localize['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');
386
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
387
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
388
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
389
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
390
+        $localize['action_edit']                = __('Edit', 'invoicing');
391
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
392
+
393
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
394
+
395
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
396 396
 
397 397
         // Load payment form scripts on our admin pages only.
398
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
398
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
399 399
 
400
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
401
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
402
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
400
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
401
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
402
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
403 403
 
404
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
405
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
404
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
405
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
406 406
         
407
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
407
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
408 408
                 'elements'      => $this->form_elements->get_elements(),
409
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
409
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
410 410
                 'all_items'     => $this->form_elements->get_published_items(),
411 411
                 'currency'      => wpinv_currency_symbol(),
412 412
                 'position'      => wpinv_currency_position(),
413 413
                 'decimals'      => (int) wpinv_decimals(),
414 414
                 'thousands_sep' => wpinv_thousands_separator(),
415 415
                 'decimals_sep'  => wpinv_decimal_separator(),
416
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
417
-            ) );
416
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
417
+            ));
418 418
 
419
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
419
+            wp_enqueue_script('wpinv-admin-payment-form-script');
420 420
         }
421 421
 
422
-        if ( $page == 'wpinv-subscriptions' ) {
423
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
424
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
422
+        if ($page == 'wpinv-subscriptions') {
423
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
424
+            wp_enqueue_script('wpinv-sub-admin-script');
425 425
         }
426 426
 
427 427
     }
428 428
 
429
-    public function admin_body_class( $classes ) {
429
+    public function admin_body_class($classes) {
430 430
         global $pagenow, $post, $current_screen;
431 431
         
432
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
432
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
433 433
             $classes .= ' wpinv-cpt';
434 434
         }
435 435
         
436
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
436
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
437 437
 
438
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
439
-        if ( $add_class ) {
440
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
438
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
439
+        if ($add_class) {
440
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
441 441
         }
442 442
         
443 443
         $settings_class = array();
444
-        if ( $page == 'wpinv-settings' ) {
445
-            if ( !empty( $_REQUEST['tab'] ) ) {
446
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
444
+        if ($page == 'wpinv-settings') {
445
+            if (!empty($_REQUEST['tab'])) {
446
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
447 447
             }
448 448
             
449
-            if ( !empty( $_REQUEST['section'] ) ) {
450
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
449
+            if (!empty($_REQUEST['section'])) {
450
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
451 451
             }
452 452
             
453
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
453
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
454 454
         }
455 455
         
456
-        if ( !empty( $settings_class ) ) {
457
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
456
+        if (!empty($settings_class)) {
457
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
458 458
         }
459 459
         
460 460
         $post_type = wpinv_admin_post_type();
461 461
 
462
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
462
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
463 463
             return $classes .= ' wpinv';
464 464
         }
465 465
         
466
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
466
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
467 467
             $classes .= ' wpi-editable-n';
468 468
         }
469 469
 
@@ -475,21 +475,21 @@  discard block
 block discarded – undo
475 475
     }
476 476
     
477 477
     public function wpinv_actions() {
478
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
479
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
478
+        if (isset($_REQUEST['wpi_action'])) {
479
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
480 480
         }
481 481
     }
482 482
     
483
-    public function pre_get_posts( $wp_query ) {
484
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
485
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
483
+    public function pre_get_posts($wp_query) {
484
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
485
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
486 486
         }
487 487
         
488 488
         return $wp_query;
489 489
     }
490 490
     
491 491
     public function bp_invoicing_init() {
492
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
492
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
493 493
     }
494 494
 
495 495
 	/**
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 */
499 499
 	public function register_widgets() {
500
-		register_widget( "WPInv_Checkout_Widget" );
501
-		register_widget( "WPInv_History_Widget" );
502
-		register_widget( "WPInv_Receipt_Widget" );
503
-		register_widget( "WPInv_Subscriptions_Widget" );
504
-		register_widget( "WPInv_Buy_Item_Widget" );
505
-        register_widget( "WPInv_Messages_Widget" );
506
-        register_widget( 'WPInv_Payment_Form_Widget' );
500
+		register_widget("WPInv_Checkout_Widget");
501
+		register_widget("WPInv_History_Widget");
502
+		register_widget("WPInv_Receipt_Widget");
503
+		register_widget("WPInv_Subscriptions_Widget");
504
+		register_widget("WPInv_Buy_Item_Widget");
505
+        register_widget("WPInv_Messages_Widget");
506
+        register_widget('WPInv_Payment_Form_Widget');
507 507
 	}
508 508
     
509 509
     /**
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
      * @since 1.0.19
513 513
      * @param int[] $excluded_posts_ids
514 514
      */
515
-    function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
515
+    function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
516 516
 
517 517
         // Ensure that we have an array.
518
-        if ( ! is_array( $excluded_posts_ids ) ) {
518
+        if (!is_array($excluded_posts_ids)) {
519 519
             $excluded_posts_ids = array();
520 520
         }
521 521
 
@@ -523,24 +523,24 @@  discard block
 block discarded – undo
523 523
         $our_pages = array();
524 524
     
525 525
         // Checkout page.
526
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
526
+        $our_pages[] = wpinv_get_option('checkout_page', false);
527 527
 
528 528
         // Success page.
529
-        $our_pages[] = wpinv_get_option( 'success_page', false );
529
+        $our_pages[] = wpinv_get_option('success_page', false);
530 530
 
531 531
         // Failure page.
532
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
532
+        $our_pages[] = wpinv_get_option('failure_page', false);
533 533
 
534 534
         // History page.
535
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
535
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
536 536
 
537 537
         // Subscriptions page.
538
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
538
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
539 539
 
540
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
540
+        $our_pages   = array_map('intval', array_filter($our_pages));
541 541
 
542 542
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
543
-        return array_unique( $excluded_posts_ids );
543
+        return array_unique($excluded_posts_ids);
544 544
 
545 545
     }
546 546
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +625 added lines, -625 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 final class WPInv_Invoice {
15
-    public $ID  = 0;
15
+    public $ID = 0;
16 16
     public $title;
17 17
     public $post_type;
18 18
     
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
     public $full_name = '';
67 67
     public $parent_invoice = 0;
68 68
     
69
-    public function __construct( $invoice_id = false ) {
70
-        if( empty( $invoice_id ) ) {
69
+    public function __construct($invoice_id = false) {
70
+        if (empty($invoice_id)) {
71 71
             return false;
72 72
         }
73 73
 
74
-        $this->setup_invoice( $invoice_id );
74
+        $this->setup_invoice($invoice_id);
75 75
     }
76 76
 
77
-    public function get( $key ) {
78
-        if ( method_exists( $this, 'get_' . $key ) ) {
79
-            $value = call_user_func( array( $this, 'get_' . $key ) );
77
+    public function get($key) {
78
+        if (method_exists($this, 'get_' . $key)) {
79
+            $value = call_user_func(array($this, 'get_' . $key));
80 80
         } else {
81 81
             $value = $this->$key;
82 82
         }
@@ -84,51 +84,51 @@  discard block
 block discarded – undo
84 84
         return $value;
85 85
     }
86 86
 
87
-    public function set( $key, $value ) {
88
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
87
+    public function set($key, $value) {
88
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
89 89
 
90
-        if ( $key === 'status' ) {
90
+        if ($key === 'status') {
91 91
             $this->old_status = $this->status;
92 92
         }
93 93
 
94
-        if ( ! in_array( $key, $ignore ) ) {
95
-            $this->pending[ $key ] = $value;
94
+        if (!in_array($key, $ignore)) {
95
+            $this->pending[$key] = $value;
96 96
         }
97 97
 
98
-        if( '_ID' !== $key ) {
98
+        if ('_ID' !== $key) {
99 99
             $this->$key = $value;
100 100
         }
101 101
     }
102 102
 
103
-    public function _isset( $name ) {
104
-        if ( property_exists( $this, $name) ) {
105
-            return false === empty( $this->$name );
103
+    public function _isset($name) {
104
+        if (property_exists($this, $name)) {
105
+            return false === empty($this->$name);
106 106
         } else {
107 107
             return null;
108 108
         }
109 109
     }
110 110
 
111
-    private function setup_invoice( $invoice_id ) {
111
+    private function setup_invoice($invoice_id) {
112 112
         $this->pending = array();
113 113
 
114
-        if ( empty( $invoice_id ) ) {
114
+        if (empty($invoice_id)) {
115 115
             return false;
116 116
         }
117 117
 
118
-        $invoice = get_post( $invoice_id );
118
+        $invoice = get_post($invoice_id);
119 119
 
120
-        if( !$invoice || is_wp_error( $invoice ) ) {
120
+        if (!$invoice || is_wp_error($invoice)) {
121 121
             return false;
122 122
         }
123 123
 
124
-        if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) {
124
+        if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) {
125 125
             return false;
126 126
         }
127 127
 
128
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
128
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
129 129
         
130 130
         // Primary Identifier
131
-        $this->ID              = absint( $invoice_id );
131
+        $this->ID              = absint($invoice_id);
132 132
         $this->post_type       = $invoice->post_type;
133 133
         
134 134
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
         $this->completed_date  = $this->setup_completed_date();
139 139
         $this->status          = $invoice->post_status;
140 140
 
141
-        if ( 'future' == $this->status ) {
141
+        if ('future' == $this->status) {
142 142
             $this->status = 'publish';
143 143
         }
144 144
 
145 145
         $this->post_status     = $this->status;
146 146
         $this->mode            = $this->setup_mode();
147 147
         $this->parent_invoice  = $invoice->post_parent;
148
-        $this->post_name       = $this->setup_post_name( $invoice );
148
+        $this->post_name       = $this->setup_post_name($invoice);
149 149
         $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
150 150
 
151 151
         // Items
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
         
169 169
         // User based
170 170
         $this->ip              = $this->setup_ip();
171
-        $this->user_id         = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
172
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
171
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
172
+        $this->email           = get_the_author_meta('email', $this->user_id);
173 173
         
174 174
         $this->user_info       = $this->setup_user_info();
175 175
                 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $this->company         = $this->user_info['company'];
179 179
         $this->vat_number      = $this->user_info['vat_number'];
180 180
         $this->vat_rate        = $this->user_info['vat_rate'];
181
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
181
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
182 182
         $this->address         = $this->user_info['address'];
183 183
         $this->city            = $this->user_info['city'];
184 184
         $this->country         = $this->user_info['country'];
@@ -193,39 +193,39 @@  discard block
 block discarded – undo
193 193
         // Other Identifiers
194 194
         $this->key             = $this->setup_invoice_key();
195 195
         $this->number          = $this->setup_invoice_number();
196
-        $this->title           = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
196
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
197 197
         
198
-        $this->full_name       = trim( $this->first_name . ' '. $this->last_name );
198
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
199 199
         
200 200
         // Allow extensions to add items to this object via hook
201
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
201
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
202 202
 
203 203
         return true;
204 204
     }
205 205
 
206
-    private function setup_status_nicename( $status ) {
207
-        $all_invoice_statuses  = wpinv_get_invoice_statuses( true, true, $this );
206
+    private function setup_status_nicename($status) {
207
+        $all_invoice_statuses = wpinv_get_invoice_statuses(true, true, $this);
208 208
 
209
-        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
210
-            $all_invoice_statuses  = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
209
+        if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
210
+            $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
211 211
         }
212
-        $status   = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' );
212
+        $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing');
213 213
 
214
-        return apply_filters( 'setup_status_nicename', $status );
214
+        return apply_filters('setup_status_nicename', $status);
215 215
     }
216 216
 
217
-    private function setup_post_name( $post = NULL ) {
217
+    private function setup_post_name($post = NULL) {
218 218
         global $wpdb;
219 219
         
220 220
         $post_name = '';
221 221
         
222
-        if ( !empty( $post ) ) {
223
-            if( !empty( $post->post_name ) ) {
222
+        if (!empty($post)) {
223
+            if (!empty($post->post_name)) {
224 224
                 $post_name = $post->post_name;
225
-            } else if ( !empty( $post->ID ) ) {
226
-                $post_name = wpinv_generate_post_name( $post->ID );
225
+            } else if (!empty($post->ID)) {
226
+                $post_name = wpinv_generate_post_name($post->ID);
227 227
 
228
-                $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
228
+                $wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
229 229
             }
230 230
         }
231 231
 
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
     }
234 234
     
235 235
     private function setup_due_date() {
236
-        $due_date = $this->get_meta( '_wpinv_due_date' );
236
+        $due_date = $this->get_meta('_wpinv_due_date');
237 237
         
238
-        if ( empty( $due_date ) ) {
239
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) );
240
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
241
-        } else if ( $due_date == 'none' ) {
238
+        if (empty($due_date)) {
239
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days')));
240
+            $due_date = date_i18n('Y-m-d', $overdue_time);
241
+        } else if ($due_date == 'none') {
242 242
             $due_date = '';
243 243
         }
244 244
         
@@ -246,67 +246,67 @@  discard block
 block discarded – undo
246 246
     }
247 247
     
248 248
     private function setup_completed_date() {
249
-        $invoice = get_post( $this->ID );
249
+        $invoice = get_post($this->ID);
250 250
 
251
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
251
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
252 252
             return false; // This invoice was never paid
253 253
         }
254 254
 
255
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
255
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
256 256
 
257 257
         return $date;
258 258
     }
259 259
     
260 260
     private function setup_cart_details() {
261
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
261
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
262 262
         return $cart_details;
263 263
     }
264 264
     
265 265
     public function array_convert() {
266
-        return get_object_vars( $this );
266
+        return get_object_vars($this);
267 267
     }
268 268
     
269 269
     private function setup_items() {
270
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
270
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
271 271
         return $items;
272 272
     }
273 273
     
274 274
     private function setup_fees() {
275
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
275
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
276 276
         return $payment_fees;
277 277
     }
278 278
         
279 279
     private function setup_currency() {
280
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
280
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
281 281
         return $currency;
282 282
     }
283 283
     
284 284
     private function setup_discount() {
285 285
         //$discount = $this->get_meta( '_wpinv_discount', true );
286
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
287
-        if ( $discount < 0 ) {
286
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
287
+        if ($discount < 0) {
288 288
             $discount = 0;
289 289
         }
290
-        $discount = wpinv_round_amount( $discount );
290
+        $discount = wpinv_round_amount($discount);
291 291
         
292 292
         return $discount;
293 293
     }
294 294
     
295 295
     private function setup_discount_code() {
296
-        $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
296
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
297 297
         return $discount_code;
298 298
     }
299 299
     
300 300
     private function setup_tax() {
301 301
 
302
-        $tax = $this->get_meta( '_wpinv_tax', true );
302
+        $tax = $this->get_meta('_wpinv_tax', true);
303 303
 
304 304
         // We don't have tax as it's own meta and no meta was passed
305
-        if ( '' === $tax ) {            
306
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
305
+        if ('' === $tax) {            
306
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
307 307
         }
308 308
         
309
-        if ( $tax < 0 || ! $this->is_taxable() ) {
309
+        if ($tax < 0 || !$this->is_taxable()) {
310 310
             $tax = 0;
311 311
         }
312 312
 
@@ -317,16 +317,16 @@  discard block
 block discarded – undo
317 317
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
318 318
      */
319 319
     private function setup_is_taxable() {
320
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
320
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
321 321
     }
322 322
 
323 323
     private function setup_subtotal() {
324 324
         $subtotal     = 0;
325 325
         $cart_details = $this->cart_details;
326 326
 
327
-        if ( is_array( $cart_details ) ) {
328
-            foreach ( $cart_details as $item ) {
329
-                if ( isset( $item['subtotal'] ) ) {
327
+        if (is_array($cart_details)) {
328
+            foreach ($cart_details as $item) {
329
+                if (isset($item['subtotal'])) {
330 330
                     $subtotal += $item['subtotal'];
331 331
                 }
332 332
             }
@@ -340,23 +340,23 @@  discard block
 block discarded – undo
340 340
     }
341 341
 
342 342
     private function setup_discounts() {
343
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
343
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
344 344
         return $discounts;
345 345
     }
346 346
     
347 347
     private function setup_total() {
348
-        $amount = $this->get_meta( '_wpinv_total', true );
348
+        $amount = $this->get_meta('_wpinv_total', true);
349 349
 
350
-        if ( empty( $amount ) && '0.00' != $amount ) {
351
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
352
-            $meta   = maybe_unserialize( $meta );
350
+        if (empty($amount) && '0.00' != $amount) {
351
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
352
+            $meta   = maybe_unserialize($meta);
353 353
 
354
-            if ( isset( $meta['amount'] ) ) {
354
+            if (isset($meta['amount'])) {
355 355
                 $amount = $meta['amount'];
356 356
             }
357 357
         }
358 358
 
359
-        if($amount < 0){
359
+        if ($amount < 0) {
360 360
             $amount = 0;
361 361
         }
362 362
 
@@ -364,13 +364,13 @@  discard block
 block discarded – undo
364 364
     }
365 365
     
366 366
     private function setup_mode() {
367
-        return $this->get_meta( '_wpinv_mode' );
367
+        return $this->get_meta('_wpinv_mode');
368 368
     }
369 369
 
370 370
     private function setup_gateway() {
371
-        $gateway = $this->get_meta( '_wpinv_gateway' );
371
+        $gateway = $this->get_meta('_wpinv_gateway');
372 372
         
373
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
373
+        if (empty($gateway) && 'publish' === $this->status) {
374 374
             $gateway = 'manual';
375 375
         }
376 376
         
@@ -378,23 +378,23 @@  discard block
 block discarded – undo
378 378
     }
379 379
 
380 380
     private function setup_gateway_title() {
381
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
381
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
382 382
         return $gateway_title;
383 383
     }
384 384
 
385 385
     private function setup_transaction_id() {
386
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
386
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
387 387
 
388
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
388
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
389 389
             $gateway        = $this->gateway;
390
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
390
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
391 391
         }
392 392
 
393 393
         return $transaction_id;
394 394
     }
395 395
 
396 396
     private function setup_ip() {
397
-        $ip = $this->get_meta( '_wpinv_user_ip' );
397
+        $ip = $this->get_meta('_wpinv_user_ip');
398 398
         return $ip;
399 399
     }
400 400
 
@@ -404,62 +404,62 @@  discard block
 block discarded – undo
404 404
     ///}
405 405
         
406 406
     private function setup_first_name() {
407
-        $first_name = $this->get_meta( '_wpinv_first_name' );
407
+        $first_name = $this->get_meta('_wpinv_first_name');
408 408
         return $first_name;
409 409
     }
410 410
     
411 411
     private function setup_last_name() {
412
-        $last_name = $this->get_meta( '_wpinv_last_name' );
412
+        $last_name = $this->get_meta('_wpinv_last_name');
413 413
         return $last_name;
414 414
     }
415 415
     
416 416
     private function setup_company() {
417
-        $company = $this->get_meta( '_wpinv_company' );
417
+        $company = $this->get_meta('_wpinv_company');
418 418
         return $company;
419 419
     }
420 420
     
421 421
     private function setup_vat_number() {
422
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
422
+        $vat_number = $this->get_meta('_wpinv_vat_number');
423 423
         return $vat_number;
424 424
     }
425 425
     
426 426
     private function setup_vat_rate() {
427
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
427
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
428 428
         return $vat_rate;
429 429
     }
430 430
     
431 431
     private function setup_adddress_confirmed() {
432
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
432
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
433 433
         return $adddress_confirmed;
434 434
     }
435 435
     
436 436
     private function setup_phone() {
437
-        $phone = $this->get_meta( '_wpinv_phone' );
437
+        $phone = $this->get_meta('_wpinv_phone');
438 438
         return $phone;
439 439
     }
440 440
     
441 441
     private function setup_address() {
442
-        $address = $this->get_meta( '_wpinv_address', true );
442
+        $address = $this->get_meta('_wpinv_address', true);
443 443
         return $address;
444 444
     }
445 445
     
446 446
     private function setup_city() {
447
-        $city = $this->get_meta( '_wpinv_city', true );
447
+        $city = $this->get_meta('_wpinv_city', true);
448 448
         return $city;
449 449
     }
450 450
     
451 451
     private function setup_country() {
452
-        $country = $this->get_meta( '_wpinv_country', true );
452
+        $country = $this->get_meta('_wpinv_country', true);
453 453
         return $country;
454 454
     }
455 455
     
456 456
     private function setup_state() {
457
-        $state = $this->get_meta( '_wpinv_state', true );
457
+        $state = $this->get_meta('_wpinv_state', true);
458 458
         return $state;
459 459
     }
460 460
     
461 461
     private function setup_zip() {
462
-        $zip = $this->get_meta( '_wpinv_zip', true );
462
+        $zip = $this->get_meta('_wpinv_zip', true);
463 463
         return $zip;
464 464
     }
465 465
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             'user_id'        => $this->user_id,
469 469
             'first_name'     => $this->first_name,
470 470
             'last_name'      => $this->last_name,
471
-            'email'          => get_the_author_meta( 'email', $this->user_id ),
471
+            'email'          => get_the_author_meta('email', $this->user_id),
472 472
             'phone'          => $this->phone,
473 473
             'address'        => $this->address,
474 474
             'city'           => $this->city,
@@ -483,12 +483,12 @@  discard block
 block discarded – undo
483 483
         );
484 484
         
485 485
         $user_info = array();
486
-        if ( isset( $this->payment_meta['user_info'] ) ) {
487
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
486
+        if (isset($this->payment_meta['user_info'])) {
487
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
488 488
             
489
-            if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
489
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
490 490
                 $this->user_id = $post->post_author;
491
-                $this->email = get_the_author_meta( 'email', $this->user_id );
491
+                $this->email = get_the_author_meta('email', $this->user_id);
492 492
                 
493 493
                 $user_info['user_id'] = $this->user_id;
494 494
                 $user_info['email'] = $this->email;
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
             }
498 498
         }
499 499
         
500
-        $user_info    = wp_parse_args( $user_info, $defaults );
500
+        $user_info = wp_parse_args($user_info, $defaults);
501 501
         
502 502
         // Get the user, but only if it's been created
503
-        $user = get_userdata( $this->user_id );
503
+        $user = get_userdata($this->user_id);
504 504
         
505
-        if ( !empty( $user ) && $user->ID > 0 ) {
506
-            if ( empty( $user_info ) ) {
505
+        if (!empty($user) && $user->ID > 0) {
506
+            if (empty($user_info)) {
507 507
                 $user_info = array(
508 508
                     'user_id'    => $user->ID,
509 509
                     'first_name' => $user->first_name,
@@ -512,23 +512,23 @@  discard block
 block discarded – undo
512 512
                     'discount'   => '',
513 513
                 );
514 514
             } else {
515
-                foreach ( $user_info as $key => $value ) {
516
-                    if ( ! empty( $value ) ) {
515
+                foreach ($user_info as $key => $value) {
516
+                    if (!empty($value)) {
517 517
                         continue;
518 518
                     }
519 519
 
520
-                    switch( $key ) {
520
+                    switch ($key) {
521 521
                         case 'user_id':
522
-                            $user_info[ $key ] = $user->ID;
522
+                            $user_info[$key] = $user->ID;
523 523
                             break;
524 524
                         case 'first_name':
525
-                            $user_info[ $key ] = $user->first_name;
525
+                            $user_info[$key] = $user->first_name;
526 526
                             break;
527 527
                         case 'last_name':
528
-                            $user_info[ $key ] = $user->last_name;
528
+                            $user_info[$key] = $user->last_name;
529 529
                             break;
530 530
                         case 'email':
531
-                            $user_info[ $key ] = $user->user_email;
531
+                            $user_info[$key] = $user->user_email;
532 532
                             break;
533 533
                     }
534 534
                 }
@@ -539,25 +539,25 @@  discard block
 block discarded – undo
539 539
     }
540 540
 
541 541
     private function setup_invoice_key() {
542
-        $key = $this->get_meta( '_wpinv_key', true );
542
+        $key = $this->get_meta('_wpinv_key', true);
543 543
         
544 544
         return $key;
545 545
     }
546 546
 
547 547
     private function setup_invoice_number() {
548
-        $number = $this->get_meta( '_wpinv_number', true );
548
+        $number = $this->get_meta('_wpinv_number', true);
549 549
 
550
-        if ( !$number ) {
550
+        if (!$number) {
551 551
             $number = $this->ID;
552 552
 
553
-            if ( $this->status == 'auto-draft' ) {
554
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
555
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
553
+            if ($this->status == 'auto-draft') {
554
+                if (wpinv_sequential_number_active($this->post_type)) {
555
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
556 556
                     $number      = $next_number;
557 557
                 }
558 558
             }
559 559
             
560
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
560
+            $number = wpinv_format_invoice_number($number, $this->post_type);
561 561
         }
562 562
 
563 563
         return $number;
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
     private function insert_invoice() {
567 567
         global $wpdb;
568 568
 
569
-        if ( empty( $this->post_type ) ) {
570
-            if ( !empty( $this->ID ) && $post_type = get_post_type( $this->ID ) ) {
569
+        if (empty($this->post_type)) {
570
+            if (!empty($this->ID) && $post_type = get_post_type($this->ID)) {
571 571
                 $this->post_type = $post_type;
572
-            } else if ( !empty( $this->parent_invoice ) && $post_type = get_post_type( $this->parent_invoice ) ) {
572
+            } else if (!empty($this->parent_invoice) && $post_type = get_post_type($this->parent_invoice)) {
573 573
                 $this->post_type = $post_type;
574 574
             } else {
575 575
                 $this->post_type = 'wpi_invoice';
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
         }
578 578
 
579 579
         $invoice_number = $this->ID;
580
-        if ( $number = $this->get_meta( '_wpinv_number', true ) ) {
580
+        if ($number = $this->get_meta('_wpinv_number', true)) {
581 581
             $invoice_number = $number;
582 582
         }
583 583
 
584
-        if ( empty( $this->key ) ) {
584
+        if (empty($this->key)) {
585 585
             $this->key = self::generate_key();
586 586
             $this->pending['key'] = $this->key;
587 587
         }
588 588
 
589
-        if ( empty( $this->ip ) ) {
589
+        if (empty($this->ip)) {
590 590
             $this->ip = wpinv_get_ip();
591 591
             $this->pending['ip'] = $this->ip;
592 592
         }
@@ -623,61 +623,61 @@  discard block
 block discarded – undo
623 623
                         'post_status'   => $this->status,
624 624
                         'post_author'   => $this->user_id,
625 625
                         'post_type'     => $this->post_type,
626
-                        'post_date'     => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time( 'mysql' ),
627
-                        'post_date_gmt' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date( $this->date ) : current_time( 'mysql', 1 ),
626
+                        'post_date'     => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time('mysql'),
627
+                        'post_date_gmt' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date($this->date) : current_time('mysql', 1),
628 628
                         'post_parent'   => $this->parent_invoice,
629 629
                     );
630
-        $args = apply_filters( 'wpinv_insert_invoice_args', $post_data, $this );
630
+        $args = apply_filters('wpinv_insert_invoice_args', $post_data, $this);
631 631
 
632 632
         // Create a blank invoice
633
-        if ( !empty( $this->ID ) ) {
634
-            $args['ID']         = $this->ID;
633
+        if (!empty($this->ID)) {
634
+            $args['ID'] = $this->ID;
635 635
 
636
-            $invoice_id = wp_update_post( $args, true );
636
+            $invoice_id = wp_update_post($args, true);
637 637
         } else {
638
-            $invoice_id = wp_insert_post( $args, true );
638
+            $invoice_id = wp_insert_post($args, true);
639 639
         }
640 640
 
641
-        if ( is_wp_error( $invoice_id ) ) {
641
+        if (is_wp_error($invoice_id)) {
642 642
             return false;
643 643
         }
644 644
 
645
-        if ( !empty( $invoice_id ) ) {
645
+        if (!empty($invoice_id)) {
646 646
             $this->ID  = $invoice_id;
647 647
             $this->_ID = $invoice_id;
648 648
 
649
-            $this->payment_meta = apply_filters( 'wpinv_payment_meta', $this->payment_meta, $payment_data );
650
-            if ( ! empty( $this->payment_meta['fees'] ) ) {
651
-                $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
652
-                foreach( $this->fees as $fee ) {
653
-                    $this->increase_fees( $fee['amount'] );
649
+            $this->payment_meta = apply_filters('wpinv_payment_meta', $this->payment_meta, $payment_data);
650
+            if (!empty($this->payment_meta['fees'])) {
651
+                $this->fees = array_merge($this->fees, $this->payment_meta['fees']);
652
+                foreach ($this->fees as $fee) {
653
+                    $this->increase_fees($fee['amount']);
654 654
                 }
655 655
             }
656 656
 
657
-            $this->update_meta( '_wpinv_payment_meta', $this->payment_meta );    
657
+            $this->update_meta('_wpinv_payment_meta', $this->payment_meta);    
658 658
             $this->new = true;
659 659
         }
660 660
 
661 661
         return $this->ID;
662 662
     }
663 663
 
664
-    public function save( $setup = false ) {
664
+    public function save($setup = false) {
665 665
         global $wpi_session;
666 666
         
667 667
         $saved = false;
668
-        if ( empty( $this->items ) ) {
668
+        if (empty($this->items)) {
669 669
             return $saved; // Don't save empty invoice.
670 670
         }
671 671
         
672
-        if ( empty( $this->key ) ) {
672
+        if (empty($this->key)) {
673 673
             $this->key = self::generate_key();
674 674
             $this->pending['key'] = $this->key;
675 675
         }
676 676
         
677
-        if ( empty( $this->ID ) ) {
677
+        if (empty($this->ID)) {
678 678
             $invoice_id = $this->insert_invoice();
679 679
 
680
-            if ( false === $invoice_id ) {
680
+            if (false === $invoice_id) {
681 681
                 $saved = false;
682 682
             } else {
683 683
                 $this->ID = $invoice_id;
@@ -685,27 +685,27 @@  discard block
 block discarded – undo
685 685
         }
686 686
 
687 687
         // If we have something pending, let's save it
688
-        if ( !empty( $this->pending ) ) {
688
+        if (!empty($this->pending)) {
689 689
             $total_increase = 0;
690 690
             $total_decrease = 0;
691 691
 
692
-            foreach ( $this->pending as $key => $value ) {
693
-                switch( $key ) {
692
+            foreach ($this->pending as $key => $value) {
693
+                switch ($key) {
694 694
                     case 'items':
695 695
                         // Update totals for pending items
696
-                        foreach ( $this->pending[ $key ] as $item ) {
697
-                            switch( $item['action'] ) {
696
+                        foreach ($this->pending[$key] as $item) {
697
+                            switch ($item['action']) {
698 698
                                 case 'add':
699 699
                                     $price = $item['price'];
700 700
                                     $taxes = $item['tax'];
701 701
 
702
-                                    if ( 'publish' === $this->status ) {
702
+                                    if ('publish' === $this->status) {
703 703
                                         $total_increase += $price;
704 704
                                     }
705 705
                                     break;
706 706
 
707 707
                                 case 'remove':
708
-                                    if ( 'publish' === $this->status ) {
708
+                                    if ('publish' === $this->status) {
709 709
                                         $total_decrease += $item['price'];
710 710
                                     }
711 711
                                     break;
@@ -713,16 +713,16 @@  discard block
 block discarded – undo
713 713
                         }
714 714
                         break;
715 715
                     case 'fees':
716
-                        if ( 'publish' !== $this->status ) {
716
+                        if ('publish' !== $this->status) {
717 717
                             break;
718 718
                         }
719 719
 
720
-                        if ( empty( $this->pending[ $key ] ) ) {
720
+                        if (empty($this->pending[$key])) {
721 721
                             break;
722 722
                         }
723 723
 
724
-                        foreach ( $this->pending[ $key ] as $fee ) {
725
-                            switch( $fee['action'] ) {
724
+                        foreach ($this->pending[$key] as $fee) {
725
+                            switch ($fee['action']) {
726 726
                                 case 'add':
727 727
                                     $total_increase += $fee['amount'];
728 728
                                     break;
@@ -734,86 +734,86 @@  discard block
 block discarded – undo
734 734
                         }
735 735
                         break;
736 736
                     case 'status':
737
-                        $this->update_status( $this->status );
737
+                        $this->update_status($this->status);
738 738
                         break;
739 739
                     case 'gateway':
740
-                        $this->update_meta( '_wpinv_gateway', $this->gateway );
740
+                        $this->update_meta('_wpinv_gateway', $this->gateway);
741 741
                         break;
742 742
                     case 'mode':
743
-                        $this->update_meta( '_wpinv_mode', $this->mode );
743
+                        $this->update_meta('_wpinv_mode', $this->mode);
744 744
                         break;
745 745
                     case 'transaction_id':
746
-                        $this->update_meta( '_wpinv_transaction_id', $this->transaction_id );
746
+                        $this->update_meta('_wpinv_transaction_id', $this->transaction_id);
747 747
                         break;
748 748
                     case 'ip':
749
-                        $this->update_meta( '_wpinv_user_ip', $this->ip );
749
+                        $this->update_meta('_wpinv_user_ip', $this->ip);
750 750
                         break;
751 751
                     ///case 'user_id':
752 752
                         ///$this->update_meta( '_wpinv_user_id', $this->user_id );
753 753
                         ///$this->user_info['user_id'] = $this->user_id;
754 754
                         ///break;
755 755
                     case 'first_name':
756
-                        $this->update_meta( '_wpinv_first_name', $this->first_name );
756
+                        $this->update_meta('_wpinv_first_name', $this->first_name);
757 757
                         $this->user_info['first_name'] = $this->first_name;
758 758
                         break;
759 759
                     case 'last_name':
760
-                        $this->update_meta( '_wpinv_last_name', $this->last_name );
760
+                        $this->update_meta('_wpinv_last_name', $this->last_name);
761 761
                         $this->user_info['last_name'] = $this->last_name;
762 762
                         break;
763 763
                     case 'phone':
764
-                        $this->update_meta( '_wpinv_phone', $this->phone );
764
+                        $this->update_meta('_wpinv_phone', $this->phone);
765 765
                         $this->user_info['phone'] = $this->phone;
766 766
                         break;
767 767
                     case 'address':
768
-                        $this->update_meta( '_wpinv_address', $this->address );
768
+                        $this->update_meta('_wpinv_address', $this->address);
769 769
                         $this->user_info['address'] = $this->address;
770 770
                         break;
771 771
                     case 'city':
772
-                        $this->update_meta( '_wpinv_city', $this->city );
772
+                        $this->update_meta('_wpinv_city', $this->city);
773 773
                         $this->user_info['city'] = $this->city;
774 774
                         break;
775 775
                     case 'country':
776
-                        $this->update_meta( '_wpinv_country', $this->country );
776
+                        $this->update_meta('_wpinv_country', $this->country);
777 777
                         $this->user_info['country'] = $this->country;
778 778
                         break;
779 779
                     case 'state':
780
-                        $this->update_meta( '_wpinv_state', $this->state );
780
+                        $this->update_meta('_wpinv_state', $this->state);
781 781
                         $this->user_info['state'] = $this->state;
782 782
                         break;
783 783
                     case 'zip':
784
-                        $this->update_meta( '_wpinv_zip', $this->zip );
784
+                        $this->update_meta('_wpinv_zip', $this->zip);
785 785
                         $this->user_info['zip'] = $this->zip;
786 786
                         break;
787 787
                     case 'company':
788
-                        $this->update_meta( '_wpinv_company', $this->company );
788
+                        $this->update_meta('_wpinv_company', $this->company);
789 789
                         $this->user_info['company'] = $this->company;
790 790
                         break;
791 791
                     case 'vat_number':
792
-                        $this->update_meta( '_wpinv_vat_number', $this->vat_number );
792
+                        $this->update_meta('_wpinv_vat_number', $this->vat_number);
793 793
                         $this->user_info['vat_number'] = $this->vat_number;
794 794
                         
795
-                        $vat_info = $wpi_session->get( 'user_vat_data' );
796
-                        if ( $this->vat_number && !empty( $vat_info ) && isset( $vat_info['number'] ) && isset( $vat_info['valid'] ) && $vat_info['number'] == $this->vat_number ) {
797
-                            $adddress_confirmed = isset( $vat_info['adddress_confirmed'] ) ? $vat_info['adddress_confirmed'] : false;
798
-                            $this->update_meta( '_wpinv_adddress_confirmed', (bool)$adddress_confirmed );
799
-                            $this->user_info['adddress_confirmed'] = (bool)$adddress_confirmed;
795
+                        $vat_info = $wpi_session->get('user_vat_data');
796
+                        if ($this->vat_number && !empty($vat_info) && isset($vat_info['number']) && isset($vat_info['valid']) && $vat_info['number'] == $this->vat_number) {
797
+                            $adddress_confirmed = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false;
798
+                            $this->update_meta('_wpinv_adddress_confirmed', (bool) $adddress_confirmed);
799
+                            $this->user_info['adddress_confirmed'] = (bool) $adddress_confirmed;
800 800
                         }
801 801
     
802 802
                         break;
803 803
                     case 'vat_rate':
804
-                        $this->update_meta( '_wpinv_vat_rate', $this->vat_rate );
804
+                        $this->update_meta('_wpinv_vat_rate', $this->vat_rate);
805 805
                         $this->user_info['vat_rate'] = $this->vat_rate;
806 806
                         break;
807 807
                     case 'adddress_confirmed':
808
-                        $this->update_meta( '_wpinv_adddress_confirmed', $this->adddress_confirmed );
808
+                        $this->update_meta('_wpinv_adddress_confirmed', $this->adddress_confirmed);
809 809
                         $this->user_info['adddress_confirmed'] = $this->adddress_confirmed;
810 810
                         break;
811 811
                     
812 812
                     case 'key':
813
-                        $this->update_meta( '_wpinv_key', $this->key );
813
+                        $this->update_meta('_wpinv_key', $this->key);
814 814
                         break;
815 815
                     case 'disable_taxes':
816
-                        $this->update_meta( '_wpinv_disable_taxes', $this->disable_taxes );
816
+                        $this->update_meta('_wpinv_disable_taxes', $this->disable_taxes);
817 817
                         break;
818 818
                     case 'date':
819 819
                         $args = array(
@@ -822,49 +822,49 @@  discard block
 block discarded – undo
822 822
                             'edit_date' => true,
823 823
                         );
824 824
 
825
-                        wp_update_post( $args );
825
+                        wp_update_post($args);
826 826
                         break;
827 827
                     case 'due_date':
828
-                        if ( empty( $this->due_date ) ) {
828
+                        if (empty($this->due_date)) {
829 829
                             $this->due_date = 'none';
830 830
                         }
831 831
                         
832
-                        $this->update_meta( '_wpinv_due_date', $this->due_date );
832
+                        $this->update_meta('_wpinv_due_date', $this->due_date);
833 833
                         break;
834 834
                     case 'completed_date':
835
-                        $this->update_meta( '_wpinv_completed_date', $this->completed_date );
835
+                        $this->update_meta('_wpinv_completed_date', $this->completed_date);
836 836
                         break;
837 837
                     case 'discounts':
838
-                        if ( ! is_array( $this->discounts ) ) {
839
-                            $this->discounts = explode( ',', $this->discounts );
838
+                        if (!is_array($this->discounts)) {
839
+                            $this->discounts = explode(',', $this->discounts);
840 840
                         }
841 841
 
842
-                        $this->user_info['discount'] = implode( ',', $this->discounts );
842
+                        $this->user_info['discount'] = implode(',', $this->discounts);
843 843
                         break;
844 844
                     case 'discount':
845
-                        $this->update_meta( '_wpinv_discount', wpinv_round_amount( $this->discount ) );
845
+                        $this->update_meta('_wpinv_discount', wpinv_round_amount($this->discount));
846 846
                         break;
847 847
                     case 'discount_code':
848
-                        $this->update_meta( '_wpinv_discount_code', $this->discount_code );
848
+                        $this->update_meta('_wpinv_discount_code', $this->discount_code);
849 849
                         break;
850 850
                     case 'parent_invoice':
851 851
                         $args = array(
852 852
                             'ID'          => $this->ID,
853 853
                             'post_parent' => $this->parent_invoice,
854 854
                         );
855
-                        wp_update_post( $args );
855
+                        wp_update_post($args);
856 856
                         break;
857 857
                     default:
858
-                        do_action( 'wpinv_save', $this, $key );
858
+                        do_action('wpinv_save', $this, $key);
859 859
                         break;
860 860
                 }
861 861
             }
862 862
 
863
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
864
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
865
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
863
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
864
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
865
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
866 866
             
867
-            $this->items    = array_values( $this->items );
867
+            $this->items = array_values($this->items);
868 868
             
869 869
             $new_meta = array(
870 870
                 'items'         => $this->items,
@@ -875,12 +875,12 @@  discard block
 block discarded – undo
875 875
             );
876 876
             
877 877
             $meta        = $this->get_meta();
878
-            $merged_meta = array_merge( $meta, $new_meta );
878
+            $merged_meta = array_merge($meta, $new_meta);
879 879
 
880 880
             // Only save the payment meta if it's changed
881
-            if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta) ) ) {
882
-                $updated     = $this->update_meta( '_wpinv_payment_meta', $merged_meta );
883
-                if ( false !== $updated ) {
881
+            if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
882
+                $updated = $this->update_meta('_wpinv_payment_meta', $merged_meta);
883
+                if (false !== $updated) {
884 884
                     $saved = true;
885 885
                 }
886 886
             }
@@ -888,15 +888,15 @@  discard block
 block discarded – undo
888 888
             $this->pending = array();
889 889
             $saved         = true;
890 890
         } else {
891
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
892
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
893
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
891
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
892
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
893
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
894 894
         }
895 895
         
896
-        do_action( 'wpinv_invoice_save', $this, $saved );
896
+        do_action('wpinv_invoice_save', $this, $saved);
897 897
 
898
-        if ( true === $saved || $setup ) {
899
-            $this->setup_invoice( $this->ID );
898
+        if (true === $saved || $setup) {
899
+            $this->setup_invoice($this->ID);
900 900
         }
901 901
         
902 902
         $this->refresh_item_ids();
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
         return $saved;
905 905
     }
906 906
     
907
-    public function add_fee( $args, $global = true ) {
907
+    public function add_fee($args, $global = true) {
908 908
         $default_args = array(
909 909
             'label'       => '',
910 910
             'amount'      => 0,
@@ -914,75 +914,75 @@  discard block
 block discarded – undo
914 914
             'item_id'     => 0,
915 915
         );
916 916
 
917
-        $fee = wp_parse_args( $args, $default_args );
917
+        $fee = wp_parse_args($args, $default_args);
918 918
         
919
-        if ( empty( $fee['label'] ) ) {
919
+        if (empty($fee['label'])) {
920 920
             return false;
921 921
         }
922 922
         
923
-        $fee['id']  = sanitize_title( $fee['label'] );
923
+        $fee['id'] = sanitize_title($fee['label']);
924 924
         
925
-        $this->fees[]               = $fee;
925
+        $this->fees[] = $fee;
926 926
         
927 927
         $added_fee               = $fee;
928 928
         $added_fee['action']     = 'add';
929 929
         $this->pending['fees'][] = $added_fee;
930
-        reset( $this->fees );
930
+        reset($this->fees);
931 931
 
932
-        $this->increase_fees( $fee['amount'] );
932
+        $this->increase_fees($fee['amount']);
933 933
         return true;
934 934
     }
935 935
 
936
-    public function remove_fee( $key ) {
936
+    public function remove_fee($key) {
937 937
         $removed = false;
938 938
 
939
-        if ( is_numeric( $key ) ) {
940
-            $removed = $this->remove_fee_by( 'index', $key );
939
+        if (is_numeric($key)) {
940
+            $removed = $this->remove_fee_by('index', $key);
941 941
         }
942 942
 
943 943
         return $removed;
944 944
     }
945 945
 
946
-    public function remove_fee_by( $key, $value, $global = false ) {
947
-        $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array(
946
+    public function remove_fee_by($key, $value, $global = false) {
947
+        $allowed_fee_keys = apply_filters('wpinv_fee_keys', array(
948 948
             'index', 'label', 'amount', 'type',
949
-        ) );
949
+        ));
950 950
 
951
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
951
+        if (!in_array($key, $allowed_fee_keys)) {
952 952
             return false;
953 953
         }
954 954
 
955 955
         $removed = false;
956
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
957
-            $removed_fee             = $this->fees[ $value ];
956
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
957
+            $removed_fee             = $this->fees[$value];
958 958
             $removed_fee['action']   = 'remove';
959 959
             $this->pending['fees'][] = $removed_fee;
960 960
 
961
-            $this->decrease_fees( $removed_fee['amount'] );
961
+            $this->decrease_fees($removed_fee['amount']);
962 962
 
963
-            unset( $this->fees[ $value ] );
963
+            unset($this->fees[$value]);
964 964
             $removed = true;
965
-        } else if ( 'index' !== $key ) {
966
-            foreach ( $this->fees as $index => $fee ) {
967
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
965
+        } else if ('index' !== $key) {
966
+            foreach ($this->fees as $index => $fee) {
967
+                if (isset($fee[$key]) && $fee[$key] == $value) {
968 968
                     $removed_fee             = $fee;
969 969
                     $removed_fee['action']   = 'remove';
970 970
                     $this->pending['fees'][] = $removed_fee;
971 971
 
972
-                    $this->decrease_fees( $removed_fee['amount'] );
972
+                    $this->decrease_fees($removed_fee['amount']);
973 973
 
974
-                    unset( $this->fees[ $index ] );
974
+                    unset($this->fees[$index]);
975 975
                     $removed = true;
976 976
 
977
-                    if ( false === $global ) {
977
+                    if (false === $global) {
978 978
                         break;
979 979
                     }
980 980
                 }
981 981
             }
982 982
         }
983 983
 
984
-        if ( true === $removed ) {
985
-            $this->fees = array_values( $this->fees );
984
+        if (true === $removed) {
985
+            $this->fees = array_values($this->fees);
986 986
         }
987 987
 
988 988
         return $removed;
@@ -990,35 +990,35 @@  discard block
 block discarded – undo
990 990
 
991 991
     
992 992
 
993
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
993
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
994 994
         // Bail if no note specified
995
-        if( !$note ) {
995
+        if (!$note) {
996 996
             return false;
997 997
         }
998 998
 
999
-        if ( empty( $this->ID ) )
999
+        if (empty($this->ID))
1000 1000
             return false;
1001 1001
         
1002
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
1003
-            $user                 = get_user_by( 'id', get_current_user_id() );
1002
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
1003
+            $user                 = get_user_by('id', get_current_user_id());
1004 1004
             $comment_author       = $user->display_name;
1005 1005
             $comment_author_email = $user->user_email;
1006 1006
         } else {
1007 1007
             $comment_author       = 'System';
1008 1008
             $comment_author_email = 'system@';
1009
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
1010
-            $comment_author_email = sanitize_email( $comment_author_email );
1009
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
1010
+            $comment_author_email = sanitize_email($comment_author_email);
1011 1011
         }
1012 1012
 
1013
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
1013
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
1014 1014
 
1015
-        $note_id = wp_insert_comment( wp_filter_comment( array(
1015
+        $note_id = wp_insert_comment(wp_filter_comment(array(
1016 1016
             'comment_post_ID'      => $this->ID,
1017 1017
             'comment_content'      => $note,
1018 1018
             'comment_agent'        => 'WPInvoicing',
1019 1019
             'user_id'              => is_admin() ? get_current_user_id() : 0,
1020
-            'comment_date'         => current_time( 'mysql' ),
1021
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
1020
+            'comment_date'         => current_time('mysql'),
1021
+            'comment_date_gmt'     => current_time('mysql', 1),
1022 1022
             'comment_approved'     => 1,
1023 1023
             'comment_parent'       => 0,
1024 1024
             'comment_author'       => $comment_author,
@@ -1026,53 +1026,53 @@  discard block
 block discarded – undo
1026 1026
             'comment_author_url'   => '',
1027 1027
             'comment_author_email' => $comment_author_email,
1028 1028
             'comment_type'         => 'wpinv_note'
1029
-        ) ) );
1029
+        )));
1030 1030
 
1031
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
1031
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
1032 1032
         
1033
-        if ( $customer_type ) {
1034
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
1033
+        if ($customer_type) {
1034
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
1035 1035
 
1036
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) );
1036
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note));
1037 1037
         }
1038 1038
 
1039 1039
         return $note_id;
1040 1040
     }
1041 1041
 
1042
-    private function increase_subtotal( $amount = 0.00 ) {
1042
+    private function increase_subtotal($amount = 0.00) {
1043 1043
         $amount          = (float) $amount;
1044 1044
         $this->subtotal += $amount;
1045
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1045
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1046 1046
 
1047 1047
         $this->recalculate_total();
1048 1048
     }
1049 1049
 
1050
-    private function decrease_subtotal( $amount = 0.00 ) {
1050
+    private function decrease_subtotal($amount = 0.00) {
1051 1051
         $amount          = (float) $amount;
1052 1052
         $this->subtotal -= $amount;
1053
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1053
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1054 1054
 
1055
-        if ( $this->subtotal < 0 ) {
1055
+        if ($this->subtotal < 0) {
1056 1056
             $this->subtotal = 0;
1057 1057
         }
1058 1058
 
1059 1059
         $this->recalculate_total();
1060 1060
     }
1061 1061
 
1062
-    private function increase_fees( $amount = 0.00 ) {
1063
-        $amount            = (float)$amount;
1062
+    private function increase_fees($amount = 0.00) {
1063
+        $amount            = (float) $amount;
1064 1064
         $this->fees_total += $amount;
1065
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1065
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1066 1066
 
1067 1067
         $this->recalculate_total();
1068 1068
     }
1069 1069
 
1070
-    private function decrease_fees( $amount = 0.00 ) {
1070
+    private function decrease_fees($amount = 0.00) {
1071 1071
         $amount            = (float) $amount;
1072 1072
         $this->fees_total -= $amount;
1073
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1073
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1074 1074
 
1075
-        if ( $this->fees_total < 0 ) {
1075
+        if ($this->fees_total < 0) {
1076 1076
             $this->fees_total = 0;
1077 1077
         }
1078 1078
 
@@ -1083,54 +1083,54 @@  discard block
 block discarded – undo
1083 1083
         global $wpi_nosave;
1084 1084
         
1085 1085
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
1086
-        $this->total = wpinv_round_amount( $this->total );
1086
+        $this->total = wpinv_round_amount($this->total);
1087 1087
         
1088
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
1088
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
1089 1089
     }
1090 1090
     
1091
-    public function increase_tax( $amount = 0.00 ) {
1091
+    public function increase_tax($amount = 0.00) {
1092 1092
         $amount       = (float) $amount;
1093 1093
         $this->tax   += $amount;
1094 1094
 
1095 1095
         $this->recalculate_total();
1096 1096
     }
1097 1097
 
1098
-    public function decrease_tax( $amount = 0.00 ) {
1098
+    public function decrease_tax($amount = 0.00) {
1099 1099
         $amount     = (float) $amount;
1100 1100
         $this->tax -= $amount;
1101 1101
 
1102
-        if ( $this->tax < 0 ) {
1102
+        if ($this->tax < 0) {
1103 1103
             $this->tax = 0;
1104 1104
         }
1105 1105
 
1106 1106
         $this->recalculate_total();
1107 1107
     }
1108 1108
 
1109
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
1110
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
1109
+    public function update_status($new_status = false, $note = '', $manual = false) {
1110
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
1111 1111
 
1112
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
1112
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
1113 1113
             return false; // Don't permit status changes that aren't changes
1114 1114
         }
1115 1115
 
1116
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
1116
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
1117 1117
         $updated = false;
1118 1118
 
1119
-        if ( $do_change ) {
1120
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
1119
+        if ($do_change) {
1120
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
1121 1121
 
1122 1122
             $update_post_data                   = array();
1123 1123
             $update_post_data['ID']             = $this->ID;
1124 1124
             $update_post_data['post_status']    = $new_status;
1125
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
1126
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
1125
+            $update_post_data['edit_date']      = current_time('mysql', 0);
1126
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
1127 1127
             
1128
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
1128
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
1129 1129
 
1130
-            $updated = wp_update_post( $update_post_data );     
1130
+            $updated = wp_update_post($update_post_data);     
1131 1131
            
1132 1132
             // Process any specific status functions
1133
-            switch( $new_status ) {
1133
+            switch ($new_status) {
1134 1134
                 case 'wpi-refunded':
1135 1135
                     $this->process_refund();
1136 1136
                     break;
@@ -1143,9 +1143,9 @@  discard block
 block discarded – undo
1143 1143
             }
1144 1144
             
1145 1145
             // Status was changed.
1146
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
1147
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
1148
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
1146
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
1147
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
1148
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
1149 1149
         }
1150 1150
 
1151 1151
         return $updated;
@@ -1159,20 +1159,20 @@  discard block
 block discarded – undo
1159 1159
         $this->save();
1160 1160
     }
1161 1161
 
1162
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1163
-        if ( empty( $meta_key ) ) {
1162
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1163
+        if (empty($meta_key)) {
1164 1164
             return false;
1165 1165
         }
1166 1166
 
1167
-        if ( $meta_key == 'key' || $meta_key == 'date' ) {
1167
+        if ($meta_key == 'key' || $meta_key == 'date') {
1168 1168
             $current_meta = $this->get_meta();
1169
-            $current_meta[ $meta_key ] = $meta_value;
1169
+            $current_meta[$meta_key] = $meta_value;
1170 1170
 
1171 1171
             $meta_key     = '_wpinv_payment_meta';
1172 1172
             $meta_value   = $current_meta;
1173 1173
         }
1174 1174
 
1175
-        $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1175
+        $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID);
1176 1176
         
1177 1177
         // Do not update created date on invoice marked as paid.
1178 1178
         /*if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) {
@@ -1187,45 +1187,45 @@  discard block
 block discarded – undo
1187 1187
             wp_update_post( $args );
1188 1188
         }*/
1189 1189
         
1190
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1190
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1191 1191
     }
1192 1192
 
1193 1193
     private function process_refund() {
1194 1194
         $process_refund = true;
1195 1195
 
1196 1196
         // If the payment was not in publish, don't decrement stats as they were never incremented
1197
-        if ( 'publish' != $this->old_status || 'wpi-refunded' != $this->status ) {
1197
+        if ('publish' != $this->old_status || 'wpi-refunded' != $this->status) {
1198 1198
             $process_refund = false;
1199 1199
         }
1200 1200
 
1201 1201
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1202
-        $process_refund = apply_filters( 'wpinv_should_process_refund', $process_refund, $this );
1202
+        $process_refund = apply_filters('wpinv_should_process_refund', $process_refund, $this);
1203 1203
 
1204
-        if ( false === $process_refund ) {
1204
+        if (false === $process_refund) {
1205 1205
             return;
1206 1206
         }
1207 1207
 
1208
-        do_action( 'wpinv_pre_refund_invoice', $this );
1208
+        do_action('wpinv_pre_refund_invoice', $this);
1209 1209
         
1210
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_refund', true, $this );
1211
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_refund', true, $this );
1212
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_refund', true, $this );
1210
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_refund', true, $this);
1211
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_refund', true, $this);
1212
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_refund', true, $this);
1213 1213
         
1214
-        do_action( 'wpinv_post_refund_invoice', $this );
1214
+        do_action('wpinv_post_refund_invoice', $this);
1215 1215
     }
1216 1216
 
1217 1217
     private function process_failure() {
1218 1218
         $discounts = $this->discounts;
1219
-        if ( empty( $discounts ) ) {
1219
+        if (empty($discounts)) {
1220 1220
             return;
1221 1221
         }
1222 1222
 
1223
-        if ( ! is_array( $discounts ) ) {
1224
-            $discounts = array_map( 'trim', explode( ',', $discounts ) );
1223
+        if (!is_array($discounts)) {
1224
+            $discounts = array_map('trim', explode(',', $discounts));
1225 1225
         }
1226 1226
 
1227
-        foreach ( $discounts as $discount ) {
1228
-            wpinv_decrease_discount_usage( $discount );
1227
+        foreach ($discounts as $discount) {
1228
+            wpinv_decrease_discount_usage($discount);
1229 1229
         }
1230 1230
     }
1231 1231
     
@@ -1233,92 +1233,92 @@  discard block
 block discarded – undo
1233 1233
         $process_pending = true;
1234 1234
 
1235 1235
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1236
-        if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'wpi-pending' != $this->status ) {
1236
+        if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'wpi-pending' != $this->status) {
1237 1237
             $process_pending = false;
1238 1238
         }
1239 1239
 
1240 1240
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1241
-        $process_pending = apply_filters( 'wpinv_should_process_pending', $process_pending, $this );
1241
+        $process_pending = apply_filters('wpinv_should_process_pending', $process_pending, $this);
1242 1242
 
1243
-        if ( false === $process_pending ) {
1243
+        if (false === $process_pending) {
1244 1244
             return;
1245 1245
         }
1246 1246
 
1247
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_pending', true, $this );
1248
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_pending', true, $this );
1249
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_pending', true, $this );
1247
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_pending', true, $this);
1248
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_pending', true, $this);
1249
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_pending', true, $this);
1250 1250
 
1251 1251
         $this->completed_date = '';
1252
-        $this->update_meta( '_wpinv_completed_date', '' );
1252
+        $this->update_meta('_wpinv_completed_date', '');
1253 1253
     }
1254 1254
     
1255 1255
     // get data
1256
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
1257
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
1256
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
1257
+        $meta = get_post_meta($this->ID, $meta_key, $single);
1258 1258
 
1259
-        if ( $meta_key === '_wpinv_payment_meta' ) {
1259
+        if ($meta_key === '_wpinv_payment_meta') {
1260 1260
 
1261
-            if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is.
1261
+            if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is.
1262 1262
 
1263
-            if ( empty( $meta['key'] ) ) {
1263
+            if (empty($meta['key'])) {
1264 1264
                 $meta['key'] = $this->setup_invoice_key();
1265 1265
             }
1266 1266
 
1267
-            if ( empty( $meta['date'] ) ) {
1268
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
1267
+            if (empty($meta['date'])) {
1268
+                $meta['date'] = get_post_field('post_date', $this->ID);
1269 1269
             }
1270 1270
         }
1271 1271
 
1272
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
1272
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
1273 1273
 
1274
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
1274
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
1275 1275
     }
1276 1276
     
1277 1277
     public function get_description() {
1278
-        $post = get_post( $this->ID );
1278
+        $post = get_post($this->ID);
1279 1279
         
1280
-        $description = !empty( $post ) ? $post->post_content : '';
1281
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1280
+        $description = !empty($post) ? $post->post_content : '';
1281
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1282 1282
     }
1283 1283
     
1284
-    public function get_status( $nicename = false ) {
1285
-        if ( !$nicename ) {
1284
+    public function get_status($nicename = false) {
1285
+        if (!$nicename) {
1286 1286
             $status = $this->status;
1287 1287
         } else {
1288 1288
             $status = $this->status_nicename;
1289 1289
         }
1290 1290
         
1291
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1291
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1292 1292
     }
1293 1293
     
1294 1294
     public function get_cart_details() {
1295
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1295
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1296 1296
     }
1297 1297
     
1298
-    public function get_subtotal( $currency = false ) {
1299
-        $subtotal = wpinv_round_amount( $this->subtotal );
1298
+    public function get_subtotal($currency = false) {
1299
+        $subtotal = wpinv_round_amount($this->subtotal);
1300 1300
         
1301
-        if ( $currency ) {
1302
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() );
1301
+        if ($currency) {
1302
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency());
1303 1303
         }
1304 1304
         
1305
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1305
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1306 1306
     }
1307 1307
     
1308
-    public function get_total( $currency = false ) {        
1309
-        if ( $this->is_free_trial() ) {
1310
-            $total = wpinv_round_amount( 0 );
1308
+    public function get_total($currency = false) {        
1309
+        if ($this->is_free_trial()) {
1310
+            $total = wpinv_round_amount(0);
1311 1311
         } else {
1312
-            $total = wpinv_round_amount( $this->total );
1312
+            $total = wpinv_round_amount($this->total);
1313 1313
         }
1314
-        if ( $currency ) {
1315
-            $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() );
1314
+        if ($currency) {
1315
+            $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency());
1316 1316
         }
1317 1317
         
1318
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1318
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1319 1319
     }
1320 1320
     
1321
-    public function get_recurring_details( $field = '', $currency = false ) {        
1321
+    public function get_recurring_details($field = '', $currency = false) {        
1322 1322
         $data                 = array();
1323 1323
         $data['cart_details'] = $this->cart_details;
1324 1324
         $data['subtotal']     = $this->get_subtotal();
@@ -1326,119 +1326,119 @@  discard block
 block discarded – undo
1326 1326
         $data['tax']          = $this->get_tax();
1327 1327
         $data['total']        = $this->get_total();
1328 1328
     
1329
-        if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) {
1329
+        if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) {
1330 1330
             $is_free_trial = $this->is_free_trial();
1331
-            $discounts = $this->get_discounts( true );
1331
+            $discounts = $this->get_discounts(true);
1332 1332
             
1333
-            if ( $is_free_trial || !empty( $discounts ) ) {
1333
+            if ($is_free_trial || !empty($discounts)) {
1334 1334
                 $first_use_only = false;
1335 1335
                 
1336
-                if ( !empty( $discounts ) ) {
1337
-                    foreach ( $discounts as $key => $code ) {
1338
-                        if ( wpinv_discount_is_recurring( $code, true ) && !$this->is_renewal() ) {
1336
+                if (!empty($discounts)) {
1337
+                    foreach ($discounts as $key => $code) {
1338
+                        if (wpinv_discount_is_recurring($code, true) && !$this->is_renewal()) {
1339 1339
                             $first_use_only = true;
1340 1340
                             break;
1341 1341
                         }
1342 1342
                     }
1343 1343
                 }
1344 1344
                     
1345
-                if ( !$first_use_only ) {
1346
-                    $data['subtotal'] = wpinv_round_amount( $this->subtotal );
1347
-                    $data['discount'] = wpinv_round_amount( $this->discount );
1348
-                    $data['tax']      = wpinv_round_amount( $this->tax );
1349
-                    $data['total']    = wpinv_round_amount( $this->total );
1345
+                if (!$first_use_only) {
1346
+                    $data['subtotal'] = wpinv_round_amount($this->subtotal);
1347
+                    $data['discount'] = wpinv_round_amount($this->discount);
1348
+                    $data['tax']      = wpinv_round_amount($this->tax);
1349
+                    $data['total']    = wpinv_round_amount($this->total);
1350 1350
                 } else {
1351 1351
                     $cart_subtotal   = 0;
1352 1352
                     $cart_discount   = $this->discount;
1353 1353
                     $cart_tax        = 0;
1354 1354
 
1355
-                    foreach ( $this->cart_details as $key => $item ) {
1356
-                        $item_quantity  = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1357
-                        $item_subtotal  = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1355
+                    foreach ($this->cart_details as $key => $item) {
1356
+                        $item_quantity  = $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1357
+                        $item_subtotal  = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1358 1358
                         $item_discount  = 0;
1359
-                        $item_tax       = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0;
1359
+                        $item_tax       = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float) $item['vat_rate']) : 0;
1360 1360
                         
1361
-                        if ( wpinv_prices_include_tax() ) {
1362
-                            $item_subtotal -= wpinv_round_amount( $item_tax );
1361
+                        if (wpinv_prices_include_tax()) {
1362
+                            $item_subtotal -= wpinv_round_amount($item_tax);
1363 1363
                         }
1364 1364
                         
1365 1365
                         $item_total     = $item_subtotal - $item_discount + $item_tax;
1366 1366
                         // Do not allow totals to go negative
1367
-                        if ( $item_total < 0 ) {
1367
+                        if ($item_total < 0) {
1368 1368
                             $item_total = 0;
1369 1369
                         }
1370 1370
                         
1371
-                        $cart_subtotal  += (float)($item_subtotal);
1372
-                        $cart_discount  += (float)($item_discount);
1373
-                        $cart_tax       += (float)($item_tax);
1371
+                        $cart_subtotal  += (float) ($item_subtotal);
1372
+                        $cart_discount  += (float) ($item_discount);
1373
+                        $cart_tax       += (float) ($item_tax);
1374 1374
                         
1375
-                        $data['cart_details'][$key]['discount']   = wpinv_round_amount( $item_discount );
1376
-                        $data['cart_details'][$key]['tax']        = wpinv_round_amount( $item_tax );
1377
-                        $data['cart_details'][$key]['price']      = wpinv_round_amount( $item_total );
1375
+                        $data['cart_details'][$key]['discount']   = wpinv_round_amount($item_discount);
1376
+                        $data['cart_details'][$key]['tax']        = wpinv_round_amount($item_tax);
1377
+                        $data['cart_details'][$key]['price']      = wpinv_round_amount($item_total);
1378 1378
                     }
1379 1379
 
1380 1380
 	                $total = $data['subtotal'] - $data['discount'] + $data['tax'];
1381
-	                if ( $total < 0 ) {
1381
+	                if ($total < 0) {
1382 1382
 		                $total = 0;
1383 1383
 	                }
1384 1384
 
1385
-                    $data['subtotal'] = wpinv_round_amount( $cart_subtotal );
1386
-                    $data['discount'] = wpinv_round_amount( $cart_discount );
1387
-                    $data['tax']      = wpinv_round_amount( $cart_tax );
1388
-                    $data['total']    = wpinv_round_amount( $total );
1385
+                    $data['subtotal'] = wpinv_round_amount($cart_subtotal);
1386
+                    $data['discount'] = wpinv_round_amount($cart_discount);
1387
+                    $data['tax']      = wpinv_round_amount($cart_tax);
1388
+                    $data['total']    = wpinv_round_amount($total);
1389 1389
                 }
1390 1390
             }
1391 1391
         }
1392 1392
         
1393
-        $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency );
1393
+        $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency);
1394 1394
 
1395
-        if ( isset( $data[$field] ) ) {
1396
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1395
+        if (isset($data[$field])) {
1396
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1397 1397
         }
1398 1398
         
1399 1399
         return $data;
1400 1400
     }
1401 1401
     
1402
-    public function get_final_tax( $currency = false ) {        
1403
-        $final_total = wpinv_round_amount( $this->tax );
1404
-        if ( $currency ) {
1405
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() );
1402
+    public function get_final_tax($currency = false) {        
1403
+        $final_total = wpinv_round_amount($this->tax);
1404
+        if ($currency) {
1405
+            $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency());
1406 1406
         }
1407 1407
         
1408
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1408
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1409 1409
     }
1410 1410
     
1411
-    public function get_discounts( $array = false ) {
1411
+    public function get_discounts($array = false) {
1412 1412
         $discounts = $this->discounts;
1413
-        if ( $array && $discounts ) {
1414
-            $discounts = explode( ',', $discounts );
1413
+        if ($array && $discounts) {
1414
+            $discounts = explode(',', $discounts);
1415 1415
         }
1416
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1416
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1417 1417
     }
1418 1418
     
1419
-    public function get_discount( $currency = false, $dash = false ) {
1420
-        if ( !empty( $this->discounts ) ) {
1419
+    public function get_discount($currency = false, $dash = false) {
1420
+        if (!empty($this->discounts)) {
1421 1421
             global $ajax_cart_details;
1422 1422
             $ajax_cart_details = $this->get_cart_details();
1423 1423
             
1424
-            if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1424
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1425 1425
                 $cart_items = $ajax_cart_details;
1426 1426
             } else {
1427 1427
                 $cart_items = $this->items;
1428 1428
             }
1429 1429
 
1430
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts );
1430
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1431 1431
         }
1432
-        $discount   = wpinv_round_amount( $this->discount );
1432
+        $discount   = wpinv_round_amount($this->discount);
1433 1433
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1434 1434
         
1435
-        if ( $currency ) {
1436
-            $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() );
1435
+        if ($currency) {
1436
+            $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency());
1437 1437
         }
1438 1438
         
1439
-        $discount   = $dash . $discount;
1439
+        $discount = $dash . $discount;
1440 1440
         
1441
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1441
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1442 1442
     }
1443 1443
     
1444 1444
     public function get_discount_code() {
@@ -1450,49 +1450,49 @@  discard block
 block discarded – undo
1450 1450
         return (int) $this->disable_taxes === 0;
1451 1451
     }
1452 1452
 
1453
-    public function get_tax( $currency = false ) {
1454
-        $tax = wpinv_round_amount( $this->tax );
1453
+    public function get_tax($currency = false) {
1454
+        $tax = wpinv_round_amount($this->tax);
1455 1455
 
1456
-        if ( $currency ) {
1457
-            $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() );
1456
+        if ($currency) {
1457
+            $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency());
1458 1458
         }
1459 1459
 
1460
-        if ( ! $this->is_taxable() ) {
1461
-            $tax = wpinv_round_amount( 0.00 );
1460
+        if (!$this->is_taxable()) {
1461
+            $tax = wpinv_round_amount(0.00);
1462 1462
         }
1463 1463
 
1464
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1464
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1465 1465
     }
1466 1466
     
1467
-    public function get_fees( $type = 'all' ) {
1468
-        $fees    = array();
1467
+    public function get_fees($type = 'all') {
1468
+        $fees = array();
1469 1469
 
1470
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1471
-            foreach ( $this->fees as $fee ) {
1472
-                if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1470
+        if (!empty($this->fees) && is_array($this->fees)) {
1471
+            foreach ($this->fees as $fee) {
1472
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1473 1473
                     continue;
1474 1474
                 }
1475 1475
 
1476
-                $fee['label'] = stripslashes( $fee['label'] );
1477
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1478
-                $fees[]    = $fee;
1476
+                $fee['label'] = stripslashes($fee['label']);
1477
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1478
+                $fees[] = $fee;
1479 1479
             }
1480 1480
         }
1481 1481
 
1482
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1482
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1483 1483
     }
1484 1484
     
1485
-    public function get_fees_total( $type = 'all' ) {
1485
+    public function get_fees_total($type = 'all') {
1486 1486
         $fees_total = (float) 0.00;
1487 1487
 
1488
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1489
-        if ( ! empty( $payment_fees ) ) {
1490
-            foreach ( $payment_fees as $fee ) {
1488
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1489
+        if (!empty($payment_fees)) {
1490
+            foreach ($payment_fees as $fee) {
1491 1491
                 $fees_total += (float) $fee['amount'];
1492 1492
             }
1493 1493
         }
1494 1494
 
1495
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1495
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1496 1496
         /*
1497 1497
         $fees = $this->get_fees( $type );
1498 1498
 
@@ -1512,116 +1512,116 @@  discard block
 block discarded – undo
1512 1512
     }
1513 1513
 
1514 1514
     public function get_user_id() {
1515
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1515
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1516 1516
     }
1517 1517
     
1518 1518
     public function get_first_name() {
1519
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1519
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1520 1520
     }
1521 1521
     
1522 1522
     public function get_last_name() {
1523
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1523
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1524 1524
     }
1525 1525
     
1526 1526
     public function get_user_full_name() {
1527
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1527
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1528 1528
     }
1529 1529
     
1530 1530
     public function get_user_info() {
1531
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1531
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1532 1532
     }
1533 1533
     
1534 1534
     public function get_email() {
1535
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1535
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1536 1536
     }
1537 1537
     
1538 1538
     public function get_address() {
1539
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1539
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1540 1540
     }
1541 1541
     
1542 1542
     public function get_phone() {
1543
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1543
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1544 1544
     }
1545 1545
     
1546 1546
     public function get_number() {
1547
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1547
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1548 1548
     }
1549 1549
     
1550 1550
     public function get_items() {
1551
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1551
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1552 1552
     }
1553 1553
     
1554 1554
     public function get_key() {
1555
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1555
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1556 1556
     }
1557 1557
     
1558 1558
     public function get_transaction_id() {
1559
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1559
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1560 1560
     }
1561 1561
     
1562 1562
     public function get_gateway() {
1563
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1563
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1564 1564
     }
1565 1565
     
1566 1566
     public function get_gateway_title() {
1567
-        $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway );
1567
+        $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway);
1568 1568
         
1569
-        return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this );
1569
+        return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this);
1570 1570
     }
1571 1571
     
1572 1572
     public function get_currency() {
1573
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1573
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1574 1574
     }
1575 1575
     
1576 1576
     public function get_created_date() {
1577
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1577
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1578 1578
     }
1579 1579
     
1580
-    public function get_due_date( $display = false ) {
1581
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1580
+    public function get_due_date($display = false) {
1581
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1582 1582
         
1583
-        if ( !$display || empty( $due_date ) ) {
1583
+        if (!$display || empty($due_date)) {
1584 1584
             return $due_date;
1585 1585
         }
1586 1586
         
1587
-        return date_i18n( get_option( 'date_format' ), strtotime( $due_date ) );
1587
+        return date_i18n(get_option('date_format'), strtotime($due_date));
1588 1588
     }
1589 1589
     
1590 1590
     public function get_completed_date() {
1591
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1591
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1592 1592
     }
1593 1593
     
1594
-    public function get_invoice_date( $formatted = true ) {
1594
+    public function get_invoice_date($formatted = true) {
1595 1595
         $date_completed = $this->completed_date;
1596 1596
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1597 1597
         
1598
-        if ( $invoice_date == '' ) {
1598
+        if ($invoice_date == '') {
1599 1599
             $date_created   = $this->date;
1600 1600
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1601 1601
         }
1602 1602
         
1603
-        if ( $formatted && $invoice_date ) {
1604
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
1603
+        if ($formatted && $invoice_date) {
1604
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
1605 1605
         }
1606 1606
 
1607
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1607
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1608 1608
     }
1609 1609
     
1610 1610
     public function get_ip() {
1611
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1611
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1612 1612
     }
1613 1613
         
1614
-    public function has_status( $status ) {
1615
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1614
+    public function has_status($status) {
1615
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1616 1616
     }
1617 1617
     
1618
-    public function add_item( $item_id = 0, $args = array() ) {
1618
+    public function add_item($item_id = 0, $args = array()) {
1619 1619
         global $wpi_current_id, $wpi_item_id;
1620 1620
         
1621
-        $item = new WPInv_Item( $item_id );
1621
+        $item = new WPInv_Item($item_id);
1622 1622
 
1623 1623
         // Bail if this post isn't a item
1624
-        if( !$item || $item->post_type !== 'wpi_item' ) {
1624
+        if (!$item || $item->post_type !== 'wpi_item') {
1625 1625
             return false;
1626 1626
         }
1627 1627
         
@@ -1640,8 +1640,8 @@  discard block
 block discarded – undo
1640 1640
             'fees'          => array()
1641 1641
         );
1642 1642
 
1643
-        $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults );
1644
-        $args['quantity']   = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1;
1643
+        $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults);
1644
+        $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1;
1645 1645
 
1646 1646
         $wpi_current_id         = $this->ID;
1647 1647
         $wpi_item_id            = $item->ID;
@@ -1653,19 +1653,19 @@  discard block
 block discarded – undo
1653 1653
         $found_cart_key         = false;
1654 1654
         
1655 1655
         if ($has_quantities) {
1656
-            $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1656
+            $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1657 1657
             
1658
-            foreach ( $this->items as $key => $cart_item ) {
1659
-                if ( (int)$item_id !== (int)$cart_item['id'] ) {
1658
+            foreach ($this->items as $key => $cart_item) {
1659
+                if ((int) $item_id !== (int) $cart_item['id']) {
1660 1660
                     continue;
1661 1661
                 }
1662 1662
 
1663
-                $this->items[ $key ]['quantity'] += $args['quantity'];
1663
+                $this->items[$key]['quantity'] += $args['quantity'];
1664 1664
                 break;
1665 1665
             }
1666 1666
             
1667
-            foreach ( $this->cart_details as $cart_key => $cart_item ) {
1668
-                if ( $item_id != $cart_item['id'] ) {
1667
+            foreach ($this->cart_details as $cart_key => $cart_item) {
1668
+                if ($item_id != $cart_item['id']) {
1669 1669
                     continue;
1670 1670
                 }
1671 1671
 
@@ -1677,29 +1677,29 @@  discard block
 block discarded – undo
1677 1677
         if ($has_quantities && $found_cart_key !== false) {
1678 1678
             $cart_item          = $this->cart_details[$found_cart_key];
1679 1679
             $item_price         = $cart_item['item_price'];
1680
-            $quantity           = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1681
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1680
+            $quantity           = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1681
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1682 1682
             
1683 1683
             $new_quantity       = $quantity + $args['quantity'];
1684 1684
             $subtotal           = $item_price * $new_quantity;
1685 1685
             
1686 1686
             $args['quantity']   = $new_quantity;
1687
-            $discount           = !empty( $args['discount'] ) ? $args['discount'] : 0;
1688
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1687
+            $discount           = !empty($args['discount']) ? $args['discount'] : 0;
1688
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1689 1689
             
1690
-            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0;
1691
-            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0;
1690
+            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float) $cart_item['discount'] ? $discount - (float) $cart_item['discount'] : 0;
1691
+            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float) $cart_item['tax'] ? $tax - (float) $cart_item['tax'] : 0;
1692 1692
             // The total increase equals the number removed * the item_price
1693
-            $total_increased    = wpinv_round_amount( $item_price );
1693
+            $total_increased    = wpinv_round_amount($item_price);
1694 1694
             
1695
-            if ( wpinv_prices_include_tax() ) {
1696
-                $subtotal -= wpinv_round_amount( $tax );
1695
+            if (wpinv_prices_include_tax()) {
1696
+                $subtotal -= wpinv_round_amount($tax);
1697 1697
             }
1698 1698
 
1699
-            $total              = $subtotal - $discount + $tax;
1699
+            $total = $subtotal - $discount + $tax;
1700 1700
 
1701 1701
             // Do not allow totals to go negative
1702
-            if( $total < 0 ) {
1702
+            if ($total < 0) {
1703 1703
                 $total = 0;
1704 1704
             }
1705 1705
             
@@ -1715,25 +1715,25 @@  discard block
 block discarded – undo
1715 1715
             $this->cart_details[$found_cart_key] = $cart_item;
1716 1716
         } else {
1717 1717
             // Set custom price.
1718
-            if ( $args['custom_price'] !== '' ) {
1718
+            if ($args['custom_price'] !== '') {
1719 1719
                 $item_price = $args['custom_price'];
1720 1720
             } else {
1721 1721
                 // Allow overriding the price
1722
-                if ( false !== $args['item_price'] ) {
1722
+                if (false !== $args['item_price']) {
1723 1723
                     $item_price = $args['item_price'];
1724 1724
                 } else {
1725
-                    $item_price = wpinv_get_item_price( $item->ID );
1725
+                    $item_price = wpinv_get_item_price($item->ID);
1726 1726
                 }
1727 1727
             }
1728 1728
 
1729 1729
             // Sanitizing the price here so we don't have a dozen calls later
1730
-            $item_price = wpinv_sanitize_amount( $item_price );
1731
-            $subtotal   = wpinv_round_amount( $item_price * $args['quantity'] );
1730
+            $item_price = wpinv_sanitize_amount($item_price);
1731
+            $subtotal   = wpinv_round_amount($item_price * $args['quantity']);
1732 1732
         
1733
-            $discount   = !empty( $args['discount'] ) ? $args['discount'] : 0;
1734
-            $tax_class  = !empty( $args['vat_class'] ) ? $args['vat_class'] : '';
1735
-            $tax_rate   = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0;
1736
-            $tax        = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1733
+            $discount   = !empty($args['discount']) ? $args['discount'] : 0;
1734
+            $tax_class  = !empty($args['vat_class']) ? $args['vat_class'] : '';
1735
+            $tax_rate   = !empty($args['vat_rate']) ? $args['vat_rate'] : 0;
1736
+            $tax        = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1737 1737
 
1738 1738
             // Setup the items meta item
1739 1739
             $new_item = array(
@@ -1741,29 +1741,29 @@  discard block
 block discarded – undo
1741 1741
                 'quantity' => $args['quantity'],
1742 1742
             );
1743 1743
 
1744
-            $this->items[]  = $new_item;
1744
+            $this->items[] = $new_item;
1745 1745
 
1746
-            if ( wpinv_prices_include_tax() ) {
1747
-                $subtotal -= wpinv_round_amount( $tax );
1746
+            if (wpinv_prices_include_tax()) {
1747
+                $subtotal -= wpinv_round_amount($tax);
1748 1748
             }
1749 1749
 
1750
-            $total      = $subtotal - $discount + $tax;
1750
+            $total = $subtotal - $discount + $tax;
1751 1751
 
1752 1752
             // Do not allow totals to go negative
1753
-            if( $total < 0 ) {
1753
+            if ($total < 0) {
1754 1754
                 $total = 0;
1755 1755
             }
1756 1756
         
1757 1757
             $this->cart_details[] = array(
1758 1758
                 'name'          => !empty($args['name']) ? $args['name'] : $item->get_name(),
1759 1759
                 'id'            => $item->ID,
1760
-                'item_price'    => wpinv_round_amount( $item_price ),
1761
-                'custom_price'  => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ),
1760
+                'item_price'    => wpinv_round_amount($item_price),
1761
+                'custom_price'  => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''),
1762 1762
                 'quantity'      => $args['quantity'],
1763 1763
                 'discount'      => $discount,
1764
-                'subtotal'      => wpinv_round_amount( $subtotal ),
1765
-                'tax'           => wpinv_round_amount( $tax ),
1766
-                'price'         => wpinv_round_amount( $total ),
1764
+                'subtotal'      => wpinv_round_amount($subtotal),
1765
+                'tax'           => wpinv_round_amount($tax),
1766
+                'price'         => wpinv_round_amount($total),
1767 1767
                 'vat_rate'      => $tax_rate,
1768 1768
                 'vat_class'     => $tax_class,
1769 1769
                 'meta'          => $args['meta'],
@@ -1773,18 +1773,18 @@  discard block
 block discarded – undo
1773 1773
             $subtotal = $subtotal - $discount;
1774 1774
         }
1775 1775
         
1776
-        $added_item = end( $this->cart_details );
1777
-        $added_item['action']  = 'add';
1776
+        $added_item = end($this->cart_details);
1777
+        $added_item['action'] = 'add';
1778 1778
         
1779 1779
         $this->pending['items'][] = $added_item;
1780 1780
         
1781
-        $this->increase_subtotal( $subtotal );
1782
-        $this->increase_tax( $tax );
1781
+        $this->increase_subtotal($subtotal);
1782
+        $this->increase_tax($tax);
1783 1783
 
1784 1784
         return true;
1785 1785
     }
1786 1786
     
1787
-    public function remove_item( $item_id, $args = array() ) {
1787
+    public function remove_item($item_id, $args = array()) {
1788 1788
         // Set some defaults
1789 1789
         $defaults = array(
1790 1790
             'quantity'      => 1,
@@ -1792,51 +1792,51 @@  discard block
 block discarded – undo
1792 1792
             'custom_price'  => '',
1793 1793
             'cart_index'    => false,
1794 1794
         );
1795
-        $args = wp_parse_args( $args, $defaults );
1795
+        $args = wp_parse_args($args, $defaults);
1796 1796
 
1797 1797
         // Bail if this post isn't a item
1798
-        if ( get_post_type( $item_id ) !== 'wpi_item' ) {
1798
+        if (get_post_type($item_id) !== 'wpi_item') {
1799 1799
             return false;
1800 1800
         }
1801 1801
         
1802
-        $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1802
+        $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1803 1803
 
1804
-        foreach ( $this->items as $key => $item ) {
1805
-            if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) {
1804
+        foreach ($this->items as $key => $item) {
1805
+            if (!empty($item['id']) && (int) $item_id !== (int) $item['id']) {
1806 1806
                 continue;
1807 1807
             }
1808 1808
 
1809
-            if ( false !== $args['cart_index'] ) {
1810
-                $cart_index = absint( $args['cart_index'] );
1811
-                $cart_item  = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false;
1809
+            if (false !== $args['cart_index']) {
1810
+                $cart_index = absint($args['cart_index']);
1811
+                $cart_item  = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false;
1812 1812
 
1813
-                if ( ! empty( $cart_item ) ) {
1813
+                if (!empty($cart_item)) {
1814 1814
                     // If the cart index item isn't the same item ID, don't remove it
1815
-                    if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) {
1815
+                    if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) {
1816 1816
                         continue;
1817 1817
                     }
1818 1818
                 }
1819 1819
             }
1820 1820
 
1821
-            $item_quantity = $this->items[ $key ]['quantity'];
1822
-            if ( $item_quantity > $args['quantity'] ) {
1823
-                $this->items[ $key ]['quantity'] -= $args['quantity'];
1821
+            $item_quantity = $this->items[$key]['quantity'];
1822
+            if ($item_quantity > $args['quantity']) {
1823
+                $this->items[$key]['quantity'] -= $args['quantity'];
1824 1824
                 break;
1825 1825
             } else {
1826
-                unset( $this->items[ $key ] );
1826
+                unset($this->items[$key]);
1827 1827
                 break;
1828 1828
             }
1829 1829
         }
1830 1830
 
1831 1831
         $found_cart_key = false;
1832
-        if ( false === $args['cart_index'] ) {
1833
-            foreach ( $this->cart_details as $cart_key => $item ) {
1834
-                if ( $item_id != $item['id'] ) {
1832
+        if (false === $args['cart_index']) {
1833
+            foreach ($this->cart_details as $cart_key => $item) {
1834
+                if ($item_id != $item['id']) {
1835 1835
                     continue;
1836 1836
                 }
1837 1837
 
1838
-                if ( false !== $args['item_price'] ) {
1839
-                    if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) {
1838
+                if (false !== $args['item_price']) {
1839
+                    if (isset($item['item_price']) && (float) $args['item_price'] != (float) $item['item_price']) {
1840 1840
                         continue;
1841 1841
                     }
1842 1842
                 }
@@ -1845,13 +1845,13 @@  discard block
 block discarded – undo
1845 1845
                 break;
1846 1846
             }
1847 1847
         } else {
1848
-            $cart_index = absint( $args['cart_index'] );
1848
+            $cart_index = absint($args['cart_index']);
1849 1849
 
1850
-            if ( ! array_key_exists( $cart_index, $this->cart_details ) ) {
1850
+            if (!array_key_exists($cart_index, $this->cart_details)) {
1851 1851
                 return false; // Invalid cart index passed.
1852 1852
             }
1853 1853
 
1854
-            if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) {
1854
+            if ((int) $this->cart_details[$cart_index]['id'] > 0 && (int) $this->cart_details[$cart_index]['id'] !== (int) $item_id) {
1855 1855
                 return false; // We still need the proper Item ID to be sure.
1856 1856
             }
1857 1857
 
@@ -1859,41 +1859,41 @@  discard block
 block discarded – undo
1859 1859
         }
1860 1860
         
1861 1861
         $cart_item  = $this->cart_details[$found_cart_key];
1862
-        $quantity   = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1862
+        $quantity   = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1863 1863
         
1864
-        if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) {
1864
+        if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) {
1865 1865
             //return false; // Invoice must contain at least one item.
1866 1866
         }
1867 1867
         
1868
-        $discounts  = $this->get_discounts();
1868
+        $discounts = $this->get_discounts();
1869 1869
         
1870
-        if ( $quantity > $args['quantity'] ) {
1870
+        if ($quantity > $args['quantity']) {
1871 1871
             $item_price         = $cart_item['item_price'];
1872
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1872
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1873 1873
             
1874
-            $new_quantity       = max( $quantity - $args['quantity'], 1);
1874
+            $new_quantity       = max($quantity - $args['quantity'], 1);
1875 1875
             $subtotal           = $item_price * $new_quantity;
1876 1876
             
1877 1877
             $args['quantity']   = $new_quantity;
1878
-            $discount           = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1879
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1878
+            $discount           = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1879
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1880 1880
             
1881
-            $discount_decrease  = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0;
1882
-            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; 
1883
-            $tax_decrease       = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0;
1884
-            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease;
1881
+            $discount_decrease  = (float) $cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['discount'] / $quantity)) : 0;
1882
+            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float) $cart_item['discount'] > $discount ? (float) $cart_item['discount'] - $discount : $discount_decrease; 
1883
+            $tax_decrease       = (float) $cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['tax'] / $quantity)) : 0;
1884
+            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float) $cart_item['tax'] > $tax ? (float) $cart_item['tax'] - $tax : $tax_decrease;
1885 1885
             
1886 1886
             // The total increase equals the number removed * the item_price
1887
-            $total_decrease     = wpinv_round_amount( $item_price );
1887
+            $total_decrease     = wpinv_round_amount($item_price);
1888 1888
             
1889
-            if ( wpinv_prices_include_tax() ) {
1890
-                $subtotal -= wpinv_round_amount( $tax );
1889
+            if (wpinv_prices_include_tax()) {
1890
+                $subtotal -= wpinv_round_amount($tax);
1891 1891
             }
1892 1892
 
1893
-            $total              = $subtotal - $discount + $tax;
1893
+            $total = $subtotal - $discount + $tax;
1894 1894
 
1895 1895
             // Do not allow totals to go negative
1896
-            if( $total < 0 ) {
1896
+            if ($total < 0) {
1897 1897
                 $total = 0;
1898 1898
             }
1899 1899
             
@@ -1912,16 +1912,16 @@  discard block
 block discarded – undo
1912 1912
             
1913 1913
             $this->cart_details[$found_cart_key] = $cart_item;
1914 1914
             
1915
-            $remove_item = end( $this->cart_details );
1915
+            $remove_item = end($this->cart_details);
1916 1916
         } else {
1917 1917
             $item_price     = $cart_item['item_price'];
1918
-            $discount       = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1919
-            $tax            = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0;
1918
+            $discount       = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1919
+            $tax            = !empty($cart_item['tax']) ? $cart_item['tax'] : 0;
1920 1920
         
1921
-            $subtotal_decrease  = ( $item_price * $quantity ) - $discount;
1921
+            $subtotal_decrease  = ($item_price * $quantity) - $discount;
1922 1922
             $tax_decrease       = $tax;
1923 1923
 
1924
-            unset( $this->cart_details[$found_cart_key] );
1924
+            unset($this->cart_details[$found_cart_key]);
1925 1925
             
1926 1926
             $remove_item             = $args;
1927 1927
             $remove_item['id']       = $item_id;
@@ -1932,8 +1932,8 @@  discard block
 block discarded – undo
1932 1932
         $remove_item['action']      = 'remove';
1933 1933
         $this->pending['items'][]   = $remove_item;
1934 1934
                
1935
-        $this->decrease_subtotal( $subtotal_decrease );
1936
-        $this->decrease_tax( $tax_decrease );
1935
+        $this->decrease_subtotal($subtotal_decrease);
1936
+        $this->decrease_tax($tax_decrease);
1937 1937
         
1938 1938
         return true;
1939 1939
     }
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
     public function update_items($temp = false) {
1942 1942
         global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave;
1943 1943
         
1944
-        if ( !empty( $this->cart_details ) ) {
1944
+        if (!empty($this->cart_details)) {
1945 1945
             $wpi_nosave             = $temp;
1946 1946
             $cart_subtotal          = 0;
1947 1947
             $cart_discount          = 0;
@@ -1951,65 +1951,65 @@  discard block
 block discarded – undo
1951 1951
             $_POST['wpinv_country'] = $this->country;
1952 1952
             $_POST['wpinv_state']   = $this->state;
1953 1953
 
1954
-            foreach ( $this->cart_details as $key => $item ) {
1954
+            foreach ($this->cart_details as $key => $item) {
1955 1955
                 $item_price = $item['item_price'];
1956
-                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1957
-                $amount     = wpinv_round_amount( $item_price * $quantity );
1956
+                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1957
+                $amount     = wpinv_round_amount($item_price * $quantity);
1958 1958
                 $subtotal   = $item_price * $quantity;
1959 1959
                 
1960 1960
                 $wpi_current_id         = $this->ID;
1961 1961
                 $wpi_item_id            = $item['id'];
1962 1962
                 
1963
-                $discount   = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() );
1963
+                $discount   = wpinv_get_cart_item_discount_amount($item, $this->get_discounts());
1964 1964
                 
1965
-                $tax_rate   = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id );
1966
-                $tax_class  = $wpinv_euvat->get_item_class( $wpi_item_id );
1967
-                $tax        = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1965
+                $tax_rate   = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id);
1966
+                $tax_class  = $wpinv_euvat->get_item_class($wpi_item_id);
1967
+                $tax        = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1968 1968
 
1969
-                if ( ! $this->is_taxable() ) {
1969
+                if (!$this->is_taxable()) {
1970 1970
                     $tax = 0;
1971 1971
                 }
1972 1972
 
1973
-                if ( wpinv_prices_include_tax() ) {
1974
-                    $subtotal -= wpinv_round_amount( $tax );
1973
+                if (wpinv_prices_include_tax()) {
1974
+                    $subtotal -= wpinv_round_amount($tax);
1975 1975
                 }
1976 1976
 
1977
-                $total      = $subtotal - $discount + $tax;
1977
+                $total = $subtotal - $discount + $tax;
1978 1978
 
1979 1979
                 // Do not allow totals to go negative
1980
-                if( $total < 0 ) {
1980
+                if ($total < 0) {
1981 1981
                     $total = 0;
1982 1982
                 }
1983 1983
 
1984 1984
                 $cart_details[] = array(
1985 1985
                     'id'          => $item['id'],
1986 1986
                     'name'        => $item['name'],
1987
-                    'item_price'  => wpinv_round_amount( $item_price ),
1988
-                    'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ),
1987
+                    'item_price'  => wpinv_round_amount($item_price),
1988
+                    'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''),
1989 1989
                     'quantity'    => $quantity,
1990 1990
                     'discount'    => $discount,
1991
-                    'subtotal'    => wpinv_round_amount( $subtotal ),
1992
-                    'tax'         => wpinv_round_amount( $tax ),
1993
-                    'price'       => wpinv_round_amount( $total ),
1991
+                    'subtotal'    => wpinv_round_amount($subtotal),
1992
+                    'tax'         => wpinv_round_amount($tax),
1993
+                    'price'       => wpinv_round_amount($total),
1994 1994
                     'vat_rate'    => $tax_rate,
1995 1995
                     'vat_class'   => $tax_class,
1996 1996
                     'meta'        => isset($item['meta']) ? $item['meta'] : array(),
1997 1997
                     'fees'        => isset($item['fees']) ? $item['fees'] : array(),
1998 1998
                 );
1999 1999
 
2000
-                $cart_subtotal  += (float)($subtotal - $discount); // TODO
2001
-                $cart_discount  += (float)($discount);
2002
-                $cart_tax       += (float)($tax);
2000
+                $cart_subtotal  += (float) ($subtotal - $discount); // TODO
2001
+                $cart_discount  += (float) ($discount);
2002
+                $cart_tax       += (float) ($tax);
2003 2003
             }
2004
-            if ( $cart_subtotal < 0 ) {
2004
+            if ($cart_subtotal < 0) {
2005 2005
                 $cart_subtotal = 0;
2006 2006
             }
2007
-            if ( $cart_tax < 0 ) {
2007
+            if ($cart_tax < 0) {
2008 2008
                 $cart_tax = 0;
2009 2009
             }
2010
-            $this->subtotal = wpinv_round_amount( $cart_subtotal );
2011
-            $this->tax      = wpinv_round_amount( $cart_tax );
2012
-            $this->discount = wpinv_round_amount( $cart_discount );
2010
+            $this->subtotal = wpinv_round_amount($cart_subtotal);
2011
+            $this->tax      = wpinv_round_amount($cart_tax);
2012
+            $this->discount = wpinv_round_amount($cart_discount);
2013 2013
             
2014 2014
             $this->recalculate_total();
2015 2015
             
@@ -2021,177 +2021,177 @@  discard block
 block discarded – undo
2021 2021
     
2022 2022
     public function recalculate_totals($temp = false) {        
2023 2023
         $this->update_items($temp);
2024
-        $this->save( true );
2024
+        $this->save(true);
2025 2025
         
2026 2026
         return $this;
2027 2027
     }
2028 2028
     
2029 2029
     public function needs_payment() {
2030
-        $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this );
2030
+        $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this);
2031 2031
 
2032
-        if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free() ) ) {
2032
+        if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free())) {
2033 2033
             $needs_payment = true;
2034 2034
         } else {
2035 2035
             $needs_payment = false;
2036 2036
         }
2037 2037
 
2038
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses );
2038
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses);
2039 2039
     }
2040 2040
     
2041
-    public function get_checkout_payment_url( $with_key = false, $secret = false ) {
2041
+    public function get_checkout_payment_url($with_key = false, $secret = false) {
2042 2042
         $pay_url = wpinv_get_checkout_uri();
2043 2043
 
2044
-        if ( is_ssl() ) {
2045
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
2044
+        if (is_ssl()) {
2045
+            $pay_url = str_replace('http:', 'https:', $pay_url);
2046 2046
         }
2047 2047
         
2048 2048
         $key = $this->get_key();
2049 2049
 
2050
-        if ( $with_key ) {
2051
-            $pay_url = add_query_arg( 'invoice_key', $key, $pay_url );
2050
+        if ($with_key) {
2051
+            $pay_url = add_query_arg('invoice_key', $key, $pay_url);
2052 2052
         } else {
2053
-            $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url );
2053
+            $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url);
2054 2054
         }
2055 2055
         
2056
-        if ( $secret ) {
2057
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url );
2056
+        if ($secret) {
2057
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url);
2058 2058
         }
2059 2059
 
2060
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret );
2060
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret);
2061 2061
     }
2062 2062
     
2063
-    public function get_view_url( $with_key = false ) {
2064
-        $invoice_url = get_permalink( $this->ID );
2063
+    public function get_view_url($with_key = false) {
2064
+        $invoice_url = get_permalink($this->ID);
2065 2065
 
2066
-        if ( $with_key ) {
2067
-            $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
2066
+        if ($with_key) {
2067
+            $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
2068 2068
         }
2069 2069
 
2070
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this, $with_key );
2070
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this, $with_key);
2071 2071
     }
2072 2072
     
2073
-    public function generate_key( $string = '' ) {
2074
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2075
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
2073
+    public function generate_key($string = '') {
2074
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2075
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
2076 2076
     }
2077 2077
     
2078 2078
     public function is_recurring() {
2079
-        if ( empty( $this->cart_details ) ) {
2079
+        if (empty($this->cart_details)) {
2080 2080
             return false;
2081 2081
         }
2082 2082
         
2083 2083
         $has_subscription = false;
2084
-        foreach( $this->cart_details as $cart_item ) {
2085
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2084
+        foreach ($this->cart_details as $cart_item) {
2085
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2086 2086
                 $has_subscription = true;
2087 2087
                 break;
2088 2088
             }
2089 2089
         }
2090 2090
         
2091
-        if ( count( $this->cart_details ) > 1 ) {
2091
+        if (count($this->cart_details) > 1) {
2092 2092
             $has_subscription = false;
2093 2093
         }
2094 2094
 
2095
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
2095
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
2096 2096
     }
2097 2097
 
2098 2098
     public function is_free_trial() {
2099 2099
         $is_free_trial = false;
2100 2100
         
2101
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
2102
-            if ( !empty( $item ) && $item->has_free_trial() ) {
2101
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
2102
+            if (!empty($item) && $item->has_free_trial()) {
2103 2103
                 $is_free_trial = true;
2104 2104
             }
2105 2105
         }
2106 2106
 
2107
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
2107
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
2108 2108
     }
2109 2109
 
2110 2110
     public function is_initial_free() {
2111 2111
         $is_initial_free = false;
2112 2112
         
2113
-        if ( ! ( (float)wpinv_round_amount( $this->get_total() ) > 0 ) && $this->is_parent() && $this->is_recurring() && ! $this->is_free_trial() && ! $this->is_free() ) {
2113
+        if (!((float) wpinv_round_amount($this->get_total()) > 0) && $this->is_parent() && $this->is_recurring() && !$this->is_free_trial() && !$this->is_free()) {
2114 2114
             $is_initial_free = true;
2115 2115
         }
2116 2116
 
2117
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details );
2117
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details);
2118 2118
     }
2119 2119
     
2120
-    public function get_recurring( $object = false ) {
2120
+    public function get_recurring($object = false) {
2121 2121
         $item = NULL;
2122 2122
         
2123
-        if ( empty( $this->cart_details ) ) {
2123
+        if (empty($this->cart_details)) {
2124 2124
             return $item;
2125 2125
         }
2126 2126
         
2127
-        foreach( $this->cart_details as $cart_item ) {
2128
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2127
+        foreach ($this->cart_details as $cart_item) {
2128
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2129 2129
                 $item = $cart_item['id'];
2130 2130
                 break;
2131 2131
             }
2132 2132
         }
2133 2133
         
2134
-        if ( $object ) {
2135
-            $item = $item ? new WPInv_Item( $item ) : NULL;
2134
+        if ($object) {
2135
+            $item = $item ? new WPInv_Item($item) : NULL;
2136 2136
             
2137
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
2137
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
2138 2138
         }
2139 2139
 
2140
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
2140
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
2141 2141
     }
2142 2142
     
2143 2143
     public function get_subscription_name() {
2144
-        $item = $this->get_recurring( true );
2144
+        $item = $this->get_recurring(true);
2145 2145
         
2146
-        if ( empty( $item ) ) {
2146
+        if (empty($item)) {
2147 2147
             return NULL;
2148 2148
         }
2149 2149
         
2150
-        if ( !($name = $item->get_name()) ) {
2150
+        if (!($name = $item->get_name())) {
2151 2151
             $name = $item->post_name;
2152 2152
         }
2153 2153
 
2154
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this );
2154
+        return apply_filters('wpinv_invoice_get_subscription_name', $name, $this);
2155 2155
     }
2156 2156
     
2157 2157
     public function get_subscription_id() {
2158
-        $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true );
2158
+        $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true);
2159 2159
         
2160
-        if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) {
2161
-            $parent_invoice = wpinv_get_invoice( $this->parent_invoice );
2160
+        if (empty($subscription_id) && !empty($this->parent_invoice)) {
2161
+            $parent_invoice = wpinv_get_invoice($this->parent_invoice);
2162 2162
             
2163
-            $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true );
2163
+            $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true);
2164 2164
         }
2165 2165
         
2166 2166
         return $subscription_id;
2167 2167
     }
2168 2168
     
2169 2169
     public function is_parent() {
2170
-        $is_parent = empty( $this->parent_invoice ) ? true : false;
2170
+        $is_parent = empty($this->parent_invoice) ? true : false;
2171 2171
 
2172
-        return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this );
2172
+        return apply_filters('wpinv_invoice_is_parent', $is_parent, $this);
2173 2173
     }
2174 2174
     
2175 2175
     public function is_renewal() {
2176 2176
         $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false;
2177 2177
 
2178
-        return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this );
2178
+        return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this);
2179 2179
     }
2180 2180
     
2181 2181
     public function get_parent_payment() {
2182 2182
         $parent_payment = NULL;
2183 2183
         
2184
-        if ( $this->is_renewal() ) {
2185
-            $parent_payment = wpinv_get_invoice( $this->parent_invoice );
2184
+        if ($this->is_renewal()) {
2185
+            $parent_payment = wpinv_get_invoice($this->parent_invoice);
2186 2186
         }
2187 2187
         
2188 2188
         return $parent_payment;
2189 2189
     }
2190 2190
     
2191 2191
     public function is_paid() {
2192
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2192
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2193 2193
 
2194
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2194
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2195 2195
     }
2196 2196
 
2197 2197
     /**
@@ -2204,23 +2204,23 @@  discard block
 block discarded – undo
2204 2204
     }
2205 2205
     
2206 2206
     public function is_refunded() {
2207
-        $is_refunded = $this->has_status( array( 'wpi-refunded' ) );
2207
+        $is_refunded = $this->has_status(array('wpi-refunded'));
2208 2208
 
2209
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2209
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2210 2210
     }
2211 2211
     
2212 2212
     public function is_free() {
2213 2213
         $is_free = false;
2214 2214
         
2215
-        if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) {
2216
-            if ( $this->is_parent() && $this->is_recurring() ) {
2217
-                $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true;
2215
+        if (!((float) wpinv_round_amount($this->get_total()) > 0)) {
2216
+            if ($this->is_parent() && $this->is_recurring()) {
2217
+                $is_free = (float) wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true;
2218 2218
             } else {
2219 2219
                 $is_free = true;
2220 2220
             }
2221 2221
         }
2222 2222
         
2223
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2223
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2224 2224
     }
2225 2225
     
2226 2226
     public function has_vat() {
@@ -2228,41 +2228,41 @@  discard block
 block discarded – undo
2228 2228
         
2229 2229
         $requires_vat = false;
2230 2230
         
2231
-        if ( $this->country ) {
2231
+        if ($this->country) {
2232 2232
             $wpi_country        = $this->country;
2233 2233
             
2234
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2234
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2235 2235
         }
2236 2236
         
2237
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2237
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2238 2238
     }
2239 2239
     
2240 2240
     public function refresh_item_ids() {
2241 2241
         $item_ids = array();
2242 2242
         
2243
-        if ( !empty( $this->cart_details ) ) {
2244
-            foreach ( $this->cart_details as $key => $item ) {
2245
-                if ( !empty( $item['id'] ) ) {
2243
+        if (!empty($this->cart_details)) {
2244
+            foreach ($this->cart_details as $key => $item) {
2245
+                if (!empty($item['id'])) {
2246 2246
                     $item_ids[] = $item['id'];
2247 2247
                 }
2248 2248
             }
2249 2249
         }
2250 2250
         
2251
-        $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : '';
2251
+        $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : '';
2252 2252
         
2253
-        update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids );
2253
+        update_post_meta($this->ID, '_wpinv_item_ids', $item_ids);
2254 2254
     }
2255 2255
     
2256
-    public function get_invoice_quote_type( $post_id ) {
2257
-        if ( empty( $post_id ) ) {
2256
+    public function get_invoice_quote_type($post_id) {
2257
+        if (empty($post_id)) {
2258 2258
             return '';
2259 2259
         }
2260 2260
 
2261
-        $type = get_post_type( $post_id );
2261
+        $type = get_post_type($post_id);
2262 2262
 
2263
-        if ( 'wpi_invoice' === $type ) {
2263
+        if ('wpi_invoice' === $type) {
2264 2264
             $post_type = __('Invoice', 'invoicing');
2265
-        } else{
2265
+        } else {
2266 2266
             $post_type = __('Quote', 'invoicing');
2267 2267
         }
2268 2268
 
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,74 +1,74 @@  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
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-shortcode', __('Shortcode', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
     
35
-    if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
36
-        add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
35
+    if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
36
+        add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
37 37
     }
38 38
 
39 39
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40 40
 }
41
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
41
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
42 42
 
43
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
44
-    remove_action( 'save_post', __FUNCTION__ );
43
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
44
+    remove_action('save_post', __FUNCTION__);
45 45
     
46 46
     // $post_id and $post are required
47
-    if ( empty( $post_id ) || empty( $post ) ) {
47
+    if (empty($post_id) || empty($post)) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
51
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
52 52
         return;
53 53
     }
54 54
     
55 55
     // Dont' save meta boxes for revisions or autosaves
56
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
56
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
57 57
         return;
58 58
     }
59 59
         
60
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
61
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
60
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
61
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
62 62
             return;
63 63
         }
64 64
     
65
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
66
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
65
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
66
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
67 67
         }
68
-    } else if ( $post->post_type == 'wpi_item' ) {
68
+    } else if ($post->post_type == 'wpi_item') {
69 69
         // verify nonce
70
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
71
-            $fields                                 = array();
70
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
71
+            $fields = array();
72 72
             $fields['_wpinv_price']              = 'wpinv_item_price';
73 73
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
74 74
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -83,97 +83,97 @@  discard block
 block discarded – undo
83 83
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
84 84
             $fields['_minimum_price']            = 'wpinv_minimum_price';
85 85
             
86
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
86
+            if (!isset($_POST['wpinv_is_recurring'])) {
87 87
                 $_POST['wpinv_is_recurring'] = 0;
88 88
             }
89 89
 
90
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
90
+            if (!isset($_POST['wpinv_name_your_price'])) {
91 91
                 $_POST['wpinv_name_your_price'] = 0;
92 92
             }
93 93
             
94
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
94
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
95 95
                 $_POST['wpinv_free_trial'] = 0;
96 96
             }
97 97
             
98
-            foreach ( $fields as $field => $name ) {
99
-                if ( isset( $_POST[ $name ] ) ) {
100
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
98
+            foreach ($fields as $field => $name) {
99
+                if (isset($_POST[$name])) {
100
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
101 101
 
102
-                    if ( !$allowed ) {
102
+                    if (!$allowed) {
103 103
                         continue;
104 104
                     }
105 105
 
106
-                    if ( $field == '_wpinv_price' ) {
107
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
106
+                    if ($field == '_wpinv_price') {
107
+                        $value = wpinv_sanitize_amount($_POST[$name]);
108 108
                     } else {
109
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
109
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
110 110
                     }
111 111
                     
112
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
113
-                    update_post_meta( $post_id, $field, $value );
112
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
113
+                    update_post_meta($post_id, $field, $value);
114 114
                 }
115 115
             }
116 116
             
117
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
118
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
117
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
118
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
119 119
             }
120 120
         }
121 121
     }
122 122
 }
123
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
123
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
124 124
 
125 125
 function wpinv_register_item_meta_boxes() {    
126 126
     global $wpinv_euvat;
127 127
     
128
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
128
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
129 129
 
130
-    if ( $wpinv_euvat->allow_vat_rules() ) {
131
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
130
+    if ($wpinv_euvat->allow_vat_rules()) {
131
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
132 132
     }
133 133
     
134
-    if ( $wpinv_euvat->allow_vat_classes() ) {
135
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
134
+    if ($wpinv_euvat->allow_vat_classes()) {
135
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
136 136
     }
137 137
     
138
-    add_meta_box( 'wpinv_field_item_shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Items::shortcode', 'wpi_item', 'side', 'core' );
139
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
140
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
138
+    add_meta_box('wpinv_field_item_shortcode', __('Shortcode', 'invoicing'), 'WPInv_Meta_Box_Items::shortcode', 'wpi_item', 'side', 'core');
139
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
140
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
141 141
 }
142 142
 
143 143
 function wpinv_register_discount_meta_boxes() {
144
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
144
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
145 145
 }
146 146
 
147
-function wpinv_discount_metabox_details( $post ) {
147
+function wpinv_discount_metabox_details($post) {
148 148
     $discount_id    = $post->ID;
149
-    $discount       = wpinv_get_discount( $discount_id );
149
+    $discount       = wpinv_get_discount($discount_id);
150 150
     
151
-    $type               = wpinv_get_discount_type( $discount_id );
152
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
153
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
154
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
155
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
156
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
157
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
158
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
159
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
160
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
151
+    $type               = wpinv_get_discount_type($discount_id);
152
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
153
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
154
+    $min_total          = wpinv_get_discount_min_total($discount_id);
155
+    $max_total          = wpinv_get_discount_max_total($discount_id);
156
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
157
+    $single_use         = wpinv_discount_is_single_use($discount_id);
158
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
159
+    $start_date         = wpinv_get_discount_start_date($discount_id);
160
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
161 161
     
162
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
163
-        $start_time         = strtotime( $start_date );
164
-        $start_h            = date_i18n( 'H', $start_time );
165
-        $start_m            = date_i18n( 'i', $start_time );
166
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
162
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
163
+        $start_time         = strtotime($start_date);
164
+        $start_h            = date_i18n('H', $start_time);
165
+        $start_m            = date_i18n('i', $start_time);
166
+        $start_date         = date_i18n('Y-m-d', $start_time);
167 167
     } else {
168 168
         $start_h            = '00';
169 169
         $start_m            = '00';
170 170
     }
171 171
 
172
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
173
-        $expiration_time    = strtotime( $expiration_date );
174
-        $expiration_h       = date_i18n( 'H', $expiration_time );
175
-        $expiration_m       = date_i18n( 'i', $expiration_time );
176
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
172
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
173
+        $expiration_time    = strtotime($expiration_date);
174
+        $expiration_h       = date_i18n('H', $expiration_time);
175
+        $expiration_m       = date_i18n('i', $expiration_time);
176
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
177 177
     } else {
178 178
         $expiration_h       = '23';
179 179
         $expiration_m       = '59';
@@ -183,207 +183,207 @@  discard block
 block discarded – undo
183 183
     $max_total          = $max_total > 0 ? $max_total : '';
184 184
     $max_uses           = $max_uses > 0 ? $max_uses : '';
185 185
 ?>
186
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
187
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
186
+<?php do_action('wpinv_discount_form_top', $post); ?>
187
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
188 188
 <table class="form-table wpi-form-table">
189 189
     <tbody>
190
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
191
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
190
+        <?php do_action('wpinv_discount_form_first', $post); ?>
191
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
192 192
         <tr>
193 193
             <th valign="top" scope="row">
194
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
194
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
195 195
             </th>
196 196
             <td>
197
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
198
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
197
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
198
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
199 199
             </td>
200 200
         </tr>
201
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
201
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
202 202
         <tr>
203 203
             <th valign="top" scope="row">
204
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
204
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
205 205
             </th>
206 206
             <td>
207 207
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
208
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
209
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
208
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
209
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
210 210
                     <?php } ?>
211 211
                 </select>
212
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
212
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
213 213
             </td>
214 214
         </tr>
215
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
215
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
216 216
         <tr>
217 217
             <th valign="top" scope="row">
218
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
218
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
219 219
             </th>
220 220
             <td>
221
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
222
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
223
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
221
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
222
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
223
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
224 224
             </td>
225 225
         </tr>
226
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
226
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
227 227
         <tr>
228 228
             <th valign="top" scope="row">
229
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
229
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
230 230
             </th>
231 231
             <td>
232
-                <p><?php echo wpinv_item_dropdown( array(
232
+                <p><?php echo wpinv_item_dropdown(array(
233 233
                         'name'              => 'items[]',
234 234
                         'id'                => 'items',
235 235
                         'selected'          => $item_reqs,
236 236
                         'multiple'          => true,
237 237
                         'class'             => 'medium-text wpi_select2',
238
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
238
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
239 239
                         'show_recurring'    => true,
240
-                    ) ); ?>
240
+                    )); ?>
241 241
                 </p>
242
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
242
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
243 243
             </td>
244 244
         </tr>
245
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
245
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
246 246
         <tr>
247 247
             <th valign="top" scope="row">
248
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
248
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
249 249
             </th>
250 250
             <td>
251
-                <p><?php echo wpinv_item_dropdown( array(
251
+                <p><?php echo wpinv_item_dropdown(array(
252 252
                         'name'              => 'excluded_items[]',
253 253
                         'id'                => 'excluded_items',
254 254
                         'selected'          => $excluded_items,
255 255
                         'multiple'          => true,
256 256
                         'class'             => 'medium-text wpi_select2',
257
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
257
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
258 258
                         'show_recurring'    => true,
259
-                    ) ); ?>
259
+                    )); ?>
260 260
                 </p>
261
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
261
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
262 262
             </td>
263 263
         </tr>
264
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
264
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
265 265
         <tr>
266 266
             <th valign="top" scope="row">
267
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
267
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
268 268
             </th>
269 269
             <td>
270
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
271
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
272
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
270
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
271
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
272
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
273 273
                     <?php } ?>
274 274
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
275
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
276
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
275
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
276
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
277 277
                     <?php } ?>
278 278
                 </select>
279
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
279
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
280 280
             </td>
281 281
         </tr>
282
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
282
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
283 283
         <tr>
284 284
             <th valign="top" scope="row">
285
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
285
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
286 286
             </th>
287 287
             <td>
288
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
289
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
290
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
288
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
289
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
290
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
291 291
                     <?php } ?>
292 292
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
293
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
294
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
293
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
294
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
295 295
                     <?php } ?>
296 296
                 </select>
297
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
297
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
298 298
             </td>
299 299
         </tr>
300
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
300
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
301 301
         <tr>
302 302
             <th valign="top" scope="row">
303
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
303
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
304 304
             </th>
305 305
             <td>
306 306
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
307
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
307
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
308 308
             </td>
309 309
         </tr>
310
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
310
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
311 311
         <tr>
312 312
             <th valign="top" scope="row">
313
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
313
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
314 314
             </th>
315 315
             <td>
316 316
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
317
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
317
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
318 318
             </td>
319 319
         </tr>
320
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
320
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
321 321
         <tr>
322 322
             <th valign="top" scope="row">
323
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
323
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
324 324
             </th>
325 325
             <td>
326 326
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
327
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
328
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
327
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
328
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
329 329
                 </select>
330
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
330
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
331 331
             </td>
332 332
         </tr>
333
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
333
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
334 334
         <tr>
335 335
             <th valign="top" scope="row">
336
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
336
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
337 337
             </th>
338 338
             <td>
339 339
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
340
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
340
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
341 341
             </td>
342 342
         </tr>
343
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
343
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
344 344
         <tr>
345 345
             <th valign="top" scope="row">
346
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
346
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
347 347
             </th>
348 348
             <td>
349
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
350
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
349
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
350
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
351 351
             </td>
352 352
         </tr>
353
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
353
+        <?php do_action('wpinv_discount_form_last', $post); ?>
354 354
     </tbody>
355 355
 </table>
356
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
356
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
357 357
     <?php
358 358
 }
359 359
 
360
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
361
-    $post_type = !empty( $post ) ? $post->post_type : '';
360
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
361
+    $post_type = !empty($post) ? $post->post_type : '';
362 362
     
363
-    if ( $post_type != 'wpi_discount' ) {
363
+    if ($post_type != 'wpi_discount') {
364 364
         return;
365 365
     }
366 366
     
367
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
367
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
368 368
         return;
369 369
     }
370 370
     
371
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
371
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
372 372
         return;
373 373
     }
374 374
     
375
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
375
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
376 376
         return;
377 377
     }
378 378
     
379
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
379
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
380 380
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
381 381
     }
382 382
 
383
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
383
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
384 384
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
385 385
     }
386 386
     
387
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
387
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
388 388
 }
389
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
390 389
\ No newline at end of file
390
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
391 391
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  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_Items {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
 
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float) $invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type wpi_select2',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
127 127
 
128 128
                                             <div class="wp-clearfix">
129 129
                                                 <?php 
130
-                                                    echo wpinv_html_textarea( array(
130
+                                                    echo wpinv_html_textarea(array(
131 131
                                                         'name'  => '_wpinv_quick[excerpt]',
132 132
                                                         'id'    => '_wpinv_quick_excerpt',
133 133
                                                         'value' => '',
134 134
                                                         'class' => 'large-text',
135
-                                                        'label' => __( 'Item description', 'invoicing' ),
136
-                                                    ) ); 
135
+                                                        'label' => __('Item description', 'invoicing'),
136
+                                                    )); 
137 137
                                                 ?>
138 138
                                             </div>
139 139
 
140 140
                                             <div class="wp-clearfix">
141 141
                                                 <label class="wpi-item-actions">
142 142
                                                     <span class="input-text-wrap">
143
-                                                        <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
143
+                                                        <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
144 144
                                                     </span>
145 145
                                                 </label>
146 146
                                             </div>
147 147
                                         </td>
148 148
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
149
-                                        <?php if ( $item_quantities ) { ?>
149
+                                        <?php if ($item_quantities) { ?>
150 150
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
151 151
                                         <?php } ?>
152 152
                                         <td class="total"></td>
153
-                                        <?php if ( $use_taxes ) { ?>
153
+                                        <?php if ($use_taxes) { ?>
154 154
                                         <td class="tax"></td>
155 155
                                         <?php } ?>
156 156
                                         <td class="action"></td>
@@ -163,29 +163,29 @@  discard block
 block discarded – undo
163 163
                         <td colspan="<?php echo $cols; ?>"></td>
164 164
                     </tr>
165 165
                     <tr class="totals">
166
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
166
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
167 167
                         <td colspan="4">
168 168
                             <table cellspacing="0" cellpadding="0">
169 169
                                 <tr class="subtotal">
170
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
171
-                                    <td class="total"><?php echo $subtotal;?></td>
170
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
171
+                                    <td class="total"><?php echo $subtotal; ?></td>
172 172
                                     <td class="action"></td>
173 173
                                 </tr>
174 174
                                 <tr class="discount">
175
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
176
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
175
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
176
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179
-                                <?php if ( $use_taxes ) { ?>
179
+                                <?php if ($use_taxes) { ?>
180 180
                                 <tr class="tax">
181
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
182
-                                    <td class="total"><?php echo $tax;?></td>
181
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
182
+                                    <td class="total"><?php echo $tax; ?></td>
183 183
                                     <td class="action"></td>
184 184
                                 </tr>
185 185
                                 <?php } ?>
186 186
                                 <tr class="total">
187
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
188
-                                    <td class="total"><?php echo $total;?></td>
187
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
188
+                                    <td class="total"><?php echo $total; ?></td>
189 189
                                     <td class="action"></td>
190 190
                                 </tr>
191 191
                             </table>
@@ -196,90 +196,90 @@  discard block
 block discarded – undo
196 196
             <div class="wpinv-actions">
197 197
                 <?php ob_start(); ?>
198 198
                 <?php
199
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
200
-                        if ( !$invoice->is_recurring() ) {
201
-                            echo wpinv_item_dropdown( array(
199
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
200
+                        if (!$invoice->is_recurring()) {
201
+                            echo wpinv_item_dropdown(array(
202 202
                                 'name'             => 'wpinv_invoice_item',
203 203
                                 'id'               => 'wpinv_invoice_item',
204 204
                                 'show_recurring'   => true,
205 205
                                 'class'            => 'wpi_select2',
206
-                            ) );
206
+                            ));
207 207
                     ?>
208
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
208
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
209 209
                     <?php } ?>
210
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
211
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
210
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
211
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
212 212
             </div>
213 213
         </div>
214 214
         <?php
215 215
     }
216 216
 
217
-    public static function prices( $post ) {        
217
+    public static function prices($post) {        
218 218
         $symbol         = wpinv_currency_symbol();
219 219
         $position       = wpinv_currency_position();
220
-        $item           = new WPInv_Item( $post->ID );
220
+        $item           = new WPInv_Item($post->ID);
221 221
 
222 222
         $price                = $item->get_price();
223 223
         $is_dynamic_pricing   = $item->get_is_dynamic_pricing();
224 224
         $minimum_price        = $item->get_minimum_price();
225 225
         $is_recurring         = $item->is_recurring();
226 226
         $period               = $item->get_recurring_period();
227
-        $interval             = absint( $item->get_recurring_interval() );
228
-        $times                = absint( $item->get_recurring_limit() );
227
+        $interval             = absint($item->get_recurring_interval());
228
+        $times                = absint($item->get_recurring_limit());
229 229
         $free_trial           = $item->has_free_trial();
230 230
         $trial_interval       = $item->get_trial_interval();
231 231
         $trial_period         = $item->get_trial_period();
232 232
 
233 233
         $intervals            = array();
234
-        for ( $i = 1; $i <= 90; $i++ ) {
234
+        for ($i = 1; $i <= 90; $i++) {
235 235
             $intervals[$i] = $i;
236 236
         }
237 237
 
238
-        $interval       = $interval > 0 ? $interval : 1;
238
+        $interval = $interval > 0 ? $interval : 1;
239 239
 
240 240
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
241 241
 
242 242
         $minimum_price_style = 'margin-left: 24px;';
243
-        if(! $is_dynamic_pricing ) {
243
+        if (!$is_dynamic_pricing) {
244 244
             $minimum_price_style .= 'display: none;';
245 245
         }
246 246
 
247 247
         ?>
248
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
249
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
248
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
249
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
250 250
         </p>
251 251
 
252
-    <?php if( $item->supports_dynamic_pricing() ) { ?>
252
+    <?php if ($item->supports_dynamic_pricing()) { ?>
253 253
 
254 254
         <p class="wpinv-row-name-your-price">
255 255
             <label>
256
-                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> />
257
-                <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?>
256
+                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> />
257
+                <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?>
258 258
             </label>
259
-            <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?>
259
+            <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?>
260 260
         </p>
261 261
 
262 262
         <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>">
263 263
             <label>
264
-                <?php _e( 'Minimum Price', 'invoicing' ); ?>
265
-                <?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?>
264
+                <?php _e('Minimum Price', 'invoicing'); ?>
265
+                <?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?>
266 266
             </label>
267 267
 
268
-            <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?>
268
+            <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?>
269 269
         </p>
270 270
 
271 271
     <?php } ?>
272 272
 
273 273
         <p class="wpinv-row-is-recurring">
274 274
             <label for="wpinv_is_recurring">
275
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
276
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
275
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
276
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
277 277
             </label>
278
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
278
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
279 279
         </p>
280
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
281
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
282
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
280
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
281
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
282
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
283 283
                 'options'          => $intervals,
284 284
                 'name'             => 'wpinv_recurring_interval',
285 285
                 'id'               => 'wpinv_recurring_interval',
@@ -287,30 +287,30 @@  discard block
 block discarded – undo
287 287
                 'show_option_all'  => false,
288 288
                 'show_option_none' => false,
289 289
                 'class'            => 'wpi_select2',
290
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
291
-            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
290
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
291
+            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
292 292
             <span class="clear wpi-trial-clr"></span>
293 293
             <label class="wpinv-free-trial" for="wpinv_free_trial">
294
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
295
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
294
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool) $free_trial); ?> /> 
295
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
296 296
             </label>
297 297
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
298
-                <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
298
+                <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
299 299
             </label>
300
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
300
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
301 301
         </p>
302
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
303
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
302
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
303
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
304 304
         <?php
305 305
     }
306 306
 
307
-    public static function vat_rules( $post ) {
307
+    public static function vat_rules($post) {
308 308
         global $wpinv_euvat;
309 309
 
310
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
310
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
311 311
         ?>
312
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
313
-        <?php echo wpinv_html_select( array(
312
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
313
+        <?php echo wpinv_html_select(array(
314 314
                     'options'          => $wpinv_euvat->get_rules(),
315 315
                     'name'             => 'wpinv_vat_rules',
316 316
                     'id'               => 'wpinv_vat_rules',
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
                     'show_option_all'  => false,
319 319
                     'show_option_none' => false,
320 320
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
321
-                ) ); ?>
321
+                )); ?>
322 322
         </p>
323
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
324
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
325
-        <p class="wpi-m0"><?php _e( 'Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing' ); ?></p>
323
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
324
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
325
+        <p class="wpi-m0"><?php _e('Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing'); ?></p>
326 326
         <?php
327 327
     }
328 328
 
329
-    public static function vat_classes( $post ) {
329
+    public static function vat_classes($post) {
330 330
         global $wpinv_euvat;
331 331
         
332
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
332
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
333 333
         ?>
334
-        <p><?php echo wpinv_html_select( array(
334
+        <p><?php echo wpinv_html_select(array(
335 335
                     'options'          => $wpinv_euvat->get_all_classes(),
336 336
                     'name'             => 'wpinv_vat_class',
337 337
                     'id'               => 'wpinv_vat_class',
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
                     'show_option_all'  => false,
340 340
                     'show_option_none' => false,
341 341
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
342
-                ) ); ?>
342
+                )); ?>
343 343
         </p>
344
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
344
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
345 345
         <?php
346 346
     }
347 347
 
348
-    public static function item_info( $post ) {
349
-        $item_type = wpinv_get_item_type( $post->ID );
350
-        do_action( 'wpinv_item_info_metabox_before', $post );
348
+    public static function item_info($post) {
349
+        $item_type = wpinv_get_item_type($post->ID);
350
+        do_action('wpinv_item_info_metabox_before', $post);
351 351
         ?>
352
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
353
-        <?php echo wpinv_html_select( array(
352
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
353
+        <?php echo wpinv_html_select(array(
354 354
                     'options'          => wpinv_get_item_types(),
355 355
                     'name'             => 'wpinv_item_type',
356 356
                     'id'               => 'wpinv_item_type',
@@ -358,123 +358,123 @@  discard block
 block discarded – undo
358 358
                     'show_option_all'  => false,
359 359
                     'show_option_none' => false,
360 360
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
361
-                ) ); ?>
361
+                )); ?>
362 362
         </p>
363
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
363
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
364 364
         <?php
365
-        do_action( 'wpinv_item_info_metabox_after', $post );
365
+        do_action('wpinv_item_info_metabox_after', $post);
366 366
     }
367 367
 
368
-    public static function meta_values( $post ) {
369
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
368
+    public static function meta_values($post) {
369
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
370 370
             'type',
371 371
             'custom_id'
372
-        ) );
372
+        ));
373 373
 
374
-        if ( empty( $meta_keys ) ) {
374
+        if (empty($meta_keys)) {
375 375
             return;
376 376
         }
377 377
 
378
-        do_action( 'wpinv_meta_values_metabox_before', $post );
378
+        do_action('wpinv_meta_values_metabox_before', $post);
379 379
 
380
-        foreach ( $meta_keys as $meta_key ) {
380
+        foreach ($meta_keys as $meta_key) {
381 381
             ?>
382
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
382
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
383 383
             <?php 
384 384
         }
385 385
 
386
-        do_action( 'wpinv_meta_values_metabox_after', $post );
386
+        do_action('wpinv_meta_values_metabox_after', $post);
387 387
     }
388 388
 
389 389
     /**
390 390
      * Display the items buy now shortcode.
391 391
      */
392
-    public static function shortcode( $post ) {
392
+    public static function shortcode($post) {
393 393
 
394
-        if ( ! is_numeric( $post ) ) {
394
+        if (!is_numeric($post)) {
395 395
             $post = $post->ID;
396 396
         }
397
-        $label = '"' . __( 'Buy', 'invoicing' ) . '"';
397
+        $label = '"' . __('Buy', 'invoicing') . '"';
398 398
 
399 399
         echo "<input type='text' style='min-width: 100%; font-size: small;' value='[wpinv_buy items=$post label=$label]' disabled>";
400
-        echo "<p class='description'><a target='_blank' href='https://wpinvoicing.com/docs/core-plugin/core-shortcodes/#buy-button'>" . __( 'Learn More', 'invoicing' ) ."</a></p>";
400
+        echo "<p class='description'><a target='_blank' href='https://wpinvoicing.com/docs/core-plugin/core-shortcodes/#buy-button'>" . __('Learn More', 'invoicing') . "</a></p>";
401 401
     }
402 402
 
403
-    public static function save( $post_id, $data, $post ) {
404
-        $invoice        = new WPInv_Invoice( $post_id );
403
+    public static function save($post_id, $data, $post) {
404
+        $invoice        = new WPInv_Invoice($post_id);
405 405
 
406 406
         // Billing
407
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
408
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
409
-        $company        = sanitize_text_field( $data['wpinv_company'] );
410
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
411
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
412
-        $address        = sanitize_text_field( $data['wpinv_address'] );
413
-        $city           = sanitize_text_field( $data['wpinv_city'] );
414
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
415
-        $country        = sanitize_text_field( $data['wpinv_country'] );
416
-        $state          = sanitize_text_field( $data['wpinv_state'] );
407
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
408
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
409
+        $company        = sanitize_text_field($data['wpinv_company']);
410
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
411
+        $phone          = sanitize_text_field($data['wpinv_phone']);
412
+        $address        = sanitize_text_field($data['wpinv_address']);
413
+        $city           = sanitize_text_field($data['wpinv_city']);
414
+        $zip            = sanitize_text_field($data['wpinv_zip']);
415
+        $country        = sanitize_text_field($data['wpinv_country']);
416
+        $state          = sanitize_text_field($data['wpinv_state']);
417 417
 
418 418
         // Details
419
-        $status         = sanitize_text_field( $data['wpinv_status'] );
420
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
421
-        $number         = sanitize_text_field( $data['wpinv_number'] );
422
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
423
-        $date_created   = isset( $data['date_created'] ) ? sanitize_text_field( $data['date_created'] ) : '';
419
+        $status         = sanitize_text_field($data['wpinv_status']);
420
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
421
+        $number         = sanitize_text_field($data['wpinv_number']);
422
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
423
+        $date_created   = isset($data['date_created']) ? sanitize_text_field($data['date_created']) : '';
424 424
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
425 425
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
426 426
 
427 427
         $disable_taxes = 0;
428 428
 
429
-        if ( ! empty( $data['disable_taxes'] ) ) {
429
+        if (!empty($data['disable_taxes'])) {
430 430
             $disable_taxes = 1;
431 431
         }
432 432
 
433
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
434
-
435
-        $invoice->set( 'due_date', $due_date );
436
-        $invoice->set( 'first_name', $first_name );
437
-        $invoice->set( 'last_name', $last_name );
438
-        $invoice->set( 'company', $company );
439
-        $invoice->set( 'vat_number', $vat_number );
440
-        $invoice->set( 'phone', $phone );
441
-        $invoice->set( 'address', $address );
442
-        $invoice->set( 'city', $city );
443
-        $invoice->set( 'zip', $zip );
444
-        $invoice->set( 'country', $country );
445
-        $invoice->set( 'state', $state );
446
-        $invoice->set( 'status', $status );
447
-        $invoice->set( 'set', $status );
433
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
434
+
435
+        $invoice->set('due_date', $due_date);
436
+        $invoice->set('first_name', $first_name);
437
+        $invoice->set('last_name', $last_name);
438
+        $invoice->set('company', $company);
439
+        $invoice->set('vat_number', $vat_number);
440
+        $invoice->set('phone', $phone);
441
+        $invoice->set('address', $address);
442
+        $invoice->set('city', $city);
443
+        $invoice->set('zip', $zip);
444
+        $invoice->set('country', $country);
445
+        $invoice->set('state', $state);
446
+        $invoice->set('status', $status);
447
+        $invoice->set('set', $status);
448 448
         //$invoice->set( 'number', $number );
449 449
         //$invoice->set( 'discounts', $discounts );
450 450
         //$invoice->set( 'discount', $discount );
451
-        $invoice->set( 'disable_taxes', $disable_taxes );
452
-        $invoice->set( 'ip', $ip );
451
+        $invoice->set('disable_taxes', $disable_taxes);
452
+        $invoice->set('ip', $ip);
453 453
         $invoice->old_status = $_POST['original_post_status'];
454 454
         
455 455
         $currency = $invoice->get_currency();
456
-        if ( ! empty( $data['wpinv_currency'] ) ) {
457
-            $currency = sanitize_text_field( $data['wpinv_currency'] );
456
+        if (!empty($data['wpinv_currency'])) {
457
+            $currency = sanitize_text_field($data['wpinv_currency']);
458 458
         }
459 459
 
460
-        if ( empty( $currency ) ) {
460
+        if (empty($currency)) {
461 461
             $currency = wpinv_get_currency();
462 462
         }
463 463
 
464
-        if ( ! $invoice->is_paid() ) {
464
+        if (!$invoice->is_paid()) {
465 465
             $invoice->currency = $currency;
466 466
         }
467 467
 
468
-        if ( !empty( $data['wpinv_gateway'] ) ) {
469
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
468
+        if (!empty($data['wpinv_gateway'])) {
469
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
470 470
         }
471 471
         $saved = $invoice->save();
472 472
 
473
-        if ( ! empty( $date_created ) && strtotime( $date_created, current_time( 'timestamp' ) ) ) {
473
+        if (!empty($date_created) && strtotime($date_created, current_time('timestamp'))) {
474 474
 
475
-            $time = strtotime( $date_created, current_time( 'timestamp' ) );
476
-            $date = date( 'Y-m-d H:i:s', $time );
477
-            $date_gmt = get_gmt_from_date( $date );
475
+            $time = strtotime($date_created, current_time('timestamp'));
476
+            $date = date('Y-m-d H:i:s', $time);
477
+            $date_gmt = get_gmt_from_date($date);
478 478
 
479 479
             wp_update_post(
480 480
                 array(
@@ -489,37 +489,37 @@  discard block
 block discarded – undo
489 489
         }
490 490
 
491 491
         // Check for payment notes
492
-        if ( !empty( $data['invoice_note'] ) ) {
493
-            $note               = wp_kses( $data['invoice_note'], array() );
494
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
492
+        if (!empty($data['invoice_note'])) {
493
+            $note               = wp_kses($data['invoice_note'], array());
494
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
495 495
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
496 496
 
497
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
497
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
498 498
         }
499 499
 
500 500
         // Update user address if empty.
501
-        if ( $saved && !empty( $invoice ) ) {
502
-            if ( $user_id = $invoice->get_user_id() ) {
503
-                $user_address = wpinv_get_user_address( $user_id, false );
501
+        if ($saved && !empty($invoice)) {
502
+            if ($user_id = $invoice->get_user_id()) {
503
+                $user_address = wpinv_get_user_address($user_id, false);
504 504
 
505 505
                 if (empty($user_address['first_name'])) {
506
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
507
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
506
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
507
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
508 508
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
509
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
509
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
510 510
                 }
511 511
 
512 512
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
513
-                    update_user_meta( $user_id, '_wpinv_address', $address );
514
-                    update_user_meta( $user_id, '_wpinv_city', $city );
515
-                    update_user_meta( $user_id, '_wpinv_state', $state );
516
-                    update_user_meta( $user_id, '_wpinv_country', $country );
517
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
518
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
513
+                    update_user_meta($user_id, '_wpinv_address', $address);
514
+                    update_user_meta($user_id, '_wpinv_city', $city);
515
+                    update_user_meta($user_id, '_wpinv_state', $state);
516
+                    update_user_meta($user_id, '_wpinv_country', $country);
517
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
518
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
519 519
                 }
520 520
             }
521 521
 
522
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
522
+            do_action('wpinv_invoice_metabox_saved', $invoice);
523 523
         }
524 524
 
525 525
         return $saved;
Please login to merge, or discard this patch.
includes/wpinv-post-types.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -7,41 +7,41 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {
16 16
 
17 17
     $items_labels = array(
18
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
19
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
20
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
23
-        'new_item'           => __( 'New Item', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
25
-        'view_item'          => __( 'View Item', 'invoicing' ),
26
-        'all_items'          => __( 'Items', 'invoicing' ),
27
-        'search_items'       => __( 'Search Items', 'invoicing' ),
18
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
19
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
20
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
22
+        'add_new_item'       => __('Add New Item', 'invoicing'),
23
+        'new_item'           => __('New Item', 'invoicing'),
24
+        'edit_item'          => __('Edit Item', 'invoicing'),
25
+        'view_item'          => __('View Item', 'invoicing'),
26
+        'all_items'          => __('Items', 'invoicing'),
27
+        'search_items'       => __('Search Items', 'invoicing'),
28 28
         'parent_item_colon'  => '',
29
-        'not_found'          => __( 'No items found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
29
+        'not_found'          => __('No items found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
31 31
     );
32
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
32
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
33 33
 
34 34
     $cap_type          = 'wpi_item';
35 35
     $invoice_item_args = array(
36 36
         'labels'                => $items_labels,
37
-        'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
37
+        'description'           => __('This is where you can add new invoice items.', 'invoicing'),
38 38
         'public'                => false,
39 39
         'has_archive'           => false,
40 40
         '_builtin'              => false,
41 41
         'show_ui'               => true,
42 42
         'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
43 43
         'show_in_nav_menus'     => false,
44
-        'supports'              => array( 'title', 'excerpt' ),
44
+        'supports'              => array('title', 'excerpt'),
45 45
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
46 46
         'rewrite'               => false,
47 47
         'query_var'             => false,
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
         ),
69 69
         'can_export'            => true,
70 70
     );
71
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
71
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
72 72
 
73
-    register_post_type( 'wpi_item', $invoice_item_args );
73
+    register_post_type('wpi_item', $invoice_item_args);
74 74
 
75 75
     $cap_type = 'wpi_payment_form';
76 76
     register_post_type(
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
             'wpinv_register_post_type_payment_form',
80 80
             array(
81 81
                 'labels'             => array(
82
-                    'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
83
-                    'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
84
-                    'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
85
-                    'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
86
-                    'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
87
-                    'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
88
-                    'new_item'           => __( 'New Payment Form', 'invoicing' ),
89
-                    'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
90
-                    'view_item'          => __( 'View Payment Form', 'invoicing' ),
91
-                    'all_items'          => __( 'Payment Forms', 'invoicing' ),
92
-                    'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
93
-                    'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
94
-                    'not_found'          => __( 'No payment forms found.', 'invoicing' ),
95
-                    'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
82
+                    'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
83
+                    'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
84
+                    'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
85
+                    'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
86
+                    'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
87
+                    'add_new_item'       => __('Add New Payment Form', 'invoicing'),
88
+                    'new_item'           => __('New Payment Form', 'invoicing'),
89
+                    'edit_item'          => __('Edit Payment Form', 'invoicing'),
90
+                    'view_item'          => __('View Payment Form', 'invoicing'),
91
+                    'all_items'          => __('Payment Forms', 'invoicing'),
92
+                    'search_items'       => __('Search Payment Forms', 'invoicing'),
93
+                    'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
94
+                    'not_found'          => __('No payment forms found.', 'invoicing'),
95
+                    'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
96 96
                 ),
97
-                'description'        => __( 'Stores payment forms.', 'invoicing' ),
97
+                'description'        => __('Stores payment forms.', 'invoicing'),
98 98
                 'public'             => false,
99 99
                 'show_ui'            => true,
100 100
                 'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
@@ -105,37 +105,37 @@  discard block
 block discarded – undo
105 105
                 'has_archive'        => false,
106 106
                 'hierarchical'       => false,
107 107
                 'menu_position'      => null,
108
-                'supports'           => array( 'title' ),
108
+                'supports'           => array('title'),
109 109
                 'menu_icon'          => 'dashicons-media-form',
110 110
             )
111 111
         )
112 112
     );
113 113
 
114 114
     $labels = array(
115
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
116
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
117
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
118
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
119
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
120
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
121
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
122
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
123
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
124
-        'all_items'          => __( 'Invoices', 'invoicing' ),
125
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
126
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
127
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
128
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
115
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
116
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
117
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
118
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
119
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
120
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
121
+        'new_item'           => __('New Invoice', 'invoicing'),
122
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
123
+        'view_item'          => __('View Invoice', 'invoicing'),
124
+        'all_items'          => __('Invoices', 'invoicing'),
125
+        'search_items'       => __('Search Invoices', 'invoicing'),
126
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
127
+        'not_found'          => __('No invoices found.', 'invoicing'),
128
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
129 129
     );
130
-    $labels = apply_filters( 'wpinv_labels', $labels );
130
+    $labels = apply_filters('wpinv_labels', $labels);
131 131
     
132 132
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
133
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
133
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
134 134
 
135 135
     $cap_type = 'wpi_invoice';
136 136
     $args = array(
137 137
         'labels'             => $labels,
138
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
138
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
139 139
         'public'             => true,
140 140
         'can_export'         => true,
141 141
         '_builtin'           => false,
@@ -168,37 +168,37 @@  discard block
 block discarded – undo
168 168
         'has_archive'        => false,
169 169
         'hierarchical'       => false,
170 170
         'menu_position'      => null,
171
-        'supports'           => array( 'title', 'author' ),
171
+        'supports'           => array('title', 'author'),
172 172
         'menu_icon'          => 'dashicons-media-spreadsheet',
173 173
     );
174 174
             
175
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
175
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
176 176
     
177
-    register_post_type( 'wpi_invoice', $args );
177
+    register_post_type('wpi_invoice', $args);
178 178
 
179 179
     $labels = array(
180
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
181
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
182
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
183
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
184
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
185
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
186
-        'new_item'           => __( 'New Discount', 'invoicing' ),
187
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
188
-        'view_item'          => __( 'View Discount', 'invoicing' ),
189
-        'all_items'          => __( 'Discounts', 'invoicing' ),
190
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
191
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
192
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
193
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
180
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
181
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
182
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
183
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
184
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
185
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
186
+        'new_item'           => __('New Discount', 'invoicing'),
187
+        'edit_item'          => __('Edit Discount', 'invoicing'),
188
+        'view_item'          => __('View Discount', 'invoicing'),
189
+        'all_items'          => __('Discounts', 'invoicing'),
190
+        'search_items'       => __('Search Discounts', 'invoicing'),
191
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
192
+        'not_found'          => __('No discounts found.', 'invoicing'),
193
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
194 194
     );
195
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
195
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
196 196
 
197 197
     $cap_type = 'wpi_discount';
198 198
     
199 199
     $args = array(
200 200
         'labels'             => $labels,
201
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
201
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
202 202
         'public'             => false,
203 203
         'can_export'         => true,
204 204
         '_builtin'           => false,
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         ),
230 230
         'has_archive'        => false,
231 231
         'hierarchical'       => false,
232
-        'supports'           => array( 'title', 'excerpt' ),
232
+        'supports'           => array('title', 'excerpt'),
233 233
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
234 234
         'show_in_nav_menus'  => false,
235 235
         'show_in_admin_bar'  => true,
@@ -237,106 +237,106 @@  discard block
 block discarded – undo
237 237
         'menu_position'      => null,
238 238
     );
239 239
             
240
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
240
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
241 241
     
242
-    register_post_type( 'wpi_discount', $args );
242
+    register_post_type('wpi_discount', $args);
243 243
 }
244 244
 
245 245
 function wpinv_get_default_labels() {
246 246
     $defaults = array(
247
-       'singular' => __( 'Invoice', 'invoicing' ),
248
-       'plural'   => __( 'Invoices', 'invoicing' )
247
+       'singular' => __('Invoice', 'invoicing'),
248
+       'plural'   => __('Invoices', 'invoicing')
249 249
     );
250 250
     
251
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
251
+    return apply_filters('wpinv_default_invoices_name', $defaults);
252 252
 }
253 253
 
254
-function wpinv_get_label_singular( $lowercase = false ) {
254
+function wpinv_get_label_singular($lowercase = false) {
255 255
     $defaults = wpinv_get_default_labels();
256 256
     
257
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
257
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
258 258
 }
259 259
 
260
-function wpinv_get_label_plural( $lowercase = false ) {
260
+function wpinv_get_label_plural($lowercase = false) {
261 261
     $defaults = wpinv_get_default_labels();
262 262
     
263
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
263
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
264 264
 }
265 265
 
266
-function wpinv_change_default_title( $title ) {
267
-     if ( !is_admin() ) {
266
+function wpinv_change_default_title($title) {
267
+     if (!is_admin()) {
268 268
         $label = wpinv_get_label_singular();
269
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
269
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
270 270
         return $title;
271 271
      }
272 272
 
273 273
      $screen = get_current_screen();
274 274
 
275
-     if ( 'wpi_invoice' == $screen->post_type ) {
275
+     if ('wpi_invoice' == $screen->post_type) {
276 276
         $label = wpinv_get_label_singular();
277
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
277
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
278 278
      }
279 279
 
280 280
      return $title;
281 281
 }
282
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
282
+add_filter('enter_title_here', 'wpinv_change_default_title');
283 283
 
284 284
 function wpinv_register_post_status() {
285
-    register_post_status( 'wpi-pending', array(
286
-        'label'                     => _x( 'Pending', 'Invoice status', 'invoicing' ),
285
+    register_post_status('wpi-pending', array(
286
+        'label'                     => _x('Pending', 'Invoice status', 'invoicing'),
287 287
         'public'                    => true,
288 288
         'exclude_from_search'       => true,
289 289
         'show_in_admin_all_list'    => true,
290 290
         'show_in_admin_status_list' => true,
291
-        'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' )
292
-    ) );
293
-    register_post_status( 'wpi-processing', array(
294
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
291
+        'label_count'               => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing')
292
+    ));
293
+    register_post_status('wpi-processing', array(
294
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
295 295
         'public'                    => true,
296 296
         'exclude_from_search'       => true,
297 297
         'show_in_admin_all_list'    => true,
298 298
         'show_in_admin_status_list' => true,
299
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
300
-    ) );
301
-    register_post_status( 'wpi-onhold', array(
302
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
299
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
300
+    ));
301
+    register_post_status('wpi-onhold', array(
302
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
303 303
         'public'                    => true,
304 304
         'exclude_from_search'       => true,
305 305
         'show_in_admin_all_list'    => true,
306 306
         'show_in_admin_status_list' => true,
307
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
308
-    ) );
309
-    register_post_status( 'wpi-cancelled', array(
310
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
307
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
308
+    ));
309
+    register_post_status('wpi-cancelled', array(
310
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
311 311
         'public'                    => true,
312 312
         'exclude_from_search'       => true,
313 313
         'show_in_admin_all_list'    => true,
314 314
         'show_in_admin_status_list' => true,
315
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
316
-    ) );
317
-    register_post_status( 'wpi-refunded', array(
318
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
315
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
316
+    ));
317
+    register_post_status('wpi-refunded', array(
318
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
319 319
         'public'                    => true,
320 320
         'exclude_from_search'       => true,
321 321
         'show_in_admin_all_list'    => true,
322 322
         'show_in_admin_status_list' => true,
323
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
324
-    ) );
325
-    register_post_status( 'wpi-failed', array(
326
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
323
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
324
+    ));
325
+    register_post_status('wpi-failed', array(
326
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
327 327
         'public'                    => true,
328 328
         'exclude_from_search'       => true,
329 329
         'show_in_admin_all_list'    => true,
330 330
         'show_in_admin_status_list' => true,
331
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
332
-    ) );
333
-    register_post_status( 'wpi-renewal', array(
334
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
331
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
332
+    ));
333
+    register_post_status('wpi-renewal', array(
334
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
335 335
         'public'                    => true,
336 336
         'exclude_from_search'       => true,
337 337
         'show_in_admin_all_list'    => true,
338 338
         'show_in_admin_status_list' => true,
339
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
340
-    ) );
339
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
340
+    ));
341 341
 }
342
-add_action( 'init', 'wpinv_register_post_status', 10 );
342
+add_action('init', 'wpinv_register_post_status', 10);
Please login to merge, or discard this patch.