Passed
Pull Request — master (#377)
by Brian
04:53
created
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 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_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 
20 20
         } else {
21
-            echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>';
21
+            echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>';
22 22
         }
23 23
 
24 24
         echo '</ul>';
25 25
         ?>
26 26
         <div class="add_note">
27
-            <h4><?php _e( 'Add note', 'invoicing' ); ?></h4>
27
+            <h4><?php _e('Add note', 'invoicing'); ?></h4>
28 28
             <p>
29 29
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
30 30
             </p>
31 31
             <p>
32 32
                 <select name="invoice_note_type" id="invoice_note_type" class="regular-text">
33
-                    <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option>
34
-                    <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option>
33
+                    <option value=""><?php _e('Private note', 'invoicing'); ?></option>
34
+                    <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option>
35 35
                 </select>
36
-                <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
36
+                <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
37 37
             </p>
38 38
         </div>
39 39
         <?php
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,43 +21,43 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Invoice items.
30 30
         $items = $invoice->get_items();
31 31
 
32 32
         // New item url.
33
-        $new_item = admin_url( 'post-new.php?post_type=wpi_item' );
33
+        $new_item = admin_url('post-new.php?post_type=wpi_item');
34 34
 
35 35
         // Totals.
36 36
         $totals = array(
37 37
 
38 38
             'subtotal'  => array(
39
-                'label' => __( 'Items Subtotal', 'invoicing' ),
40
-                'value' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ) ),
39
+                'label' => __('Items Subtotal', 'invoicing'),
40
+                'value' => wpinv_price(wpinv_format_amount($invoice->get_subtotal())),
41 41
             ),
42 42
 
43 43
             'discount'  => array(
44
-                'label' => __( 'Total Discount', 'invoicing' ),
45
-                'value' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ) ),
44
+                'label' => __('Total Discount', 'invoicing'),
45
+                'value' => wpinv_price(wpinv_format_amount($invoice->get_total_discount())),
46 46
             ),
47 47
 
48 48
             'tax'       => array(
49
-                'label' => __( 'Total Tax', 'invoicing' ),
50
-                'value' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ) ),
49
+                'label' => __('Total Tax', 'invoicing'),
50
+                'value' => wpinv_price(wpinv_format_amount($invoice->get_total_tax())),
51 51
             ),
52 52
 
53 53
             'total'     => array(
54
-                'label' => __( 'Invoice Total', 'invoicing' ),
55
-                'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
54
+                'label' => __('Invoice Total', 'invoicing'),
55
+                'value' => wpinv_price(wpinv_format_amount($invoice->get_total())),
56 56
             )
57 57
         );
58 58
 
59
-        if ( ! wpinv_use_taxes() ) {
60
-            unset( $totals['tax'] );
59
+        if (!wpinv_use_taxes()) {
60
+            unset($totals['tax']);
61 61
         }
62 62
         ?>
63 63
 
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
             }
74 74
         </style>
75 75
 
76
-                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class( $invoice->get_template( 'edit' ) ); ?> <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
76
+                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class($invoice->get_template('edit')); ?> <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
77 77
 
78
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
79
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
78
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
79
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
80 80
 
81 81
                         <div class="row">
82 82
                             <div class="col-12 col-sm-6">
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
                                         array(
86 86
                                             'id'          => 'wpinv_template',
87 87
                                             'name'        => 'wpinv_template',
88
-                                            'label'       => __( 'Template', 'invoicing' ),
88
+                                            'label'       => __('Template', 'invoicing'),
89 89
                                             'label_type'  => 'vertical',
90
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
90
+                                            'placeholder' => __('Choose a template', 'invoicing'),
91 91
                                             'class'       => 'form-control-sm',
92
-                                            'value'       => $invoice->get_template( 'edit' ),
92
+                                            'value'       => $invoice->get_template('edit'),
93 93
                                             'options'     => array(
94
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
95
-                                                'hours'    => __( 'Hours', 'invoicing' ),
96
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
94
+                                                'quantity' => __('Quantity', 'invoicing'),
95
+                                                'hours'    => __('Hours', 'invoicing'),
96
+                                                'amount'   => __('Amount Only', 'invoicing'),
97 97
                                             ),
98 98
                                             'data-allow-clear' => 'false',
99 99
                                             'select2'          => true,
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
                                         array(
110 110
                                             'id'          => 'wpinv_currency',
111 111
                                             'name'        => 'wpinv_currency',
112
-                                            'label'       => __( 'Currency', 'invoicing' ),
112
+                                            'label'       => __('Currency', 'invoicing'),
113 113
                                             'label_type'  => 'vertical',
114
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
114
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
115 115
                                             'class'       => 'form-control-sm',
116
-                                            'value'       => $invoice->get_currency( 'edit' ),
116
+                                            'value'       => $invoice->get_currency('edit'),
117 117
                                             'required'    => false,
118 118
                                             'data-allow-clear' => 'false',
119 119
                                             'select2'          => true,
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
                             </div>
126 126
                         </div>
127 127
 
128
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
128
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
129 129
                     <?php endif; ?>
130 130
 
131 131
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
132 132
                         <thead>
133 133
                             <tr>
134
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
134
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
135 135
                                 <th class="getpaid-quantity hide-if-amount text-right">
136
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
137
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
136
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
137
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
138 138
                                 </th>
139 139
                                 <th class="getpaid-price hide-if-amount text-right">
140
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
141
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
140
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
141
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
142 142
                                 </th>
143 143
                                 <th class="getpaid-item-subtotal text-right">
144
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
145
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
144
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
145
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
146 146
                                 </th>
147 147
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
148 148
                             </tr>
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 		                <tbody class="getpaid_invoice_line_items">
151 151
                             <tr class="hide-if-has-items hide-if-not-editable">
152 152
                                 <td colspan="2" class="pt-4 pb-4">
153
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
154
-	                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
153
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
154
+	                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
155 155
                                 </td>
156 156
                                 <td class="hide-if-amount">&nbsp;</th>
157 157
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
                             <div class="col-12 col-sm-6 offset-sm-6">
184 184
                                 <table class="getpaid-invoice-totals text-right w-100">
185 185
                                     <tbody>
186
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
187
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
188
-                                                <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td>
186
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
187
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
188
+                                                <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td>
189 189
                                                 <td width="1%"></td>
190
-                                                <td class="value"><?php echo sanitize_text_field( $data['value'] ) ?></td>
190
+                                                <td class="value"><?php echo sanitize_text_field($data['value']) ?></td>
191 191
                                             </tr>
192 192
                                         <?php endforeach; ?>
193 193
                                     </tbody>
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
201 201
                         <div class="row">
202 202
                             <div class="text-left col-12 col-sm-8">
203
-                                <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
204
-                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
205
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
203
+                                <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
204
+                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
205
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
206 206
                             </div>
207 207
                             <div class="text-right col-12 col-sm-4">
208
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
208
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
209 209
                             </div>
210 210
                         </div>
211 211
                     </div>
212 212
 
213 213
                     <div class="getpaid-invoice-item-actions hide-if-editable">
214
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
214
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
215 215
                     </div>
216 216
 
217 217
                     <!-- Add items to an invoice -->
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
                         <div class="modal-dialog modal-dialog-centered" role="document">
220 220
                             <div class="modal-content">
221 221
                                 <div class="modal-header">
222
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
223
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
222
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
223
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
224 224
                                         <span aria-hidden="true">&times;</span>
225 225
                                     </button>
226 226
                                 </div>
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                                     <table class="widefat">
229 229
                                         <thead>
230 230
                                             <tr>
231
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
231
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
232 232
                                                 <th class="pr-0 text-right hide-if-amount">
233
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
234
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
233
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
234
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
235 235
                                                 </th>
236 236
                                             </tr>
237 237
                                         </thead>
238 238
 										<tbody>
239 239
 								            <tr>
240 240
 									            <td class="pl-0 text-left">
241
-                                                    <select class="getpaid-item-search regular-text" data-placeholder="<?php esc_attr_e( 'Search for an item…', 'invoicing' ); ?>"></select>
241
+                                                    <select class="getpaid-item-search regular-text" data-placeholder="<?php esc_attr_e('Search for an item…', 'invoicing'); ?>"></select>
242 242
                                                 </td>
243 243
 									            <td class="pr-0 text-right hide-if-amount">
244 244
                                                     <input type="number" class="w100" step="1" min="1" autocomplete="off" value="1" placeholder="1">
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 						            </table>
249 249
                                 </div>
250 250
                                 <div class="modal-footer">
251
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
252
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
251
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
252
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
253 253
                                 </div>
254 254
                             </div>
255 255
                         </div>
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
                         <div class="modal-dialog modal-dialog-centered" role="document">
261 261
                             <div class="modal-content">
262 262
                                 <div class="modal-header">
263
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
264
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
263
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
264
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
265 265
                                         <span aria-hidden="true">&times;</span>
266 266
                                     </button>
267 267
                                 </div>
@@ -269,27 +269,27 @@  discard block
 block discarded – undo
269 269
                                     <div class="getpaid-edit-item-div">
270 270
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
271 271
                                         <label class="form-group w-100">
272
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
273
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
272
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
273
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
274 274
                                         </label>
275 275
                                         <label class="form-group w-100">
276
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
277
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
278
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
276
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
277
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
278
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
279 279
                                         </label>
280 280
                                         <label class="form-group w-100 hide-if-amount">
281
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
281
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
282 282
                                             <input type="number" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
283 283
                                         </label>
284 284
                                         <label class="form-group w-100">
285
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
286
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
285
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
286
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
287 287
                                         </label>
288 288
                                     </div>
289 289
                                 </div>
290 290
                                 <div class="modal-footer">
291
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
292
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
291
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
292
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
293 293
                                 </div>
294 294
                             </div>
295 295
                         </div>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -289,35 +289,35 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
     /**
292
-	 * Save meta box data.
293
-	 *
294
-	 * @param int $post_id
295
-	 */
296
-	public static function save( $post_id ) {
292
+     * Save meta box data.
293
+     *
294
+     * @param int $post_id
295
+     */
296
+    public static function save( $post_id ) {
297 297
 
298 298
         // Prepare the item.
299 299
         $item = new WPInv_Item( $post_id );
300 300
 
301 301
         // Load new data.
302 302
         $item->set_props(
303
-			array(
304
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
303
+            array(
304
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
+                'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
309 309
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null,
310
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
317
-			)
310
+                'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
317
+            )
318 318
         );
319 319
 
320
-		$item->save();
321
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
322
-	}
320
+        $item->save();
321
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
322
+    }
323 323
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <input type="hidden" id="_wpi_is_editable" value="<?php echo (int) $item->is_editable(); ?>" />
46 46
         <style>
47 47
             #poststuff .input-group-text,
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
         </style>
52 52
         <div class='bsui' style='max-width: 600px;padding-top: 10px; max-width: 820px;'>
53 53
 
54
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
54
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
55 55
             <div class="form-group row">
56
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
56
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
57 57
                 <div class="col-sm-8">
58 58
                     <div class="row">
59 59
                         <div class="col-sm-4 getpaid-price-input">
60 60
                             <div class="input-group input-group-sm">
61
-                                <?php if( 'left' == $position ) : ?>
61
+                                <?php if ('left' == $position) : ?>
62 62
                                 <div class="input-group-prepend">
63 63
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
64 64
                                 </div>
65 65
                                 <?php endif; ?>
66
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
66
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
67 67
 
68
-                                <?php if( 'left' != $position ) : ?>
68
+                                <?php if ('left' != $position) : ?>
69 69
                                 <div class="input-group-append">
70 70
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
71 71
                                 </div>
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
                                     array(
80 80
                                         'id'               => 'wpinv_recurring_interval',
81 81
                                         'name'             => 'wpinv_recurring_interval',
82
-                                        'label'            => __( 'Interval', 'invoicing' ),
83
-                                        'placeholder'      => __( 'Select Interval', 'invoicing' ),
84
-                                        'value'            => $item->get_recurring_interval( 'edit' ),
82
+                                        'label'            => __('Interval', 'invoicing'),
83
+                                        'placeholder'      => __('Select Interval', 'invoicing'),
84
+                                        'value'            => $item->get_recurring_interval('edit'),
85 85
                                         'select2'          => true,
86 86
                                         'data-allow-clear' => 'false',
87 87
                                         'options'          => array(
88
-                                            '1'  => __( 'every', 'invoicing' ),
89
-                                            '2'  => __( 'every 2nd', 'invoicing' ),
90
-                                            '3'  => __( 'every 3rd', 'invoicing' ),
91
-                                            '4'  => __( 'every 4th', 'invoicing' ),
92
-                                            '5'  => __( 'every 5th', 'invoicing' ),
93
-                                            '6'  => __( 'every 6th', 'invoicing' ),
94
-                                            '8'  => __( 'every 8th', 'invoicing' ),
95
-                                            '9'  => __( 'every 9th', 'invoicing' ),
96
-                                            '10' => __( 'every 10th', 'invoicing' ),
97
-                                            '11' => __( 'every 11th', 'invoicing' ),
98
-                                            '12' => __( 'every 12th', 'invoicing' ),
99
-                                            '13' => __( 'every 13th', 'invoicing' ),
100
-                                            '14' => __( 'every 14th', 'invoicing' ),
88
+                                            '1'  => __('every', 'invoicing'),
89
+                                            '2'  => __('every 2nd', 'invoicing'),
90
+                                            '3'  => __('every 3rd', 'invoicing'),
91
+                                            '4'  => __('every 4th', 'invoicing'),
92
+                                            '5'  => __('every 5th', 'invoicing'),
93
+                                            '6'  => __('every 6th', 'invoicing'),
94
+                                            '8'  => __('every 8th', 'invoicing'),
95
+                                            '9'  => __('every 9th', 'invoicing'),
96
+                                            '10' => __('every 10th', 'invoicing'),
97
+                                            '11' => __('every 11th', 'invoicing'),
98
+                                            '12' => __('every 12th', 'invoicing'),
99
+                                            '13' => __('every 13th', 'invoicing'),
100
+                                            '14' => __('every 14th', 'invoicing'),
101 101
                                         )
102 102
                                     )
103 103
                                 );
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
                                     array(
110 110
                                         'id'               => 'wpinv_recurring_period',
111 111
                                         'name'             => 'wpinv_recurring_period',
112
-                                        'label'            => __( 'Period', 'invoicing' ),
113
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
114
-                                        'value'            => $item->get_recurring_period( 'edit' ),
112
+                                        'label'            => __('Period', 'invoicing'),
113
+                                        'placeholder'      => __('Select Period', 'invoicing'),
114
+                                        'value'            => $item->get_recurring_period('edit'),
115 115
                                         'select2'          => true,
116 116
                                         'data-allow-clear' => 'false',
117 117
                                         'options'     => array(
118
-                                            'D'  => __( 'day', 'invoicing' ),
119
-                                            'W'  => __( 'week', 'invoicing' ),
120
-                                            'M'  => __( 'month', 'invoicing' ),
121
-                                            'Y'  => __( 'year', 'invoicing' ),
118
+                                            'D'  => __('day', 'invoicing'),
119
+                                            'W'  => __('week', 'invoicing'),
120
+                                            'M'  => __('month', 'invoicing'),
121
+                                            'Y'  => __('year', 'invoicing'),
122 122
                                         )
123 123
                                     )
124 124
                                 );
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                             <?php
131 131
 
132 132
                                 // Dynamic pricing.
133
-                                if( $item->supports_dynamic_pricing() ) {
133
+                                if ($item->supports_dynamic_pricing()) {
134 134
 
135
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
135
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
136 136
 
137 137
                                     // NYP toggle.
138 138
                                     echo aui()->input(
@@ -140,31 +140,31 @@  discard block
 block discarded – undo
140 140
                                             'id'          => 'wpinv_name_your_price',
141 141
                                             'name'        => 'wpinv_name_your_price',
142 142
                                             'type'        => 'checkbox',
143
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
143
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
144 144
                                             'value'       => '1',
145 145
                                             'checked'     => $item->user_can_set_their_price(),
146 146
                                             'no_wrap'     => true,
147 147
                                         )
148 148
                                     );
149 149
 
150
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
150
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
151 151
 
152 152
                                 }
153 153
 
154 154
                                 // Subscriptions.
155
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
155
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
156 156
                                 echo aui()->input(
157 157
                                     array(
158 158
                                         'id'          => 'wpinv_is_recurring',
159 159
                                         'name'        => 'wpinv_is_recurring',
160 160
                                         'type'        => 'checkbox',
161
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
161
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
162 162
                                         'value'       => '1',
163 163
                                         'checked'     => $item->is_recurring(),
164 164
                                         'no_wrap'     => true,
165 165
                                     )
166 166
                                 );
167
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
167
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
168 168
 
169 169
                             ?>
170 170
                             <div class="wpinv_show_if_recurring">
@@ -174,30 +174,30 @@  discard block
 block discarded – undo
174 174
                     </div>
175 175
                 </div>
176 176
                 <div class="col-sm-1 pt-2 pl-0">
177
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
177
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
178 178
                 </div>
179 179
             </div>
180
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
180
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
181 181
 
182
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
183
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
182
+            <?php if ($item->supports_dynamic_pricing()) : ?>
183
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
184 184
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
185 185
 
186 186
                     <div class="form-group row">
187 187
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
188
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
188
+                            <?php _e('Minimum Price', 'invoicing'); ?>
189 189
                         </label>
190 190
                         <div class="col-sm-8">
191 191
                             <div class="input-group input-group-sm">
192
-                                <?php if( 'left' == $position ) : ?>
192
+                                <?php if ('left' == $position) : ?>
193 193
                                     <div class="input-group-prepend">
194 194
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
195 195
                                     </div>
196 196
                                 <?php endif; ?>
197 197
 
198
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
198
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
199 199
 
200
-                                <?php if( 'left' != $position ) : ?>
200
+                                <?php if ('left' != $position) : ?>
201 201
                                     <div class="input-group-append">
202 202
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
203 203
                                     </div>
@@ -206,45 +206,45 @@  discard block
 block discarded – undo
206 206
                         </div>
207 207
 
208 208
                         <div class="col-sm-1 pt-2 pl-0">
209
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
209
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
210 210
                         </div>
211 211
                     </div>
212 212
 
213 213
                 </div>
214
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
214
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
215 215
             <?php endif; ?>
216 216
 
217
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
217
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
218 218
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
219 219
 
220 220
                 <div class="form-group row">
221 221
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
222
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
222
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
223 223
                     </label>
224 224
                     <div class="col-sm-8">
225
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
225
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
226 226
                     </div>
227 227
                     <div class="col-sm-1 pt-2 pl-0">
228
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
228
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
229 229
                     </div>
230 230
                 </div>
231 231
 
232 232
             </div>
233
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
233
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
234 234
 
235
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
235
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
236 236
             <div class="wpinv_show_if_recurring wpinv_free_trial">
237 237
 
238 238
                 <div class="form-group row">
239
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label>
239
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label>
240 240
 
241 241
                     <div class="col-sm-8">
242 242
                         <div class="row">
243 243
                             <div class="col-sm-6">
244
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
244
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
245 245
 
246 246
                                 <div>
247
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
247
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
248 248
                                 </div>
249 249
                             </div>
250 250
                             <div class="col-sm-6">
@@ -253,17 +253,17 @@  discard block
 block discarded – undo
253 253
                                         array(
254 254
                                             'id'               => 'wpinv_trial_period',
255 255
                                             'name'             => 'wpinv_trial_period',
256
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
257
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
258
-                                            'value'            => $item->get_recurring_period( 'edit' ),
256
+                                            'label'            => __('Trial Period', 'invoicing'),
257
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
258
+                                            'value'            => $item->get_recurring_period('edit'),
259 259
                                             'select2'          => true,
260 260
                                             'data-allow-clear' => 'false',
261 261
                                             'no_wrap'          => true,
262 262
                                             'options'          => array(
263
-                                                'D'  => __( 'day(s)', 'invoicing' ),
264
-                                                'W'  => __( 'week(s)', 'invoicing' ),
265
-                                                'M'  => __( 'month(s)', 'invoicing' ),
266
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
263
+                                                'D'  => __('day(s)', 'invoicing'),
264
+                                                'W'  => __('week(s)', 'invoicing'),
265
+                                                'M'  => __('month(s)', 'invoicing'),
266
+                                                'Y'  => __('year(s)', 'invoicing'),
267 267
                                             )
268 268
                                         )
269 269
                                     );
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
                     </div>
275 275
 
276 276
                     <div class="col-sm-1 pt-2 pl-0">
277
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
277
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
278 278
                     </div>
279 279
 
280 280
                 </div>
281 281
 
282 282
             </div>
283
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
283
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
284 284
 
285
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
285
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
286 286
         </div>
287 287
         <?php
288 288
 
@@ -293,31 +293,31 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param int $post_id
295 295
 	 */
296
-	public static function save( $post_id ) {
296
+	public static function save($post_id) {
297 297
 
298 298
         // Prepare the item.
299
-        $item = new WPInv_Item( $post_id );
299
+        $item = new WPInv_Item($post_id);
300 300
 
301 301
         // Load new data.
302 302
         $item->set_props(
303 303
 			array(
304
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
309
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null,
310
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
304
+				'price'                => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null,
305
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
306
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
307
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
308
+				'is_dynamic_pricing'   => isset($_POST['wpinv_name_your_price']),
309
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null,
310
+				'is_recurring'         => isset($_POST['wpinv_is_recurring']),
311
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
312
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
315
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
316
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
317 317
 			)
318 318
         );
319 319
 
320 320
 		$item->save();
321
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
321
+		do_action('getpaid_item_metabox_save', $post_id, $item);
322 322
 	}
323 323
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
     }
301 301
 
