Passed
Push — master ( 9fddb7...b6ca0b )
by Brian
06:57 queued 02:55
created
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.