Passed
Push — master ( 1df2cc...649099 )
by Brian
04:22
created
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 1 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
 
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
                         <div class="col-12 col-sm-6">
42 42
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
43 43
                                 <div>
44
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
44
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
45 45
                                 </div>
46 46
                                 <?php 
47 47
                                     wpinv_dropdown_users(
48 48
                                         array(
49 49
                                             'name'             => 'post_author_override',
50
-                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(),
50
+                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(),
51 51
                                             'include_selected' => true,
52 52
                                             'show'             => 'display_name_with_login',
53 53
                                             'orderby'          => 'user_email',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                                             'type'        => 'text',
66 66
                                             'id'          => 'getpaid-invoice-new-user-email',
67 67
                                             'name'        => 'wpinv_email',
68
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
68
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
69 69
                                             'label_type'  => 'vertical',
70 70
                                             'placeholder' => '[email protected]',
71 71
                                             'class'       => 'form-control-sm',
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
                             </div>
76 76
                         </div>
77 77
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
78
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
78
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
79 79
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
80 80
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
81
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
81
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
82 82
                                 </a>
83 83
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
84 84
                                     <i aria-hidden="true" class="fa fa-plus"></i>
85
-                                    <?php _e( 'Add New User', 'invoicing' );?>
85
+                                    <?php _e('Add New User', 'invoicing'); ?>
86 86
                                 </a>
87 87
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
88 88
                                     <i aria-hidden="true" class="fa fa-close"></i>
89
-                                    <?php _e( 'Cancel', 'invoicing' );?>
89
+                                    <?php _e('Cancel', 'invoicing'); ?>
90 90
                                 </a>
91 91
                             <?php endif; ?>
92 92
                         </div>
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
                                         'type'        => 'text',
100 100
                                         'id'          => 'wpinv_first_name',
101 101
                                         'name'        => 'wpinv_first_name',
102
-                                        'label'       => __( 'First Name', 'invoicing' ),
102
+                                        'label'       => __('First Name', 'invoicing'),
103 103
                                         'label_type'  => 'vertical',
104 104
                                         'placeholder' => '',
105 105
                                         'class'       => 'form-control-sm',
106
-                                        'value'       => $invoice->get_first_name( 'edit' ),
106
+                                        'value'       => $invoice->get_first_name('edit'),
107 107
                                     )
108 108
                                 );
109 109
                             ?>
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
                                         'type'        => 'text',
116 116
                                         'id'          => 'wpinv_last_name',
117 117
                                         'name'        => 'wpinv_last_name',
118
-                                        'label'       => __( 'Last Name', 'invoicing' ),
118
+                                        'label'       => __('Last Name', 'invoicing'),
119 119
                                         'label_type'  => 'vertical',
120 120
                                         'placeholder' => '',
121 121
                                         'class'       => 'form-control-sm',
122
-                                        'value'       => $invoice->get_last_name( 'edit' ),
122
+                                        'value'       => $invoice->get_last_name('edit'),
123 123
                                     )
124 124
                                 );
125 125
                             ?>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
                                         'type'        => 'text',
135 135
                                         'id'          => 'wpinv_company',
136 136
                                         'name'        => 'wpinv_company',
137
-                                        'label'       => __( 'Company', 'invoicing' ),
137
+                                        'label'       => __('Company', 'invoicing'),
138 138
                                         'label_type'  => 'vertical',
139 139
                                         'placeholder' => '',
140 140
                                         'class'       => 'form-control-sm',
141
-                                        'value'       => $invoice->get_company( 'edit' ),
141
+                                        'value'       => $invoice->get_company('edit'),
142 142
                                     )
143 143
                                 );
144 144
                             ?>
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
                                         'type'        => 'text',
151 151
                                         'id'          => 'wpinv_vat_number',
152 152
                                         'name'        => 'wpinv_vat_number',
153
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
153
+                                        'label'       => __('Vat Number', 'invoicing'),
154 154
                                         'label_type'  => 'vertical',
155 155
                                         'placeholder' => '',
156 156
                                         'class'       => 'form-control-sm',
157
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
157
+                                        'value'       => $invoice->get_vat_number('edit'),
158 158
                                     )
159 159
                                 );
160 160
                             ?>
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
                                         'type'        => 'text',
170 170
                                         'id'          => 'wpinv_address',
171 171
                                         'name'        => 'wpinv_address',
172
-                                        'label'       => __( 'Address', 'invoicing' ),
172
+                                        'label'       => __('Address', 'invoicing'),
173 173
                                         'label_type'  => 'vertical',
174 174
                                         'placeholder' => '',
175 175
                                         'class'       => 'form-control-sm',
176
-                                        'value'       => $invoice->get_address( 'edit' ),
176
+                                        'value'       => $invoice->get_address('edit'),
177 177
                                     )
178 178
                                 );
179 179
                             ?>
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
                                         'type'        => 'text',
186 186
                                         'id'          => 'wpinv_city',
187 187
                                         'name'        => 'wpinv_city',
188
-                                        'label'       => __( 'City', 'invoicing' ),
188
+                                        'label'       => __('City', 'invoicing'),
189 189
                                         'label_type'  => 'vertical',
190 190
                                         'placeholder' => '',
191 191
                                         'class'       => 'form-control-sm',
192
-                                        'value'       => $invoice->get_city( 'edit' ),
192
+                                        'value'       => $invoice->get_city('edit'),
193 193
                                     )
194 194
                                 );
