Passed
Push — master ( f93832...793157 )
by Brian
04:20
created
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +68 added lines, -68 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,42 +21,42 @@  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 = array(
36 36
 
37 37
             'subtotal'  => array(
38
-                'label' => __( 'Items Subtotal', 'invoicing' ),
39
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
38
+                'label' => __('Items Subtotal', 'invoicing'),
39
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
40 40
             ),
41 41
 
42 42
             'discount'  => array(
43
-                'label' => __( 'Total Discount', 'invoicing' ),
44
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
43
+                'label' => __('Total Discount', 'invoicing'),
44
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
45 45
             ),
46 46
 
47 47
             'tax'       => array(
48
-                'label' => __( 'Total Tax', 'invoicing' ),
49
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
48
+                'label' => __('Total Tax', 'invoicing'),
49
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
50 50
             ),
51 51
 
52 52
             'total'     => array(
53
-                'label' => __( 'Invoice Total', 'invoicing' ),
54
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
53
+                'label' => __('Invoice Total', 'invoicing'),
54
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
55 55
             )
56 56
         );
57 57
 
58
-        if ( ! wpinv_use_taxes() ) {
59
-            unset( $totals['tax'] );
58
+        if (!wpinv_use_taxes()) {
59
+            unset($totals['tax']);
60 60
         }
61 61
 
62 62
         $item_args = array(
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'orderby'        => 'title',
65 65
             'order'          => 'ASC',
66 66
             'posts_per_page' => -1,
67
-            'post_status'    => array( 'publish' ),
67
+            'post_status'    => array('publish'),
68 68
             'meta_query'     => array(
69 69
                 array(
70 70
                     'key'       => '_wpinv_type',
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
             }
89 89
         </style>
90 90
 
91
-                <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">
91
+                <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">
92 92
 
93
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
94
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
93
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
94
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
95 95
 
96 96
                         <div class="row">
97 97
                             <div class="col-12 col-sm-6">
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
                                         array(
101 101
                                             'id'          => 'wpinv_template',
102 102
                                             'name'        => 'wpinv_template',
103
-                                            'label'       => __( 'Template', 'invoicing' ),
103
+                                            'label'       => __('Template', 'invoicing'),
104 104
                                             'label_type'  => 'vertical',
105
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
105
+                                            'placeholder' => __('Choose a template', 'invoicing'),
106 106
                                             'class'       => 'form-control-sm',
107
-                                            'value'       => $invoice->get_template( 'edit' ),
107
+                                            'value'       => $invoice->get_template('edit'),
108 108
                                             'options'     => array(
109
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
110
-                                                'hours'    => __( 'Hours', 'invoicing' ),
111
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
109
+                                                'quantity' => __('Quantity', 'invoicing'),
110
+                                                'hours'    => __('Hours', 'invoicing'),
111
+                                                'amount'   => __('Amount Only', 'invoicing'),
112 112
                                             ),
113 113
                                             'data-allow-clear' => 'false',
114 114
                                             'select2'          => true,
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
                                         array(
125 125
                                             'id'          => 'wpinv_currency',
126 126
                                             'name'        => 'wpinv_currency',
127
-                                            'label'       => __( 'Currency', 'invoicing' ),
127
+                                            'label'       => __('Currency', 'invoicing'),
128 128
                                             'label_type'  => 'vertical',
129
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
129
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
130 130
                                             'class'       => 'form-control-sm',
131
-                                            'value'       => $invoice->get_currency( 'edit' ),
131
+                                            'value'       => $invoice->get_currency('edit'),
132 132
                                             'required'    => false,
133 133
                                             'data-allow-clear' => 'false',
134 134
                                             'select2'          => true,
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
                             </div>
141 141
                         </div>
142 142
 
143
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
143
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
144 144
                     <?php endif; ?>
145 145
 
146 146
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
147 147
                         <thead>
148 148
                             <tr>
149
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
149
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
150 150
                                 <th class="getpaid-quantity hide-if-amount text-right">
151
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
152
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
151
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
152
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
153 153
                                 </th>
154 154
                                 <th class="getpaid-price hide-if-amount text-right">
155
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
156
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
155
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
156
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
157 157
                                 </th>
158 158
                                 <th class="getpaid-item-subtotal text-right">
159
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
160
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
159
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
160
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
161 161
                                 </th>
162 162
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
163 163
                             </tr>
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 		                <tbody class="getpaid_invoice_line_items">
166 166
                             <tr class="hide-if-has-items hide-if-not-editable">
167 167
                                 <td colspan="2" class="pt-4 pb-4">
168
-                                    <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>
169
-	                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
168
+                                    <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>
169
+	                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
170 170
                                 </td>
171 171
                                 <td class="hide-if-amount">&nbsp;</th>
172 172
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                             <div class="col-12 col-sm-6 offset-sm-6">
199 199
                                 <table class="getpaid-invoice-totals text-right w-100">
200 200
                                     <tbody>
201
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
202
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
203
-                                                <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td>
201
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
202
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
203
+                                                <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td>
204 204
                                                 <td width="1%"></td>
205
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
205
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
206 206
                                             </tr>
207 207
                                         <?php endforeach; ?>
208 208
                                     </tbody>
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
216 216
                         <div class="row">
217 217
                             <div class="text-left col-12 col-sm-8">
218
-                                <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>
219
-                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
220
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
218
+                                <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>
219
+                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
220
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
221 221
                             </div>
222 222
                             <div class="text-right col-12 col-sm-4">
223
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
223
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
224 224
                             </div>
225 225
                         </div>
226 226
                     </div>
227 227
 
228 228
                     <div class="getpaid-invoice-item-actions hide-if-editable">
229
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
229
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
230 230
                     </div>
231 231
 
232 232
                     <!-- Add items to an invoice -->
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
                         <div class="modal-dialog modal-dialog-centered" role="document">
235 235
                             <div class="modal-content">
236 236
                                 <div class="modal-header">
237
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
238
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
237
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
238
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
239 239
                                         <span aria-hidden="true">&times;</span>
240 240
                                     </button>
241 241
                                 </div>
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
                                     <table class="widefat">
244 244
                                         <thead>
245 245
                                             <tr>
246
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
246
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
247 247
                                                 <th class="pr-0 text-right hide-if-amount">
248
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
249
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
248
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
249
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
250 250
                                                 </th>
251 251
                                             </tr>
252 252
                                         </thead>
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 								            <tr>
255 255
 									            <td class="pl-0 text-left">
256 256
                                                     <select class="regular-text getpaid-add-invoice-item-select">
257
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
258
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
259
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
257
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
258
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
259
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
260 260
                                                         <?php endforeach; ?>
261 261
                                                     </select>
262 262
                                                 </td>
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 						            </table>
269 269
                                 </div>
270 270
                                 <div class="modal-footer">
271
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
272
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
271
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
272
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
273 273
                                 </div>
274 274
                             </div>
275 275
                         </div>
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
                         <div class="modal-dialog modal-dialog-centered" role="document">
281 281
                             <div class="modal-content">
282 282
                                 <div class="modal-header">
283
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
284
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
283
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
284
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
285 285
                                         <span aria-hidden="true">&times;</span>
286 286
                                     </button>
287 287
                                 </div>
@@ -289,27 +289,27 @@  discard block
 block discarded – undo
289 289
                                     <div class="getpaid-edit-item-div">
290 290
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
291 291
                                         <label class="form-group w-100">
292
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
293
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
292
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
293
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
294 294
                                         </label>
295 295
                                         <label class="form-group w-100">
296
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
297
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
298
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
296
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
297
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
298
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
299 299
                                         </label>
300 300
                                         <label class="form-group w-100 hide-if-amount">
301
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
301
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
302 302
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
303 303
                                         </label>
304 304
                                         <label class="form-group w-100">
305
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
306
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
305
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
306
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
307 307
                                         </label>
308 308
                                     </div>
309 309
                                 </div>
310 310
                                 <div class="modal-footer">
311
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
312
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
311
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
312
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
313 313
                                 </div>
314 314
                             </div>
315 315
                         </div>
Please login to merge, or discard this patch.