302 302
     /**
303
-	 * Save meta box data.
304
-	 *
305
-	 * @param int $post_id
306
-	 */
307
-	public static function save( $post_id ) {
303
+     * Save meta box data.
304
+     *
305
+     * @param int $post_id
306
+     */
307
+    public static function save( $post_id ) {
308 308
 
309 309
         // Prepare the invoice.
310 310
         $invoice = new WPInv_Invoice( $post_id );
311 311
 
312 312
         // Load new data.
313 313
         $invoice->set_props(
314
-			array(
314
+            array(
315 315
                 'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
316 316
                 'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
317 317
                 'disable_taxes'        => isset( $_POST['disable_taxes'] ),
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                 'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
333 333
                 'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
334 334
                 'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
335
-			)
335
+            )
336 336
         );
337 337
 
338 338
         // Recalculate totals.
@@ -362,6 +362,6 @@  discard block
 block discarded – undo
362 362
         }
363 363
 
364 364
         // Fires after an invoice is saved.
365
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
-	}
365
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
+    }
367 367
 }
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
29
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
30 30
 
31 31
         ?>
32 32
 
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
                         <div class="col-12 col-sm-6">
43 43
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
44 44
                                 <div>
45
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
45
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
46 46
                                 </div>
47 47
                                 <?php 
48 48
                                     wpinv_dropdown_users(
49 49
                                         array(
50 50
                                             'name'             => 'post_author_override',
51
-                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(),
51
+                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(),
52 52
                                             'include_selected' => true,
53 53
                                             'show'             => 'display_name_with_email',
54 54
                                             'orderby'          => 'user_email',
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                                             'type'        => 'text',
67 67
                                             'id'          => 'getpaid-invoice-new-user-email',
68 68
                                             'name'        => 'wpinv_email',
69
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
69
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
70 70
                                             'label_type'  => 'vertical',
71 71
                                             'placeholder' => '[email protected]',
72 72
                                             'class'       => 'form-control-sm',
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
                             </div>
77 77
                         </div>
78 78
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
79
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
79
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
80 80
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
81 81
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
82
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
82
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
83 83
                                 </a>
84 84
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
85 85
                                     <i aria-hidden="true" class="fa fa-plus"></i>
86
-                                    <?php _e( 'Add New User', 'invoicing' );?>
86
+                                    <?php _e('Add New User', 'invoicing'); ?>
87 87
                                 </a>
88 88
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
89 89
                                     <i aria-hidden="true" class="fa fa-close"></i>
90
-                                    <?php _e( 'Cancel', 'invoicing' );?>
90
+                                    <?php _e('Cancel', 'invoicing'); ?>
91 91
                                 </a>
92 92
                             <?php endif; ?>
93 93
                         </div>
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
                                         'type'        => 'text',
101 101
                                         'id'          => 'wpinv_first_name',
102 102
                                         'name'        => 'wpinv_first_name',
103
-                                        'label'       => __( 'First Name', 'invoicing' ),
103
+                                        'label'       => __('First Name', 'invoicing'),
104 104
                                         'label_type'  => 'vertical',
105 105
                                         'placeholder' => 'Jane',
106 106
                                         'class'       => 'form-control-sm',
107
-                                        'value'       => $invoice->get_first_name( 'edit' ),
107
+                                        'value'       => $invoice->get_first_name('edit'),
108 108
                                     )
109 109
                                 );
110 110
                             ?>
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
                                         'type'        => 'text',
117 117
                                         'id'          => 'wpinv_last_name',
118 118
                                         'name'        => 'wpinv_last_name',
119
-                                        'label'       => __( 'Last Name', 'invoicing' ),
119
+                                        'label'       => __('Last Name', 'invoicing'),
120 120
                                         'label_type'  => 'vertical',
121 121
                                         'placeholder' => 'Doe',
122 122
                                         'class'       => 'form-control-sm',
123
-                                        'value'       => $invoice->get_last_name( 'edit' ),
123
+                                        'value'       => $invoice->get_last_name('edit'),
124 124
                                     )
125 125
                                 );
126 126
                             ?>
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
                                         'type'        => 'text',
136 136
                                         'id'          => 'wpinv_company',
137 137
                                         'name'        => 'wpinv_company',
138
-                                        'label'       => __( 'Company', 'invoicing' ),
138
+                                        'label'       => __('Company', 'invoicing'),
139 139
                                         'label_type'  => 'vertical',
140 140
                                         'placeholder' => 'Acme Corporation',
141 141
                                         'class'       => 'form-control-sm',
142
-                                        'value'       => $invoice->get_company( 'edit' ),
142
+                                        'value'       => $invoice->get_company('edit'),
143 143
                                     )
144 144
                                 );
145 145
                             ?>
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
                                         'type'        => 'text',
152 152
                                         'id'          => 'wpinv_vat_number',
153 153
                                         'name'        => 'wpinv_vat_number',
154
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
154
+                                        'label'       => __('Vat Number', 'invoicing'),
155 155
                                         'label_type'  => 'vertical',
156 156
                                         'placeholder' => '1234567890',
157 157
                                         'class'       => 'form-control-sm',
158
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
158
+                                        'value'       => $invoice->get_vat_number('edit'),
159 159
                                     )
160 160
                                 );
161 161
                             ?>
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
                                         'type'        => 'text',
171 171
                                         'id'          => 'wpinv_address',
172 172
                                         'name'        => 'wpinv_address',
173
-                                        'label'       => __( 'Address', 'invoicing' ),
173
+                                        'label'       => __('Address', 'invoicing'),
174 174
                                         'label_type'  => 'vertical',
175 175
                                         'placeholder' => 'Blekersdijk 295',
176 176
                                         'class'       => 'form-control-sm',
177
-                                        'value'       => $invoice->get_address( 'edit' ),
177
+                                        'value'       => $invoice->get_address('edit'),
178 178
                                     )
179 179
                                 );
180 180
                             ?>
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
                                         'type'        => 'text',
187 187
                                         'id'          => 'wpinv_city',
188 188
                                         'name'        => 'wpinv_city',
189
-                                        'label'       => __( 'City', 'invoicing' ),
189
+                                        'label'       => __('City', 'invoicing'),
190 190
                                         'label_type'  => 'vertical',
191 191
                                         'placeholder' => 'Dolembreux',
192 192
                                         'class'       => 'form-control-sm',
193
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
193
+                                        'value'       => $invoice->get_vat_number('edit'),
194 194
                                     )
195 195
                                 );
196 196
                             ?>
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
                                     array(
205 205
                                         'id'          => 'wpinv_country',
206 206
                                         'name'        => 'wpinv_country',
207
-                                        'label'       => __( 'Country', 'invoicing' ),
207
+                                        'label'       => __('Country', 'invoicing'),
208 208
                                         'label_type'  => 'vertical',
209
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
209
+                                        'placeholder' => __('Choose a country', 'invoicing'),
210 210
                                         'class'       => 'form-control-sm',
211
-                                        'value'       => $invoice->get_country( 'edit' ),
211
+                                        'value'       => $invoice->get_country('edit'),
212 212
                                         'options'     => wpinv_get_country_list(),
213 213
                                         'data-allow-clear' => 'false',
214 214
                                         'select2'          => true,
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
                         <div class="col-12 col-sm-6">
220 220
                             <?php
221 221
 
222
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
222
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
223 223
 
224
-                                if ( empty( $states ) ) {
224
+                                if (empty($states)) {
225 225
 
226 226
                                     echo aui()->input(
227 227
                                         array(
228 228
                                             'type'        => 'text',
229 229
                                             'id'          => 'wpinv_state',
230 230
                                             'name'        => 'wpinv_state',
231
-                                            'label'       => __( 'State', 'invoicing' ),
231
+                                            'label'       => __('State', 'invoicing'),
232 232
                                             'label_type'  => 'vertical',
233 233
                                             'placeholder' => 'Liège',
234 234
                                             'class'       => 'form-control-sm',
235
-                                            'value'       => $invoice->get_state( 'edit' ),
235
+                                            'value'       => $invoice->get_state('edit'),
236 236
                                         )
237 237
                                     );
238 238
 
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
                                         array(
243 243
                                             'id'          => 'wpinv_state',
244 244
                                             'name'        => 'wpinv_state',
245
-                                            'label'       => __( 'State', 'invoicing' ),
245
+                                            'label'       => __('State', 'invoicing'),
246 246
                                             'label_type'  => 'vertical',
247
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
247
+                                            'placeholder' => __('Select a state', 'invoicing'),
248 248
                                             'class'       => 'form-control-sm',
249
-                                            'value'       => $invoice->get_state( 'edit' ),
249
+                                            'value'       => $invoice->get_state('edit'),
250 250
                                             'options'     => $states,
251 251
                                             'data-allow-clear' => 'false',
252 252
                                             'select2'          => true,
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
                                         'type'        => 'text',
268 268
                                         'id'          => 'wpinv_zip',
269 269
                                         'name'        => 'wpinv_zip',
270
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
270
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
271 271
                                         'label_type'  => 'vertical',
272 272
                                         'placeholder' => '4140',
273 273
                                         'class'       => 'form-control-sm',
274
-                                        'value'       => $invoice->get_zip( 'edit' ),
274
+                                        'value'       => $invoice->get_zip('edit'),
275 275
                                     )
276 276
                                 );
277 277
                             ?>
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
                                         'type'        => 'text',
284 284
                                         'id'          => 'wpinv_phone',
285 285
                                         'name'        => 'wpinv_phone',
286
-                                        'label'       => __( 'Phone', 'invoicing' ),
286
+                                        'label'       => __('Phone', 'invoicing'),
287 287
                                         'label_type'  => 'vertical',
288 288
                                         'placeholder' => '0493 18 45822',
289 289
                                         'class'       => 'form-control-sm',
290
-                                        'value'       => $invoice->get_phone( 'edit' ),
290
+                                        'value'       => $invoice->get_phone('edit'),
291 291
                                     )
292 292
                                 );
293 293
                             ?>
@@ -304,34 +304,34 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @param int $post_id
306 306
 	 */
307
-	public static function save( $post_id ) {
307
+	public static function save($post_id) {
308 308
 
309 309
         // Prepare the invoice.
310
-        $invoice = new WPInv_Invoice( $post_id );
310
+        $invoice = new WPInv_Invoice($post_id);
311 311
 
312 312
         // Load new data.
313 313
         $invoice->set_props(
314 314
 			array(
315
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
316
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
317
-                'disable_taxes'        => isset( $_POST['disable_taxes'] ),
318
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
319
-                'gateway'              => isset( $_POST['wpinv_gateway'] ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
320
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
321
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
322
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
323
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
324
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
325
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
326
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
327
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
328
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
329
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
330
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
331
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
332
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
333
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
334
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
315
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
316
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
317
+                'disable_taxes'        => isset($_POST['disable_taxes']),
318
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
319
+                'gateway'              => isset($_POST['wpinv_gateway']) ? wpinv_clean($_POST['wpinv_gateway']) : null,
320
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
321
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
322
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
323
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
324
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
325
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
326
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
327
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
328
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
329
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
330
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
331
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
332
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
333
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
334
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
335 335
 			)
336 336
         );
337 337
 
@@ -339,17 +339,17 @@  discard block
 block discarded – undo
339 339
         $invoice->recalculate_total();
340 340
 
341 341
         // If we're creating a new user...
342
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) {
342
+        if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) {
343 343
 
344 344
             // Attempt to create the user.
345
-            $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) );
345
+            $user = wpinv_create_user(sanitize_email($_POST['wpinv_email']));
346 346
 
347 347
 
348 348
             // If successful, update the invoice author.
349
-            if ( is_numeric( $user ) ) {
350
-                $invoice->set_author( $user );
349
+            if (is_numeric($user)) {
350
+                $invoice->set_author($user);
351 351
             } else {
352
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
352
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
353 353
             }
354 354
         }
355 355
 
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
         $invoice->save();
358 358
 
359 359
         // (Maybe) send new user notification.
360
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) {
361
-            wp_send_new_user_notifications( $user, 'user' );
360
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) {
361
+            wp_send_new_user_notifications($user, 'user');
362 362
         }
363 363
 
364 364
         // Fires after an invoice is saved.
365
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
365
+		do_action('wpinv_invoice_metabox_saved', $invoice);
366 366
 	}
367 367
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         ?>
30 30
 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
                                 'type'        => 'text',
47 47
                                 'id'          => 'wpinv_key',
48 48
                                 'name'        => 'wpinv_key',
49
-                                'label'       => __( 'Invoice Key:', 'invoicing' ),
49
+                                'label'       => __('Invoice Key:', 'invoicing'),
50 50
                                 'label_type'  => 'vertical',
51 51
                                 'class'       => 'form-control-sm',
52
-                                'value'       => $invoice->get_key( 'edit' ),
52
+                                'value'       => $invoice->get_key('edit'),
53 53
                                 'extra_attributes' => array(
54 54
                                     'onclick'  => 'this.select();',
55 55
                                     'readonly' => 'true',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
                         );
59 59
 
60 60
                         // View URL.
61
-                        if ( ! $invoice->is_draft() ) {
61
+                        if (!$invoice->is_draft()) {
62 62
                             echo aui()->input(
63 63
                                 array(
64 64
                                     'type'        => 'text',
65 65
                                     'id'          => 'wpinv_view_url',
66 66
                                     'name'        => 'wpinv_view_url',
67
-                                    'label'       => __( 'Invoice URL:', 'invoicing' ),
67
+                                    'label'       => __('Invoice URL:', 'invoicing'),
68 68
                                     'label_type'  => 'vertical',
69 69
                                     'class'       => 'form-control-sm',
70 70
                                     'value'       => $invoice->get_view_url(),
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                         }
78 78
 
79 79
                         // If the invoice is paid...
80
-                        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
80
+                        if ($invoice->is_paid() || $invoice->is_refunded()) {
81 81
 
82 82
                             // Payment date.
83 83
                             echo aui()->input(
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
                                     'type'        => 'datepicker',
86 86
                                     'id'          => 'wpinv_date_completed',
87 87
                                     'name'        => 'date_completed',
88
-                                    'label'       => __( 'Payment Date:', 'invoicing' ),
88
+                                    'label'       => __('Payment Date:', 'invoicing'),
89 89
                                     'label_type'  => 'vertical',
90 90
                                     'placeholder' => 'YYYY-MM-DD 00:00',
91 91
                                     'class'       => 'form-control-sm',
92
-                                    'value'       => $invoice->get_date_completed( 'edit' ),
92
+                                    'value'       => $invoice->get_date_completed('edit'),
93 93
                                     'extra_attributes' => array(
94 94
                                         'data-enable-time' => 'true',
95 95
                                         'data-time_24hr'   => 'true',
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
                                     'type'        => 'text',
105 105
                                     'id'          => 'wpinv_gateway',
106 106
                                     'name'        => 'wpinv_gateway',
107
-                                    'label'       => __( 'Gateway:', 'invoicing' ),
107
+                                    'label'       => __('Gateway:', 'invoicing'),
108 108
                                     'label_type'  => 'vertical',
109 109
                                     'class'       => 'form-control-sm',
110
-                                    'value'       => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
110
+                                    'value'       => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')),
111 111
                                     'extra_attributes' => array(
112 112
                                         'onclick'  => 'this.select();',
113 113
                                         'readonly' => 'true',
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
                                     'type'        => 'text',
122 122
                                     'id'          => 'wpinv_transaction_id',
123 123
                                     'name'        => 'wpinv_transaction_id',
124
-                                    'label'       => __( 'Transaction ID:', 'invoicing' ),
124
+                                    'label'       => __('Transaction ID:', 'invoicing'),
125 125
                                     'label_type'  => 'vertical',
126 126
                                     'class'       => 'form-control-sm',
127
-                                    'value'       => $invoice->get_transaction_id( 'edit' ),
128
-                                    'help_text'   => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
127
+                                    'value'       => $invoice->get_transaction_id('edit'),
128
+                                    'help_text'   => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice),
129 129
                                     'extra_attributes' => array(
130 130
                                         'onclick'  => 'this.select();',
131 131
                                         'readonly' => 'true',
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
                                     'type'        => 'text',
140 140
                                     'id'          => 'wpinv_currency',
141 141
                                     'name'        => 'wpinv_currency',
142
-                                    'label'       => __( 'Currency:', 'invoicing' ),
142
+                                    'label'       => __('Currency:', 'invoicing'),
143 143
                                     'label_type'  => 'vertical',
144 144
                                     'class'       => 'form-control-sm',
145
-                                    'value'       => $invoice->get_currency( 'edit' ),
145
+                                    'value'       => $invoice->get_currency('edit'),
146 146
                                     'extra_attributes' => array(
147 147
                                         'onclick'  => 'this.select();',
148 148
                                         'readonly' => 'true',
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
                         } else {
154 154
 
155 155
                             // Payment URL.
156
-                            if ( ! $invoice->is_draft() ) {
156
+                            if (!$invoice->is_draft()) {
157 157
                                 echo aui()->input(
158 158
                                     array(
159 159
                                         'type'        => 'text',
160 160
                                         'id'          => 'wpinv_payment_url',
161 161
                                         'name'        => 'wpinv_payment_url',
162
-                                        'label'       => __( 'Payment URL:', 'invoicing' ),
162
+                                        'label'       => __('Payment URL:', 'invoicing'),
163 163
                                         'label_type'  => 'vertical',
164 164
                                         'class'       => 'form-control-sm',
165 165
                                         'value'       => $invoice->get_checkout_payment_url(),
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
                                 array(
177 177
                                     'id'               => 'wpinv_gateway',
178 178
                                     'name'             => 'wpinv_gateway',
179
-                                    'label'            => __( 'Gateway:', 'invoicing' ),
179
+                                    'label'            => __('Gateway:', 'invoicing'),
180 180
                                     'label_type'       => 'vertical',
181
-                                    'placeholder'      => __( 'Select Gateway', 'invoicing' ),
182
-                                    'value'            => $invoice->get_gateway( 'edit' ),
181
+                                    'placeholder'      => __('Select Gateway', 'invoicing'),
182
+                                    'value'            => $invoice->get_gateway('edit'),
183 183
                                     'select2'          => true,
184 184
                                     'data-allow-clear' => 'false',
185
-                                    'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
185
+                                    'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
186 186
                                 )
187 187
                             );
188 188
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -13,259 +13,259 @@
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-
29
-		// Table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
32
-
33
-		// Deleting posts.
34
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
35
-	}
36
-
37
-	/**
38
-	 * Post updated messages.
39
-	 */
40
-	public static function post_updated_messages( $messages ) {
41
-		global $post;
42
-
43
-		$messages['wpi_discount'] = array(
44
-			0   => '',
45
-			1   => __( 'Discount updated.', 'invoicing' ),
46
-			2   => __( 'Custom field updated.', 'invoicing' ),
47
-			3   => __( 'Custom field deleted.', 'invoicing' ),
48
-			4   => __( 'Discount updated.', 'invoicing' ),
49
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
50
-			6   => __( 'Discount updated.', 'invoicing' ),
51
-			7   => __( 'Discount saved.', 'invoicing' ),
52
-			8   => __( 'Discount submitted.', 'invoicing' ),
53
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
54
-			10  => __( 'Discount draft updated.', 'invoicing' ),
55
-		);
56
-
57
-		$messages['wpi_payment_form'] = array(
58
-			0   => '',
59
-			1   => __( 'Payment Form updated.', 'invoicing' ),
60
-			2   => __( 'Custom field updated.', 'invoicing' ),
61
-			3   => __( 'Custom field deleted.', 'invoicing' ),
62
-			4   => __( 'Payment Form updated.', 'invoicing' ),
63
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
64
-			6   => __( 'Payment Form updated.', 'invoicing' ),
65
-			7   => __( 'Payment Form saved.', 'invoicing' ),
66
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
67
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
68
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
69
-		);
70
-
71
-		return $messages;
72
-
73
-	}
74
-
75
-	/**
76
-	 * Post row actions.
77
-	 */
78
-	public static function post_row_actions( $actions, $post ) {
79
-
80
-		$post = get_post( $post );
81
-
82
-		// We do not want to edit the default payment form.
83
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
84
-			unset( $actions['trash'] );
85
-			unset( $actions['inline hide-if-no-js'] );
86
-		}
87
-
88
-		return $actions;
89
-	}
90
-
91
-	/**
92
-	 * Returns an array of invoice table columns.
93
-	 */
94
-	public static function invoice_columns( $columns ) {
95
-
96
-		$columns = array(
97
-			'cb'                => $columns['cb'],
98
-			'number'            => __( 'Invoice', 'invoicing' ),
99
-			'customer'          => __( 'Customer', 'invoicing' ),
100
-			'invoice_date'      => __( 'Date', 'invoicing' ),
101
-			'amount'            => __( 'Amount', 'invoicing' ),
102
-			'recurring'         => __( 'Recurring', 'invoicing' ),
103
-			'status'            => __( 'Status', 'invoicing' ),
104
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
105
-		);
106
-
107
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
108
-	}
109
-
110
-	/**
111
-	 * Displays invoice table columns.
112
-	 */
113
-	public static function display_invoice_columns( $column_name, $post_id ) {
114
-
115
-		$invoice = new WPInv_Invoice( $post_id );
116
-
117
-		switch ( $column_name ) {
118
-
119
-			case 'invoice_date' :
120
-				$date_time = sanitize_text_field( $invoice->get_created_date() );
121
-				$date      = mysql2date( get_option( 'date_format' ), $date_time );
122
-				echo "<span title='$date_time'>$date</span>";
123
-				break;
124
-
125
-			case 'amount' :
126
-
127
-				$amount = $invoice->get_total();
128
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
129
-
130
-				if ( $invoice->is_refunded() ) {
131
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
132
-					echo "<del>$formated_amount</del><ins>$refunded_amount</ins>";
133
-				} else {
134
-
135
-					$discount = $invoice->get_total_discount();
136
-
137
-					if ( ! empty( $discount ) ) {
138
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
139
-						echo "<del>$new_amount</del><ins>$formated_amount</ins>";
140
-					} else {
141
-						echo $formated_amount;
142
-					}
143
-
144
-				}
145
-
146
-				break;
147
-
148
-			case 'status' :
149
-				$status       = sanitize_text_field( $invoice->get_status() );
150
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
151
-
152
-				// If it is paid, show the gateway title.
153
-				if ( $invoice->is_paid() ) {
154
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
155
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
156 19
 
157
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
158
-				} else {
159
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
160
-				}
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
161 22
 
162
-				// If it is not paid, display the overdue and view status.
163
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
164 25
 
165
-					// Invoice view status.
166
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
167
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
168
-					} else {
169
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
170
-					}
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
171 28
 
172
-					// Display the overview status.
173
-					if ( wpinv_get_option( 'overdue_active' ) ) {
174
-						$due_date = $invoice->get_due_date();
29
+        // Table columns.
30
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
175 32
 
176
-						if ( ! empty( $due_date ) ) {
177
-							$date = mysql2date( get_option( 'date_format' ), $due_date );
178
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date );
179
-							echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>";
180
-						}
181
-					}
33
+        // Deleting posts.
34
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
35
+    }
182 36
 
183
-				}
37
+    /**
38
+     * Post updated messages.
39
+     */
40
+    public static function post_updated_messages( $messages ) {
41
+        global $post;
42
+
43
+        $messages['wpi_discount'] = array(
44
+            0   => '',
45
+            1   => __( 'Discount updated.', 'invoicing' ),
46
+            2   => __( 'Custom field updated.', 'invoicing' ),
47
+            3   => __( 'Custom field deleted.', 'invoicing' ),
48
+            4   => __( 'Discount updated.', 'invoicing' ),
49
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
50
+            6   => __( 'Discount updated.', 'invoicing' ),
51
+            7   => __( 'Discount saved.', 'invoicing' ),
52
+            8   => __( 'Discount submitted.', 'invoicing' ),
53
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
54
+            10  => __( 'Discount draft updated.', 'invoicing' ),
55
+        );
56
+
57
+        $messages['wpi_payment_form'] = array(
58
+            0   => '',
59
+            1   => __( 'Payment Form updated.', 'invoicing' ),
60
+            2   => __( 'Custom field updated.', 'invoicing' ),
61
+            3   => __( 'Custom field deleted.', 'invoicing' ),
62
+            4   => __( 'Payment Form updated.', 'invoicing' ),
63
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
64
+            6   => __( 'Payment Form updated.', 'invoicing' ),
65
+            7   => __( 'Payment Form saved.', 'invoicing' ),
66
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
67
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
68
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
69
+        );
70
+
71
+        return $messages;
72
+
73
+    }
74
+
75
+    /**
76
+     * Post row actions.
77
+     */
78
+    public static function post_row_actions( $actions, $post ) {
79
+
80
+        $post = get_post( $post );
81
+
82
+        // We do not want to edit the default payment form.
83
+        if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
84
+            unset( $actions['trash'] );
85
+            unset( $actions['inline hide-if-no-js'] );
86
+        }
87
+
88
+        return $actions;
89
+    }
90
+
91
+    /**
92
+     * Returns an array of invoice table columns.
93
+     */
94
+    public static function invoice_columns( $columns ) {
95
+
96
+        $columns = array(
97
+            'cb'                => $columns['cb'],
98
+            'number'            => __( 'Invoice', 'invoicing' ),
99
+            'customer'          => __( 'Customer', 'invoicing' ),
100
+            'invoice_date'      => __( 'Date', 'invoicing' ),
101
+            'amount'            => __( 'Amount', 'invoicing' ),
102
+            'recurring'         => __( 'Recurring', 'invoicing' ),
103
+            'status'            => __( 'Status', 'invoicing' ),
104
+            'wpi_actions'       => __( 'Actions', 'invoicing' ),
105
+        );
106
+
107
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
108
+    }
109
+
110
+    /**
111
+     * Displays invoice table columns.
112
+     */
113
+    public static function display_invoice_columns( $column_name, $post_id ) {
114
+
115
+        $invoice = new WPInv_Invoice( $post_id );
116
+
117
+        switch ( $column_name ) {
118
+
119
+            case 'invoice_date' :
120
+                $date_time = sanitize_text_field( $invoice->get_created_date() );
121
+                $date      = mysql2date( get_option( 'date_format' ), $date_time );
122
+                echo "<span title='$date_time'>$date</span>";
123
+                break;
124
+
125
+            case 'amount' :
126
+
127
+                $amount = $invoice->get_total();
128
+                $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
129
+
130
+                if ( $invoice->is_refunded() ) {
131
+                    $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
132
+                    echo "<del>$formated_amount</del><ins>$refunded_amount</ins>";
133
+                } else {
184 134
 
185
-				break;
135
+                    $discount = $invoice->get_total_discount();
186 136
 
187
-			case 'recurring':
137
+                    if ( ! empty( $discount ) ) {
138
+                        $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
139
+                        echo "<del>$new_amount</del><ins>$formated_amount</ins>";
140
+                    } else {
141
+                        echo $formated_amount;
142
+                    }
188 143
 
189
-				if ( $invoice->is_recurring() ) {
190
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
191
-				} else {
192
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
193
-				}
194
-				break;
144
+                }
195 145
 
196
-			case 'number' :
146
+                break;
197 147
 
198
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
199
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
200
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
148
+            case 'status' :
149
+                $status       = sanitize_text_field( $invoice->get_status() );
150
+                $status_label = sanitize_text_field( $invoice->get_status_nicename() );
201 151
 
202
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
152
+                // If it is paid, show the gateway title.
153
+                if ( $invoice->is_paid() ) {
154
+                    $gateway = sanitize_text_field( $invoice->get_gateway_title() );
155
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
203 156
 
204
-				break;
157
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
158
+                } else {
159
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
160
+                }
205 161
 
206
-			case 'customer' :
162
+                // If it is not paid, display the overdue and view status.
163
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
164
+
165
+                    // Invoice view status.
166
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
167
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
168
+                    } else {
169
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
170
+                    }
171
+
172
+                    // Display the overview status.
173
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
174
+                        $due_date = $invoice->get_due_date();
175
+
176
+                        if ( ! empty( $due_date ) ) {
177
+                            $date = mysql2date( get_option( 'date_format' ), $due_date );
178
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date );
179
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>";
180
+                        }
181
+                    }
182
+
183
+                }
184
+
185
+                break;
186
+
187
+            case 'recurring':
188
+
189
+                if ( $invoice->is_recurring() ) {
190
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
191
+                } else {
192
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
193
+                }
194
+                break;
195
+
196
+            case 'number' :
197
+
198
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
199
+                $invoice_number  = sanitize_text_field( $invoice->get_number() );
200
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
201
+
202
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
203
+
204
+                break;
205
+
206
+            case 'customer' :
207 207
 	
208
-				$customer_name = $invoice->get_user_full_name();
208
+                $customer_name = $invoice->get_user_full_name();
209 209
 	
210
-				if ( empty( $customer_name ) ) {
211
-					$customer_name = $invoice->get_email();
212
-				}
210
+                if ( empty( $customer_name ) ) {
211
+                    $customer_name = $invoice->get_email();
212
+                }
213 213
 	
214
-				if ( ! empty( $customer_name ) ) {
215
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
216
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
217
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
218
-				} else {
219
-					echo '<div>&mdash;</div>';
220
-				}
221
-
222
-				break;
223
-
224
-			case 'wpi_actions' :
225
-
226
-				if ( ! $invoice->is_draft() ) {
227
-					$url    = esc_url( $invoice->get_view_url() );
228
-					$print  = esc_attr__( 'Print invoice', 'invoicing' );
229
-					echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
230
-				}
231
-
232
-				if ( $invoice->get_email() ) {
233
-					$url    = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) );
234
-					$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
235
-					echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
236
-				}
214
+                if ( ! empty( $customer_name ) ) {
215
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
216
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
217
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
218
+                } else {
219
+                    echo '<div>&mdash;</div>';
220
+                }
221
+
222
+                break;
223
+
224
+            case 'wpi_actions' :
225
+
226
+                if ( ! $invoice->is_draft() ) {
227
+                    $url    = esc_url( $invoice->get_view_url() );
228
+                    $print  = esc_attr__( 'Print invoice', 'invoicing' );
229
+                    echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
230
+                }
231
+
232
+                if ( $invoice->get_email() ) {
233
+                    $url    = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) );
234
+                    $send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
235
+                    echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
236
+                }
237 237
 				