195 195
                             ?>
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
                                     array(
204 204
                                         'id'          => 'wpinv_country',
205 205
                                         'name'        => 'wpinv_country',
206
-                                        'label'       => __( 'Country', 'invoicing' ),
206
+                                        'label'       => __('Country', 'invoicing'),
207 207
                                         'label_type'  => 'vertical',
208
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
208
+                                        'placeholder' => __('Choose a country', 'invoicing'),
209 209
                                         'class'       => 'form-control-sm',
210
-                                        'value'       => $invoice->get_country( 'edit' ),
210
+                                        'value'       => $invoice->get_country('edit'),
211 211
                                         'options'     => wpinv_get_country_list(),
212 212
                                         'data-allow-clear' => 'false',
213 213
                                         'select2'          => true,
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
                         <div class="col-12 col-sm-6">
219 219
                             <?php
220 220
 
221
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
221
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
222 222
 
223
-                                if ( empty( $states ) ) {
223
+                                if (empty($states)) {
224 224
 
225 225
                                     echo aui()->input(
226 226
                                         array(
227 227
                                             'type'        => 'text',
228 228
                                             'id'          => 'wpinv_state',
229 229
                                             'name'        => 'wpinv_state',
230
-                                            'label'       => __( 'State', 'invoicing' ),
230
+                                            'label'       => __('State', 'invoicing'),
231 231
                                             'label_type'  => 'vertical',
232 232
                                             'placeholder' => '',
233 233
                                             'class'       => 'form-control-sm',
234
-                                            'value'       => $invoice->get_state( 'edit' ),
234
+                                            'value'       => $invoice->get_state('edit'),
235 235
                                         )
236 236
                                     );
237 237
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
                                         array(
242 242
                                             'id'          => 'wpinv_state',
243 243
                                             'name'        => 'wpinv_state',
244
-                                            'label'       => __( 'State', 'invoicing' ),
244
+                                            'label'       => __('State', 'invoicing'),
245 245
                                             'label_type'  => 'vertical',
246
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
246
+                                            'placeholder' => __('Select a state', 'invoicing'),
247 247
                                             'class'       => 'form-control-sm',
248
-                                            'value'       => $invoice->get_state( 'edit' ),
248
+                                            'value'       => $invoice->get_state('edit'),
249 249
                                             'options'     => $states,
250 250
                                             'data-allow-clear' => 'false',
251 251
                                             'select2'          => true,
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
                                         'type'        => 'text',
267 267
                                         'id'          => 'wpinv_zip',
268 268
                                         'name'        => 'wpinv_zip',
269
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
269
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
270 270
                                         'label_type'  => 'vertical',
271 271
                                         'placeholder' => '',
272 272
                                         'class'       => 'form-control-sm',
273
-                                        'value'       => $invoice->get_zip( 'edit' ),
273
+                                        'value'       => $invoice->get_zip('edit'),
274 274
                                     )
275 275
                                 );
276 276
                             ?>
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
                                         'type'        => 'text',
283 283
                                         'id'          => 'wpinv_phone',
284 284
                                         'name'        => 'wpinv_phone',
285
-                                        'label'       => __( 'Phone', 'invoicing' ),
285
+                                        'label'       => __('Phone', 'invoicing'),
286 286
                                         'label_type'  => 'vertical',
287 287
                                         'placeholder' => '',
288 288
                                         'class'       => 'form-control-sm',
289
-                                        'value'       => $invoice->get_phone( 'edit' ),
289
+                                        'value'       => $invoice->get_phone('edit'),
290 290
                                     )
291 291
                                 );
292 292
                             ?>
@@ -302,34 +302,34 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @param int $post_id
304 304
 	 */
305
-	public static function save( $post_id ) {
305
+	public static function save($post_id) {
306 306
 
307 307
         // Prepare the invoice.
308
-        $invoice = new WPInv_Invoice( $post_id );
308
+        $invoice = new WPInv_Invoice($post_id);
309 309
 
310 310
         // Load new data.
311 311
         $invoice->set_props(
312 312
 			array(
313
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
314
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
315
-                'disable_taxes'        => isset( $_POST['disable_taxes'] ),
316
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
317
-                'gateway'              => isset( $_POST['wpinv_gateway'] ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
318
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
319
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
320
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
321
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
322
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
323
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
324
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
325
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
326
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
327
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
328
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
329
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
330
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
331
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
332
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
313
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
314
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
315
+                'disable_taxes'        => isset($_POST['disable_taxes']),
316
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
317
+                'gateway'              => isset($_POST['wpinv_gateway']) ? wpinv_clean($_POST['wpinv_gateway']) : null,
318
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
319
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
320
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
321
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
322
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
323
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
324
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
325
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
326
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
327
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
328
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
329
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
330
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
331
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
332
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
333 333
 			)
334 334
         );
335 335
 
@@ -337,17 +337,17 @@  discard block
 block discarded – undo
337 337
         $invoice->recalculate_total();
338 338
 
339 339
         // If we're creating a new user...
340
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) {
340
+        if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) {
341 341
 
342 342
             // Attempt to create the user.
343
-            $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) );
343
+            $user = wpinv_create_user(sanitize_email($_POST['wpinv_email']));
344 344
 
345 345
 
346 346
             // If successful, update the invoice author.
347
-            if ( is_numeric( $user ) ) {
348
-                $invoice->set_author( $user );
347
+            if (is_numeric($user)) {
348
+                $invoice->set_author($user);
349 349
             } else {
350
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
350
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
351 351
             }
352 352
         }
353 353
 
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
         $invoice->save();
356 356
 
357 357
         // (Maybe) send new user notification.
358
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) {
359
-            wp_send_new_user_notifications( $user, 'user' );
358
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) {
359
+            wp_send_new_user_notifications($user, 'user');
360 360
         }
361 361
 
362 362
         // Fires after an invoice is saved.
363
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
363
+		do_action('wpinv_invoice_metabox_saved', $invoice);
364 364
 	}
365 365
 }
Please login to merge, or discard this patch.