238
-				break;
239
-		}
240
-
241
-	}
242
-
243
-	/**
244
-	 * Fired when deleting a post.
245
-	 */
246
-	public static function delete_post( $post_id ) {
247
-
248
-		switch ( get_post_type( $post_id ) ) {
249
-
250
-			case 'wpi_item' :
251
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
252
-				break;
253
-
254
-			case 'wpi_payment_form' :
255
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
256
-				break;
257
-
258
-			case 'wpi_discount' :
259
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
260
-				break;
261
-
262
-			case 'wpi_invoice' :
263
-				$invoice = new WPInv_Invoice( $post_id );
264
-				do_action( "getpaid_before_delete_invoice", $invoice );
265
-				$invoice->get_data_store()->delete_items( $invoice );
266
-				$invoice->get_data_store()->delete_special_fields( $invoice );
267
-				break;
268
-		}
269
-	}
238
+                break;
239
+        }
240
+
241
+    }
242
+
243
+    /**
244
+     * Fired when deleting a post.
245
+     */
246
+    public static function delete_post( $post_id ) {
247
+
248
+        switch ( get_post_type( $post_id ) ) {
249
+
250
+            case 'wpi_item' :
251
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
252
+                break;
253
+
254
+            case 'wpi_payment_form' :
255
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
256
+                break;
257
+
258
+            case 'wpi_discount' :
259
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
260
+                break;
261
+
262
+            case 'wpi_invoice' :
263
+                $invoice = new WPInv_Invoice( $post_id );
264
+                do_action( "getpaid_before_delete_invoice", $invoice );
265
+                $invoice->get_data_store()->delete_items( $invoice );
266
+                $invoice->get_data_store()->delete_special_fields( $invoice );
267
+                break;
268
+        }
269
+    }
270 270
 
271 271
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,51 +21,51 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28 28
 
29 29
 		// Table columns.
30
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
31
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
30
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
31
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
32 32
 
33 33
 		// Deleting posts.
34
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
34
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * Post updated messages.
39 39
 	 */
40
-	public static function post_updated_messages( $messages ) {
40
+	public static function post_updated_messages($messages) {
41 41
 		global $post;
42 42
 
43 43
 		$messages['wpi_discount'] = array(
44 44
 			0   => '',
45
-			1   => __( 'Discount updated.', 'invoicing' ),
46
-			2   => __( 'Custom field updated.', 'invoicing' ),
47
-			3   => __( 'Custom field deleted.', 'invoicing' ),
48
-			4   => __( 'Discount updated.', 'invoicing' ),
49
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
50
-			6   => __( 'Discount updated.', 'invoicing' ),
51
-			7   => __( 'Discount saved.', 'invoicing' ),
52
-			8   => __( 'Discount submitted.', 'invoicing' ),
53
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
54
-			10  => __( 'Discount draft updated.', 'invoicing' ),
45
+			1   => __('Discount updated.', 'invoicing'),
46
+			2   => __('Custom field updated.', 'invoicing'),
47
+			3   => __('Custom field deleted.', 'invoicing'),
48
+			4   => __('Discount updated.', 'invoicing'),
49
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
50
+			6   => __('Discount updated.', 'invoicing'),
51
+			7   => __('Discount saved.', 'invoicing'),
52
+			8   => __('Discount submitted.', 'invoicing'),
53
+			9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
54
+			10  => __('Discount draft updated.', 'invoicing'),
55 55
 		);
56 56
 
57 57
 		$messages['wpi_payment_form'] = array(
58 58
 			0   => '',
59
-			1   => __( 'Payment Form updated.', 'invoicing' ),
60
-			2   => __( 'Custom field updated.', 'invoicing' ),
61
-			3   => __( 'Custom field deleted.', 'invoicing' ),
62
-			4   => __( 'Payment Form updated.', 'invoicing' ),
63
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
64
-			6   => __( 'Payment Form updated.', 'invoicing' ),
65
-			7   => __( 'Payment Form saved.', 'invoicing' ),
66
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
67
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
68
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
59
+			1   => __('Payment Form updated.', 'invoicing'),
60
+			2   => __('Custom field updated.', 'invoicing'),
61
+			3   => __('Custom field deleted.', 'invoicing'),
62
+			4   => __('Payment Form updated.', 'invoicing'),
63
+			5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
64
+			6   => __('Payment Form updated.', 'invoicing'),
65
+			7   => __('Payment Form saved.', 'invoicing'),
66
+			8   => __('Payment Form submitted.', 'invoicing'),
67
+			9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
68
+			10  => __('Payment Form draft updated.', 'invoicing'),
69 69
 		);
70 70
 
71 71
 		return $messages;
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * Post row actions.
77 77
 	 */
78
-	public static function post_row_actions( $actions, $post ) {
78
+	public static function post_row_actions($actions, $post) {
79 79
 
80
-		$post = get_post( $post );
80
+		$post = get_post($post);
81 81
 
82 82
 		// We do not want to edit the default payment form.
83
-		if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
84
-			unset( $actions['trash'] );
85
-			unset( $actions['inline hide-if-no-js'] );
83
+		if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
84
+			unset($actions['trash']);
85
+			unset($actions['inline hide-if-no-js']);
86 86
 		}
87 87
 
88 88
 		return $actions;
@@ -91,51 +91,51 @@  discard block
 block discarded – undo
91 91
 	/**
92 92
 	 * Returns an array of invoice table columns.
93 93
 	 */
94
-	public static function invoice_columns( $columns ) {
94
+	public static function invoice_columns($columns) {
95 95
 
96 96
 		$columns = array(
97 97
 			'cb'                => $columns['cb'],
98
-			'number'            => __( 'Invoice', 'invoicing' ),
99
-			'customer'          => __( 'Customer', 'invoicing' ),
100
-			'invoice_date'      => __( 'Date', 'invoicing' ),
101
-			'amount'            => __( 'Amount', 'invoicing' ),
102
-			'recurring'         => __( 'Recurring', 'invoicing' ),
103
-			'status'            => __( 'Status', 'invoicing' ),
104
-			'wpi_actions'       => __( 'Actions', 'invoicing' ),
98
+			'number'            => __('Invoice', 'invoicing'),
99
+			'customer'          => __('Customer', 'invoicing'),
100
+			'invoice_date'      => __('Date', 'invoicing'),
101
+			'amount'            => __('Amount', 'invoicing'),
102
+			'recurring'         => __('Recurring', 'invoicing'),
103
+			'status'            => __('Status', 'invoicing'),
104
+			'wpi_actions'       => __('Actions', 'invoicing'),
105 105
 		);
106 106
 
107
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
107
+		return apply_filters('wpi_invoice_table_columns', $columns);
108 108
 	}
109 109
 
110 110
 	/**
111 111
 	 * Displays invoice table columns.
112 112
 	 */
113
-	public static function display_invoice_columns( $column_name, $post_id ) {
113
+	public static function display_invoice_columns($column_name, $post_id) {
114 114
 
115
-		$invoice = new WPInv_Invoice( $post_id );
115
+		$invoice = new WPInv_Invoice($post_id);
116 116
 
117
-		switch ( $column_name ) {
117
+		switch ($column_name) {
118 118
 
119 119
 			case 'invoice_date' :
120
-				$date_time = sanitize_text_field( $invoice->get_created_date() );
121
-				$date      = mysql2date( get_option( 'date_format' ), $date_time );
120
+				$date_time = sanitize_text_field($invoice->get_created_date());
121
+				$date      = mysql2date(get_option('date_format'), $date_time);
122 122
 				echo "<span title='$date_time'>$date</span>";
123 123
 				break;
124 124
 
125 125
 			case 'amount' :
126 126
 
127 127
 				$amount = $invoice->get_total();
128
-				$formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() );
128
+				$formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency());
129 129
 
130
-				if ( $invoice->is_refunded() ) {
131
-					$refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() );
130
+				if ($invoice->is_refunded()) {
131
+					$refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency());
132 132
 					echo "<del>$formated_amount</del><ins>$refunded_amount</ins>";
133 133
 				} else {
134 134
 
135 135
 					$discount = $invoice->get_total_discount();
136 136
 
137
-					if ( ! empty( $discount ) ) {
138
-						$new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() );
137
+					if (!empty($discount)) {
138
+						$new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency());
139 139
 						echo "<del>$new_amount</del><ins>$formated_amount</ins>";
140 140
 					} else {
141 141
 						echo $formated_amount;
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 				break;
147 147
 
148 148
 			case 'status' :
149
-				$status       = sanitize_text_field( $invoice->get_status() );
150
-				$status_label = sanitize_text_field( $invoice->get_status_nicename() );
149
+				$status       = sanitize_text_field($invoice->get_status());
150
+				$status_label = sanitize_text_field($invoice->get_status_nicename());
151 151
 
152 152
 				// If it is paid, show the gateway title.
153
-				if ( $invoice->is_paid() ) {
154
-					$gateway = sanitize_text_field( $invoice->get_gateway_title() );
155
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
153
+				if ($invoice->is_paid()) {
154
+					$gateway = sanitize_text_field($invoice->get_gateway_title());
155
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway);
156 156
 
157 157
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
158 158
 				} else {
@@ -160,22 +160,22 @@  discard block
 block discarded – undo
160 160
 				}
161 161
 
162 162
 				// If it is not paid, display the overdue and view status.
163
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
163
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
164 164
 
165 165
 					// Invoice view status.
166
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
167
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
166
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
167
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
168 168
 					} else {
169
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
169
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
170 170
 					}
171 171
 
172 172
 					// Display the overview status.
173
-					if ( wpinv_get_option( 'overdue_active' ) ) {
173
+					if (wpinv_get_option('overdue_active')) {
174 174
 						$due_date = $invoice->get_due_date();
175 175
 
176
-						if ( ! empty( $due_date ) ) {
177
-							$date = mysql2date( get_option( 'date_format' ), $due_date );
178
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date );
176
+						if (!empty($due_date)) {
177
+							$date = mysql2date(get_option('date_format'), $due_date);
178
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $date);
179 179
 							echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>";
180 180
 						}
181 181
 					}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 			case 'recurring':
188 188
 
189
-				if ( $invoice->is_recurring() ) {
189
+				if ($invoice->is_recurring()) {
190 190
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
191 191
 				} else {
192 192
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
 			case 'number' :
197 197
 
198
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
199
-				$invoice_number  = sanitize_text_field( $invoice->get_number() );
200
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
198
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
199
+				$invoice_number  = sanitize_text_field($invoice->get_number());
200
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
201 201
 
202 202
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
203 203
 
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 	
208 208
 				$customer_name = $invoice->get_user_full_name();
209 209
 	
210
-				if ( empty( $customer_name ) ) {
210
+				if (empty($customer_name)) {
211 211
 					$customer_name = $invoice->get_email();
212 212
 				}
213 213
 	
214
-				if ( ! empty( $customer_name ) ) {
215
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
216
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
214
+				if (!empty($customer_name)) {
215
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
216
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
217 217
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
218 218
 				} else {
219 219
 					echo '<div>&mdash;</div>';
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
 
224 224
 			case 'wpi_actions' :
225 225
 
226
-				if ( ! $invoice->is_draft() ) {
227
-					$url    = esc_url( $invoice->get_view_url() );
228
-					$print  = esc_attr__( 'Print invoice', 'invoicing' );
226
+				if (!$invoice->is_draft()) {
227
+					$url    = esc_url($invoice->get_view_url());
228
+					$print  = esc_attr__('Print invoice', 'invoicing');
229 229
 					echo "&nbsp;<a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>";
230 230
 				}
231 231
 
232
-				if ( $invoice->get_email() ) {
233
-					$url    = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) );
234
-					$send   = esc_attr__( 'Send invoice to customer', 'invoicing' );
232
+				if ($invoice->get_email()) {
233
+					$url    = esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id())));
234
+					$send   = esc_attr__('Send invoice to customer', 'invoicing');
235 235
 					echo "&nbsp;&nbsp;<a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>";
236 236
 				}
237 237
 				
@@ -243,27 +243,27 @@  discard block
 block discarded – undo
243 243
 	/**
244 244
 	 * Fired when deleting a post.
245 245
 	 */
246
-	public static function delete_post( $post_id ) {
246
+	public static function delete_post($post_id) {
247 247
 
248
-		switch ( get_post_type( $post_id ) ) {
248
+		switch (get_post_type($post_id)) {
249 249
 
250 250
 			case 'wpi_item' :
251
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
251
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
252 252
 				break;
253 253
 
254 254
 			case 'wpi_payment_form' :
255
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
255
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
256 256
 				break;
257 257
 
258 258
 			case 'wpi_discount' :
259
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
259
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
260 260
 				break;
261 261
 
262 262
 			case 'wpi_invoice' :
263
-				$invoice = new WPInv_Invoice( $post_id );
264
-				do_action( "getpaid_before_delete_invoice", $invoice );
265
-				$invoice->get_data_store()->delete_items( $invoice );
266
-				$invoice->get_data_store()->delete_special_fields( $invoice );
263
+				$invoice = new WPInv_Invoice($post_id);
264
+				do_action("getpaid_before_delete_invoice", $invoice);
265
+				$invoice->get_data_store()->delete_items($invoice);
266
+				$invoice->get_data_store()->delete_special_fields($invoice);
267 267
 				break;
268 268
 		}
269 269
 	}
Please login to merge, or discard this patch.
includes/admin/class-getpaid-metaboxes.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -12,181 +12,181 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
21
-
22 15
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
26
-
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2 );
29
-
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
32 21
 
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
-
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
22
+    /**
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
39 26
 
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
44
-		global $wpinv_euvat;
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2 );
45 29
 
46
-		// For invoices...
47
-		if ( $post_type == 'wpi_invoice' ) {
48
-			$invoice = new WPInv_Invoice( $post );
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
49 32
 
50
-			// Resend invoice.
51
-			if ( ! $invoice->is_draft() ) {
52
-				add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' );
53
-			}
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
54 35
 
55
-			// Subscriptions.
56
-			if ( $invoice->is_recurring() ) {
57
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' );
58
-			}
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
59 39
 
60
-			// Invoice details.
61
-			add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
44
+        global $wpinv_euvat;
45
+
46
+        // For invoices...
47
+        if ( $post_type == 'wpi_invoice' ) {
48
+            $invoice = new WPInv_Invoice( $post );
49
+
50
+            // Resend invoice.
51
+            if ( ! $invoice->is_draft() ) {
52
+                add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' );
53
+            }
54
+
55
+            // Subscriptions.
56
+            if ( $invoice->is_recurring() ) {
57
+                add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' );
58
+            }
59
+
60
+            // Invoice details.
61
+            add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
62 62
 			
63
-			// Payment details.
64
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
63
+            // Payment details.
64
+            add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
65 65
 
66
-			// Billing details.
67
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
66
+            // Billing details.
67
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
68 68
 			
69
-			// Invoice items.
70
-			add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
69
+            // Invoice items.
70
+            add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
71 71
 			
72
-			// Invoice notes.
73
-			add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
72
+            // Invoice notes.
73
+            add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
74 74
 
75
-			// Payment form information.
76
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
77
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
78
-			}
79
-		}
75
+            // Payment form information.
76
+            if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
77
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
78
+            }
79
+        }
80 80
 
81
-		// For payment forms.
82
-		if ( $post_type == 'wpi_payment_form' ) {
81
+        // For payment forms.
82
+        if ( $post_type == 'wpi_payment_form' ) {
83 83
 
84
-			// Design payment form.
85
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
84
+            // Design payment form.
85
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
86 86
 
87
-			// Payment form information.
88
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
87
+            // Payment form information.
88
+            add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
89 89
 
90
-		}
90
+        }
91 91
 
92
-		// For invoice items.
93
-		if ( $post_type == 'wpi_item' ) {
92
+        // For invoice items.
93
+        if ( $post_type == 'wpi_item' ) {
94 94
 
95
-			// Item details.
96
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
95
+            // Item details.
96
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
97 97
 
98
-			// If taxes are enabled, register the tax metabox.
99
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
100
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
101
-			}
98
+            // If taxes are enabled, register the tax metabox.
99
+            if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
100
+                add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
101
+            }
102 102
 
103
-			// Item info.
104
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
103
+            // Item info.
104
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
105 105
 
106
-		}
106
+        }
107 107
 
108
-		// For invoice discounts.
109
-		if ( $post_type == 'wpi_discount' ) {
110
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
111
-		}
108
+        // For invoice discounts.
109
+        if ( $post_type == 'wpi_discount' ) {
110
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
111
+        }
112 112
 		
113 113
 
114
-	}
114
+    }
115 115
 
116
-	/**
117
-	 * Remove some metaboxes.
118
-	 */
119
-	public static function remove_meta_boxes() {
120
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
121
-	}
116
+    /**
117
+     * Remove some metaboxes.
118
+     */
119
+    public static function remove_meta_boxes() {
120
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
121
+    }
122 122
 
123
-	/**
124
-	 * Rename other metaboxes.
125
-	 */
126
-	public static function rename_meta_boxes() {
123
+    /**
124
+     * Rename other metaboxes.
125
+     */
126
+    public static function rename_meta_boxes() {
127 127
 		
128
-	}
129
-
130
-	/**
131
-	 * Check if we're saving, then trigger an action based on the post type.
132
-	 *
133
-	 * @param  int    $post_id Post ID.
134
-	 * @param  object $post Post object.
135
-	 */
136
-	public static function save_meta_boxes( $post_id, $post ) {
137
-		$post_id = absint( $post_id );
138
-
139
-		// Do not save for ajax requests.
140
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
141
-			return;
142
-		}
143
-
144
-		// $post_id and $post are required
145
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
146
-			return;
147
-		}
148
-
149
-		// Dont' save meta boxes for revisions or autosaves.
150
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
151
-			return;
152
-		}
153
-
154
-		// Check the nonce.
155
-		if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) {
156
-			return;
157
-		}
158
-
159
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
160
-		if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
161
-			return;
162
-		}
163
-
164
-		// Check user has permission to edit.
165
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
166
-			return;
167
-		}
168
-
169
-		// Ensure this is our post type.
170
-		$post_types_map = array(
171
-			'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
172
-			'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
173
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
174
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
175
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
176
-		);
177
-
178
-		// Is this our post type?
179
-		if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
180
-			return;
181
-		}
182
-
183
-		// We need this save event to run once to avoid potential endless loops.
184
-		self::$saved_meta_boxes = true;
128
+    }
129
+
130
+    /**
131
+     * Check if we're saving, then trigger an action based on the post type.
132
+     *
133
+     * @param  int    $post_id Post ID.
134
+     * @param  object $post Post object.
135
+     */
136
+    public static function save_meta_boxes( $post_id, $post ) {
137
+        $post_id = absint( $post_id );
138
+
139
+        // Do not save for ajax requests.
140
+        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
141
+            return;
142
+        }
143
+
144
+        // $post_id and $post are required
145
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
146
+            return;
147
+        }
148
+
149
+        // Dont' save meta boxes for revisions or autosaves.
150
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
151
+            return;
152
+        }
153
+
154
+        // Check the nonce.
155
+        if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) {
156
+            return;
157
+        }
158
+
159
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
160
+        if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
161
+            return;
162
+        }
163
+
164
+        // Check user has permission to edit.
165
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
166
+            return;
167
+        }
168
+
169
+        // Ensure this is our post type.
170
+        $post_types_map = array(
171
+            'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
172
+            'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
173
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
174
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
175
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
176
+        );
177
+
178
+        // Is this our post type?
179
+        if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
180
+            return;
181
+        }
182
+
183
+        // We need this save event to run once to avoid potential endless loops.
184
+        self::$saved_meta_boxes = true;
185 185
 		
186
-		// Save the post.
187
-		$class = $post_types_map[ $post->post_type ];
188
-		$class::save( $post_id, $_POST, $post );
186
+        // Save the post.
187
+        $class = $post_types_map[ $post->post_type ];
188
+        $class::save( $post_id, $_POST, $post );
189 189
 
190
-	}
190
+    }
191 191
 
192 192
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Metaboxes Admin Class
@@ -25,89 +25,89 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 		global $wpinv_euvat;
45 45
 
46 46
 		// For invoices...
47
-		if ( $post_type == 'wpi_invoice' ) {
48
-			$invoice = new WPInv_Invoice( $post );
47
+		if ($post_type == 'wpi_invoice') {
48
+			$invoice = new WPInv_Invoice($post);
49 49
 
50 50
 			// Resend invoice.
51
-			if ( ! $invoice->is_draft() ) {
52
-				add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' );
51
+			if (!$invoice->is_draft()) {
52
+				add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high');
53 53
 			}
54 54
 
55 55
 			// Subscriptions.
56
-			if ( $invoice->is_recurring() ) {
57
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' );
56
+			if ($invoice->is_recurring()) {
57
+				add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high');
58 58
 			}
59 59
 
60 60
 			// Invoice details.
61
-			add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
61
+			add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default');
62 62
 			
63 63
 			// Payment details.
64
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
64
+			add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default');
65 65
 
66 66
 			// Billing details.
67
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
67
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high');
68 68
 			
69 69
 			// Invoice items.
70
-			add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
70
+			add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high');
71 71
 			
72 72
 			// Invoice notes.
73
-			add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
73
+			add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
74 74
 
75 75
 			// Payment form information.
76
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
77
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
76
+			if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
77
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
78 78
 			}
79 79
 		}
80 80
 
81 81
 		// For payment forms.
82
-		if ( $post_type == 'wpi_payment_form' ) {
82
+		if ($post_type == 'wpi_payment_form') {
83 83
 
84 84
 			// Design payment form.
85
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
85
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
86 86
 
87 87
 			// Payment form information.
88
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
88
+			add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
89 89
 
90 90
 		}
91 91
 
92 92
 		// For invoice items.
93
-		if ( $post_type == 'wpi_item' ) {
93
+		if ($post_type == 'wpi_item') {
94 94
 
95 95
 			// Item details.
96
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
96
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
97 97
 
98 98
 			// If taxes are enabled, register the tax metabox.
99
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
100
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
99
+			if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
100
+				add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
101 101
 			}
102 102
 
103 103
 			// Item info.
104
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
104
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
105 105
 
106 106
 		}
107 107
 
108 108
 		// For invoice discounts.
109
-		if ( $post_type == 'wpi_discount' ) {
110
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
109
+		if ($post_type == 'wpi_discount') {
110
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
111 111
 		}
112 112
 		
113 113
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * Remove some metaboxes.
118 118
 	 */
119 119
 	public static function remove_meta_boxes() {
120
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
120
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
121 121
 	}
122 122
 
123 123
 	/**
@@ -133,36 +133,36 @@  discard block
 block discarded – undo
133 133
 	 * @param  int    $post_id Post ID.
134 134
 	 * @param  object $post Post object.
135 135
 	 */
136
-	public static function save_meta_boxes( $post_id, $post ) {
137
-		$post_id = absint( $post_id );
136
+	public static function save_meta_boxes($post_id, $post) {
137
+		$post_id = absint($post_id);
138 138
 
139 139
 		// Do not save for ajax requests.
140
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
140
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
141 141
 			return;
142 142
 		}
143 143
 
144 144
 		// $post_id and $post are required
145
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
145
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
146 146
 			return;
147 147
 		}
148 148
 
149 149
 		// Dont' save meta boxes for revisions or autosaves.
150
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
150
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
151 151
 			return;
152 152
 		}
153 153
 
154 154
 		// Check the nonce.
155
-		if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) {
155
+		if (empty($_POST['getpaid_meta_nonce']) || !wp_verify_nonce(wp_unslash($_POST['getpaid_meta_nonce']), 'getpaid_meta_nonce')) {
156 156
 			return;
157 157
 		}
158 158
 
159 159
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
160
-		if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
160
+		if (empty($_POST['post_ID']) || absint($_POST['post_ID']) !== $post_id) {
161 161
 			return;
162 162
 		}
163 163
 
164 164
 		// Check user has permission to edit.
165
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
165
+		if (!current_user_can('edit_post', $post_id)) {
166 166
 			return;
167 167
 		}
168 168
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		);
177 177
 
178 178
 		// Is this our post type?
179
-		if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
179
+		if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) {
180 180
 			return;
181 181
 		}
182 182
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 		self::$saved_meta_boxes = true;
185 185
 		
186 186
 		// Save the post.
187
-		$class = $post_types_map[ $post->post_type ];
188
-		$class::save( $post_id, $_POST, $post );
187
+		$class = $post_types_map[$post->post_type];
188
+		$class::save($post_id, $_POST, $post);
189 189
 
190 190
 	}
191 191
 
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -56,69 +56,69 @@  discard block
 block discarded – undo
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59
-	global $wpinv_options, $pagenow, $post;
59
+    global $wpinv_options, $pagenow, $post;
60 60
 
61
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
62
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
63
-	}
61
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
62
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
63
+    }
64 64
 
65
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
66
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
67
-	}
65
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
66
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
67
+    }
68 68
 
69
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
70
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
71
-	}
69
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
70
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
71
+    }
72 72
 
73
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
74
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
75
-	}
73
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
74
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
75
+    }
76 76
 
77
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
78
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
79
-	}
77
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
78
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
79
+    }
80 80
 
81
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
82
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
83
-	}
81
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
82
+        add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
83
+    }
84 84
 
85
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
86
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
87
-	}
85
+    if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
86
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
87
+    }
88 88
 
89
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
90
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
89
+    if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
90
+        add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
91 91
     }
92 92
     
93 93
     if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
94
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
94
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
95 95
     }
96 96
 
97 97
     if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
98 98
         add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
99 99
     }
100 100
 
101
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
102
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
103
-	}
101
+    if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
102
+        add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
103
+    }
104 104
 
105
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
106
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
107
-	}
105
+    if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
106
+        add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
107
+    }
108 108
 
109
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
110
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
111
-	}
109
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
110
+        add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
111
+    }
112 112
     
113
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
114
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
113
+    if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
114
+        $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
115 115
 
116
-		if ( !empty( $message ) ) {
117
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
118
-		}
119
-	}
116
+        if ( !empty( $message ) ) {
117
+            add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
118
+        }
119
+    }
120 120
 
121
-	settings_errors( 'wpinv-notices' );
121
+    settings_errors( 'wpinv-notices' );
122 122
 }
123 123
 add_action( 'admin_notices', 'wpinv_admin_messages' );
124 124
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         break;
213 213
         case 'id' :
214 214
            echo $post->ID;
215
-           echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
215
+            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
216 216
                     <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
217 217
                     if ( $wpinv_euvat->allow_vat_rules() ) {
218 218
                         echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -7,127 +7,127 @@  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_bulk_actions( $actions ) {
15
-    if ( isset( $actions['edit'] ) ) {
16
-        unset( $actions['edit'] );
14
+function wpinv_bulk_actions($actions) {
15
+    if (isset($actions['edit'])) {
16
+        unset($actions['edit']);
17 17
     }
18 18
 
19 19
     return $actions;
20 20
 }
21
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
22
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
21
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
22
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
23 23
 
24
-function wpinv_admin_post_id( $id = 0 ) {
24
+function wpinv_admin_post_id($id = 0) {
25 25
     global $post;
26 26
 
27
-    if ( isset( $id ) && ! empty( $id ) ) {
28
-        return (int)$id;
29
-    } else if ( get_the_ID() ) {
27
+    if (isset($id) && !empty($id)) {
28
+        return (int) $id;
29
+    } else if (get_the_ID()) {
30 30
         return (int) get_the_ID();
31
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
31
+    } else if (isset($post->ID) && !empty($post->ID)) {
32 32
         return (int) $post->ID;
33
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
33
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
34 34
         return (int) $_GET['post'];
35
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
35
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
36 36
         return (int) $_GET['id'];
37
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
37
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
38 38
         return (int) $_POST['id'];
39 39
     } 
40 40
 
41 41
     return null;
42 42
 }
43 43
     
44
-function wpinv_admin_post_type( $id = 0 ) {
45
-    if ( !$id ) {
44
+function wpinv_admin_post_type($id = 0) {
45
+    if (!$id) {
46 46
         $id = wpinv_admin_post_id();
47 47
     }
48 48
     
49
-    $type = get_post_type( $id );
49
+    $type = get_post_type($id);
50 50
     
51
-    if ( !$type ) {
52
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
51
+    if (!$type) {
52
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
53 53
     }
54 54
     
55
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
55
+    return apply_filters('wpinv_admin_post_type', $type, $id);
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59 59
 	global $wpinv_options, $pagenow, $post;
60 60
 
61
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
62
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
61
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
62
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
63 63
 	}
64 64
 
65
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
66
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
65
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
66
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
67 67
 	}
68 68
 
69
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
70
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
69
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
70
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
71 71
 	}
72 72
 
73
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
74
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
73
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
74
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
75 75
 	}
76 76
 
77
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
78
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
77
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
78
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
79 79
 	}
80 80
 
81
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
82
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
81
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
82
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
83 83
 	}
84 84
 
85
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
86
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
85
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
86
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
87 87
 	}
88 88
 
89
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
90
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
89
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
90
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
91 91
     }
92 92
     
93
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
94
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
93
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
94
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
95 95
     }
96 96
 
97
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
98
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
97
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
98
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
99 99
     }
100 100
 
101
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
102
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
101
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
102
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
103 103
 	}
104 104
 
105
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
106
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
105
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
106
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
107 107
 	}
108 108
 
109
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
110
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
109
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
110
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
111 111
 	}
112 112
     
113
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
114
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
113
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
114
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
115 115
 
116
-		if ( !empty( $message ) ) {
117
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
116
+		if (!empty($message)) {
117
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
118 118
 		}
119 119
 	}
120 120
 
121
-	settings_errors( 'wpinv-notices' );
121
+	settings_errors('wpinv-notices');
122 122
 }
123
-add_action( 'admin_notices', 'wpinv_admin_messages' );
123
+add_action('admin_notices', 'wpinv_admin_messages');
124 124
 
125
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
126
-function wpinv_show_test_payment_gateway_notice(){
127
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
125
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
126
+function wpinv_show_test_payment_gateway_notice() {
127
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
128 128
 }
129 129
 
130
-function wpinv_test_payment_gateway_messages(){
130
+function wpinv_test_payment_gateway_messages() {
131 131
     $gateways = wpinv_get_enabled_payment_gateways();
132 132
     $name = array(); $test_gateways = '';
133 133
     if ($gateways) {
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
         }
139 139
         $test_gateways = implode(', ', $name);
140 140
     }
141
-    if(isset($test_gateways) && !empty($test_gateways)){
141
+    if (isset($test_gateways) && !empty($test_gateways)) {
142 142
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
143
-        $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 );
143
+        $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);
144 144
         ?>
145 145
         <div class="notice notice-warning is-dismissible">
146 146
             <p><?php echo $notice; ?></p>
@@ -149,30 +149,30 @@  discard block
 block discarded – undo
149 149
     }
150 150
 }
151 151
 
152
-function wpinv_items_columns( $existing_columns ) {
152
+function wpinv_items_columns($existing_columns) {
153 153
     global $wpinv_euvat;
154 154
     
155 155
     $columns                = array();
156 156
     $columns['cb']          = $existing_columns['cb'];
157
-    $columns['title']       = __( 'Title', 'invoicing' );
158
-    $columns['price']       = __( 'Price', 'invoicing' );
159
-    $columns['shortcode']   = __( 'Shortcode', 'invoicing' );
160
-    if ( $wpinv_euvat->allow_vat_rules() ) {
161
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
157
+    $columns['title']       = __('Title', 'invoicing');
158
+    $columns['price']       = __('Price', 'invoicing');
159
+    $columns['shortcode']   = __('Shortcode', 'invoicing');
160
+    if ($wpinv_euvat->allow_vat_rules()) {
161
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
162 162
     }
163
-    if ( $wpinv_euvat->allow_vat_classes() ) {
164
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
163
+    if ($wpinv_euvat->allow_vat_classes()) {
164
+        $columns['vat_class']   = __('VAT class', 'invoicing');
165 165
     }
166
-    $columns['type']        = __( 'Type', 'invoicing' );
167
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
168
-    $columns['date']        = __( 'Date', 'invoicing' );
169
-    $columns['id']          = __( 'ID', 'invoicing' );
166
+    $columns['type']        = __('Type', 'invoicing');
167
+    $columns['recurring']   = __('Recurring', 'invoicing');
168
+    $columns['date']        = __('Date', 'invoicing');
169
+    $columns['id']          = __('ID', 'invoicing');
170 170
 
171
-    return apply_filters( 'wpinv_items_columns', $columns );
171
+    return apply_filters('wpinv_items_columns', $columns);
172 172
 }
173
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
173
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
174 174
 
175
-function wpinv_items_sortable_columns( $columns ) {
175
+function wpinv_items_sortable_columns($columns) {
176 176
     $columns['price']       = 'price';
177 177
     $columns['vat_rule']    = 'vat_rule';
178 178
     $columns['vat_class']   = 'vat_class';
@@ -182,133 +182,133 @@  discard block
 block discarded – undo
182 182
 
183 183
     return $columns;
184 184
 }
185
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
185
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
186 186
 
187
-function wpinv_items_table_custom_column( $column ) {
187
+function wpinv_items_table_custom_column($column) {
188 188
     global $wpinv_euvat, $post, $wpi_item;
189 189
     
190
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
191
-        $wpi_item = new WPInv_Item( $post->ID );
190
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
191
+        $wpi_item = new WPInv_Item($post->ID);
192 192
     }
193 193
 
194
-    switch ( $column ) {
194
+    switch ($column) {
195 195
         case 'price' :
196
-            echo wpinv_item_price( $post->ID );
196
+            echo wpinv_item_price($post->ID);
197 197
         break;
198 198
         case 'vat_rule' :
199
-            echo $wpinv_euvat->item_rule_label( $post->ID );
199
+            echo $wpinv_euvat->item_rule_label($post->ID);
200 200
         break;
201 201
         case 'shortcode' :
202
-            echo WPInv_Meta_Box_Items::shortcode( $post->ID );
202
+            echo WPInv_Meta_Box_Items::shortcode($post->ID);
203 203
         break;
204 204
         case 'vat_class' :
205
-            echo $wpinv_euvat->item_class_label( $post->ID );
205
+            echo $wpinv_euvat->item_class_label($post->ID);
206 206
         break;
207 207
         case 'type' :
208
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
208
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
209 209
         break;
210 210
         case 'recurring' :
211
-            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>' );
211
+            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>');
212 212
         break;
213 213
         case 'id' :
214 214
            echo $post->ID;
215 215
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
216
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
217
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
218
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
216
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
217
+                    if ($wpinv_euvat->allow_vat_rules()) {
218
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
219 219
                     }
220
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
221
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
220
+                    if ($wpinv_euvat->allow_vat_classes()) {
221
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
222 222
                     }
223
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
223
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
224 224
                 </div>';
225 225
         break;
226 226
     }
227 227
     
228
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
228
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
229 229
 }
230
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
230
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
231 231
 
232 232
 function wpinv_add_items_filters() {
233 233
     global $wpinv_euvat, $typenow;
234 234
 
235 235
     // Checks if the current post type is 'item'
236
-    if ( $typenow == 'wpi_item') {
237
-        if ( $wpinv_euvat->allow_vat_rules() ) {
236
+    if ($typenow == 'wpi_item') {
237
+        if ($wpinv_euvat->allow_vat_rules()) {
238 238
 
239 239
             // Sanitize selected vat rule.
240
-            $vat_rule   = '';
241
-            if( isset( $_GET['vat_rule'] ) && array_key_exists(  $_GET['type'], $wpinv_euvat->get_rules() ) ) {
242
-                $class   =  $_GET['type'];
240
+            $vat_rule = '';
241
+            if (isset($_GET['vat_rule']) && array_key_exists($_GET['type'], $wpinv_euvat->get_rules())) {
242
+                $class = $_GET['type'];
243 243
             }
244 244
 
245
-            echo wpinv_html_select( array(
246
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
245
+            echo wpinv_html_select(array(
246
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
247 247
                     'name'             => 'vat_rule',
248 248
                     'id'               => 'vat_rule',
249
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
249
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
250 250
                     'show_option_all'  => false,
251 251
                     'show_option_none' => false,
252 252
                     'class'            => 'gdmbx2-text-medium wpi_select2',
253
-                    'placeholder'      => __( 'Select VAT rule', 'invoicing' ),
254
-                ) );
253
+                    'placeholder'      => __('Select VAT rule', 'invoicing'),
254
+                ));
255 255
         }
256 256
 
257
-        if ( $wpinv_euvat->allow_vat_classes() ) {
257
+        if ($wpinv_euvat->allow_vat_classes()) {
258 258
 
259 259
             $classes = $wpinv_euvat->get_all_classes();
260 260
 
261 261
             // Sanitize selected vat class.
262 262
             $class   = '';
263
-            if( isset( $_GET['vat_class'] ) && array_key_exists(  $_GET['vat_class'], $classes ) ) {
264
-                $class   =  $_GET['vat_class'];
263
+            if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $classes)) {
264
+                $class = $_GET['vat_class'];
265 265
             }
266 266
 
267
-            echo wpinv_html_select( array(
268
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $classes ),
267
+            echo wpinv_html_select(array(
268
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $classes),
269 269
                     'name'             => 'vat_class',
270 270
                     'id'               => 'vat_class',
271 271
                     'selected'         => $class,
272 272
                     'show_option_all'  => false,
273 273
                     'show_option_none' => false,
274 274
                     'class'            => 'gdmbx2-text-medium wpi_select2',
275
-                    'placeholder'      => __( 'Select VAT class', 'invoicing' ),
276
-                ) );
275
+                    'placeholder'      => __('Select VAT class', 'invoicing'),
276
+                ));
277 277
         }
278 278
         
279 279
         // Sanitize selected item type.
280
-        $type   = '';
281
-        if( isset( $_GET['type'] ) && array_key_exists(  $_GET['type'], wpinv_get_item_types() ) ) {
282
-            $class   =  $_GET['type'];
280
+        $type = '';
281
+        if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) {
282
+            $class = $_GET['type'];
283 283
         }
284 284
 
285
-        echo wpinv_html_select( array(
286
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
285
+        echo wpinv_html_select(array(
286
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
287 287
                 'name'             => 'type',
288 288
                 'id'               => 'type',
289 289
                 'selected'         => $type,
290 290
                 'show_option_all'  => false,
291 291
                 'show_option_none' => false,
292 292
                 'class'            => 'gdmbx2-text-medium',
293
-            ) );
293
+            ));
294 294
 
295
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
295
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
296 296
             echo '<input type="hidden" name="all_posts" value="1" />';
297 297
         }
298 298
     }
299 299
 }
300
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
300
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
301 301
 
302
-function wpinv_send_invoice_after_save( $invoice ) {
303
-    if ( empty( $_POST['wpi_save_send'] ) ) {
302
+function wpinv_send_invoice_after_save($invoice) {
303
+    if (empty($_POST['wpi_save_send'])) {
304 304
         return;
305 305
     }
306 306
     
307
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
308
-        wpinv_user_invoice_notification( $invoice->ID );
307
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
308
+        wpinv_user_invoice_notification($invoice->ID);
309 309
     }
310 310
 }
311
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
311
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
312 312
 
313 313
 
314 314
 add_action('admin_init', 'admin_init_example_type');
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 function admin_init_example_type() {
320 320
     global $typenow;
321 321
 
322
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
322
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
323 323
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
324 324
     }
325 325
 }
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
     global $wpdb;
335 335
 
336 336
     if ($query->is_main_query() && !empty($query->query['s'])) {
337
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
338
-        if ( ! empty( $search ) ) {
339
-            $search = preg_replace( '/^ AND /', '', $search );
337
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
338
+        if (!empty($search)) {
339
+            $search = preg_replace('/^ AND /', '', $search);
340 340
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
341 341
         } else {
342 342
             $search = " AND ( {$conditions_str} )";
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
     return $search;
347 347
 }
348 348
 
349
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
350
-function wpinv_reset_invoice_count(){
351
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
349
+add_action('admin_init', 'wpinv_reset_invoice_count');
350
+function wpinv_reset_invoice_count() {
351
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
352 352
         wpinv_update_option('invoice_sequence_start', 1);
353 353
         delete_option('wpinv_last_invoice_number');
354 354
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 }
360 360
 
361 361
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
362
-function wpinv_invoice_count_reset_message(){
363
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
362
+function wpinv_invoice_count_reset_message() {
363
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
364 364
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
365 365
         ?>
366 366
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +818 added lines, -818 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  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
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
 
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
@@ -546,16 +546,16 @@  discard block
 block discarded – undo
546 546
     );
547 547
 
548 548
     $options = array();
549
-    if ( $items ) {
550
-        foreach ( $items as $item ) {
551
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
549
+    if ($items) {
550
+        foreach ($items as $item) {
551
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
552 552
         }
553 553
     }
554 554
 
555 555
     return $options;
556 556
 }
557 557
 
558
-function wpinv_html_checkbox( $args = array() ) {
558
+function wpinv_html_checkbox($args = array()) {
559 559
     $defaults = array(
560 560
         'name'     => null,
561 561
         'current'  => null,
@@ -566,38 +566,38 @@  discard block
 block discarded – undo
566 566
         )
567 567
     );
568 568
 
569
-    $args = wp_parse_args( $args, $defaults );
569
+    $args = wp_parse_args($args, $defaults);
570 570
 
571
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
571
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
572 572
     $options = '';
573
-    if ( ! empty( $args['options']['disabled'] ) ) {
573
+    if (!empty($args['options']['disabled'])) {
574 574
         $options .= ' disabled="disabled"';
575
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
575
+    } elseif (!empty($args['options']['readonly'])) {
576 576
         $options .= ' readonly';
577 577
     }
578 578
 
579
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
579
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
580 580
 
581 581
     return $output;
582 582
 }
583 583
 
584
-function wpinv_html_text( $args = array() ) {
584
+function wpinv_html_text($args = array()) {
585 585
     // Backwards compatibility
586
-    if ( func_num_args() > 1 ) {
586
+    if (func_num_args() > 1) {
587 587
         $args = func_get_args();
588 588
 
589 589
         $name  = $args[0];
590
-        $value = isset( $args[1] ) ? $args[1] : '';
591
-        $label = isset( $args[2] ) ? $args[2] : '';
592
-        $desc  = isset( $args[3] ) ? $args[3] : '';
590
+        $value = isset($args[1]) ? $args[1] : '';
591
+        $label = isset($args[2]) ? $args[2] : '';
592
+        $desc  = isset($args[3]) ? $args[3] : '';
593 593
     }
594 594
 
595 595
     $defaults = array(
596 596
         'id'           => '',
597
-        'name'         => isset( $name )  ? $name  : 'text',
598
-        'value'        => isset( $value ) ? $value : null,
599
-        'label'        => isset( $label ) ? $label : null,
600
-        'desc'         => isset( $desc )  ? $desc  : null,
597
+        'name'         => isset($name) ? $name : 'text',
598
+        'value'        => isset($value) ? $value : null,
599
+        'label'        => isset($label) ? $label : null,
600
+        'desc'         => isset($desc) ? $desc : null,
601 601
         'placeholder'  => '',
602 602
         'class'        => 'regular-text',
603 603
         'disabled'     => false,
@@ -607,51 +607,51 @@  discard block
 block discarded – undo
607 607
         'data'         => false
608 608
     );
609 609
 
610
-    $args = wp_parse_args( $args, $defaults );
610
+    $args = wp_parse_args($args, $defaults);
611 611
 
612
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
612
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
613 613
     $options = '';
614
-    if( $args['required'] ) {
614
+    if ($args['required']) {
615 615
         $options .= ' required="required"';
616 616
     }
617
-    if( $args['readonly'] ) {
617
+    if ($args['readonly']) {
618 618
         $options .= ' readonly';
619 619
     }
620
-    if( $args['readonly'] ) {
620
+    if ($args['readonly']) {
621 621
         $options .= ' readonly';
622 622
     }
623 623
 
624 624
     $data = '';
625
-    if ( !empty( $args['data'] ) ) {
626
-        foreach ( $args['data'] as $key => $value ) {
627
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
625
+    if (!empty($args['data'])) {
626
+        foreach ($args['data'] as $key => $value) {
627
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
628 628
         }
629 629
     }
630 630
 
631
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
632
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
633
-    if ( ! empty( $args['desc'] ) ) {
634
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
631
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
632
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
633
+    if (!empty($args['desc'])) {
634
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
635 635
     }
636 636
 
637
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
637
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
638 638
 
639 639
     $output .= '</span>';
640 640
 
641 641
     return $output;
642 642
 }
643 643
 
644
-function wpinv_html_date_field( $args = array() ) {
645
-    if( empty( $args['class'] ) ) {
644
+function wpinv_html_date_field($args = array()) {
645
+    if (empty($args['class'])) {
646 646
         $args['class'] = 'wpiDatepicker';
647
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
647
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
648 648
         $args['class'] .= ' wpiDatepicker';
649 649
     }
650 650
 
651
-    return wpinv_html_text( $args );
651
+    return wpinv_html_text($args);
652 652
 }
653 653
 
654
-function wpinv_html_textarea( $args = array() ) {
654
+function wpinv_html_textarea($args = array()) {
655 655
     $defaults = array(
656 656
         'name'        => 'textarea',
657 657
         'value'       => null,
@@ -662,31 +662,31 @@  discard block
 block discarded – undo
662 662
         'placeholder' => '',
663 663
     );
664 664
 
665
-    $args = wp_parse_args( $args, $defaults );
665
+    $args = wp_parse_args($args, $defaults);
666 666
 
667
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
667
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
668 668
     $disabled = '';
669
-    if( $args['disabled'] ) {
669
+    if ($args['disabled']) {
670 670
         $disabled = ' disabled="disabled"';
671 671
     }
672 672
 
673
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
674
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
675
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
673
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
674
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
675
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
676 676
 
677
-    if ( ! empty( $args['desc'] ) ) {
678
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
677
+    if (!empty($args['desc'])) {
678
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
679 679
     }
680 680
     $output .= '</span>';
681 681
 
682 682
     return $output;
683 683
 }
684 684
 
685
-function wpinv_html_ajax_user_search( $args = array() ) {
685
+function wpinv_html_ajax_user_search($args = array()) {
686 686
     $defaults = array(
687 687
         'name'        => 'user_id',
688 688
         'value'       => null,
689
-        'placeholder' => __( 'Enter username', 'invoicing' ),
689
+        'placeholder' => __('Enter username', 'invoicing'),
690 690
         'label'       => null,
691 691
         'desc'        => null,
692 692
         'class'       => '',
@@ -695,13 +695,13 @@  discard block
 block discarded – undo
695 695
         'data'        => false
696 696
     );
697 697
 
698
-    $args = wp_parse_args( $args, $defaults );
698
+    $args = wp_parse_args($args, $defaults);
699 699
 
700 700
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
701 701
 
702 702
     $output  = '<span class="wpinv_user_search_wrap">';
703
-        $output .= wpinv_html_text( $args );
704
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
703
+        $output .= wpinv_html_text($args);
704
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
705 705
     $output .= '</span>';
706 706
 
707 707
     return $output;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 function wpinv_ip_geolocation() {
711 711
     global $wpinv_euvat;
712 712
     
713
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
713
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
714 714
     $content    = '';
715 715
     $iso        = '';
716 716
     $country    = '';
@@ -721,69 +721,69 @@  discard block
 block discarded – undo
721 721
     $credit     = '';
722 722
     $address    = '';
723 723
     
724
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
724
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
725 725
         try {
726 726
             $iso        = $geoip2_city->country->isoCode;
727 727
             $country    = $geoip2_city->country->name;
728
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
728
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
729 729
             $city       = $geoip2_city->city->name;
730 730
             $longitude  = $geoip2_city->location->longitude;
731 731
             $latitude   = $geoip2_city->location->latitude;
732
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
733
-        } catch( Exception $e ) { }
732
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
733
+        } catch (Exception $e) { }
734 734
     }
735 735
     
736
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
736
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
737 737
         try {
738
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
738
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
739 739
             
740
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
740
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
741 741
                 $iso        = $load_xml->geoplugin_countryCode;
742 742
                 $country    = $load_xml->geoplugin_countryName;
743
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
744
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
743
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
744
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
745 745
                 $longitude  = $load_xml->geoplugin_longitude;
746 746
                 $latitude   = $load_xml->geoplugin_latitude;
747 747
                 $credit     = $load_xml->geoplugin_credit;
748
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
748
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
749 749
             }
750
-        } catch( Exception $e ) { }
750
+        } catch (Exception $e) { }
751 751
     }
752 752
     
753
-    if ( $iso && $longitude && $latitude ) {
754
-        if ( $city ) {
753
+    if ($iso && $longitude && $latitude) {
754
+        if ($city) {
755 755
             $address .= $city . ', ';
756 756
         }
757 757
         
758
-        if ( $region ) {
758
+        if ($region) {
759 759
             $address .= $region . ', ';
760 760
         }
761 761
         
762 762
         $address .= $country . ' (' . $iso . ')';
763
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
764
-        $content .= '<p>'. $credit . '</p>';
763
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
764
+        $content .= '<p>' . $credit . '</p>';
765 765
     } else {
766
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
766
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
767 767
     }
768 768
     ?>
769 769
 <!DOCTYPE html>
770
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
770
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
771 771
 <body>
772
-    <?php if ( $latitude && $latitude ) { ?>
772
+    <?php if ($latitude && $latitude) { ?>
773 773
     <div id="map"></div>
774 774
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
775 775
         <script type="text/javascript">
776 776
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
777 777
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
778 778
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
779
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
779
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
780 780
 
781 781
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
782 782
 
783 783
         var marker = new L.Marker(latlng);
784 784
         map.addLayer(marker);
785 785
 
786
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
786
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
787 787
     </script>
788 788
     <?php } ?>
789 789
     <div style="height:100px"><?php echo $content; ?></div>
@@ -791,18 +791,18 @@  discard block
 block discarded – undo
791 791
 <?php
792 792
     exit;
793 793
 }
794
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
795
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
794
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
795
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
796 796
 
797 797
 // Set up the template for the invoice.
798
-function wpinv_template( $template ) {
798
+function wpinv_template($template) {
799 799
     global $post, $wp_query;
800 800
     
801
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
802
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
803
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
801
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
802
+        if (wpinv_user_can_view_invoice($post->ID)) {
803
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
804 804
         } else {
805
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
805
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
806 806
         }
807 807
     }
808 808
 
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 
812 812
 function wpinv_get_business_address() {
813 813
     $business_address   = wpinv_store_address();
814
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
814
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
815 815
     
816 816
     /*
817 817
     $default_country    = wpinv_get_default_country();
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
     
836 836
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
837 837
     
838
-    return apply_filters( 'wpinv_get_business_address', $business_address );
838
+    return apply_filters('wpinv_get_business_address', $business_address);
839 839
 }
840 840
 
841 841
 function wpinv_display_from_address() {
@@ -845,116 +845,116 @@  discard block
 block discarded – undo
845 845
     if (empty($from_name)) {
846 846
         $from_name = wpinv_get_business_name();
847 847
     }
848
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
848
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
849 849
     <div class="wrapper col-xs-10">
850
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
851
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
852
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
850
+        <div class="name"><?php echo esc_html($from_name); ?></div>
851
+        <?php if ($address = wpinv_get_business_address()) { ?>
852
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
853 853
         <?php } ?>
854
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
855
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
854
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
855
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
856 856
         <?php } ?>
857 857
     </div>
858 858
     <?php
859 859
 }
860 860
 
861
-function wpinv_watermark( $id = 0 ) {
862
-    $output = wpinv_get_watermark( $id );
861
+function wpinv_watermark($id = 0) {
862
+    $output = wpinv_get_watermark($id);
863 863
     
864
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
864
+    return apply_filters('wpinv_get_watermark', $output, $id);
865 865
 }
866 866
 
867
-function wpinv_get_watermark( $id ) {
868
-    if ( !$id > 0 ) {
867
+function wpinv_get_watermark($id) {
868
+    if (!$id > 0) {
869 869
         return NULL;
870 870
     }
871
-    $invoice = wpinv_get_invoice( $id );
871
+    $invoice = wpinv_get_invoice($id);
872 872
     
873
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
874
-        if ( $invoice->is_paid() ) {
875
-            return __( 'Paid', 'invoicing' );
873
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
874
+        if ($invoice->is_paid()) {
875
+            return __('Paid', 'invoicing');
876 876
         }
877
-        if ( $invoice->is_refunded() ) {
878
-            return __( 'Refunded', 'invoicing' );
877
+        if ($invoice->is_refunded()) {
878
+            return __('Refunded', 'invoicing');
879 879
         }
880
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
881
-            return __( 'Cancelled', 'invoicing' );
880
+        if ($invoice->has_status(array('wpi-cancelled'))) {
881
+            return __('Cancelled', 'invoicing');
882 882
         }
883 883
     }
884 884
     
885 885
     return NULL;
886 886
 }
887 887
 
888
-function wpinv_display_invoice_details( $invoice ) {
888
+function wpinv_display_invoice_details($invoice) {
889 889
     global $wpinv_euvat;
890 890
     
891 891
     $invoice_id = $invoice->ID;
892 892
     $vat_name   = $wpinv_euvat->get_vat_name();
893 893
     $use_taxes  = wpinv_use_taxes();
894 894
     
895
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
895
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
896 896
     ?>
897 897
     <table class="table table-bordered table-sm">
898
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
898
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
899 899
             <tr class="wpi-row-number">
900
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
901
-                <td><?php echo esc_html( $invoice_number ); ?></td>
900
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
901
+                <td><?php echo esc_html($invoice_number); ?></td>
902 902
             </tr>
903 903
         <?php } ?>
904 904
         <tr class="wpi-row-status">
905
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
906
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
905
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
906
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
907 907
         </tr>
908
-        <?php if ( $invoice->is_renewal() ) { ?>
908
+        <?php if ($invoice->is_renewal()) { ?>
909 909
         <tr class="wpi-row-parent">
910
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
911
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
910
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
911
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
912 912
         </tr>
913 913
         <?php } ?>
914
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
914
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
915 915
             <tr class="wpi-row-gateway">
916
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
916
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
917 917
                 <td><?php echo $gateway_name; ?></td>
918 918
             </tr>
919 919
         <?php } ?>
920
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
920
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
921 921
             <tr class="wpi-row-date">
922
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
922
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
923 923
                 <td><?php echo $invoice_date; ?></td>
924 924
             </tr>
925 925
         <?php } ?>
926
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
927
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
926
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
927
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
928 928
             <tr class="wpi-row-date">
929
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
929
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
930 930
                 <td><?php echo $due_date; ?></td>
931 931
             </tr>
932 932
         <?php } ?>
933
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
934
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
933
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
934
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
935 935
             <tr class="wpi-row-ovatno">
936
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
936
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
937 937
                 <td><?php echo $owner_vat_number; ?></td>
938 938
             </tr>
939 939
         <?php } ?>
940
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
940
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
941 941
             <tr class="wpi-row-uvatno">
942
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
942
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
943 943
                 <td><?php echo $user_vat_number; ?></td>
944 944
             </tr>
945 945
         <?php } ?>
946 946
         <tr class="table-active tr-total wpi-row-total">
947
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
948
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
947
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
948
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
949 949
         </tr>
950
-        <?php if ( $subscription = wpinv_get_subscription( $invoice_id ) ) { ?>
950
+        <?php if ($subscription = wpinv_get_subscription($invoice_id)) { ?>
951 951
         <tr class="table-active wpi-row-recurring-total">
952
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Recurring Amount', 'invoicing' ), $invoice ); ?></th>
953
-            <td><strong><?php echo wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ); ?></strong></td>
952
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Recurring Amount', 'invoicing'), $invoice); ?></th>
953
+            <td><strong><?php echo wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()); ?></strong></td>
954 954
         </tr>
955 955
         <tr class="wpi-row-expires">
956
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Renews On', 'invoicing' ), $invoice ); ?></th>
957
-            <td><?php echo sanitize_text_field( $subscription->expiration ); ?></td>
956
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Renews On', 'invoicing'), $invoice); ?></th>
957
+            <td><?php echo sanitize_text_field($subscription->expiration); ?></td>
958 958
         </tr>
959 959
         <?php } ?>
960 960
     </table>
@@ -971,84 +971,84 @@  discard block
 block discarded – undo
971 971
  * @param  string $separator How to separate address lines.
972 972
  * @return string
973 973
  */
974
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
974
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
975 975
 
976 976
     // Retrieve the address markup...
977
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
978
-    $format = wpinv_get_full_address_format( $country );
977
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
978
+    $format = wpinv_get_full_address_format($country);
979 979
 
980 980
     // ... and the replacements.
981
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
981
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
982 982
 
983
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
983
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
984 984
     
985 985
 	// Remove unavailable tags.
986
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
986
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
987 987
 
988 988
     // Clean up white space.
989
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
990
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
989
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
990
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
991 991
     
992 992
     // Break newlines apart and remove empty lines/trim commas and white space.
993
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
993
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
994 994
 
995 995
     // Add html breaks.
996
-	$formatted_address = implode( $separator, $formatted_address );
996
+	$formatted_address = implode($separator, $formatted_address);
997 997
 
998 998
 	// We're done!
999 999
 	return $formatted_address;
1000 1000
     
1001 1001
 }
1002 1002
 
1003
-function wpinv_display_to_address( $invoice_id = 0 ) {
1004
-    $invoice = wpinv_get_invoice( $invoice_id );
1003
+function wpinv_display_to_address($invoice_id = 0) {
1004
+    $invoice = wpinv_get_invoice($invoice_id);
1005 1005
     
1006
-    if ( empty( $invoice ) ) {
1006
+    if (empty($invoice)) {
1007 1007
         return NULL;
1008 1008
     }
1009 1009
     
1010 1010
     $billing_details = $invoice->get_user_info();
1011
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
1011
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
1012 1012
     $output .= '<div class="wrapper col-xs-10">';
1013 1013
     
1014 1014
     ob_start();
1015
-    do_action( 'wpinv_display_to_address_top', $invoice );
1015
+    do_action('wpinv_display_to_address_top', $invoice);
1016 1016
     $output .= ob_get_clean();
1017 1017
     
1018
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1018
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1019 1019
 
1020
-    if ( $address_row ) {
1020
+    if ($address_row) {
1021 1021
         $output .= '<div class="address">' . $address_row . '</div>';
1022 1022
     }
1023 1023
 
1024
-    if ( $phone = $invoice->get_phone() ) {
1025
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
1024
+    if ($phone = $invoice->get_phone()) {
1025
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
1026 1026
     }
1027
-    if ( $email = $invoice->get_email() ) {
1028
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
1027
+    if ($email = $invoice->get_email()) {
1028
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
1029 1029
     }
1030 1030
 
1031 1031
     ob_start();
1032
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
1032
+    do_action('wpinv_display_to_address_bottom', $invoice);
1033 1033
     $output .= ob_get_clean();
1034 1034
     
1035 1035
     $output .= '</div>';
1036
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1036
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1037 1037
 
1038 1038
     echo $output;
1039 1039
 }
1040 1040
 
1041
-function wpinv_display_line_items( $invoice_id = 0 ) {
1041
+function wpinv_display_line_items($invoice_id = 0) {
1042 1042
     global $wpinv_euvat, $ajax_cart_details;
1043
-    $invoice            = wpinv_get_invoice( $invoice_id );
1043
+    $invoice            = wpinv_get_invoice($invoice_id);
1044 1044
     $quantities_enabled = wpinv_item_quantities_enabled();
1045 1045
     $use_taxes          = wpinv_use_taxes();
1046
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1046
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1047 1047
         $use_taxes = true;
1048 1048
     }
1049
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1050
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1051
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1049
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1050
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1051
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1052 1052
 
1053 1053
     $cart_details       = $invoice->get_cart_details();
1054 1054
     $ajax_cart_details  = $cart_details;
@@ -1057,67 +1057,67 @@  discard block
 block discarded – undo
1057 1057
     <table class="table table-sm table-bordered">
1058 1058
         <thead>
1059 1059
             <tr>
1060
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1061
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1060
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1061
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1062 1062
                 <?php if ($quantities_enabled) { ?>
1063
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1063
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1064 1064
                 <?php } ?>
1065 1065
                 <?php if ($use_taxes && !$zero_tax) { ?>
1066 1066
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1067 1067
                 <?php } ?>
1068
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1068
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1069 1069
             </tr>
1070 1070
         </thead>
1071 1071
         <tbody>
1072 1072
         <?php 
1073
-            if ( !empty( $cart_details ) ) {
1074
-                do_action( 'wpinv_display_line_items_start', $invoice );
1073
+            if (!empty($cart_details)) {
1074
+                do_action('wpinv_display_line_items_start', $invoice);
1075 1075
 
1076 1076
                 $count = 0;
1077 1077
                 $cols  = 3;
1078
-                foreach ( $cart_details as $key => $cart_item ) {
1079
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1080
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1081
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1082
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1078
+                foreach ($cart_details as $key => $cart_item) {
1079
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1080
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1081
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1082
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1083 1083
 
1084
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1084
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1085 1085
                     $summary    = '';
1086
-	                $item_name    = '';
1086
+	                $item_name = '';
1087 1087
                     $cols       = 3;
1088
-                    if ( !empty($item) ) {
1088
+                    if (!empty($item)) {
1089 1089
                         $item_name  = $item->get_name();
1090 1090
                         $summary    = $item->get_summary();
1091 1091
                     }
1092
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1092
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1093 1093
 
1094
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1094
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1095 1095
 
1096 1096
                     $item_tax       = '';
1097 1097
                     $tax_rate       = '';
1098
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1099
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1100
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1101
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1098
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1099
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1100
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1101
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1102 1102
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1103 1103
                     }
1104 1104
 
1105 1105
                     $line_item_tax = $item_tax . $tax_rate;
1106 1106
 
1107
-                    if ( $line_item_tax === '' ) {
1107
+                    if ($line_item_tax === '') {
1108 1108
                         $line_item_tax = 0; // Zero tax
1109 1109
                     }
1110 1110
 
1111
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1111
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1112 1112
 
1113
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1114
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1115
-                        if ( $summary !== '' ) {
1116
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1113
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1114
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1115
+                        if ($summary !== '') {
1116
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1117 1117
                         }
1118 1118
                         $line_item .= '</td>';
1119 1119
 
1120
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1120
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1121 1121
                         if ($quantities_enabled) {
1122 1122
                             $cols++;
1123 1123
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1126,55 +1126,55 @@  discard block
 block discarded – undo
1126 1126
                             $cols++;
1127 1127
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1128 1128
                         }
1129
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1129
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1130 1130
                     $line_item .= '</tr>';
1131 1131
 
1132
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1132
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1133 1133
 
1134 1134
                     $count++;
1135 1135
                 }
1136 1136
 
1137
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1137
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1138 1138
                 ?>
1139 1139
                 <tr class="row-sub-total row_odd">
1140
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1141
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1140
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1141
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1142 1142
                 </tr>
1143 1143
                 <?php
1144
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1144
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1145 1145
                 
1146
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1147
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1146
+                if (wpinv_discount($invoice_id, false) > 0) {
1147
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1148 1148
                     ?>
1149 1149
                         <tr class="row-discount">
1150
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1151
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1150
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1151
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1152 1152
                         </tr>
1153 1153
                     <?php
1154
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1154
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1155 1155
                 }
1156 1156
 
1157
-                if ( $use_taxes ) {
1158
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1157
+                if ($use_taxes) {
1158
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1159 1159
                     ?>
1160 1160
                     <tr class="row-tax">
1161
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1162
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1161
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1162
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1163 1163
                     </tr>
1164 1164
                     <?php
1165
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1165
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1166 1166
                 }
1167 1167
 
1168
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1168
+                do_action('wpinv_display_before_total', $invoice, $cols);
1169 1169
                 ?>
1170 1170
                 <tr class="table-active row-total">
1171
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1172
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1171
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1172
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1173 1173
                 </tr>
1174 1174
                 <?php
1175
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1175
+                do_action('wpinv_display_after_total', $invoice, $cols);
1176 1176
 
1177
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1177
+                do_action('wpinv_display_line_end', $invoice, $cols);
1178 1178
             }
1179 1179
         ?>
1180 1180
         </tbody>
@@ -1186,56 +1186,56 @@  discard block
 block discarded – undo
1186 1186
 /**
1187 1187
  * @param WPInv_Invoice $invoice
1188 1188
  */
1189
-function wpinv_display_invoice_notes( $invoice ) {
1189
+function wpinv_display_invoice_notes($invoice) {
1190 1190
 
1191
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1191
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1192 1192
 
1193
-    if ( empty( $notes ) ) {
1193
+    if (empty($notes)) {
1194 1194
         return;
1195 1195
     }
1196 1196
 
1197 1197
     echo '<div class="wpi_invoice_notes_container">';
1198
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1198
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1199 1199
     echo '<ul class="wpi_invoice_notes">';
1200 1200
 
1201
-    foreach( $notes as $note ) {
1202
-        wpinv_get_invoice_note_line_item( $note );
1201
+    foreach ($notes as $note) {
1202
+        wpinv_get_invoice_note_line_item($note);
1203 1203
     }
1204 1204
 
1205 1205
     echo '</ul>';
1206 1206
     echo '</div>';
1207 1207
 }
1208
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1208
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1209 1209
 
1210
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1210
+function wpinv_display_invoice_totals($invoice_id = 0) {
1211 1211
     $use_taxes = wpinv_use_taxes();
1212 1212
 
1213
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1213
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1214 1214
     ?>
1215 1215
     <table class="table table-sm table-bordered table-responsive">
1216 1216
         <tbody>
1217
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1217
+            <?php do_action('wpinv_before_display_totals'); ?>
1218 1218
             <tr class="row-sub-total">
1219
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1220
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1219
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1220
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1221 1221
             </tr>
1222
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1223
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1222
+            <?php do_action('wpinv_after_display_totals'); ?>
1223
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1224 1224
                 <tr class="row-discount">
1225
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1226
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1225
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1226
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1227 1227
                 </tr>
1228
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1228
+            <?php do_action('wpinv_after_display_discount'); ?>
1229 1229
             <?php } ?>
1230
-            <?php if ( $use_taxes ) { ?>
1230
+            <?php if ($use_taxes) { ?>
1231 1231
             <tr class="row-tax">
1232
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1233
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1232
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1233
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1234 1234
             </tr>
1235
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1235
+            <?php do_action('wpinv_after_display_tax'); ?>
1236 1236
             <?php } ?>
1237
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1238
-                <?php foreach ( $fees as $fee ) { ?>
1237
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1238
+                <?php foreach ($fees as $fee) { ?>
1239 1239
                     <tr class="row-fee">
1240 1240
                         <td class="rate"><?php echo $fee['label']; ?></td>
1241 1241
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1243,82 +1243,82 @@  discard block
 block discarded – undo
1243 1243
                 <?php } ?>
1244 1244
             <?php } ?>
1245 1245
             <tr class="table-active row-total">
1246
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1247
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1246
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1247
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1248 1248
             </tr>
1249
-            <?php do_action( 'wpinv_after_totals' ); ?>
1249
+            <?php do_action('wpinv_after_totals'); ?>
1250 1250
         </tbody>
1251 1251
 
1252 1252
     </table>
1253 1253
 
1254
-    <?php do_action( 'wpinv_after_totals_table' );
1254
+    <?php do_action('wpinv_after_totals_table');
1255 1255
 }
1256 1256
 
1257
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1258
-    $invoice = wpinv_get_invoice( $invoice_id );
1257
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1258
+    $invoice = wpinv_get_invoice($invoice_id);
1259 1259
 
1260 1260
     ob_start();
1261
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1262
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1261
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1262
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1263 1263
         ?>
1264 1264
         <div class="wpi-payment-info">
1265
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1266
-            <?php if ( $gateway_title ) { ?>
1267
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1265
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1266
+            <?php if ($gateway_title) { ?>
1267
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1268 1268
             <?php } ?>
1269 1269
         </div>
1270 1270
         <?php
1271 1271
     }
1272
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1272
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1273 1273
     $outout = ob_get_clean();
1274 1274
 
1275
-    if ( $echo ) {
1275
+    if ($echo) {
1276 1276
         echo $outout;
1277 1277
     } else {
1278 1278
         return $outout;
1279 1279
     }
1280 1280
 }
1281 1281
 
1282
-function wpinv_display_style( $invoice ) {
1283
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1282
+function wpinv_display_style($invoice) {
1283
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1284 1284
 
1285
-    wp_print_styles( 'open-sans' );
1286
-    wp_print_styles( 'wpinv-single-style' );
1285
+    wp_print_styles('open-sans');
1286
+    wp_print_styles('wpinv-single-style');
1287 1287
 
1288 1288
     $custom_css = wpinv_get_option('template_custom_css');
1289
-    if(isset($custom_css) && !empty($custom_css)){
1290
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1291
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1289
+    if (isset($custom_css) && !empty($custom_css)) {
1290
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1291
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1292 1292
         echo '<style type="text/css">';
1293 1293
         echo $custom_css;
1294 1294
         echo '</style>';
1295 1295
     }
1296 1296
 }
1297
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1298
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1297
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1298
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1299 1299
 
1300 1300
 function wpinv_checkout_billing_details() {
1301
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1301
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1302 1302
     if (empty($invoice_id)) {
1303
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1303
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1304 1304
         return null;
1305 1305
     }
1306 1306
 
1307
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1307
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1308 1308
     if (empty($invoice)) {
1309
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1309
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1310 1310
         return null;
1311 1311
     }
1312 1312
     $user_id        = $invoice->get_user_id();
1313 1313
     $user_info      = $invoice->get_user_info();
1314
-    $address_info   = wpinv_get_user_address( $user_id );
1314
+    $address_info   = wpinv_get_user_address($user_id);
1315 1315
 
1316
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1316
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1317 1317
         $user_info['first_name'] = $user_info['first_name'];
1318 1318
         $user_info['last_name'] = $user_info['last_name'];
1319 1319
     }
1320 1320
 
1321
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1321
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1322 1322
         $user_info['country']   = $address_info['country'];
1323 1323
         $user_info['state']     = $address_info['state'];
1324 1324
         $user_info['city']      = $address_info['city'];
@@ -1334,99 +1334,99 @@  discard block
 block discarded – undo
1334 1334
         'address'
1335 1335
     );
1336 1336
 
1337
-    foreach ( $address_fields as $field ) {
1338
-        if ( empty( $user_info[$field] ) ) {
1337
+    foreach ($address_fields as $field) {
1338
+        if (empty($user_info[$field])) {
1339 1339
             $user_info[$field] = $address_info[$field];
1340 1340
         }
1341 1341
     }
1342 1342
 
1343
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1343
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1344 1344
 }
1345 1345
 
1346 1346
 function wpinv_admin_get_line_items($invoice = array()) {
1347 1347
     $item_quantities    = wpinv_item_quantities_enabled();
1348 1348
     $use_taxes          = wpinv_use_taxes();
1349 1349
 
1350
-    if ( empty( $invoice ) ) {
1350
+    if (empty($invoice)) {
1351 1351
         return NULL;
1352 1352
     }
1353 1353
 
1354 1354
     $cart_items = $invoice->get_cart_details();
1355
-    if ( empty( $cart_items ) ) {
1355
+    if (empty($cart_items)) {
1356 1356
         return NULL;
1357 1357
     }
1358 1358
 
1359 1359
     ob_start();
1360 1360
 
1361
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1361
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1362 1362
 
1363 1363
     $count = 0;
1364
-    foreach ( $cart_items as $key => $cart_item ) {
1364
+    foreach ($cart_items as $key => $cart_item) {
1365 1365
         $item_id    = $cart_item['id'];
1366
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1366
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1367 1367
 
1368 1368
         if (empty($wpi_item)) {
1369 1369
             continue;
1370 1370
         }
1371 1371
 
1372
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1373
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1374
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1372
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1373
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1374
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1375 1375
         $can_remove     = true;
1376 1376
 
1377
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1377
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1378 1378
 
1379 1379
         $item_tax       = '';
1380 1380
         $tax_rate       = '';
1381
-        if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1382
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1383
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1384
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1381
+        if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1382
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1383
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1384
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1385 1385
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1386 1386
         }
1387 1387
         $line_item_tax = $item_tax . $tax_rate;
1388 1388
 
1389
-        if ( $line_item_tax === '' ) {
1389
+        if ($line_item_tax === '') {
1390 1390
             $line_item_tax = 0; // Zero tax
1391 1391
         }
1392 1392
 
1393
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1393
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1394 1394
             $line_item .= '<td class="id">' . $item_id . '</td>';
1395
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1396
-            if ( $summary !== '' ) {
1397
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1395
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1396
+            if ($summary !== '') {
1397
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1398 1398
             }
1399 1399
             $line_item .= '</td>';
1400 1400
             $line_item .= '<td class="price">' . $item_price . '</td>';
1401 1401
             
1402
-            if ( $item_quantities ) {
1403
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1402
+            if ($item_quantities) {
1403
+                if (count($cart_items) == 1 && $quantity <= 1) {
1404 1404
                     $can_remove = false;
1405 1405
                 }
1406 1406
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1407 1407
             } else {
1408
-                if ( count( $cart_items ) == 1 ) {
1408
+                if (count($cart_items) == 1) {
1409 1409
                     $can_remove = false;
1410 1410
                 }
1411 1411
             }
1412 1412
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1413 1413
             
1414
-            if ( $use_taxes ) {
1414
+            if ($use_taxes) {
1415 1415
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1416 1416
             }
1417 1417
             $line_item .= '<td class="action">';
1418
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1418
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1419 1419
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1420 1420
             }
1421 1421
             $line_item .= '</td>';
1422 1422
         $line_item .= '</tr>';
1423 1423
 
1424
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1424
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1425 1425
 
1426 1426
         $count++;
1427 1427
     } 
1428 1428
 
1429
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1429
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1430 1430
 
1431 1431
     return ob_get_clean();
1432 1432
 }
@@ -1436,70 +1436,70 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
     // Set current invoice id.
1438 1438
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1439
-    $form_action     = esc_url( wpinv_get_checkout_uri() );
1439
+    $form_action     = esc_url(wpinv_get_checkout_uri());
1440 1440
     $payment_form    = wpinv_get_default_payment_form();
1441 1441
 
1442 1442
     ob_start();
1443
-	    do_action( 'wpinv_checkout_content_before' );
1443
+	    do_action('wpinv_checkout_content_before');
1444 1444
 
1445
-        if ( wpinv_get_cart_contents() ) {
1445
+        if (wpinv_get_cart_contents()) {
1446 1446
 
1447 1447
             // Get the form elements and items.
1448
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1449
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1448
+	        $elements = $invoicing->form_elements->get_form_elements($payment_form);
1449
+	        $items    = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart());
1450 1450
             ?>
1451 1451
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1452
-                <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
1453
-                <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/>
1454
-                <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/>
1452
+                <?php do_action('wpinv_main_checkout_form_top'); ?>
1453
+                <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/>
1454
+                <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/>
1455 1455
                     <?php
1456
-                        wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1457
-                        wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1456
+                        wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1457
+                        wp_nonce_field('vat_validation', '_wpi_nonce');
1458 1458
 
1459
-                        foreach ( $elements as $element ) {
1460
-                            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form );
1461
-                            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form );
1459
+                        foreach ($elements as $element) {
1460
+                            do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form);
1461
+                            do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form);
1462 1462
                         }
1463 1463
                     ?>
1464 1464
                 <div class='wpinv_payment_form_errors alert alert-danger d-none'></div>
1465
-                <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?>
1465
+                <?php do_action('wpinv_main_checkout_form_bottom'); ?>
1466 1466
             </form>
1467 1467
         <?php
1468 1468
 
1469 1469
         } else {
1470
-            do_action( 'wpinv_cart_empty' );
1470
+            do_action('wpinv_cart_empty');
1471 1471
         }
1472 1472
         echo '</div><!--end #wpinv_checkout_wrap-->';
1473
-	    do_action( 'wpinv_checkout_content_after' );
1473
+	    do_action('wpinv_checkout_content_after');
1474 1474
         $content = ob_get_clean();
1475 1475
 
1476
-		return str_replace( 'sr-only', '', $content );
1476
+		return str_replace('sr-only', '', $content);
1477 1477
 }
1478 1478
 
1479
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1479
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1480 1480
     global $ajax_cart_details;
1481 1481
     $ajax_cart_details = $cart_details;
1482 1482
 
1483 1483
     ob_start();
1484
-    do_action( 'wpinv_before_checkout_cart' );
1484
+    do_action('wpinv_before_checkout_cart');
1485 1485
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1486 1486
         echo '<div id="wpinv_checkout_cart_wrap">';
1487
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1487
+            wpinv_get_template_part('wpinv-checkout-cart');
1488 1488
         echo '</div>';
1489 1489
     echo '</div>';
1490
-    do_action( 'wpinv_after_checkout_cart' );
1490
+    do_action('wpinv_after_checkout_cart');
1491 1491
     $content = ob_get_clean();
1492 1492
 
1493
-    if ( $echo ) {
1493
+    if ($echo) {
1494 1494
         echo $content;
1495 1495
     } else {
1496 1496
         return $content;
1497 1497
     }
1498 1498
 }
1499
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1499
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1500 1500
 
1501 1501
 function wpinv_empty_cart_message() {
1502
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1502
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1503 1503
 }
1504 1504
 
1505 1505
 /**
@@ -1516,83 +1516,83 @@  discard block
 block discarded – undo
1516 1516
         )
1517 1517
     );
1518 1518
 }
1519
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1519
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1520 1520
 
1521 1521
 function wpinv_update_cart_button() {
1522
-    if ( !wpinv_item_quantities_enabled() )
1522
+    if (!wpinv_item_quantities_enabled())
1523 1523
         return;
1524 1524
 ?>
1525
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1525
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1526 1526
     <input type="hidden" name="wpi_action" value="update_cart"/>
1527 1527
 <?php
1528 1528
 }
1529 1529
 
1530 1530
 function wpinv_checkout_cart_columns() {
1531 1531
     $default = 3;
1532
-    if ( wpinv_item_quantities_enabled() ) {
1532
+    if (wpinv_item_quantities_enabled()) {
1533 1533
         $default++;
1534 1534
     }
1535 1535
     
1536
-    if ( wpinv_use_taxes() ) {
1536
+    if (wpinv_use_taxes()) {
1537 1537
         $default++;
1538 1538
     }
1539 1539
 
1540
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1540
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1541 1541
 }
1542 1542
 
1543 1543
 function wpinv_display_cart_messages() {
1544 1544
     global $wpi_session;
1545 1545
 
1546
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1546
+    $messages = $wpi_session->get('wpinv_cart_messages');
1547 1547
 
1548
-    if ( $messages ) {
1549
-        foreach ( $messages as $message_id => $message ) {
1548
+    if ($messages) {
1549
+        foreach ($messages as $message_id => $message) {
1550 1550
             // Try and detect what type of message this is
1551
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1551
+            if (strpos(strtolower($message), 'error')) {
1552 1552
                 $type = 'error';
1553
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1553
+            } elseif (strpos(strtolower($message), 'success')) {
1554 1554
                 $type = 'success';
1555 1555
             } else {
1556 1556
                 $type = 'info';
1557 1557
             }
1558 1558
 
1559
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1559
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1560 1560
 
1561
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1561
+            echo '<div class="' . implode(' ', $classes) . '">';
1562 1562
                 // Loop message codes and display messages
1563 1563
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1564 1564
             echo '</div>';
1565 1565
         }
1566 1566
 
1567 1567
         // Remove all of the cart saving messages
1568
-        $wpi_session->set( 'wpinv_cart_messages', null );
1568
+        $wpi_session->set('wpinv_cart_messages', null);
1569 1569
     }
1570 1570
 }
1571
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1571
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1572 1572
 
1573 1573
 function wpinv_discount_field() {
1574
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1574
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1575 1575
         return; // Only show before a payment method has been selected if ajax is disabled
1576 1576
     }
1577 1577
 
1578
-    if ( !wpinv_is_checkout() ) {
1578
+    if (!wpinv_is_checkout()) {
1579 1579
         return;
1580 1580
     }
1581 1581
 
1582
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1582
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1583 1583
     ?>
1584 1584
     <div id="wpinv-discount-field" class="panel panel-default">
1585 1585
         <div class="panel-body">
1586 1586
             <p>
1587
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1588
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1587
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1588
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1589 1589
             </p>
1590 1590
             <div class="form-group row">
1591 1591
                 <div class="col-sm-4">
1592
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1592
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1593 1593
                 </div>
1594 1594
                 <div class="col-sm-3">
1595
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1595
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1596 1596
                 </div>
1597 1597
                 <div style="clear:both"></div>
1598 1598
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1605,10 +1605,10 @@  discard block
 block discarded – undo
1605 1605
 <?php
1606 1606
     }
1607 1607
 }
1608
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1608
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1609 1609
 
1610 1610
 function wpinv_agree_to_terms_js() {
1611
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1611
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1612 1612
 ?>
1613 1613
 <script type="text/javascript">
1614 1614
     jQuery(document).ready(function($){
@@ -1623,127 +1623,127 @@  discard block
 block discarded – undo
1623 1623
 <?php
1624 1624
     }
1625 1625
 }
1626
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1626
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1627 1627
 
1628
-function wpinv_payment_mode_select( $title ) {
1629
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1630
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1631
-    $invoice = wpinv_get_invoice( 0, true );
1628
+function wpinv_payment_mode_select($title) {
1629
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1630
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1631
+    $invoice = wpinv_get_invoice(0, true);
1632 1632
 
1633 1633
     do_action('wpinv_payment_mode_top');
1634
-    $invoice_id = $invoice ? (int)$invoice->ID : 0;
1635
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1634
+    $invoice_id = $invoice ? (int) $invoice->ID : 0;
1635
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1636 1636
     ?>
1637
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>>
1638
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1637
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>>
1638
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1639 1639
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1640 1640
                 <div class="panel-heading wpi-payment_methods_title">
1641
-                    <h6 class="panel-title"><?php echo sanitize_text_field( $title ); ?></h6>
1641
+                    <h6 class="panel-title"><?php echo sanitize_text_field($title); ?></h6>
1642 1642
                 </div>
1643 1643
                 <div class="panel-body wpi-payment_methods">
1644 1644
                     <?php
1645
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1646
-
1647
-                    if ( !empty( $gateways ) ) {
1648
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1649
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1650
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1651
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1652
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1645
+                    do_action('wpinv_payment_mode_before_gateways');
1646
+
1647
+                    if (!empty($gateways)) {
1648
+                        foreach ($gateways as $gateway_id => $gateway) {
1649
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1650
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1651
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1652
+                            $description   = wpinv_get_gateway_description($gateway_id);
1653 1653
                             ?>
1654 1654
                             <div class="pt-2 pb-2">
1655 1655
                                 <div class="radio">
1656
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1656
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1657 1657
                                 </div>
1658
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1659
-                                    <?php if ( !empty( $description ) ) { ?>
1660
-                                        <div class="wpi-gateway-desc"><?php _e( $description, 'invoicing' ); ?></div>
1658
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1659
+                                    <?php if (!empty($description)) { ?>
1660
+                                        <div class="wpi-gateway-desc"><?php _e($description, 'invoicing'); ?></div>
1661 1661
                                     <?php } ?>
1662
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1662
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1663 1663
                                 </div>
1664 1664
                             </div>
1665 1665
                             <?php
1666 1666
                         }
1667 1667
                     } else {
1668
-                        echo '<div class="alert alert-danger">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1668
+                        echo '<div class="alert alert-danger">' . __('No payment gateway active', 'invoicing') . '</div>';
1669 1669
                     }
1670 1670
 
1671
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1671
+                    do_action('wpinv_payment_mode_after_gateways');
1672 1672
                     ?>
1673 1673
                 </div>
1674 1674
             </div>
1675
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1675
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1676 1676
     </div>
1677 1677
     <?php
1678 1678
     do_action('wpinv_payment_mode_bottom');
1679 1679
 }
1680
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1680
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1681 1681
 
1682 1682
 function wpinv_checkout_billing_info() {
1683
-    if ( wpinv_is_checkout() ) {
1683
+    if (wpinv_is_checkout()) {
1684 1684
         $billing_details    = wpinv_checkout_billing_details();
1685
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1685
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1686 1686
         ?>
1687 1687
         <div id="wpinv-fields" class="clearfix">
1688 1688
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1689
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1689
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1690 1690
                 <div id="wpinv-fields-box" class="panel-body">
1691
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1691
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1692 1692
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1693
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1693
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1694 1694
                         <?php
1695
-                        echo wpinv_html_text( array(
1695
+                        echo wpinv_html_text(array(
1696 1696
                                 'id'            => 'wpinv_first_name',
1697 1697
                                 'name'          => 'wpinv_first_name',
1698 1698
                                 'value'         => $billing_details['first_name'],
1699 1699
                                 'class'         => 'wpi-input form-control',
1700
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1701
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1702
-                            ) );
1700
+                                'placeholder'   => __('First name', 'invoicing'),
1701
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1702
+                            ));
1703 1703
                         ?>
1704 1704
                     </p>
1705 1705
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1706
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1706
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1707 1707
                         <?php
1708
-                        echo wpinv_html_text( array(
1708
+                        echo wpinv_html_text(array(
1709 1709
                                 'id'            => 'wpinv_last_name',
1710 1710
                                 'name'          => 'wpinv_last_name',
1711 1711
                                 'value'         => $billing_details['last_name'],
1712 1712
                                 'class'         => 'wpi-input form-control',
1713
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1714
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1715
-                            ) );
1713
+                                'placeholder'   => __('Last name', 'invoicing'),
1714
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1715
+                            ));
1716 1716
                         ?>
1717 1717
                     </p>
1718 1718
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1719
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1719
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1720 1720
                         <?php
1721
-                        echo wpinv_html_text( array(
1721
+                        echo wpinv_html_text(array(
1722 1722
                                 'id'            => 'wpinv_address',
1723 1723
                                 'name'          => 'wpinv_address',
1724 1724
                                 'value'         => $billing_details['address'],
1725 1725
                                 'class'         => 'wpi-input form-control',
1726
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1727
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1728
-                            ) );
1726
+                                'placeholder'   => __('Address', 'invoicing'),
1727
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1728
+                            ));
1729 1729
                         ?>
1730 1730
                     </p>
1731 1731
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1732
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1732
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1733 1733
                         <?php
1734
-                        echo wpinv_html_text( array(
1734
+                        echo wpinv_html_text(array(
1735 1735
                                 'id'            => 'wpinv_city',
1736 1736
                                 'name'          => 'wpinv_city',
1737 1737
                                 'value'         => $billing_details['city'],
1738 1738
                                 'class'         => 'wpi-input form-control',
1739
-                                'placeholder'   => __( 'City', 'invoicing' ),
1740
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1741
-                            ) );
1739
+                                'placeholder'   => __('City', 'invoicing'),
1740
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1741
+                            ));
1742 1742
                         ?>
1743 1743
                     </p>
1744 1744
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1745
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1746
-                        <?php echo wpinv_html_select( array(
1745
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1746
+                        <?php echo wpinv_html_select(array(
1747 1747
                             'options'          => wpinv_get_country_list(),
1748 1748
                             'name'             => 'wpinv_country',
1749 1749
                             'id'               => 'wpinv_country',
@@ -1751,16 +1751,16 @@  discard block
 block discarded – undo
1751 1751
                             'show_option_all'  => false,
1752 1752
                             'show_option_none' => false,
1753 1753
                             'class'            => 'wpi-input form-control wpi_select2',
1754
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1755
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1756
-                        ) ); ?>
1754
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1755
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1756
+                        )); ?>
1757 1757
                     </p>
1758 1758
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1759
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1759
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1760 1760
                         <?php
1761
-                        $states = wpinv_get_country_states( $selected_country );
1762
-                        if( !empty( $states ) ) {
1763
-                            echo wpinv_html_select( array(
1761
+                        $states = wpinv_get_country_states($selected_country);
1762
+                        if (!empty($states)) {
1763
+                            echo wpinv_html_select(array(
1764 1764
                                 'options'          => $states,
1765 1765
                                 'name'             => 'wpinv_state',
1766 1766
                                 'id'               => 'wpinv_state',
@@ -1768,61 +1768,61 @@  discard block
 block discarded – undo
1768 1768
                                 'show_option_all'  => false,
1769 1769
                                 'show_option_none' => false,
1770 1770
                                 'class'            => 'wpi-input form-control wpi_select2',
1771
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1772
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1773
-                            ) );
1771
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1772
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1773
+                            ));
1774 1774
                         } else {
1775
-                            echo wpinv_html_text( array(
1775
+                            echo wpinv_html_text(array(
1776 1776
                                 'name'          => 'wpinv_state',
1777 1777
                                 'value'         => $billing_details['state'],
1778 1778
                                 'id'            => 'wpinv_state',
1779 1779
                                 'class'         => 'wpi-input form-control',
1780
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1781
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1782
-                            ) );
1780
+                                'placeholder'   => __('State / Province', 'invoicing'),
1781
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1782
+                            ));
1783 1783
                         }
1784 1784
                         ?>
1785 1785
                     </p>
1786 1786
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1787
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1787
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1788 1788
                         <?php
1789
-                        echo wpinv_html_text( array(
1789
+                        echo wpinv_html_text(array(
1790 1790
                                 'name'          => 'wpinv_zip',
1791 1791
                                 'value'         => $billing_details['zip'],
1792 1792
                                 'id'            => 'wpinv_zip',
1793 1793
                                 'class'         => 'wpi-input form-control',
1794
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1795
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1796
-                            ) );
1794
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1795
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1796
+                            ));
1797 1797
                         ?>
1798 1798
                     </p>
1799 1799
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1800
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1800
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1801 1801
                         <?php
1802
-                        echo wpinv_html_text( array(
1802
+                        echo wpinv_html_text(array(
1803 1803
                                 'id'            => 'wpinv_phone',
1804 1804
                                 'name'          => 'wpinv_phone',
1805 1805
                                 'value'         => $billing_details['phone'],
1806 1806
                                 'class'         => 'wpi-input form-control',
1807
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1808
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1809
-                            ) );
1807
+                                'placeholder'   => __('Phone', 'invoicing'),
1808
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1809
+                            ));
1810 1810
                         ?>
1811 1811
                     </p>
1812
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1812
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1813 1813
                     <div class="clearfix"></div>
1814 1814
                 </div>
1815 1815
             </div>
1816
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1816
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1817 1817
         </div>
1818 1818
         <?php
1819 1819
     }
1820 1820
 }
1821
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1821
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1822 1822
 
1823 1823
 function wpinv_checkout_hidden_fields() {
1824 1824
 ?>
1825
-    <?php if ( is_user_logged_in() ) { ?>
1825
+    <?php if (is_user_logged_in()) { ?>
1826 1826
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1827 1827
     <?php } ?>
1828 1828
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
 function wpinv_checkout_button_purchase() {
1833 1833
     ob_start();
1834 1834
 ?>
1835
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1835
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1836 1836
 <?php
1837
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1837
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1838 1838
 }
1839 1839
 
1840 1840
 function wpinv_checkout_total() {
@@ -1843,64 +1843,64 @@  discard block
 block discarded – undo
1843 1843
 <div id="wpinv_checkout_total" class="panel panel-info">
1844 1844
     <div class="panel-body">
1845 1845
     <?php
1846
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1846
+    do_action('wpinv_purchase_form_before_checkout_total');
1847 1847
     ?>
1848
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1848
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1849 1849
     <?php
1850
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1850
+    do_action('wpinv_purchase_form_after_checkout_total');
1851 1851
     ?>
1852 1852
     </div>
1853 1853
 </div>
1854 1854
 <?php
1855 1855
 }
1856
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1856
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1857 1857
 
1858 1858
 function wpinv_checkout_submit() {
1859 1859
 ?>
1860 1860
 <div id="wpinv_purchase_submit" class="panel panel-success">
1861 1861
     <div class="panel-body text-center">
1862 1862
     <?php
1863
-    do_action( 'wpinv_purchase_form_before_submit' );
1863
+    do_action('wpinv_purchase_form_before_submit');
1864 1864
     wpinv_checkout_hidden_fields();
1865 1865
     echo wpinv_checkout_button_purchase();
1866
-    do_action( 'wpinv_purchase_form_after_submit' );
1866
+    do_action('wpinv_purchase_form_after_submit');
1867 1867
     ?>
1868 1868
     </div>
1869 1869
 </div>
1870 1870
 <?php
1871 1871
 }
1872
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1872
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1873 1873
 
1874
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1875
-    $invoice = wpinv_get_invoice( $invoice_id );
1874
+function wpinv_receipt_billing_address($invoice_id = 0) {
1875
+    $invoice = wpinv_get_invoice($invoice_id);
1876 1876
 
1877
-    if ( empty( $invoice ) ) {
1877
+    if (empty($invoice)) {
1878 1878
         return NULL;
1879 1879
     }
1880 1880
 
1881 1881
     $billing_details = $invoice->get_user_info();
1882
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1882
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1883 1883
 
1884 1884
     ob_start();
1885 1885
     ?>
1886 1886
     <table class="table table-bordered table-sm wpi-billing-details">
1887 1887
         <tbody>
1888 1888
             <tr class="wpi-receipt-name">
1889
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1890
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1889
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1890
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1891 1891
             </tr>
1892 1892
             <tr class="wpi-receipt-email">
1893
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1894
-                <td><?php echo $billing_details['email'] ;?></td>
1893
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1894
+                <td><?php echo $billing_details['email']; ?></td>
1895 1895
             </tr>
1896 1896
             <tr class="wpi-receipt-address">
1897
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1898
-                <td><?php echo $address_row ;?></td>
1897
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1898
+                <td><?php echo $address_row; ?></td>
1899 1899
             </tr>
1900
-            <?php if ( $billing_details['phone'] ) { ?>
1900
+            <?php if ($billing_details['phone']) { ?>
1901 1901
             <tr class="wpi-receipt-phone">
1902
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1903
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1902
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1903
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1904 1904
             </tr>
1905 1905
             <?php } ?>
1906 1906
         </tbody>
@@ -1908,74 +1908,74 @@  discard block
 block discarded – undo
1908 1908
     <?php
1909 1909
     $output = ob_get_clean();
1910 1910
     
1911
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1911
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1912 1912
 
1913 1913
     echo $output;
1914 1914
 }
1915 1915
 
1916
-function wpinv_filter_success_page_content( $content ) {
1917
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1918
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1919
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1916
+function wpinv_filter_success_page_content($content) {
1917
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1918
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1919
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1920 1920
         }
1921 1921
     }
1922 1922
 
1923 1923
     return $content;
1924 1924
 }
1925
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1925
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1926 1926
 
1927
-function wpinv_receipt_actions( $invoice ) {
1928
-    if ( !empty( $invoice ) ) {
1927
+function wpinv_receipt_actions($invoice) {
1928
+    if (!empty($invoice)) {
1929 1929
         $actions = array();
1930 1930
 
1931
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1932
-            $actions['print']   = array(
1933
-                'url'  => $invoice->get_view_url( true ),
1934
-                'name' => __( 'Print Invoice', 'invoicing' ),
1931
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1932
+            $actions['print'] = array(
1933
+                'url'  => $invoice->get_view_url(true),
1934
+                'name' => __('Print Invoice', 'invoicing'),
1935 1935
                 'class' => 'btn-primary',
1936 1936
             );
1937 1937
         }
1938 1938
 
1939
-        if ( is_user_logged_in() ) {
1939
+        if (is_user_logged_in()) {
1940 1940
             $actions['history'] = array(
1941 1941
                 'url'  => wpinv_get_history_page_uri(),
1942
-                'name' => __( 'Invoice History', 'invoicing' ),
1942
+                'name' => __('Invoice History', 'invoicing'),
1943 1943
                 'class' => 'btn-warning',
1944 1944
             );
1945 1945
         }
1946 1946
 
1947
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1947
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1948 1948
 
1949
-        if ( !empty( $actions ) ) {
1949
+        if (!empty($actions)) {
1950 1950
         ?>
1951 1951
         <div class="wpinv-receipt-actions text-right">
1952
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1953
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1952
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1953
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1954 1954
             <?php } ?>
1955 1955
         </div>
1956 1956
         <?php
1957 1957
         }
1958 1958
     }
1959 1959
 }
1960
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1960
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1961 1961
 
1962
-function wpinv_invoice_link( $invoice_id ) {
1963
-    $invoice = wpinv_get_invoice( $invoice_id );
1962
+function wpinv_invoice_link($invoice_id) {
1963
+    $invoice = wpinv_get_invoice($invoice_id);
1964 1964
 
1965
-    if ( empty( $invoice ) ) {
1965
+    if (empty($invoice)) {
1966 1966
         return NULL;
1967 1967
     }
1968 1968
 
1969
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1969
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1970 1970
 
1971
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1971
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1972 1972
 }
1973 1973
 
1974
-function wpinv_invoice_subscription_details( $invoice ) {
1975
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1976
-        $subscription = wpinv_get_subscription( $invoice, true );
1974
+function wpinv_invoice_subscription_details($invoice) {
1975
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1976
+        $subscription = wpinv_get_subscription($invoice, true);
1977 1977
 
1978
-        if ( empty( $subscription ) ) {
1978
+        if (empty($subscription)) {
1979 1979
             return;
1980 1980
         }
1981 1981
 
@@ -1986,15 +1986,15 @@  discard block
 block discarded – undo
1986 1986
         $payments = $subscription->get_child_payments();
1987 1987
         ?>
1988 1988
         <div class="wpinv-subscriptions-details">
1989
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1989
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1990 1990
             <table class="table">
1991 1991
                 <thead>
1992 1992
                     <tr>
1993
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1994
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1995
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1996
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1997
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1993
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1994
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1995
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1996
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1997
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1998 1998
                     </tr>
1999 1999
                 </thead>
2000 2000
                 <tbody>
@@ -2008,29 +2008,29 @@  discard block
 block discarded – undo
2008 2008
                 </tbody>
2009 2009
             </table>
2010 2010
         </div>
2011
-        <?php if ( !empty( $payments ) ) { ?>
2011
+        <?php if (!empty($payments)) { ?>
2012 2012
         <div class="wpinv-renewal-payments">
2013
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
2013
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
2014 2014
             <table class="table">
2015 2015
                 <thead>
2016 2016
                     <tr>
2017 2017
                         <th>#</th>
2018
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
2019
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
2020
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
2018
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
2019
+                        <th><?php _e('Date', 'invoicing'); ?></th>
2020
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
2021 2021
                     </tr>
2022 2022
                 </thead>
2023 2023
                 <tbody>
2024 2024
                     <?php
2025 2025
                         $i = 1;
2026
-                        foreach ( $payments as $payment ) {
2026
+                        foreach ($payments as $payment) {
2027 2027
                             $invoice_id = $payment->ID;
2028 2028
                     ?>
2029 2029
                     <tr>
2030
-                        <th scope="row"><?php echo $i;?></th>
2031
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2032
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2033
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2030
+                        <th scope="row"><?php echo $i; ?></th>
2031
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2032
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2033
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2034 2034
                     </tr>
2035 2035
                     <?php $i++; } ?>
2036 2036
                 </tbody>
@@ -2041,52 +2041,52 @@  discard block
 block discarded – undo
2041 2041
     }
2042 2042
 }
2043 2043
 
2044
-function wpinv_cart_total_label( $label, $invoice ) {
2045
-    if ( empty( $invoice ) ) {
2044
+function wpinv_cart_total_label($label, $invoice) {
2045
+    if (empty($invoice)) {
2046 2046
         return $label;
2047 2047
     }
2048 2048
 
2049 2049
     $prefix_label = '';
2050
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2051
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2052
-    } else if ( $invoice->is_renewal() ) {
2053
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2050
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2051
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2052
+    } else if ($invoice->is_renewal()) {
2053
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2054 2054
     }
2055 2055
 
2056
-    if ( $prefix_label != '' ) {
2057
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2056
+    if ($prefix_label != '') {
2057
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2058 2058
     }
2059 2059
 
2060 2060
     return $label;
2061 2061
 }
2062
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2063
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2064
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2062
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2063
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2064
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2065 2065
 
2066
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2066
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2067 2067
 
2068
-function wpinv_invoice_print_description( $invoice ) {
2069
-    if ( empty( $invoice ) ) {
2068
+function wpinv_invoice_print_description($invoice) {
2069
+    if (empty($invoice)) {
2070 2070
         return NULL;
2071 2071
     }
2072
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2072
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2073 2073
         ?>
2074 2074
         <div class="row wpinv-lower">
2075 2075
             <div class="col-sm-12 wpinv-description">
2076
-                <?php echo wpautop( $description ); ?>
2076
+                <?php echo wpautop($description); ?>
2077 2077
             </div>
2078 2078
         </div>
2079 2079
         <?php
2080 2080
     }
2081 2081
 }
2082
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2082
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2083 2083
 
2084
-function wpinv_invoice_print_payment_info( $invoice ) {
2085
-    if ( empty( $invoice ) ) {
2084
+function wpinv_invoice_print_payment_info($invoice) {
2085
+    if (empty($invoice)) {
2086 2086
         return NULL;
2087 2087
     }
2088 2088
 
2089
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2089
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2090 2090
         ?>
2091 2091
         <div class="row wpinv-payments">
2092 2092
             <div class="col-sm-12">
@@ -2098,43 +2098,43 @@  discard block
 block discarded – undo
2098 2098
 }
2099 2099
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2100 2100
 
2101
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2102
-    if ( empty( $note ) ) {
2101
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2102
+    if (empty($note)) {
2103 2103
         return NULL;
2104 2104
     }
2105 2105
 
2106
-    if ( is_int( $note ) ) {
2107
-        $note = get_comment( $note );
2106
+    if (is_int($note)) {
2107
+        $note = get_comment($note);
2108 2108
     }
2109 2109
 
2110
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2110
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2111 2111
         return NULL;
2112 2112
     }
2113 2113
 
2114
-    $note_classes   = array( 'note' );
2115
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2114
+    $note_classes   = array('note');
2115
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2116 2116
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2117
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2118
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2117
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2118
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2119 2119
 
2120 2120
     ob_start();
2121 2121
     ?>
2122
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2122
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2123 2123
         <div class="note_content">
2124
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2124
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2125 2125
         </div>
2126 2126
         <p class="meta">
2127
-            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
2128
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2129
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2127
+            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
2128
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2129
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2130 2130
             <?php } ?>
2131 2131
         </p>
2132 2132
     </li>
2133 2133
     <?php
2134 2134
     $note_content = ob_get_clean();
2135
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2135
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2136 2136
 
2137
-    if ( $echo ) {
2137
+    if ($echo) {
2138 2138
         echo $note_content;
2139 2139
     } else {
2140 2140
         return $note_content;
@@ -2144,43 +2144,43 @@  discard block
 block discarded – undo
2144 2144
 function wpinv_invalid_invoice_content() {
2145 2145
     global $post;
2146 2146
 
2147
-    $invoice = wpinv_get_invoice( $post->ID );
2147
+    $invoice = wpinv_get_invoice($post->ID);
2148 2148
 
2149
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2150
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2151
-        if ( is_user_logged_in() ) {
2152
-            if ( wpinv_require_login_to_checkout() ) {
2153
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2154
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2149
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2150
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2151
+        if (is_user_logged_in()) {
2152
+            if (wpinv_require_login_to_checkout()) {
2153
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2154
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2155 2155
                 }
2156 2156
             }
2157 2157
         } else {
2158
-            if ( wpinv_require_login_to_checkout() ) {
2159
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2160
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2158
+            if (wpinv_require_login_to_checkout()) {
2159
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2160
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2161 2161
                 }
2162 2162
             }
2163 2163
         }
2164 2164
     } else {
2165
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2165
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2166 2166
     }
2167 2167
     ?>
2168 2168
     <div class="row wpinv-row-invalid">
2169 2169
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2170
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2170
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2171 2171
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2172 2172
         </div>
2173 2173
     </div>
2174 2174
     <?php
2175 2175
 }
2176
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2176
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2177 2177
 
2178
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2179
-function wpinv_force_company_name_field(){
2178
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2179
+function wpinv_force_company_name_field() {
2180 2180
     $invoice = wpinv_get_invoice_cart();
2181
-    $user_id = wpinv_get_user_id( $invoice->ID );
2182
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2183
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2181
+    $user_id = wpinv_get_user_id($invoice->ID);
2182
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2183
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2184 2184
         ?>
2185 2185
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2186 2186
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2206,21 +2206,21 @@  discard block
 block discarded – undo
2206 2206
  * @return string
2207 2207
  */
2208 2208
 function wpinv_get_policy_text() {
2209
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2209
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2210 2210
 
2211
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2211
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2212 2212
 
2213
-    if(!$privacy_page_id){
2214
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2213
+    if (!$privacy_page_id) {
2214
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2215 2215
     }
2216 2216
 
2217
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2217
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2218 2218
 
2219 2219
     $find_replace = array(
2220 2220
         '[wpinv_privacy_policy]' => $privacy_link,
2221 2221
     );
2222 2222
 
2223
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2223
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2224 2224
 
2225 2225
     return wp_kses_post(wpautop($privacy_text));
2226 2226
 }
@@ -2229,25 +2229,25 @@  discard block
 block discarded – undo
2229 2229
 /**
2230 2230
  * Allows the user to set their own price for an invoice item
2231 2231
  */
2232
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2232
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2233 2233
     
2234 2234
     //Ensure we have an item id
2235
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2235
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2236 2236
         return;
2237 2237
     }
2238 2238
 
2239 2239
     //Fetch the item
2240 2240
     $item_id = $cart_item['id'];
2241
-    $item    = new WPInv_Item( $item_id );
2241
+    $item    = new WPInv_Item($item_id);
2242 2242
     
2243
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2243
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2244 2244
         return;
2245 2245
     }
2246 2246
 
2247 2247
     //Fetch the dynamic pricing "strings"
2248
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2249
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2250
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2248
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2249
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2250
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2251 2251
 
2252 2252
     //Display a "name_your_price" button
2253 2253
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
     echo '<div class="name-your-price-miniform">';
2257 2257
     
2258 2258
     //Maybe display the recommended price
2259
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2259
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2260 2260
         $suggested_price = $item->get_the_price();
2261 2261
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2262 2262
     }
@@ -2264,198 +2264,198 @@  discard block
 block discarded – undo
2264 2264
     //Display the update price form
2265 2265
     $symbol         = wpinv_currency_symbol();
2266 2266
     $position       = wpinv_currency_position();
2267
-    $minimum        = esc_attr( $item->get_minimum_price() );
2268
-    $price          = esc_attr( $cart_item['item_price'] );
2269
-    $update         = esc_attr__( "Update", 'invoicing' );
2267
+    $minimum        = esc_attr($item->get_minimum_price());
2268
+    $price          = esc_attr($cart_item['item_price']);
2269
+    $update         = esc_attr__("Update", 'invoicing');
2270 2270
 
2271 2271
     //Ensure it supports dynamic prici
2272
-    if( $price < $minimum ) {
2272
+    if ($price < $minimum) {
2273 2273
         $price = $minimum;
2274 2274
     }
2275 2275
 
2276 2276
     echo '<label>';
2277 2277
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2278 2278
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2279
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2279
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2280 2280
     echo "</label>";
2281 2281
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2282 2282
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2283 2283
 
2284 2284
     //Maybe display the minimum price
2285
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2286
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2285
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2286
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2287 2287
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2288 2288
     }
2289 2289
 
2290 2290
     echo "</div>";
2291 2291
 
2292 2292
 }
2293
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2293
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2294 2294
 
2295 2295
 function wpinv_oxygen_fix_conflict() {
2296 2296
     global $ct_ignore_post_types;
2297 2297
 
2298
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2298
+    if (!is_array($ct_ignore_post_types)) {
2299 2299
         $ct_ignore_post_types = array();
2300 2300
     }
2301 2301
 
2302
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2302
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2303 2303
 
2304
-    foreach ( $post_types as $post_type ) {
2304
+    foreach ($post_types as $post_type) {
2305 2305
         $ct_ignore_post_types[] = $post_type;
2306 2306
 
2307 2307
         // Ignore post type
2308
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2308
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2309 2309
     }
2310 2310
 
2311
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2312
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2311
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2312
+    add_filter('template_include', 'wpinv_template', 999, 1);
2313 2313
 }
2314 2314
 
2315 2315
 /**
2316 2316
  * Helper function to display a payment form on the frontend.
2317 2317
  */
2318
-function getpaid_display_payment_form( $form ) {
2318
+function getpaid_display_payment_form($form) {
2319 2319
     global $invoicing;
2320 2320
 
2321 2321
     // Ensure that it is published.
2322
-	if ( 'publish' != get_post_status( $form ) ) {
2322
+	if ('publish' != get_post_status($form)) {
2323 2323
 		return aui()->alert(
2324 2324
 			array(
2325 2325
 				'type'    => 'warning',
2326
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2326
+				'content' => __('This payment form is no longer active', 'invoicing'),
2327 2327
 			)
2328 2328
 		);
2329 2329
 	}
2330 2330
 
2331 2331
     // Get the form.
2332
-    $form = new GetPaid_Payment_Form( $form );
2333
-    $html = wpinv_get_template_html( 'payment-forms/form.php', compact( 'form' ) );
2334
-    return str_replace( 'sr-only', '', $html );
2332
+    $form = new GetPaid_Payment_Form($form);
2333
+    $html = wpinv_get_template_html('payment-forms/form.php', compact('form'));
2334
+    return str_replace('sr-only', '', $html);
2335 2335
 
2336 2336
 }
2337 2337
 
2338 2338
 /**
2339 2339
  * Helper function to display a item payment form on the frontend.
2340 2340
  */
2341
-function getpaid_display_item_payment_form( $items ) {
2341
+function getpaid_display_item_payment_form($items) {
2342 2342
     global $invoicing;
2343 2343
 
2344
-    foreach ( array_keys( $items ) as $id ) {
2345
-	    if ( 'publish' != get_post_status( $id ) ) {
2346
-		    unset( $items[ $id ] );
2344
+    foreach (array_keys($items) as $id) {
2345
+	    if ('publish' != get_post_status($id)) {
2346
+		    unset($items[$id]);
2347 2347
 	    }
2348 2348
     }
2349 2349
 
2350
-    if ( empty( $items ) ) {
2350
+    if (empty($items)) {
2351 2351
 		return aui()->alert(
2352 2352
 			array(
2353 2353
 				'type'    => 'warning',
2354
-				'content' => __( 'No published items found', 'invoicing' ),
2354
+				'content' => __('No published items found', 'invoicing'),
2355 2355
 			)
2356 2356
 		);
2357 2357
     }
2358 2358
 
2359
-    $item_key = getpaid_convert_items_to_string( $items );
2359
+    $item_key = getpaid_convert_items_to_string($items);
2360 2360
 
2361 2361
     // Get the form elements and items.
2362 2362
     $form     = wpinv_get_default_payment_form();
2363
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2364
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2363
+	$elements = $invoicing->form_elements->get_form_elements($form);
2364
+	$items    = $invoicing->form_elements->convert_normal_items($items);
2365 2365
 
2366 2366
 	ob_start();
2367 2367
 	echo "<form class='wpinv_payment_form'>";
2368
-	do_action( 'wpinv_payment_form_top' );
2368
+	do_action('wpinv_payment_form_top');
2369 2369
     echo "<input type='hidden' name='form_id' value='$form'/>";
2370 2370
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2371
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2372
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2371
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2372
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2373 2373
 
2374
-	foreach ( $elements as $element ) {
2375
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2376
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2374
+	foreach ($elements as $element) {
2375
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2376
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2377 2377
 	}
2378 2378
 
2379 2379
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2380
-	do_action( 'wpinv_payment_form_bottom' );
2380
+	do_action('wpinv_payment_form_bottom');
2381 2381
 	echo '</form>';
2382 2382
 
2383 2383
 	$content = ob_get_clean();
2384
-	return str_replace( 'sr-only', '', $content );
2384
+	return str_replace('sr-only', '', $content);
2385 2385
 }
2386 2386
 
2387 2387
 /**
2388 2388
  * Helper function to display an invoice payment form on the frontend.
2389 2389
  */
2390
-function getpaid_display_invoice_payment_form( $invoice_id ) {
2390
+function getpaid_display_invoice_payment_form($invoice_id) {
2391 2391
     global $invoicing;
2392 2392
 
2393
-    $invoice = wpinv_get_invoice( $invoice_id );
2393
+    $invoice = wpinv_get_invoice($invoice_id);
2394 2394
 
2395
-    if ( empty( $invoice ) ) {
2395
+    if (empty($invoice)) {
2396 2396
 		return aui()->alert(
2397 2397
 			array(
2398 2398
 				'type'    => 'warning',
2399
-				'content' => __( 'Invoice not found', 'invoicing' ),
2399
+				'content' => __('Invoice not found', 'invoicing'),
2400 2400
 			)
2401 2401
 		);
2402 2402
     }
2403 2403
 
2404
-    if ( $invoice->is_paid() ) {
2404
+    if ($invoice->is_paid()) {
2405 2405
 		return aui()->alert(
2406 2406
 			array(
2407 2407
 				'type'    => 'warning',
2408
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
2408
+				'content' => __('Invoice has already been paid', 'invoicing'),
2409 2409
 			)
2410 2410
 		);
2411 2411
     }
2412 2412
 
2413 2413
     // Get the form elements and items.
2414
-    $form     = wpinv_get_default_payment_form();
2415
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2416
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2414
+    $form = wpinv_get_default_payment_form();
2415
+	$elements = $invoicing->form_elements->get_form_elements($form);
2416
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
2417 2417
 
2418 2418
 	ob_start();
2419 2419
 	echo "<form class='wpinv_payment_form'>";
2420
-	do_action( 'wpinv_payment_form_top' );
2420
+	do_action('wpinv_payment_form_top');
2421 2421
     echo "<input type='hidden' name='form_id' value='$form'/>";
2422 2422
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
2423
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2424
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2423
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2424
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2425 2425
 
2426
-	foreach ( $elements as $element ) {
2427
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2428
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2426
+	foreach ($elements as $element) {
2427
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2428
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2429 2429
 	}
2430 2430
 
2431 2431
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2432
-	do_action( 'wpinv_payment_form_bottom' );
2432
+	do_action('wpinv_payment_form_bottom');
2433 2433
 	echo '</form>';
2434 2434
 
2435 2435
 	$content = ob_get_clean();
2436
-	return str_replace( 'sr-only', '', $content );
2436
+	return str_replace('sr-only', '', $content);
2437 2437
 }
2438 2438
 
2439 2439
 /**
2440 2440
  * Helper function to convert item string to array.
2441 2441
  */
2442
-function getpaid_convert_items_to_array( $items ) {
2443
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
2442
+function getpaid_convert_items_to_array($items) {
2443
+    $items    = array_filter(array_map('trim', explode(',', $items)));
2444 2444
     $prepared = array();
2445 2445
 
2446
-    foreach ( $items as $item ) {
2447
-        $data = array_map( 'trim', explode( '|', $item ) );
2446
+    foreach ($items as $item) {
2447
+        $data = array_map('trim', explode('|', $item));
2448 2448
 
2449
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
2449
+        if (empty($data[0]) || !is_numeric($data[0])) {
2450 2450
             continue;
2451 2451
         }
2452 2452
 
2453 2453
         $quantity = 1;
2454
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
2454
+        if (isset($data[1]) && is_numeric($data[1])) {
2455 2455
             $quantity = $data[1];
2456 2456
         }
2457 2457
 
2458
-        $prepared[ $data[0] ] = $quantity;
2458
+        $prepared[$data[0]] = $quantity;
2459 2459
 
2460 2460
     }
2461 2461
 
@@ -2465,13 +2465,13 @@  discard block
 block discarded – undo
2465 2465
 /**
2466 2466
  * Helper function to convert item array to string.
2467 2467
  */
2468
-function getpaid_convert_items_to_string( $items ) {
2468
+function getpaid_convert_items_to_string($items) {
2469 2469
     $prepared = array();
2470 2470
 
2471
-    foreach ( $items as $item => $quantity ) {
2471
+    foreach ($items as $item => $quantity) {
2472 2472
         $prepared[] = "$item|$quantity";
2473 2473
     }
2474
-    return implode( ',', $prepared );
2474
+    return implode(',', $prepared);
2475 2475
 }
2476 2476
 
2477 2477
 /**
@@ -2479,22 +2479,22 @@  discard block
 block discarded – undo
2479 2479
  * 
2480 2480
  * Provide a label and one of $form, $items or $invoice.
2481 2481
  */
2482
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
2483
-    $label = sanitize_text_field( $label );
2482
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
2483
+    $label = sanitize_text_field($label);
2484 2484
     $nonce = wp_create_nonce('getpaid_ajax_form');
2485 2485
 
2486
-    if ( ! empty( $form ) ) {
2487
-        $form  = esc_attr( $form );
2486
+    if (!empty($form)) {
2487
+        $form = esc_attr($form);
2488 2488
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
2489 2489
     }
2490 2490
 	
2491
-	if ( ! empty( $items ) ) {
2492
-        $items  = esc_attr( $items );
2491
+	if (!empty($items)) {
2492
+        $items = esc_attr($items);
2493 2493
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
2494 2494
     }
2495 2495
     
2496
-    if ( ! empty( $invoice ) ) {
2497
-        $invoice  = esc_attr( $invoice );
2496
+    if (!empty($invoice)) {
2497
+        $invoice = esc_attr($invoice);
2498 2498
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
2499 2499
     }
2500 2500
 
@@ -2505,15 +2505,15 @@  discard block
 block discarded – undo
2505 2505
  *
2506 2506
  * @param WPInv_Invoice $invoice
2507 2507
  */
2508
-function getpaid_the_invoice_description( $invoice ) {
2509
-    if ( empty( $invoice->description ) ) {
2508
+function getpaid_the_invoice_description($invoice) {
2509
+    if (empty($invoice->description)) {
2510 2510
         return;
2511 2511
     }
2512 2512
 
2513
-    $description = wp_kses_post( $invoice->description );
2513
+    $description = wp_kses_post($invoice->description);
2514 2514
     echo "<div style='color: #616161; font-size: 90%; margin-bottom: 20px;'><em>$description</em></div>";
2515 2515
 }
2516
-add_action( 'wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description' );
2516
+add_action('wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description');
2517 2517
 
2518 2518
 /**
2519 2519
  * Render element on a form.
@@ -2521,41 +2521,41 @@  discard block
 block discarded – undo
2521 2521
  * @param array $element
2522 2522
  * @param GetPaid_Payment_Form $form
2523 2523
  */
2524
-function getpaid_payment_form_element( $element, $form ) {
2524
+function getpaid_payment_form_element($element, $form) {
2525 2525
 
2526 2526
     // Set up the args.
2527
-    $element_type    = trim( $element['type'] );
2527
+    $element_type    = trim($element['type']);
2528 2528
     $element['form'] = $form;
2529
-    extract( $element );
2529
+    extract($element);
2530 2530
 
2531 2531
     // Try to locate the appropriate template.
2532
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
2532
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
2533 2533
     
2534 2534
     // Abort if this is not our element.
2535
-    if ( empty( $located ) || ! file_exists( $located ) ) {
2535
+    if (empty($located) || !file_exists($located)) {
2536 2536
         return;
2537 2537
     }
2538 2538
 
2539 2539
     // Generate the class and id of the element.
2540
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
2541
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
2540
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
2541
+    $id            = isset($id) ? $id : uniqid('gp');
2542 2542
 
2543 2543
     // Echo the opening wrapper.
2544 2544
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
2545 2545
 
2546 2546
     // Fires before displaying a given element type's content.
2547
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
2547
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
2548 2548
 
2549 2549
     // Include the template for the element.
2550 2550
     include $located;
2551 2551
 
2552 2552
     // Fires after displaying a given element type's content.
2553
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
2553
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
2554 2554
 
2555 2555
     // Echo the closing wrapper.
2556 2556
     echo '</div>';
2557 2557
 }
2558
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
2558
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
2559 2559
 
2560 2560
 /**
2561 2561
  * Shows a list of gateways that support recurring payments.
@@ -2563,16 +2563,16 @@  discard block
 block discarded – undo
2563 2563
 function wpinv_get_recurring_gateways_text() {
2564 2564
     $gateways = array();
2565 2565
 
2566
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
2567
-        if ( wpinv_gateway_support_subscription( $key ) ) {
2568
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
2566
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
2567
+        if (wpinv_gateway_support_subscription($key)) {
2568
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
2569 2569
         }
2570 2570
     }
2571 2571
 
2572
-    if ( empty( $gateways ) ) {
2573
-        return "<span class='form-text text-danger'>" . __( 'No active gateway supports subscription payments.', 'invoicing' ) ."</span>";
2572
+    if (empty($gateways)) {
2573
+        return "<span class='form-text text-danger'>" . __('No active gateway supports subscription payments.', 'invoicing') . "</span>";
2574 2574
     }
2575 2575
 
2576
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
2576
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
2577 2577
 
2578 2578
 }
Please login to merge, or discard this patch.