Passed
Pull Request — master (#98)
by Kiran
04:35
created
includes/wpinv-email-functions.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -664,6 +664,9 @@  discard block
 block discarded – undo
664 664
     return $sent;
665 665
 }
666 666
 
667
+/**
668
+ * @return string
669
+ */
667 670
 function wpinv_mail_get_from_address() {
668 671
     $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
669 672
     return sanitize_email( $from_address );
@@ -1123,6 +1126,9 @@  discard block
 block discarded – undo
1123 1126
 }
1124 1127
 add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1125 1128
 
1129
+/**
1130
+ * @param string $email_type
1131
+ */
1126 1132
 function wpinv_email_is_enabled( $email_type ) {
1127 1133
     $emails = wpinv_get_emails();
1128 1134
     $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
Please login to merge, or discard this patch.
Spacing   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -28,79 +28,79 @@  discard block
 block discarded – undo
28 28
         'wpinv_fully_refunded',
29 29
         'wpinv_partially_refunded',
30 30
         'wpinv_new_invoice_note'
31
-    ) );
31
+    ));
32 32
 
33
-    foreach ( $email_actions as $action ) {
34
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
33
+    foreach ($email_actions as $action) {
34
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
35 35
     }
36 36
 }
37
-add_action( 'init', 'wpinv_init_transactional_emails' );
37
+add_action('init', 'wpinv_init_transactional_emails');
38 38
 
39 39
 // New invoice email
40
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
41
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
40
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
41
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
42
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
46 46
 
47 47
 // Cancelled invoice email
48
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
49
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
48
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
49
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
50 50
 
51 51
 // Failed invoice email
52
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
53
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
52
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
53
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
54 54
 
55 55
 // On hold invoice email
56
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
57
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
56
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
57
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
58 58
 
59 59
 // Processing invoice email
60
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
60
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
61 61
 
62 62
 // Paid invoice email
63
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
63
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
64 64
 
65 65
 // Refunded invoice email
66
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
67
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
66
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
67
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
68 68
 
69 69
 // Invoice note
70
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
70
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
71 71
 
72
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
73
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
74
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
75
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
76
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
77
-add_action( 'wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4 );
72
+add_action('wpinv_email_header', 'wpinv_email_header');
73
+add_action('wpinv_email_footer', 'wpinv_email_footer');
74
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
75
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
76
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
77
+add_action('wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4);
78 78
 
79 79
 function wpinv_send_transactional_email() {
80 80
     $args       = func_get_args();
81 81
     $function   = current_filter() . '_notification';
82
-    do_action_ref_array( $function, $args );
82
+    do_action_ref_array($function, $args);
83 83
 }
84 84
     
85
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
85
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
86 86
     global $wpinv_email_search, $wpinv_email_replace;
87 87
     
88 88
     $email_type = 'new_invoice';
89
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
89
+    if (!wpinv_email_is_enabled($email_type)) {
90 90
         return false;
91 91
     }
92 92
     
93
-    $invoice = wpinv_get_invoice( $invoice_id );
94
-    if ( empty( $invoice ) ) {
93
+    $invoice = wpinv_get_invoice($invoice_id);
94
+    if (empty($invoice)) {
95 95
         return false;
96 96
     }
97 97
 
98
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
98
+    if (!("wpi_invoice" === $invoice->post_type)) {
99 99
         return false;
100 100
     }
101 101
     
102
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
103
-    if ( !is_email( $recipient ) ) {
102
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
103
+    if (!is_email($recipient)) {
104 104
         return false;
105 105
     }
106 106
         
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
     $wpinv_email_search     = $search;
118 118
     $wpinv_email_replace    = $replace;
119 119
     
120
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
121
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
122
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
123
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
120
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
121
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
122
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
123
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
124 124
     
125
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
125
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
126 126
             'invoice'       => $invoice,
127 127
             'email_type'    => $email_type,
128 128
             'email_heading' => $email_heading,
129 129
             'sent_to_admin' => true,
130 130
             'plain_text'    => false,
131
-        ) );
131
+        ));
132 132
     
133
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
133
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
134 134
 }
135 135
 
136
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
136
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
137 137
     global $wpinv_email_search, $wpinv_email_replace;
138 138
     
139 139
     $email_type = 'cancelled_invoice';
140
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
140
+    if (!wpinv_email_is_enabled($email_type)) {
141 141
         return false;
142 142
     }
143 143
     
144
-    $invoice = wpinv_get_invoice( $invoice_id );
145
-    if ( empty( $invoice ) ) {
144
+    $invoice = wpinv_get_invoice($invoice_id);
145
+    if (empty($invoice)) {
146 146
         return false;
147 147
     }
148 148
 
149
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
149
+    if (!("wpi_invoice" === $invoice->post_type)) {
150 150
         return false;
151 151
     }
152 152
     
153
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
154
-    if ( !is_email( $recipient ) ) {
153
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
154
+    if (!is_email($recipient)) {
155 155
         return false;
156 156
     }
157 157
         
@@ -168,41 +168,41 @@  discard block
 block discarded – undo
168 168
     $wpinv_email_search     = $search;
169 169
     $wpinv_email_replace    = $replace;
170 170
     
171
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
172
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
173
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
174
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
171
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
172
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
173
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
174
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
175 175
     
176
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
176
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
177 177
             'invoice'       => $invoice,
178 178
             'email_type'    => $email_type,
179 179
             'email_heading' => $email_heading,
180 180
             'sent_to_admin' => true,
181 181
             'plain_text'    => false,
182
-        ) );
182
+        ));
183 183
     
184
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
184
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
185 185
 }
186 186
 
187
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
187
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
188 188
     global $wpinv_email_search, $wpinv_email_replace;
189 189
     
190 190
     $email_type = 'failed_invoice';
191
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
191
+    if (!wpinv_email_is_enabled($email_type)) {
192 192
         return false;
193 193
     }
194 194
     
195
-    $invoice = wpinv_get_invoice( $invoice_id );
196
-    if ( empty( $invoice ) ) {
195
+    $invoice = wpinv_get_invoice($invoice_id);
196
+    if (empty($invoice)) {
197 197
         return false;
198 198
     }
199 199
 
200
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
200
+    if (!("wpi_invoice" === $invoice->post_type)) {
201 201
         return false;
202 202
     }
203 203
     
204
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
205
-    if ( !is_email( $recipient ) ) {
204
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
205
+    if (!is_email($recipient)) {
206 206
         return false;
207 207
     }
208 208
         
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
     $wpinv_email_search     = $search;
220 220
     $wpinv_email_replace    = $replace;
221 221
     
222
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
223
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
224
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
225
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
222
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
223
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
224
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
225
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
226 226
     
227
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
227
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
228 228
             'invoice'       => $invoice,
229 229
             'email_type'    => $email_type,
230 230
             'email_heading' => $email_heading,
231 231
             'sent_to_admin' => true,
232 232
             'plain_text'    => false,
233
-        ) );
233
+        ));
234 234
     
235
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
235
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
236 236
 }
237 237
 
238
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
238
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
239 239
     global $wpinv_email_search, $wpinv_email_replace;
240 240
     
241 241
     $email_type = 'onhold_invoice';
242
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
242
+    if (!wpinv_email_is_enabled($email_type)) {
243 243
         return false;
244 244
     }
245 245
     
246
-    $invoice = wpinv_get_invoice( $invoice_id );
247
-    if ( empty( $invoice ) ) {
246
+    $invoice = wpinv_get_invoice($invoice_id);
247
+    if (empty($invoice)) {
248 248
         return false;
249 249
     }
250 250
 
251
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
251
+    if (!("wpi_invoice" === $invoice->post_type)) {
252 252
         return false;
253 253
     }
254 254
     
255
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
256
-    if ( !is_email( $recipient ) ) {
255
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
256
+    if (!is_email($recipient)) {
257 257
         return false;
258 258
     }
259 259
         
@@ -270,49 +270,49 @@  discard block
 block discarded – undo
270 270
     $wpinv_email_search     = $search;
271 271
     $wpinv_email_replace    = $replace;
272 272
     
273
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
274
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
275
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
276
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
273
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
274
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
275
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
276
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
277 277
     
278
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
278
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
279 279
             'invoice'       => $invoice,
280 280
             'email_type'    => $email_type,
281 281
             'email_heading' => $email_heading,
282 282
             'sent_to_admin' => false,
283 283
             'plain_text'    => false,
284
-        ) );
284
+        ));
285 285
     
286
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
286
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
287 287
     
288
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
289
-        $recipient  = wpinv_get_admin_email();
290
-        $subject    .= ' - ADMIN BCC COPY';
291
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
288
+    if (wpinv_mail_admin_bcc_active($email_type)) {
289
+        $recipient = wpinv_get_admin_email();
290
+        $subject .= ' - ADMIN BCC COPY';
291
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
292 292
     }
293 293
     
294 294
     return $sent;
295 295
 }
296 296
 
297
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
297
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
298 298
     global $wpinv_email_search, $wpinv_email_replace;
299 299
     
300 300
     $email_type = 'processing_invoice';
301
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
301
+    if (!wpinv_email_is_enabled($email_type)) {
302 302
         return false;
303 303
     }
304 304
     
305
-    $invoice = wpinv_get_invoice( $invoice_id );
306
-    if ( empty( $invoice ) ) {
305
+    $invoice = wpinv_get_invoice($invoice_id);
306
+    if (empty($invoice)) {
307 307
         return false;
308 308
     }
309 309
 
310
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
310
+    if (!("wpi_invoice" === $invoice->post_type)) {
311 311
         return false;
312 312
     }
313 313
     
314
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
315
-    if ( !is_email( $recipient ) ) {
314
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
315
+    if (!is_email($recipient)) {
316 316
         return false;
317 317
     }
318 318
         
@@ -329,49 +329,49 @@  discard block
 block discarded – undo
329 329
     $wpinv_email_search     = $search;
330 330
     $wpinv_email_replace    = $replace;
331 331
     
332
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
333
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
334
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
335
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
332
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
333
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
334
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
335
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
336 336
     
337
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
337
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
338 338
             'invoice'       => $invoice,
339 339
             'email_type'    => $email_type,
340 340
             'email_heading' => $email_heading,
341 341
             'sent_to_admin' => false,
342 342
             'plain_text'    => false,
343
-        ) );
343
+        ));
344 344
     
345
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
345
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
346 346
     
347
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
348
-        $recipient  = wpinv_get_admin_email();
349
-        $subject    .= ' - ADMIN BCC COPY';
350
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
347
+    if (wpinv_mail_admin_bcc_active($email_type)) {
348
+        $recipient = wpinv_get_admin_email();
349
+        $subject .= ' - ADMIN BCC COPY';
350
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
351 351
     }
352 352
     
353 353
     return $sent;
354 354
 }
355 355
 
356
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
356
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
357 357
     global $wpinv_email_search, $wpinv_email_replace;
358 358
     
359 359
     $email_type = 'completed_invoice';
360
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
360
+    if (!wpinv_email_is_enabled($email_type)) {
361 361
         return false;
362 362
     }
363 363
     
364
-    $invoice = wpinv_get_invoice( $invoice_id );
365
-    if ( empty( $invoice ) ) {
364
+    $invoice = wpinv_get_invoice($invoice_id);
365
+    if (empty($invoice)) {
366 366
         return false;
367 367
     }
368 368
 
369
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
369
+    if (!("wpi_invoice" === $invoice->post_type)) {
370 370
         return false;
371 371
     }
372 372
     
373
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
374
-    if ( !is_email( $recipient ) ) {
373
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
374
+    if (!is_email($recipient)) {
375 375
         return false;
376 376
     }
377 377
         
@@ -388,49 +388,49 @@  discard block
 block discarded – undo
388 388
     $wpinv_email_search     = $search;
389 389
     $wpinv_email_replace    = $replace;
390 390
     
391
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
392
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
393
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
394
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
391
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
392
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
393
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
394
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
395 395
     
396
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
396
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
397 397
             'invoice'       => $invoice,
398 398
             'email_type'    => $email_type,
399 399
             'email_heading' => $email_heading,
400 400
             'sent_to_admin' => false,
401 401
             'plain_text'    => false,
402
-        ) );
402
+        ));
403 403
     
404
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
404
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
405 405
     
406
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
407
-        $recipient  = wpinv_get_admin_email();
408
-        $subject    .= ' - ADMIN BCC COPY';
409
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
406
+    if (wpinv_mail_admin_bcc_active($email_type)) {
407
+        $recipient = wpinv_get_admin_email();
408
+        $subject .= ' - ADMIN BCC COPY';
409
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
410 410
     }
411 411
     
412 412
     return $sent;
413 413
 }
414 414
 
415
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
415
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
416 416
     global $wpinv_email_search, $wpinv_email_replace;
417 417
     
418 418
     $email_type = 'refunded_invoice';
419
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
419
+    if (!wpinv_email_is_enabled($email_type)) {
420 420
         return false;
421 421
     }
422 422
     
423
-    $invoice = wpinv_get_invoice( $invoice_id );
424
-    if ( empty( $invoice ) ) {
423
+    $invoice = wpinv_get_invoice($invoice_id);
424
+    if (empty($invoice)) {
425 425
         return false;
426 426
     }
427 427
 
428
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
428
+    if (!("wpi_invoice" === $invoice->post_type)) {
429 429
         return false;
430 430
     }
431 431
     
432
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
433
-    if ( !is_email( $recipient ) ) {
432
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
433
+    if (!is_email($recipient)) {
434 434
         return false;
435 435
     }
436 436
         
@@ -447,50 +447,50 @@  discard block
 block discarded – undo
447 447
     $wpinv_email_search     = $search;
448 448
     $wpinv_email_replace    = $replace;
449 449
     
450
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
451
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
452
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
453
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
450
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
451
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
452
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
453
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
454 454
     
455
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
455
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
456 456
             'invoice'           => $invoice,
457 457
             'email_type'        => $email_type,
458 458
             'email_heading'     => $email_heading,
459 459
             'sent_to_admin'     => false,
460 460
             'plain_text'        => false,
461 461
             'partial_refund'    => false
462
-        ) );
462
+        ));
463 463
     
464
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
464
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
465 465
     
466
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
467
-        $recipient  = wpinv_get_admin_email();
468
-        $subject    .= ' - ADMIN BCC COPY';
469
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
466
+    if (wpinv_mail_admin_bcc_active($email_type)) {
467
+        $recipient = wpinv_get_admin_email();
468
+        $subject .= ' - ADMIN BCC COPY';
469
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
470 470
     }
471 471
     
472 472
     return $sent;
473 473
 }
474 474
 
475
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
475
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
476 476
     global $wpinv_email_search, $wpinv_email_replace;
477 477
     
478 478
     $email_type = 'refunded_invoice';
479
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
479
+    if (!wpinv_email_is_enabled($email_type)) {
480 480
         return false;
481 481
     }
482 482
     
483
-    $invoice = wpinv_get_invoice( $invoice_id );
484
-    if ( empty( $invoice ) ) {
483
+    $invoice = wpinv_get_invoice($invoice_id);
484
+    if (empty($invoice)) {
485 485
         return false;
486 486
     }
487 487
 
488
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
488
+    if (!("wpi_invoice" === $invoice->post_type)) {
489 489
         return false;
490 490
     }
491 491
     
492
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
493
-    if ( !is_email( $recipient ) ) {
492
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
493
+    if (!is_email($recipient)) {
494 494
         return false;
495 495
     }
496 496
         
@@ -507,53 +507,53 @@  discard block
 block discarded – undo
507 507
     $wpinv_email_search     = $search;
508 508
     $wpinv_email_replace    = $replace;
509 509
     
510
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
511
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
512
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
513
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
510
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
511
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
512
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
513
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
514 514
     
515
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
515
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
516 516
             'invoice'           => $invoice,
517 517
             'email_type'        => $email_type,
518 518
             'email_heading'     => $email_heading,
519 519
             'sent_to_admin'     => false,
520 520
             'plain_text'        => false,
521 521
             'partial_refund'    => true
522
-        ) );
522
+        ));
523 523
     
524
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
524
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
525 525
     
526
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
527
-        $recipient  = wpinv_get_admin_email();
528
-        $subject    .= ' - ADMIN BCC COPY';
529
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
526
+    if (wpinv_mail_admin_bcc_active($email_type)) {
527
+        $recipient = wpinv_get_admin_email();
528
+        $subject .= ' - ADMIN BCC COPY';
529
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
530 530
     }
531 531
     
532 532
     return $sent;
533 533
 }
534 534
 
535
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
535
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
536 536
 }
537 537
 
538
-function wpinv_user_invoice_notification( $invoice_id ) {
538
+function wpinv_user_invoice_notification($invoice_id) {
539 539
     global $wpinv_email_search, $wpinv_email_replace;
540 540
     
541 541
     $email_type = 'user_invoice';
542
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
542
+    if (!wpinv_email_is_enabled($email_type)) {
543 543
         return false;
544 544
     }
545 545
     
546
-    $invoice = wpinv_get_invoice( $invoice_id );
547
-    if ( empty( $invoice ) ) {
546
+    $invoice = wpinv_get_invoice($invoice_id);
547
+    if (empty($invoice)) {
548 548
         return false;
549 549
     }
550 550
 
551
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
551
+    if (!("wpi_invoice" === $invoice->post_type)) {
552 552
         return false;
553 553
     }
554 554
     
555
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
556
-    if ( !is_email( $recipient ) ) {
555
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
556
+    if (!is_email($recipient)) {
557 557
         return false;
558 558
     }
559 559
         
@@ -570,53 +570,53 @@  discard block
 block discarded – undo
570 570
     $wpinv_email_search     = $search;
571 571
     $wpinv_email_replace    = $replace;
572 572
     
573
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
574
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
575
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
576
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
573
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
574
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
575
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
576
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
577 577
     
578
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
578
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
579 579
             'invoice'       => $invoice,
580 580
             'email_type'    => $email_type,
581 581
             'email_heading' => $email_heading,
582 582
             'sent_to_admin' => false,
583 583
             'plain_text'    => false,
584
-        ) );
584
+        ));
585 585
     
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
     
588
-    if ( $sent ) {
589
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
588
+    if ($sent) {
589
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
590 590
     } else {
591
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
591
+        $note = __('Fail to send invoice to the user!', 'invoicing');
592 592
     }
593 593
     
594
-    $invoice->add_note( $note, '', '', true ); // Add system note.
594
+    $invoice->add_note($note, '', '', true); // Add system note.
595 595
 
596
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
597
-        $recipient  = wpinv_get_admin_email();
598
-        $subject    .= ' - ADMIN BCC COPY';
599
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
596
+    if (wpinv_mail_admin_bcc_active($email_type)) {
597
+        $recipient = wpinv_get_admin_email();
598
+        $subject .= ' - ADMIN BCC COPY';
599
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
600 600
     }
601 601
     
602 602
     return $sent;
603 603
 }
604 604
 
605
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
605
+function wpinv_user_note_notification($invoice_id, $args = array()) {
606 606
     global $wpinv_email_search, $wpinv_email_replace;
607 607
     
608 608
     $email_type = 'user_note';
609
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
609
+    if (!wpinv_email_is_enabled($email_type)) {
610 610
         return false;
611 611
     }
612 612
     
613
-    $invoice = wpinv_get_invoice( $invoice_id );
614
-    if ( empty( $invoice ) ) {
613
+    $invoice = wpinv_get_invoice($invoice_id);
614
+    if (empty($invoice)) {
615 615
         return false;
616 616
     }
617 617
     
618
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
619
-    if ( !is_email( $recipient ) ) {
618
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
619
+    if (!is_email($recipient)) {
620 620
         return false;
621 621
     }
622 622
     
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
         'user_note' => ''
625 625
     );
626 626
 
627
-    $args = wp_parse_args( $args, $defaults );
627
+    $args = wp_parse_args($args, $defaults);
628 628
         
629 629
     $search                     = array();
630 630
     $search['invoice_number']   = '{invoice_number}';
@@ -643,46 +643,46 @@  discard block
 block discarded – undo
643 643
     $wpinv_email_search     = $search;
644 644
     $wpinv_email_replace    = $replace;
645 645
     
646
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
647
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
648
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
649
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
646
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
647
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
648
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
649
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
650 650
     
651
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
651
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
652 652
             'invoice'       => $invoice,
653 653
             'email_type'    => $email_type,
654 654
             'email_heading' => $email_heading,
655 655
             'sent_to_admin' => false,
656 656
             'plain_text'    => false,
657 657
             'customer_note' => $args['user_note']
658
-        ) );
658
+        ));
659 659
         
660
-    $content        = wpinv_email_format_text( $content );
660
+    $content = wpinv_email_format_text($content);
661 661
     
662
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
662
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
663 663
         
664 664
     return $sent;
665 665
 }
666 666
 
667 667
 function wpinv_mail_get_from_address() {
668
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
669
-    return sanitize_email( $from_address );
668
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
669
+    return sanitize_email($from_address);
670 670
 }
671 671
 
672 672
 function wpinv_mail_get_from_name() {
673
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
674
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
673
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
674
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
675 675
 }
676 676
 
677
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
678
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
679
-    return ( $active ? true : false );
677
+function wpinv_mail_admin_bcc_active($mail_type = '') {
678
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
679
+    return ($active ? true : false);
680 680
 }
681 681
     
682
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
683
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
682
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
683
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
684 684
     
685
-    switch ( $email_type ) {
685
+    switch ($email_type) {
686 686
         case 'html' :
687 687
             $content_type = 'text/html';
688 688
             break;
@@ -697,35 +697,35 @@  discard block
 block discarded – undo
697 697
     return $content_type;
698 698
 }
699 699
     
700
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
701
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
702
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
703
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
700
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
701
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
702
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
703
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
704 704
 
705
-    $message = wpinv_email_style_body( $message );
706
-    $message = apply_filters( 'wpinv_mail_content', $message );
705
+    $message = wpinv_email_style_body($message);
706
+    $message = apply_filters('wpinv_mail_content', $message);
707 707
     
708
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
708
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
709 709
     
710
-    if ( !$sent ) {
711
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
712
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
710
+    if (!$sent) {
711
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
712
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
713 713
     }
714 714
 
715
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
716
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
717
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
715
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
716
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
717
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
718 718
 
719 719
     return $sent;
720 720
 }
721 721
     
722 722
 function wpinv_get_emails() {
723 723
     $overdue_days_options       = array();
724
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
725
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
724
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
725
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
726 726
     
727
-    for ( $i = 2; $i <= 10; $i++ ) {
728
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
727
+    for ($i = 2; $i <= 10; $i++) {
728
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
729 729
     }
730 730
 
731 731
     // Default, built-in gateways
@@ -733,130 +733,130 @@  discard block
 block discarded – undo
733 733
             'new_invoice' => array(
734 734
             'email_new_invoice_header' => array(
735 735
                 'id'   => 'email_new_invoice_header',
736
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
737
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
736
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
737
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
738 738
                 'type' => 'header',
739 739
             ),
740 740
             'email_new_invoice_active' => array(
741 741
                 'id'   => 'email_new_invoice_active',
742
-                'name' => __( 'Enable/Disable', 'invoicing' ),
743
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
742
+                'name' => __('Enable/Disable', 'invoicing'),
743
+                'desc' => __('Enable this email notification', 'invoicing'),
744 744
                 'type' => 'checkbox',
745 745
                 'std'  => 1
746 746
             ),
747 747
             'email_new_invoice_subject' => array(
748 748
                 'id'   => 'email_new_invoice_subject',
749
-                'name' => __( 'Subject', 'invoicing' ),
750
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
749
+                'name' => __('Subject', 'invoicing'),
750
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
751 751
                 'type' => 'text',
752
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
752
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
753 753
                 'size' => 'large'
754 754
             ),
755 755
             'email_new_invoice_heading' => array(
756 756
                 'id'   => 'email_new_invoice_heading',
757
-                'name' => __( 'Email Heading', 'invoicing' ),
758
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
757
+                'name' => __('Email Heading', 'invoicing'),
758
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
759 759
                 'type' => 'text',
760
-                'std'  => __( 'New payment invoice', 'invoicing' ),
760
+                'std'  => __('New payment invoice', 'invoicing'),
761 761
                 'size' => 'large'
762 762
             ),
763 763
         ),
764 764
         'cancelled_invoice' => array(
765 765
             'email_cancelled_invoice_header' => array(
766 766
                 'id'   => 'email_cancelled_invoice_header',
767
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
768
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
767
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
768
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
769 769
                 'type' => 'header',
770 770
             ),
771 771
             'email_cancelled_invoice_active' => array(
772 772
                 'id'   => 'email_cancelled_invoice_active',
773
-                'name' => __( 'Enable/Disable', 'invoicing' ),
774
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
773
+                'name' => __('Enable/Disable', 'invoicing'),
774
+                'desc' => __('Enable this email notification', 'invoicing'),
775 775
                 'type' => 'checkbox',
776 776
                 'std'  => 1
777 777
             ),
778 778
             'email_cancelled_invoice_subject' => array(
779 779
                 'id'   => 'email_cancelled_invoice_subject',
780
-                'name' => __( 'Subject', 'invoicing' ),
781
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
780
+                'name' => __('Subject', 'invoicing'),
781
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
782 782
                 'type' => 'text',
783
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
783
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
784 784
                 'size' => 'large'
785 785
             ),
786 786
             'email_cancelled_invoice_heading' => array(
787 787
                 'id'   => 'email_cancelled_invoice_heading',
788
-                'name' => __( 'Email Heading', 'invoicing' ),
789
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
788
+                'name' => __('Email Heading', 'invoicing'),
789
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
790 790
                 'type' => 'text',
791
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
791
+                'std'  => __('Cancelled invoice', 'invoicing'),
792 792
                 'size' => 'large'
793 793
             ),
794 794
         ),
795 795
         'failed_invoice' => array(
796 796
             'email_failed_invoice_header' => array(
797 797
                 'id'   => 'email_failed_invoice_header',
798
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
799
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
798
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
799
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
800 800
                 'type' => 'header',
801 801
             ),
802 802
             'email_failed_invoice_active' => array(
803 803
                 'id'   => 'email_failed_invoice_active',
804
-                'name' => __( 'Enable/Disable', 'invoicing' ),
805
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
804
+                'name' => __('Enable/Disable', 'invoicing'),
805
+                'desc' => __('Enable this email notification', 'invoicing'),
806 806
                 'type' => 'checkbox',
807 807
                 'std'  => 1
808 808
             ),
809 809
             'email_failed_invoice_subject' => array(
810 810
                 'id'   => 'email_failed_invoice_subject',
811
-                'name' => __( 'Subject', 'invoicing' ),
812
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
811
+                'name' => __('Subject', 'invoicing'),
812
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
813 813
                 'type' => 'text',
814
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
814
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
815 815
                 'size' => 'large'
816 816
             ),
817 817
             'email_failed_invoice_heading' => array(
818 818
                 'id'   => 'email_failed_invoice_heading',
819
-                'name' => __( 'Email Heading', 'invoicing' ),
820
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
819
+                'name' => __('Email Heading', 'invoicing'),
820
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
821 821
                 'type' => 'text',
822
-                'std'  => __( 'Failed invoice', 'invoicing' ),
822
+                'std'  => __('Failed invoice', 'invoicing'),
823 823
                 'size' => 'large'
824 824
             )
825 825
         ),
826 826
         'onhold_invoice' => array(
827 827
             'email_onhold_invoice_header' => array(
828 828
                 'id'   => 'email_onhold_invoice_header',
829
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
829
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_onhold_invoice_active' => array(
834 834
                 'id'   => 'email_onhold_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_onhold_invoice_subject' => array(
841 841
                 'id'   => 'email_onhold_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_onhold_invoice_heading' => array(
849 849
                 'id'   => 'email_onhold_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_onhold_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_onhold_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
@@ -864,37 +864,37 @@  discard block
 block discarded – undo
864 864
         'processing_invoice' => array(
865 865
             'email_processing_invoice_header' => array(
866 866
                 'id'   => 'email_processing_invoice_header',
867
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
868
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
867
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
868
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
869 869
                 'type' => 'header',
870 870
             ),
871 871
             'email_processing_invoice_active' => array(
872 872
                 'id'   => 'email_processing_invoice_active',
873
-                'name' => __( 'Enable/Disable', 'invoicing' ),
874
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
873
+                'name' => __('Enable/Disable', 'invoicing'),
874
+                'desc' => __('Enable this email notification', 'invoicing'),
875 875
                 'type' => 'checkbox',
876 876
                 'std'  => 1
877 877
             ),
878 878
             'email_processing_invoice_subject' => array(
879 879
                 'id'   => 'email_processing_invoice_subject',
880
-                'name' => __( 'Subject', 'invoicing' ),
881
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
880
+                'name' => __('Subject', 'invoicing'),
881
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
882 882
                 'type' => 'text',
883
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
883
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
884 884
                 'size' => 'large'
885 885
             ),
886 886
             'email_processing_invoice_heading' => array(
887 887
                 'id'   => 'email_processing_invoice_heading',
888
-                'name' => __( 'Email Heading', 'invoicing' ),
889
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
888
+                'name' => __('Email Heading', 'invoicing'),
889
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
890 890
                 'type' => 'text',
891
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
891
+                'std'  => __('Thank you for your invoice', 'invoicing'),
892 892
                 'size' => 'large'
893 893
             ),
894 894
             'email_processing_invoice_admin_bcc' => array(
895 895
                 'id'   => 'email_processing_invoice_admin_bcc',
896
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
897
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
896
+                'name' => __('Enable Admin BCC', 'invoicing'),
897
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
898 898
                 'type' => 'checkbox',
899 899
                 'std'  => 1
900 900
             ),
@@ -902,37 +902,37 @@  discard block
 block discarded – undo
902 902
         'completed_invoice' => array(
903 903
             'email_completed_invoice_header' => array(
904 904
                 'id'   => 'email_completed_invoice_header',
905
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
906
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
905
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
906
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
907 907
                 'type' => 'header',
908 908
             ),
909 909
             'email_completed_invoice_active' => array(
910 910
                 'id'   => 'email_completed_invoice_active',
911
-                'name' => __( 'Enable/Disable', 'invoicing' ),
912
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
911
+                'name' => __('Enable/Disable', 'invoicing'),
912
+                'desc' => __('Enable this email notification', 'invoicing'),
913 913
                 'type' => 'checkbox',
914 914
                 'std'  => 1
915 915
             ),
916 916
             'email_completed_invoice_subject' => array(
917 917
                 'id'   => 'email_completed_invoice_subject',
918
-                'name' => __( 'Subject', 'invoicing' ),
919
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
918
+                'name' => __('Subject', 'invoicing'),
919
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
920 920
                 'type' => 'text',
921
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
921
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
922 922
                 'size' => 'large'
923 923
             ),
924 924
             'email_completed_invoice_heading' => array(
925 925
                 'id'   => 'email_completed_invoice_heading',
926
-                'name' => __( 'Email Heading', 'invoicing' ),
927
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
926
+                'name' => __('Email Heading', 'invoicing'),
927
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
928 928
                 'type' => 'text',
929
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
929
+                'std'  => __('Your invoice has been paid', 'invoicing'),
930 930
                 'size' => 'large'
931 931
             ),
932 932
             'email_completed_invoice_admin_bcc' => array(
933 933
                 'id'   => 'email_completed_invoice_admin_bcc',
934
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
935
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
934
+                'name' => __('Enable Admin BCC', 'invoicing'),
935
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
936 936
                 'type' => 'checkbox',
937 937
             ),
938 938
             'std'  => 1
@@ -940,37 +940,37 @@  discard block
 block discarded – undo
940 940
         'refunded_invoice' => array(
941 941
             'email_refunded_invoice_header' => array(
942 942
                 'id'   => 'email_refunded_invoice_header',
943
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
944
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
943
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
944
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
945 945
                 'type' => 'header',
946 946
             ),
947 947
             'email_refunded_invoice_active' => array(
948 948
                 'id'   => 'email_refunded_invoice_active',
949
-                'name' => __( 'Enable/Disable', 'invoicing' ),
950
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
949
+                'name' => __('Enable/Disable', 'invoicing'),
950
+                'desc' => __('Enable this email notification', 'invoicing'),
951 951
                 'type' => 'checkbox',
952 952
                 'std'  => 1
953 953
             ),
954 954
             'email_refunded_invoice_subject' => array(
955 955
                 'id'   => 'email_refunded_invoice_subject',
956
-                'name' => __( 'Subject', 'invoicing' ),
957
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
956
+                'name' => __('Subject', 'invoicing'),
957
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
958 958
                 'type' => 'text',
959
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
959
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
960 960
                 'size' => 'large'
961 961
             ),
962 962
             'email_refunded_invoice_heading' => array(
963 963
                 'id'   => 'email_refunded_invoice_heading',
964
-                'name' => __( 'Email Heading', 'invoicing' ),
965
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
964
+                'name' => __('Email Heading', 'invoicing'),
965
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
966 966
                 'type' => 'text',
967
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
967
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
968 968
                 'size' => 'large'
969 969
             ),
970 970
             'email_refunded_invoice_admin_bcc' => array(
971 971
                 'id'   => 'email_refunded_invoice_admin_bcc',
972
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
973
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
972
+                'name' => __('Enable Admin BCC', 'invoicing'),
973
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
974 974
                 'type' => 'checkbox',
975 975
                 'std'  => 1
976 976
             ),
@@ -978,37 +978,37 @@  discard block
 block discarded – undo
978 978
         'user_invoice' => array(
979 979
             'email_user_invoice_header' => array(
980 980
                 'id'   => 'email_user_invoice_header',
981
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
982
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
981
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
982
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
983 983
                 'type' => 'header',
984 984
             ),
985 985
             'email_user_invoice_active' => array(
986 986
                 'id'   => 'email_user_invoice_active',
987
-                'name' => __( 'Enable/Disable', 'invoicing' ),
988
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
987
+                'name' => __('Enable/Disable', 'invoicing'),
988
+                'desc' => __('Enable this email notification', 'invoicing'),
989 989
                 'type' => 'checkbox',
990 990
                 'std'  => 1
991 991
             ),
992 992
             'email_user_invoice_subject' => array(
993 993
                 'id'   => 'email_user_invoice_subject',
994
-                'name' => __( 'Subject', 'invoicing' ),
995
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
994
+                'name' => __('Subject', 'invoicing'),
995
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
996 996
                 'type' => 'text',
997
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
997
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
998 998
                 'size' => 'large'
999 999
             ),
1000 1000
             'email_user_invoice_heading' => array(
1001 1001
                 'id'   => 'email_user_invoice_heading',
1002
-                'name' => __( 'Email Heading', 'invoicing' ),
1003
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
1002
+                'name' => __('Email Heading', 'invoicing'),
1003
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1004 1004
                 'type' => 'text',
1005
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1005
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1006 1006
                 'size' => 'large'
1007 1007
             ),
1008 1008
             'email_user_invoice_admin_bcc' => array(
1009 1009
                 'id'   => 'email_user_invoice_admin_bcc',
1010
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1011
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1010
+                'name' => __('Enable Admin BCC', 'invoicing'),
1011
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1012 1012
                 'type' => 'checkbox',
1013 1013
                 'std'  => 1
1014 1014
             ),
@@ -1016,177 +1016,177 @@  discard block
 block discarded – undo
1016 1016
         'user_note' => array(
1017 1017
             'email_user_note_header' => array(
1018 1018
                 'id'   => 'email_user_note_header',
1019
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1020
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1019
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1020
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1021 1021
                 'type' => 'header',
1022 1022
             ),
1023 1023
             'email_user_note_active' => array(
1024 1024
                 'id'   => 'email_user_note_active',
1025
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1026
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1025
+                'name' => __('Enable/Disable', 'invoicing'),
1026
+                'desc' => __('Enable this email notification', 'invoicing'),
1027 1027
                 'type' => 'checkbox',
1028 1028
                 'std'  => 1
1029 1029
             ),
1030 1030
             'email_user_note_subject' => array(
1031 1031
                 'id'   => 'email_user_note_subject',
1032
-                'name' => __( 'Subject', 'invoicing' ),
1033
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1032
+                'name' => __('Subject', 'invoicing'),
1033
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1034 1034
                 'type' => 'text',
1035
-                'std'  => __( '[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing' ),
1035
+                'std'  => __('[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing'),
1036 1036
                 'size' => 'large'
1037 1037
             ),
1038 1038
             'email_user_note_heading' => array(
1039 1039
                 'id'   => 'email_user_note_heading',
1040
-                'name' => __( 'Email Heading', 'invoicing' ),
1041
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1040
+                'name' => __('Email Heading', 'invoicing'),
1041
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1042 1042
                 'type' => 'text',
1043
-                'std'  => __( 'A note has been added to your {invoice_quote}', 'invoicing' ),
1043
+                'std'  => __('A note has been added to your {invoice_quote}', 'invoicing'),
1044 1044
                 'size' => 'large'
1045 1045
             ),
1046 1046
         ),
1047 1047
         'overdue' => array(
1048 1048
             'email_overdue_header' => array(
1049 1049
                 'id'   => 'email_overdue_header',
1050
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1051
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1050
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1051
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1052 1052
                 'type' => 'header',
1053 1053
             ),
1054 1054
             'email_overdue_active' => array(
1055 1055
                 'id'   => 'email_overdue_active',
1056
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1057
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1056
+                'name' => __('Enable/Disable', 'invoicing'),
1057
+                'desc' => __('Enable this email notification', 'invoicing'),
1058 1058
                 'type' => 'checkbox',
1059 1059
                 'std'  => 1
1060 1060
             ),
1061 1061
             'email_due_reminder_days' => array(
1062 1062
                 'id'        => 'email_due_reminder_days',
1063
-                'name'      => __( 'When to Send', 'sliced-invoices' ),
1064
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1063
+                'name'      => __('When to Send', 'sliced-invoices'),
1064
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1065 1065
                 'default'   => '',
1066 1066
                 'type'      => 'multicheck',
1067 1067
                 'options'   => $overdue_days_options,
1068 1068
             ),
1069 1069
             'email_overdue_subject' => array(
1070 1070
                 'id'   => 'email_overdue_subject',
1071
-                'name' => __( 'Subject', 'invoicing' ),
1072
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1071
+                'name' => __('Subject', 'invoicing'),
1072
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1073 1073
                 'type' => 'text',
1074
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1074
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1075 1075
                 'size' => 'large'
1076 1076
             ),
1077 1077
             'email_overdue_heading' => array(
1078 1078
                 'id'   => 'email_overdue_heading',
1079
-                'name' => __( 'Email Heading', 'invoicing' ),
1080
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1079
+                'name' => __('Email Heading', 'invoicing'),
1080
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1081 1081
                 'type' => 'text',
1082
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1082
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1083 1083
                 'size' => 'large'
1084 1084
             ),
1085 1085
             'email_overdue_body' => array(
1086 1086
                 'id'   => 'email_overdue_body',
1087
-                'name' => __( 'Email Content', 'invoicing' ),
1088
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1087
+                'name' => __('Email Content', 'invoicing'),
1088
+                'desc' => __('The content of the email.', 'invoicing'),
1089 1089
                 'type' => 'rich_editor',
1090
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_link}">Pay Now</a></p>', 'invoicing' ),
1090
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_link}">Pay Now</a></p>', 'invoicing'),
1091 1091
                 'class' => 'large',
1092 1092
                 'size'  => 10,
1093 1093
             ),
1094 1094
         ),
1095 1095
     );
1096 1096
 
1097
-    return apply_filters( 'wpinv_get_emails', $emails );
1097
+    return apply_filters('wpinv_get_emails', $emails);
1098 1098
 }
1099 1099
 
1100
-function wpinv_settings_emails( $settings = array() ) {
1100
+function wpinv_settings_emails($settings = array()) {
1101 1101
     $emails = wpinv_get_emails();
1102 1102
     
1103
-    if ( !empty( $emails ) ) {
1104
-        foreach ( $emails as $key => $email ) {
1103
+    if (!empty($emails)) {
1104
+        foreach ($emails as $key => $email) {
1105 1105
             $settings[$key] = $email;
1106 1106
         }
1107 1107
     }
1108 1108
     
1109
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1109
+    return apply_filters('wpinv_settings_get_emails', $settings);
1110 1110
 }
1111
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1111
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1112 1112
 
1113
-function wpinv_settings_sections_emails( $settings ) {
1113
+function wpinv_settings_sections_emails($settings) {
1114 1114
     $emails = wpinv_get_emails();
1115 1115
     
1116 1116
     if (!empty($emails)) {
1117
-        foreach  ($emails as $key => $email) {
1118
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1117
+        foreach ($emails as $key => $email) {
1118
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1119 1119
         }
1120 1120
     }
1121 1121
     
1122 1122
     return $settings;    
1123 1123
 }
1124
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1124
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1125 1125
 
1126
-function wpinv_email_is_enabled( $email_type ) {
1126
+function wpinv_email_is_enabled($email_type) {
1127 1127
     $emails = wpinv_get_emails();
1128
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1128
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1129 1129
 
1130
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1130
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1131 1131
 }
1132 1132
 
1133
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1134
-    switch ( $email_type ) {
1133
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1134
+    switch ($email_type) {
1135 1135
         case 'new_invoice':
1136 1136
         case 'cancelled_invoice':
1137 1137
         case 'failed_invoice':
1138 1138
             $recipient  = wpinv_get_admin_email();
1139 1139
         break;
1140 1140
         default:
1141
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1142
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1141
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1142
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1143 1143
         break;
1144 1144
     }
1145 1145
     
1146
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1146
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1147 1147
 }
1148 1148
 
1149
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1150
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1149
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1150
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1151 1151
     
1152
-    $subject    = wpinv_email_format_text( $subject );
1152
+    $subject    = wpinv_email_format_text($subject);
1153 1153
     
1154
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1154
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1155 1155
 }
1156 1156
 
1157
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1158
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1157
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1158
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1159 1159
     
1160
-    $email_heading = wpinv_email_format_text( $email_heading );
1160
+    $email_heading = wpinv_email_format_text($email_heading);
1161 1161
     
1162
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1162
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1163 1163
 }
1164 1164
 
1165
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1166
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1165
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1166
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1167 1167
     
1168
-    $content    = wpinv_email_format_text( $content );
1168
+    $content    = wpinv_email_format_text($content);
1169 1169
     
1170
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1170
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1171 1171
 }
1172 1172
 
1173
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1174 1174
     $from_name = wpinv_mail_get_from_address();
1175 1175
     $from_email = wpinv_mail_get_from_address();
1176 1176
     
1177
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1177
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1178 1178
     
1179
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1180
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1179
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1180
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1181 1181
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1182 1182
     
1183
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1183
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1184 1184
 }
1185 1185
 
1186
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1186
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1187 1187
     $attachments = array();
1188 1188
     
1189
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1189
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1190 1190
 }
1191 1191
 
1192 1192
 function wpinv_email_global_vars() {
@@ -1203,73 +1203,73 @@  discard block
 block discarded – undo
1203 1203
     $replace['sitename']    = $blogname;
1204 1204
     $replace['site-title']  = $blogname;
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) );
1206
+    return apply_filters('wpinv_email_global_vars', array($search, $replace));
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content ) {
1209
+function wpinv_email_format_text($content) {
1210 1210
     global $wpinv_email_search, $wpinv_email_replace;
1211 1211
     
1212
-    if ( empty( $wpinv_email_search ) ) {
1212
+    if (empty($wpinv_email_search)) {
1213 1213
         $wpinv_email_search = array();
1214 1214
     }
1215 1215
     
1216
-    if ( empty( $wpinv_email_replace ) ) {
1216
+    if (empty($wpinv_email_replace)) {
1217 1217
         $wpinv_email_replace = array();
1218 1218
     }
1219 1219
     
1220
-    $wpinv_email_search     = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search );
1221
-    $wpinv_email_replace    = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace );
1220
+    $wpinv_email_search     = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search);
1221
+    $wpinv_email_replace    = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace);
1222 1222
     
1223 1223
     $global_vars    = wpinv_email_global_vars();
1224 1224
     
1225
-    $search         = array_merge( $global_vars[0], $wpinv_email_search );
1226
-    $replace        = array_merge( $global_vars[1], $wpinv_email_replace );
1225
+    $search         = array_merge($global_vars[0], $wpinv_email_search);
1226
+    $replace        = array_merge($global_vars[1], $wpinv_email_replace);
1227 1227
     
1228
-    if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) {
1228
+    if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) {
1229 1229
         return  $content;
1230 1230
     }
1231 1231
         
1232
-    return str_replace( $search, $replace, $content );
1232
+    return str_replace($search, $replace, $content);
1233 1233
 }
1234 1234
 
1235
-function wpinv_email_style_body( $content ) {
1235
+function wpinv_email_style_body($content) {
1236 1236
     // make sure we only inline CSS for html emails
1237
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1237
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1238 1238
         ob_start();
1239
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1240
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1239
+        wpinv_get_template('emails/wpinv-email-styles.php');
1240
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1241 1241
         
1242 1242
         // apply CSS styles inline for picky email clients
1243 1243
         try {
1244
-            $emogrifier = new Emogrifier( $content, $css );
1244
+            $emogrifier = new Emogrifier($content, $css);
1245 1245
             $content    = $emogrifier->emogrify();
1246
-        } catch ( Exception $e ) {
1247
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1246
+        } catch (Exception $e) {
1247
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1248 1248
         }
1249 1249
     }
1250 1250
     return $content;
1251 1251
 }
1252 1252
 
1253
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1254
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1253
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1254
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1255 1255
 }
1256 1256
 
1257 1257
 /**
1258 1258
  * Get the email footer.
1259 1259
  */
1260
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1261
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1260
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1261
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_wrap_message( $message ) {
1264
+function wpinv_email_wrap_message($message) {
1265 1265
     // Buffer
1266 1266
     ob_start();
1267 1267
 
1268
-    do_action( 'wpinv_email_header' );
1268
+    do_action('wpinv_email_header');
1269 1269
 
1270
-    echo wpautop( wptexturize( $message ) );
1270
+    echo wpautop(wptexturize($message));
1271 1271
 
1272
-    do_action( 'wpinv_email_footer' );
1272
+    do_action('wpinv_email_footer');
1273 1273
 
1274 1274
     // Get contents
1275 1275
     $message = ob_get_clean();
@@ -1277,86 +1277,86 @@  discard block
 block discarded – undo
1277 1277
     return $message;
1278 1278
 }
1279 1279
 
1280
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1281
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1280
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1281
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1282 1282
 }
1283 1283
 
1284
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1285
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1284
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1285
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1286 1286
 }
1287 1287
 
1288
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1289
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1288
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1289
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1290 1290
 }
1291 1291
 
1292
-function wpinv_send_customer_invoice( $data = array() ) {
1293
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1292
+function wpinv_send_customer_invoice($data = array()) {
1293
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1294 1294
     
1295
-    if ( empty( $invoice_id ) ) {
1295
+    if (empty($invoice_id)) {
1296 1296
         return;
1297 1297
     }
1298 1298
 
1299
-    if ( !current_user_can( 'manage_options' ) ) {
1300
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1299
+    if (!current_user_can('manage_options')) {
1300
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1301 1301
     }
1302 1302
     
1303
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1303
+    $sent = wpinv_user_invoice_notification($invoice_id);
1304 1304
     
1305 1305
     $status = $sent ? 'email_sent' : 'email_fail';
1306 1306
     
1307
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1308
-    wp_redirect( $redirect );
1307
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1308
+    wp_redirect($redirect);
1309 1309
     exit;
1310 1310
 }
1311
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1311
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1312 1312
 
1313
-function wpinv_send_overdue_reminder( $data = array() ) {
1314
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1313
+function wpinv_send_overdue_reminder($data = array()) {
1314
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1315 1315
     
1316
-    if ( empty( $invoice_id ) ) {
1316
+    if (empty($invoice_id)) {
1317 1317
         return;
1318 1318
     }
1319 1319
 
1320
-    if ( !current_user_can( 'manage_options' ) ) {
1321
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1320
+    if (!current_user_can('manage_options')) {
1321
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1322 1322
     }
1323 1323
     
1324
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1324
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1325 1325
     
1326 1326
     $status = $sent ? 'email_sent' : 'email_fail';
1327 1327
     
1328
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1329
-    wp_redirect( $redirect );
1328
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1329
+    wp_redirect($redirect);
1330 1330
     exit;
1331 1331
 }
1332
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1332
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1333 1333
 
1334
-function wpinv_send_customer_note_email( $data ) {
1335
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1334
+function wpinv_send_customer_note_email($data) {
1335
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1336 1336
     
1337
-    if ( empty( $invoice_id ) ) {
1337
+    if (empty($invoice_id)) {
1338 1338
         return;
1339 1339
     }
1340 1340
     
1341
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1341
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1342 1342
 }
1343
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1343
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1344 1344
 
1345
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1346
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1347
-        $date_format = get_option( 'date_format' );
1348
-        $time_format = get_option( 'time_format' );
1345
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1346
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1347
+        $date_format = get_option('date_format');
1348
+        $time_format = get_option('time_format');
1349 1349
         ?>
1350 1350
         <div id="wpinv-email-notes">
1351
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1351
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1352 1352
             <ol class="wpinv-notes-lists">
1353 1353
         <?php
1354
-        foreach ( $invoice_notes as $note ) {
1355
-            $note_time = strtotime( $note->comment_date );
1354
+        foreach ($invoice_notes as $note) {
1355
+            $note_time = strtotime($note->comment_date);
1356 1356
             ?>
1357 1357
             <li class="comment wpinv-note">
1358
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1359
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1358
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1359
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1360 1360
             </li>
1361 1361
             <?php
1362 1362
         }
@@ -1365,21 +1365,21 @@  discard block
 block discarded – undo
1365 1365
         <?php
1366 1366
     }
1367 1367
 }
1368
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1368
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1369 1369
 
1370 1370
 function wpinv_email_payment_reminders() {    
1371 1371
     global $wpi_auto_reminder;
1372
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1372
+    if (!wpinv_get_option('email_overdue_active')) {
1373 1373
         return;
1374 1374
     }
1375 1375
     
1376
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1377
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1376
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1377
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1378 1378
         
1379
-        if ( empty( $reminder_days ) ) {
1379
+        if (empty($reminder_days)) {
1380 1380
             return;
1381 1381
         }
1382
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1382
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1383 1383
         
1384 1384
         $args = array(
1385 1385
             'post_type'     => 'wpi_invoice',
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
             'meta_query'    => array(
1390 1390
                 array(
1391 1391
                     'key'       =>  '_wpinv_due_date',
1392
-                    'value'     =>  array( '', 'none' ),
1392
+                    'value'     =>  array('', 'none'),
1393 1393
                     'compare'   =>  'NOT IN',
1394 1394
                 )
1395 1395
             ),
@@ -1398,64 +1398,64 @@  discard block
 block discarded – undo
1398 1398
             'order'         => 'ASC',
1399 1399
         );
1400 1400
         
1401
-        $invoices = get_posts( $args );
1401
+        $invoices = get_posts($args);
1402 1402
         
1403
-        if ( empty( $invoices ) ) {
1403
+        if (empty($invoices)) {
1404 1404
             return;
1405 1405
         }
1406 1406
         
1407
-        $date_to_send   = array();
1407
+        $date_to_send = array();
1408 1408
         
1409
-        foreach ( $invoices as $id ) {
1410
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1409
+        foreach ($invoices as $id) {
1410
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1411 1411
             
1412
-            foreach ( $reminder_days as $key => $days ) {
1413
-                if ( $days !== '' ) {
1414
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1412
+            foreach ($reminder_days as $key => $days) {
1413
+                if ($days !== '') {
1414
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1415 1415
                 }
1416 1416
             }
1417 1417
         }
1418 1418
 
1419
-        $today              = date_i18n( 'Y-m-d' );
1419
+        $today              = date_i18n('Y-m-d');
1420 1420
         $wpi_auto_reminder  = true;
1421 1421
 
1422
-        foreach ( $date_to_send as $id => $values ) {
1423
-            if ( in_array( $today, $values ) ) {
1424
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1422
+        foreach ($date_to_send as $id => $values) {
1423
+            if (in_array($today, $values)) {
1424
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1425 1425
 
1426
-                if ( isset( $sent ) && !empty( $sent ) ) {
1427
-                    if ( !in_array( $today, $sent ) ) {
1428
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1426
+                if (isset($sent) && !empty($sent)) {
1427
+                    if (!in_array($today, $sent)) {
1428
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1429 1429
                     }
1430 1430
                 } else {
1431
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1431
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
         
1436
-        $wpi_auto_reminder  = false;
1436
+        $wpi_auto_reminder = false;
1437 1437
     }
1438 1438
 }
1439 1439
 
1440
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1440
+function wpinv_send_payment_reminder_notification($invoice_id) {
1441 1441
     global $wpinv_email_search, $wpinv_email_replace;
1442 1442
     
1443 1443
     $email_type = 'overdue';
1444
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1444
+    if (!wpinv_email_is_enabled($email_type)) {
1445 1445
         return false;
1446 1446
     }
1447 1447
     
1448
-    $invoice    = wpinv_get_invoice( $invoice_id );
1449
-    if ( empty( $invoice ) ) {
1448
+    $invoice = wpinv_get_invoice($invoice_id);
1449
+    if (empty($invoice)) {
1450 1450
         return false;
1451 1451
     }
1452 1452
     
1453
-    if ( !$invoice->needs_payment() ) {
1453
+    if (!$invoice->needs_payment()) {
1454 1454
         return false;
1455 1455
     }
1456 1456
     
1457
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1458
-    if ( !is_email( $recipient ) ) {
1457
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1458
+    if (!is_email($recipient)) {
1459 1459
         return false;
1460 1460
     }
1461 1461
         
@@ -1471,70 +1471,70 @@  discard block
 block discarded – undo
1471 1471
     $replace                    = array();
1472 1472
     $replace['full_name']       = $invoice->get_user_full_name();
1473 1473
     $replace['invoice_number']  = $invoice->get_number();
1474
-    $replace['invoice_due_date']= $invoice->get_due_date( true );
1475
-    $replace['invoice_total']   = $invoice->get_total( true );
1476
-    $replace['invoice_link']    = $invoice->get_view_url( true );
1477
-    $replace['invoice_pay_link']= $replace['invoice_link'];
1478
-    $replace['is_was']          = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' );
1474
+    $replace['invoice_due_date'] = $invoice->get_due_date(true);
1475
+    $replace['invoice_total']   = $invoice->get_total(true);
1476
+    $replace['invoice_link']    = $invoice->get_view_url(true);
1477
+    $replace['invoice_pay_link'] = $replace['invoice_link'];
1478
+    $replace['is_was']          = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing');
1479 1479
 
1480 1480
     $wpinv_email_search         = $search;
1481 1481
     $wpinv_email_replace        = $replace;
1482 1482
     
1483
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1484
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1485
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1486
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1483
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1484
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1485
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1486
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1487 1487
     
1488
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1488
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1489 1489
     
1490
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1490
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1491 1491
             'invoice'       => $invoice,
1492 1492
             'email_type'    => $email_type,
1493 1493
             'email_heading' => $email_heading,
1494 1494
             'sent_to_admin' => false,
1495 1495
             'plain_text'    => false,
1496 1496
             'message_body'  => $message_body
1497
-        ) );
1497
+        ));
1498 1498
         
1499
-    $content        = wpinv_email_format_text( $content );
1499
+    $content = wpinv_email_format_text($content);
1500 1500
 
1501
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1502
-    if ( $sent ) {
1503
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1501
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1502
+    if ($sent) {
1503
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1504 1504
     }
1505 1505
         
1506 1506
     return $sent;
1507 1507
 }
1508
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1508
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1509 1509
 
1510
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1510
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1511 1511
     global $wpi_auto_reminder;
1512 1512
     
1513
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1513
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1514 1514
     
1515
-    if ( empty( $sent ) ) {
1515
+    if (empty($sent)) {
1516 1516
         $sent = array();
1517 1517
     }
1518
-    $sent[] = date_i18n( 'Y-m-d' );
1518
+    $sent[] = date_i18n('Y-m-d');
1519 1519
     
1520
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1520
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1521 1521
     
1522
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note, false, false, true );
1522
+    if ($wpi_auto_reminder) { // Auto reminder note.
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note, false, false, true);
1525 1525
     } else { // Menual reminder note.
1526
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1527
-        $invoice->add_note( $note );
1526
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1527
+        $invoice->add_note($note);
1528 1528
     }
1529 1529
 }
1530
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1530
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1531 1531
 
1532
-function wpinv_email_before_note_details( $invoice, $email_type, $sent_to_admin, $customer_note ) {
1532
+function wpinv_email_before_note_details($invoice, $email_type, $sent_to_admin, $customer_note) {
1533 1533
     if ("wpi_invoice" === $invoice->post_type && !empty($customer_note)) {
1534 1534
         $before_note = '';
1535
-        $before_note .= __( 'Hello, a note has just been added to your invoice:', 'invoicing' );
1536
-        $before_note .= '<blockquote class="wpinv-note">'.wpautop( wptexturize( $customer_note ) ).'</blockquote>';
1537
-        $before_note .= __( 'For your reference, your invoice details are shown below.', 'invoicing' );
1535
+        $before_note .= __('Hello, a note has just been added to your invoice:', 'invoicing');
1536
+        $before_note .= '<blockquote class="wpinv-note">' . wpautop(wptexturize($customer_note)) . '</blockquote>';
1537
+        $before_note .= __('For your reference, your invoice details are shown below.', 'invoicing');
1538 1538
         echo $before_note;
1539 1539
     }
1540 1540
 }
1541 1541
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -155,65 +155,65 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function wpinv_admin_messages() {
158
-	global $wpinv_options, $pagenow, $post;
158
+    global $wpinv_options, $pagenow, $post;
159 159
 
160
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
162
-	}
160
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
162
+    }
163 163
 
164
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
166
-	}
164
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
166
+    }
167 167
 
168
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
170
-	}
168
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
170
+    }
171 171
 
172
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
174
-	}
172
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
174
+    }
175 175
 
176
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
178
-	}
176
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
178
+    }
179 179
 
180
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
182
-	}
180
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
+        add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
182
+    }
183 183
 
184
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
184
+    if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
+        add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
186 186
     }
187 187
     
188 188
     if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
189
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
189
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
190 190
     }
191 191
 
192 192
     if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
193 193
         add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
194 194
     }
195 195
 
196
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
198
-	}
196
+    if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
+        add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
198
+    }
199 199
 
200
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
202
-	}
200
+    if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
+        add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
202
+    }
203 203
 
204
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
206
-	}
204
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
+        add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
206
+    }
207 207
     
208
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
208
+    if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
+        $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
210 210
 
211
-		if ( !empty( $message ) ) {
212
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
213
-		}
214
-	}
211
+        if ( !empty( $message ) ) {
212
+            add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
213
+        }
214
+    }
215 215
 
216
-	settings_errors( 'wpinv-notices' );
216
+    settings_errors( 'wpinv-notices' );
217 217
 }
218 218
 add_action( 'admin_notices', 'wpinv_admin_messages' );
219 219
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         break;
277 277
         case 'id' :
278 278
            echo $post->ID;
279
-           echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
279
+            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
280 280
                     <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
281 281
                     if ( $wpinv_euvat->allow_vat_rules() ) {
282 282
                         echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -7,239 +7,239 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Date', 'invoicing' ),
21
-        'status'            => __( 'Status', 'invoicing' ),
22
-        'ID'                => __( 'ID', 'invoicing' ),
23
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Date', 'invoicing'),
21
+        'status'            => __('Status', 'invoicing'),
22
+        'ID'                => __('ID', 'invoicing'),
23
+        'wpi_actions'       => __('Actions', 'invoicing'),
24 24
     );
25 25
 
26
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
26
+    return apply_filters('wpi_invoice_table_columns', $columns);
27 27
 }
28
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
28
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
29 29
 
30
-function wpinv_bulk_actions( $actions ) {
31
-    if ( isset( $actions['edit'] ) ) {
32
-        unset( $actions['edit'] );
30
+function wpinv_bulk_actions($actions) {
31
+    if (isset($actions['edit'])) {
32
+        unset($actions['edit']);
33 33
     }
34 34
 
35 35
     return $actions;
36 36
 }
37
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
38
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
37
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
38
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
39 39
 
40
-function wpinv_sortable_columns( $columns ) {
40
+function wpinv_sortable_columns($columns) {
41 41
     $columns = array(
42
-        'ID'            => array( 'ID', true ),
43
-        'number'        => array( 'number', false ),
44
-        'amount'        => array( 'amount', false ),
45
-        'invoice_date'  => array( 'date', false ),
46
-        'customer'      => array( 'customer', false ),
47
-        'status'        => array( 'status', false ),
42
+        'ID'            => array('ID', true),
43
+        'number'        => array('number', false),
44
+        'amount'        => array('amount', false),
45
+        'invoice_date'  => array('date', false),
46
+        'customer'      => array('customer', false),
47
+        'status'        => array('status', false),
48 48
     );
49 49
     
50
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
50
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
51 51
 }
52
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
52
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
53 53
 
54
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
54
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
56 56
     global $post, $wpi_invoice;
57 57
     
58
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
59
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
58
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
59
+        $wpi_invoice = new WPInv_Invoice($post->ID);
60 60
     }
61 61
 
62 62
     $value = NULL;
63 63
     
64
-    switch ( $column_name ) {
64
+    switch ($column_name) {
65 65
         case 'email' :
66
-            $value   = $wpi_invoice->get_email();
66
+            $value = $wpi_invoice->get_email();
67 67
             break;
68 68
         case 'customer' :
69 69
             $customer_name = $wpi_invoice->get_user_full_name();
70
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
71
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
72
-            if ( $email = $wpi_invoice->get_email() ) {
70
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
71
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
72
+            if ($email = $wpi_invoice->get_email()) {
73 73
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
74 74
             }
75 75
             break;
76 76
         case 'amount' :
77
-            echo $wpi_invoice->get_total( true );
77
+            echo $wpi_invoice->get_total(true);
78 78
             break;
79 79
         case 'invoice_date' :
80
-            $date_format = get_option( 'date_format' );
81
-            $time_format = get_option( 'time_format' );
82
-            $date_time_format = $date_format . ' '. $time_format;
80
+            $date_format = get_option('date_format');
81
+            $time_format = get_option('time_format');
82
+            $date_time_format = $date_format . ' ' . $time_format;
83 83
             
84
-            $t_time = get_the_time( $date_time_format );
84
+            $t_time = get_the_time($date_time_format);
85 85
             $m_time = $post->post_date;
86
-            $h_time = mysql2date( $date_format, $m_time );
86
+            $h_time = mysql2date($date_format, $m_time);
87 87
             
88 88
             $value   = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
89 89
             break;
90 90
         case 'status' :
91
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
92
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && $gateway_title = $wpi_invoice->get_gateway_title() ) {
93
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
91
+            $value   = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
92
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && $gateway_title = $wpi_invoice->get_gateway_title()) {
93
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
94 94
             }
95 95
             break;
96 96
         case 'number' :
97
-            $edit_link = get_edit_post_link( $post->ID );
98
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
97
+            $edit_link = get_edit_post_link($post->ID);
98
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
99 99
             break;
100 100
         case 'wpi_actions' :
101 101
             $value = '';
102
-            if ( !empty( $post->post_name ) ) {
103
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
102
+            if (!empty($post->post_name)) {
103
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
104 104
             }
105 105
             
106
-            if ( $email = $wpi_invoice->get_email() ) {
107
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
106
+            if ($email = $wpi_invoice->get_email()) {
107
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
108 108
             }
109 109
             
110 110
             break;
111 111
         default:
112
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
112
+            $value = isset($post->$column_name) ? $post->$column_name : '';
113 113
             break;
114 114
 
115 115
     }
116
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
116
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
117 117
     
118
-    if ( $value !== NULL ) {
118
+    if ($value !== NULL) {
119 119
         echo $value;
120 120
     }
121 121
 }
122 122
 
123
-function wpinv_admin_post_id( $id = 0 ) {
123
+function wpinv_admin_post_id($id = 0) {
124 124
     global $post;
125 125
 
126
-    if ( isset( $id ) && ! empty( $id ) ) {
126
+    if (isset($id) && !empty($id)) {
127 127
         return (int)$id;
128
-    } else if ( get_the_ID() ) {
129
-        return (int) get_the_ID();
130
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
131
-        return (int) $post->ID;
132
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
133
-        return (int) $_GET['post'];
134
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
135
-        return (int) $_GET['id'];
136
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
137
-        return (int) $_POST['id'];
128
+    } else if (get_the_ID()) {
129
+        return (int)get_the_ID();
130
+    } else if (isset($post->ID) && !empty($post->ID)) {
131
+        return (int)$post->ID;
132
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
133
+        return (int)$_GET['post'];
134
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
135
+        return (int)$_GET['id'];
136
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
137
+        return (int)$_POST['id'];
138 138
     } 
139 139
 
140 140
     return null;
141 141
 }
142 142
     
143
-function wpinv_admin_post_type( $id = 0 ) {
144
-    if ( !$id ) {
143
+function wpinv_admin_post_type($id = 0) {
144
+    if (!$id) {
145 145
         $id = wpinv_admin_post_id();
146 146
     }
147 147
     
148
-    $type = get_post_type( $id );
148
+    $type = get_post_type($id);
149 149
     
150
-    if ( !$type ) {
151
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
150
+    if (!$type) {
151
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
152 152
     }
153 153
     
154
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
154
+    return apply_filters('wpinv_admin_post_type', $type, $id);
155 155
 }
156 156
 
157 157
 function wpinv_admin_messages() {
158 158
 	global $wpinv_options, $pagenow, $post;
159 159
 
160
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
160
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
161
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
162 162
 	}
163 163
 
164
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
164
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
165
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
166 166
 	}
167 167
 
168
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
168
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
169
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
170 170
 	}
171 171
 
172
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
172
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
173
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
174 174
 	}
175 175
 
176
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
176
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
177
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
178 178
 	}
179 179
 
180
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
180
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
181
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
182 182
 	}
183 183
 
184
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
184
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
185
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
186 186
     }
187 187
     
188
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
189
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
188
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
189
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
190 190
     }
191 191
 
192
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
193
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
192
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
193
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
194 194
     }
195 195
 
196
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
196
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
197
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
198 198
 	}
199 199
 
200
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
200
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
201
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
202 202
 	}
203 203
 
204
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
204
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
205
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
206 206
 	}
207 207
     
208
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
208
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
209
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
210 210
 
211
-		if ( !empty( $message ) ) {
212
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
211
+		if (!empty($message)) {
212
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
213 213
 		}
214 214
 	}
215 215
 
216
-	settings_errors( 'wpinv-notices' );
216
+	settings_errors('wpinv-notices');
217 217
 }
218
-add_action( 'admin_notices', 'wpinv_admin_messages' );
218
+add_action('admin_notices', 'wpinv_admin_messages');
219 219
 
220
-function wpinv_items_columns( $existing_columns ) {
220
+function wpinv_items_columns($existing_columns) {
221 221
     global $wpinv_euvat;
222 222
     
223 223
     $columns                = array();
224 224
     $columns['cb']          = $existing_columns['cb'];
225
-    $columns['title']       = __( 'Title', 'invoicing' );
226
-    $columns['price']       = __( 'Price', 'invoicing' );
227
-    if ( $wpinv_euvat->allow_vat_rules() ) {
228
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
225
+    $columns['title']       = __('Title', 'invoicing');
226
+    $columns['price']       = __('Price', 'invoicing');
227
+    if ($wpinv_euvat->allow_vat_rules()) {
228
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
229 229
     }
230
-    if ( $wpinv_euvat->allow_vat_classes() ) {
231
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
230
+    if ($wpinv_euvat->allow_vat_classes()) {
231
+        $columns['vat_class']   = __('VAT class', 'invoicing');
232 232
     }
233
-    $columns['type']        = __( 'Type', 'invoicing' );
234
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
235
-    $columns['date']        = __( 'Date', 'invoicing' );
236
-    $columns['id']          = __( 'ID', 'invoicing' );
233
+    $columns['type']        = __('Type', 'invoicing');
234
+    $columns['recurring']   = __('Recurring', 'invoicing');
235
+    $columns['date']        = __('Date', 'invoicing');
236
+    $columns['id']          = __('ID', 'invoicing');
237 237
 
238
-    return apply_filters( 'wpinv_items_columns', $columns );
238
+    return apply_filters('wpinv_items_columns', $columns);
239 239
 }
240
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
240
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
241 241
 
242
-function wpinv_items_sortable_columns( $columns ) {
242
+function wpinv_items_sortable_columns($columns) {
243 243
     $columns['price']       = 'price';
244 244
     $columns['vat_rule']    = 'vat_rule';
245 245
     $columns['vat_class']   = 'vat_class';
@@ -249,151 +249,151 @@  discard block
 block discarded – undo
249 249
 
250 250
     return $columns;
251 251
 }
252
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
252
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
253 253
 
254
-function wpinv_items_table_custom_column( $column ) {
254
+function wpinv_items_table_custom_column($column) {
255 255
     global $wpinv_euvat, $post, $wpi_item;
256 256
     
257
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
258
-        $wpi_item = new WPInv_Item( $post->ID );
257
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
258
+        $wpi_item = new WPInv_Item($post->ID);
259 259
     }
260 260
 
261
-    switch ( $column ) {
261
+    switch ($column) {
262 262
         case 'price' :
263
-            echo wpinv_item_price( $post->ID );
263
+            echo wpinv_item_price($post->ID);
264 264
         break;
265 265
         case 'vat_rule' :
266
-            echo $wpinv_euvat->item_rule_label( $post->ID );
266
+            echo $wpinv_euvat->item_rule_label($post->ID);
267 267
         break;
268 268
         case 'vat_class' :
269
-            echo $wpinv_euvat->item_class_label( $post->ID );
269
+            echo $wpinv_euvat->item_class_label($post->ID);
270 270
         break;
271 271
         case 'type' :
272
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
272
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
273 273
         break;
274 274
         case 'recurring' :
275
-            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>' );
275
+            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>');
276 276
         break;
277 277
         case 'id' :
278 278
            echo $post->ID;
279 279
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
280
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
281
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
282
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
280
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
281
+                    if ($wpinv_euvat->allow_vat_rules()) {
282
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
283 283
                     }
284
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
285
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
284
+                    if ($wpinv_euvat->allow_vat_classes()) {
285
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
286 286
                     }
287
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
287
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
288 288
                 </div>';
289 289
         break;
290 290
     }
291 291
     
292
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
292
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
293 293
 }
294
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
294
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
295 295
 
296 296
 function wpinv_add_items_filters() {
297 297
     global $wpinv_euvat, $typenow;
298 298
 
299 299
     // Checks if the current post type is 'item'
300
-    if ( $typenow == 'wpi_item') {
301
-        if ( $wpinv_euvat->allow_vat_rules() ) {
302
-            echo wpinv_html_select( array(
303
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
300
+    if ($typenow == 'wpi_item') {
301
+        if ($wpinv_euvat->allow_vat_rules()) {
302
+            echo wpinv_html_select(array(
303
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
304 304
                     'name'             => 'vat_rule',
305 305
                     'id'               => 'vat_rule',
306
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
306
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
307 307
                     'show_option_all'  => false,
308 308
                     'show_option_none' => false,
309 309
                     'class'            => 'gdmbx2-text-medium',
310
-                ) );
310
+                ));
311 311
         }
312 312
         
313
-        if ( $wpinv_euvat->allow_vat_classes() ) {
314
-            echo wpinv_html_select( array(
315
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
313
+        if ($wpinv_euvat->allow_vat_classes()) {
314
+            echo wpinv_html_select(array(
315
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
316 316
                     'name'             => 'vat_class',
317 317
                     'id'               => 'vat_class',
318
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
318
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
319 319
                     'show_option_all'  => false,
320 320
                     'show_option_none' => false,
321 321
                     'class'            => 'gdmbx2-text-medium',
322
-                ) );
322
+                ));
323 323
         }
324 324
             
325
-        echo wpinv_html_select( array(
326
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
325
+        echo wpinv_html_select(array(
326
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
327 327
                 'name'             => 'type',
328 328
                 'id'               => 'type',
329
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
329
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
330 330
                 'show_option_all'  => false,
331 331
                 'show_option_none' => false,
332 332
                 'class'            => 'gdmbx2-text-medium',
333
-            ) );
333
+            ));
334 334
 
335
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
335
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
336 336
             echo '<input type="hidden" name="all_posts" value="1" />';
337 337
         }
338 338
     }
339 339
 }
340
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
340
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
341 341
 
342
-function wpinv_send_invoice_after_save( $invoice ) {
343
-    if ( empty( $_POST['wpi_save_send'] ) ) {
342
+function wpinv_send_invoice_after_save($invoice) {
343
+    if (empty($_POST['wpi_save_send'])) {
344 344
         return;
345 345
     }
346 346
     
347
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
348
-        wpinv_user_invoice_notification( $invoice->ID );
347
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
348
+        wpinv_user_invoice_notification($invoice->ID);
349 349
     }
350 350
 }
351
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
351
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
352 352
 
353
-function wpinv_send_register_new_user( $data, $postarr ) {
354
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
355
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
356
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
353
+function wpinv_send_register_new_user($data, $postarr) {
354
+    if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
355
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
356
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
357 357
         
358
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
359
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
360
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
361
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
362
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
363
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
358
+        if ($is_new_user && $email && !email_exists($email)) {
359
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
360
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
361
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
362
+            $user_nicename = $display_name ? trim($display_name) : $email;
363
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
364 364
             
365
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
366
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
365
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
366
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
367 367
                 $new_user_login = strstr($email, '@', true);
368
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
369
-                    $user_login = sanitize_user($new_user_login, true );
368
+                if (validate_username($user_login) && username_exists($user_login)) {
369
+                    $user_login = sanitize_user($new_user_login, true);
370 370
                 }
371
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
372
-                    $user_append_text = rand(10,1000);
373
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
371
+                if (validate_username($user_login) && username_exists($user_login)) {
372
+                    $user_append_text = rand(10, 1000);
373
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
374 374
                 }
375 375
                 
376
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
376
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
377 377
                     $user_login = $email;
378 378
                 }
379 379
             }
380 380
             
381 381
             $userdata = array(
382 382
                 'user_login' => $user_login,
383
-                'user_pass' => wp_generate_password( 12, false ),
384
-                'user_email' => sanitize_text_field( $email ),
383
+                'user_pass' => wp_generate_password(12, false),
384
+                'user_email' => sanitize_text_field($email),
385 385
                 'first_name' => $first_name,
386 386
                 'last_name' => $last_name,
387
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
387
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
388 388
                 'nickname' => $display_name,
389 389
                 'display_name' => $display_name,
390 390
             );
391 391
 
392
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
392
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
393 393
             
394
-            $new_user_id = wp_insert_user( $userdata );
394
+            $new_user_id = wp_insert_user($userdata);
395 395
             
396
-            if ( !is_wp_error( $new_user_id ) ) {
396
+            if (!is_wp_error($new_user_id)) {
397 397
                 $data['post_author'] = $new_user_id;
398 398
                 $_POST['post_author'] = $new_user_id;
399 399
                 $_POST['post_author_override'] = $new_user_id;
@@ -414,27 +414,27 @@  discard block
 block discarded – undo
414 414
                 
415 415
                 $meta = array();
416 416
                 ///$meta['_wpinv_user_id'] = $new_user_id;
417
-                foreach ( $meta_fields as $field ) {
418
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
417
+                foreach ($meta_fields as $field) {
418
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
419 419
                 }
420 420
                 
421
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
421
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
422 422
 
423 423
                 // Update user meta.
424
-                foreach ( $meta as $key => $value ) {
425
-                    update_user_meta( $new_user_id, $key, $value );
424
+                foreach ($meta as $key => $value) {
425
+                    update_user_meta($new_user_id, $key, $value);
426 426
                 }
427 427
                 
428
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
428
+                if (function_exists('wp_send_new_user_notifications')) {
429 429
                     // Send email notifications related to the creation of new user.
430
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
430
+                    wp_send_new_user_notifications($new_user_id, 'user');
431 431
                 }
432 432
             } else {
433
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
433
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
434 434
             }
435 435
         }
436 436
     }
437 437
     
438 438
     return $data;
439 439
 }
440
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
441 440
\ No newline at end of file
441
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
442 442
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 }
32
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
32
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
33 33
 
34
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
35
-    remove_action( 'save_post', __FUNCTION__ );
34
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
35
+    remove_action('save_post', __FUNCTION__);
36 36
     
37 37
     // $post_id and $post are required
38
-    if ( empty( $post_id ) || empty( $post ) ) {
38
+    if (empty($post_id) || empty($post)) {
39 39
         return;
40 40
     }
41 41
         
42
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
42
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
43 43
         return;
44 44
     }
45 45
     
46 46
     // Dont' save meta boxes for revisions or autosaves
47
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
47
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
52
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
51
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
52
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
53 53
             return;
54 54
         }
55 55
     
56
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
57
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
56
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
57
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
58 58
         }
59
-    } else if ( $post->post_type == 'wpi_item' ) {
59
+    } else if ($post->post_type == 'wpi_item') {
60 60
         // verify nonce
61
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
62
-            $fields                                 = array();
61
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
62
+            $fields = array();
63 63
             $fields['_wpinv_price']              = 'wpinv_item_price';
64 64
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
65 65
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -72,256 +72,256 @@  discard block
 block discarded – undo
72 72
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
73 73
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
74 74
             
75
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
75
+            if (!isset($_POST['wpinv_is_recurring'])) {
76 76
                 $_POST['wpinv_is_recurring'] = 0;
77 77
             }
78 78
             
79
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_free_trial'] = 0;
81 81
             }
82 82
             
83
-            foreach ( $fields as $field => $name ) {
84
-                if ( isset( $_POST[ $name ] ) ) {
85
-                    if ( $field == '_wpinv_price' ) {
86
-                        if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) {
87
-                            $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price.
83
+            foreach ($fields as $field => $name) {
84
+                if (isset($_POST[$name])) {
85
+                    if ($field == '_wpinv_price') {
86
+                        if (get_post_meta($post_id, '_wpinv_type', true) === 'package') {
87
+                            $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price.
88 88
                         } else {
89
-                            $value = wpinv_sanitize_amount( $_POST[ $name ] );
89
+                            $value = wpinv_sanitize_amount($_POST[$name]);
90 90
                         }
91 91
                     } else {
92
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
92
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
93 93
                     }
94 94
                     
95
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
96
-                    update_post_meta( $post_id, $field, $value );
95
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
96
+                    update_post_meta($post_id, $field, $value);
97 97
                 }
98 98
             }
99 99
             
100
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
101
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
100
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
101
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
102 102
             }
103 103
         }
104 104
     }
105 105
 }
106
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
106
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
107 107
 
108 108
 function wpinv_register_item_meta_boxes() {    
109 109
     global $wpinv_euvat;
110 110
     
111
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
111
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
112 112
 
113
-    if ( $wpinv_euvat->allow_vat_rules() ) {
114
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
113
+    if ($wpinv_euvat->allow_vat_rules()) {
114
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
115 115
     }
116 116
     
117
-    if ( $wpinv_euvat->allow_vat_classes() ) {
118
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
117
+    if ($wpinv_euvat->allow_vat_classes()) {
118
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
119 119
     }
120 120
     
121
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
122
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
121
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
122
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
123 123
 }
124 124
 
125 125
 function wpinv_register_discount_meta_boxes() {
126
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
126
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
127 127
 }
128 128
 
129
-function wpinv_discount_metabox_details( $post ) {
129
+function wpinv_discount_metabox_details($post) {
130 130
     $discount_id    = $post->ID;
131
-    $discount       = wpinv_get_discount( $discount_id );
131
+    $discount       = wpinv_get_discount($discount_id);
132 132
     
133
-    $type           = wpinv_get_discount_type( $discount_id );
134
-    $item_reqs      = wpinv_get_discount_item_reqs( $discount_id );
135
-    $excluded_items = wpinv_get_discount_excluded_items( $discount_id );
136
-    $min_total      = wpinv_get_discount_min_total( $discount_id );
137
-    $max_total      = wpinv_get_discount_max_total( $discount_id );
138
-    $max_uses       = wpinv_get_discount_max_uses( $discount_id );
139
-    $single_use     = wpinv_discount_is_single_use( $discount_id );
140
-    $recurring      = (bool)wpinv_discount_is_recurring( $discount_id );
133
+    $type           = wpinv_get_discount_type($discount_id);
134
+    $item_reqs      = wpinv_get_discount_item_reqs($discount_id);
135
+    $excluded_items = wpinv_get_discount_excluded_items($discount_id);
136
+    $min_total      = wpinv_get_discount_min_total($discount_id);
137
+    $max_total      = wpinv_get_discount_max_total($discount_id);
138
+    $max_uses       = wpinv_get_discount_max_uses($discount_id);
139
+    $single_use     = wpinv_discount_is_single_use($discount_id);
140
+    $recurring      = (bool)wpinv_discount_is_recurring($discount_id);
141 141
     
142 142
     $min_total      = $min_total > 0 ? $min_total : '';
143 143
     $max_total      = $max_total > 0 ? $max_total : '';
144 144
     $max_uses       = $max_uses > 0 ? $max_uses : '';
145 145
 ?>
146
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
147
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
146
+<?php do_action('wpinv_discount_form_top', $post); ?>
147
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
148 148
 <table class="form-table wpi-form-table">
149 149
     <tbody>
150
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
151
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
150
+        <?php do_action('wpinv_discount_form_first', $post); ?>
151
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
152 152
         <tr>
153 153
             <th valign="top" scope="row">
154
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
154
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
155 155
             </th>
156 156
             <td>
157
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
158
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
157
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
158
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
159 159
             </td>
160 160
         </tr>
161
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
161
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
162 162
         <tr>
163 163
             <th valign="top" scope="row">
164
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
164
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
165 165
             </th>
166 166
             <td>
167 167
                 <select id="wpinv_discount_type" name="type" class="medium-text">
168
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
169
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
168
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
169
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
170 170
                     <?php } ?>
171 171
                 </select>
172
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
172
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
173 173
             </td>
174 174
         </tr>
175
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
175
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
176 176
         <tr>
177 177
             <th valign="top" scope="row">
178
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
178
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
179 179
             </th>
180 180
             <td>
181
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
182
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
183
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
181
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
182
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
183
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
184 184
             </td>
185 185
         </tr>
186
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
186
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
187 187
         <tr>
188 188
             <th valign="top" scope="row">
189
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
189
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
190 190
             </th>
191 191
             <td>
192
-                <p><?php echo wpinv_item_dropdown( array(
192
+                <p><?php echo wpinv_item_dropdown(array(
193 193
                         'name'              => 'items[]',
194 194
                         'id'                => 'items',
195 195
                         'selected'          => $item_reqs,
196 196
                         'multiple'          => true,
197 197
                         'chosen'            => true,
198 198
                         'class'             => 'medium-text',
199
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
199
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
200 200
                         'show_recurring'    => true,
201
-                    ) ); ?>
201
+                    )); ?>
202 202
                 </p>
203
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
203
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
204 204
             </td>
205 205
         </tr>
206
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
206
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
207 207
         <tr>
208 208
             <th valign="top" scope="row">
209
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
209
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
210 210
             </th>
211 211
             <td>
212
-                <p><?php echo wpinv_item_dropdown( array(
212
+                <p><?php echo wpinv_item_dropdown(array(
213 213
                         'name'              => 'excluded_items[]',
214 214
                         'id'                => 'excluded_items',
215 215
                         'selected'          => $excluded_items,
216 216
                         'multiple'          => true,
217 217
                         'chosen'            => true,
218 218
                         'class'             => 'medium-text',
219
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
219
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
220 220
                         'show_recurring'    => true,
221
-                    ) ); ?>
221
+                    )); ?>
222 222
                 </p>
223
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
223
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
224 224
             </td>
225 225
         </tr>
226
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
226
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
227 227
         <tr>
228 228
             <th valign="top" scope="row">
229
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
229
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
230 230
             </th>
231 231
             <td>
232
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>">
233
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
232
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>">
233
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
234 234
             </td>
235 235
         </tr>
236
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
236
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
237 237
         <tr>
238 238
             <th valign="top" scope="row">
239
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
239
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
240 240
             </th>
241 241
             <td>
242
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>">
243
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
242
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>">
243
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
244 244
             </td>
245 245
         </tr>
246
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
246
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
247 247
         <tr>
248 248
             <th valign="top" scope="row">
249
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
249
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
250 250
             </th>
251 251
             <td>
252 252
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
253
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
253
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
254 254
             </td>
255 255
         </tr>
256
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
256
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
257 257
         <tr>
258 258
             <th valign="top" scope="row">
259
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
259
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
260 260
             </th>
261 261
             <td>
262 262
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
263
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
263
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
264 264
             </td>
265 265
         </tr>
266
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
266
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
267 267
         <tr>
268 268
             <th valign="top" scope="row">
269
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
269
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
270 270
             </th>
271 271
             <td>
272 272
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text">
273
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
274
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
273
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
274
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
275 275
                 </select>
276
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
276
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
277 277
             </td>
278 278
         </tr>
279
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
279
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
280 280
         <tr>
281 281
             <th valign="top" scope="row">
282
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
282
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
283 283
             </th>
284 284
             <td>
285 285
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
286
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
286
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
287 287
             </td>
288 288
         </tr>
289
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
289
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
290 290
         <tr>
291 291
             <th valign="top" scope="row">
292
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
292
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
293 293
             </th>
294 294
             <td>
295
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
296
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
295
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
296
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
297 297
             </td>
298 298
         </tr>
299
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
299
+        <?php do_action('wpinv_discount_form_last', $post); ?>
300 300
     </tbody>
301 301
 </table>
302
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
302
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
303 303
     <?php
304 304
 }
305 305
 
306
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
307
-    $post_type = !empty( $post ) ? $post->post_type : '';
306
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
307
+    $post_type = !empty($post) ? $post->post_type : '';
308 308
     
309
-    if ( $post_type != 'wpi_discount' ) {
309
+    if ($post_type != 'wpi_discount') {
310 310
         return;
311 311
     }
312 312
     
313
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
313
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
314 314
         return;
315 315
     }
316 316
     
317
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
317
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
318 318
         return;
319 319
     }
320 320
     
321
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
321
+    if (!current_user_can('manage_options', $post_id)) {
322 322
         return;
323 323
     }
324 324
     
325
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
325
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
326 326
 }
327
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
328 327
\ No newline at end of file
328
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
329 329
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-shortcodes.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
         add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' );
22 22
     }
23 23
 
24
+    /**
25
+     * @param string[] $function
26
+     */
24 27
     public static function shortcode_wrapper(
25 28
         $function,
26 29
         $atts    = array(),
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
             'wpinv_buy'  => __CLASS__ . '::buy',
16 16
         );
17 17
 
18
-        foreach ( $shortcodes as $shortcode => $function ) {
19
-            add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function );
18
+        foreach ($shortcodes as $shortcode => $function) {
19
+            add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function);
20 20
         }
21 21
         
22
-        add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' );
22
+        add_shortcode('wpinv_messages', __CLASS__ . '::messages');
23 23
     }
24 24
 
25 25
     public static function shortcode_wrapper(
@@ -33,25 +33,25 @@  discard block
 block discarded – undo
33 33
     ) {
34 34
         ob_start();
35 35
 
36
-        echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before'];
37
-        call_user_func( $function, $atts );
38
-        echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after'];
36
+        echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before'];
37
+        call_user_func($function, $atts);
38
+        echo empty($wrapper['after']) ? '</div>' : $wrapper['after'];
39 39
 
40 40
         return ob_get_clean();
41 41
     }
42 42
 
43
-    public static function checkout( $atts = array(), $content = null ) {
44
-        return wpinv_checkout_form( $atts, $content );
43
+    public static function checkout($atts = array(), $content = null) {
44
+        return wpinv_checkout_form($atts, $content);
45 45
     }
46 46
 
47
-    public static function messages( $atts, $content = null ) {
47
+    public static function messages($atts, $content = null) {
48 48
         ob_start();
49 49
         wpinv_print_errors();
50 50
         return '<div class="wpinv">' . ob_get_clean() . '</div>';
51 51
     }
52 52
     
53
-    public static function history( $atts, $content = null ) {
54
-        return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts );
53
+    public static function history($atts, $content = null) {
54
+        return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts);
55 55
     }
56 56
 
57 57
     /**
@@ -59,28 +59,28 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @param array $atts
61 61
      */
62
-    public static function history_output( $atts ) {
63
-        do_action( 'wpinv_before_user_invoice_history' );
64
-        wpinv_get_template_part( 'wpinv-invoice-history', $atts );
65
-        do_action( 'wpinv_after_user_invoice_history' );
62
+    public static function history_output($atts) {
63
+        do_action('wpinv_before_user_invoice_history');
64
+        wpinv_get_template_part('wpinv-invoice-history', $atts);
65
+        do_action('wpinv_after_user_invoice_history');
66 66
     }
67 67
     
68
-    public static function receipt( $atts, $content = null ) {
69
-        return wpinv_payment_receipt( $atts, $content );
68
+    public static function receipt($atts, $content = null) {
69
+        return wpinv_payment_receipt($atts, $content);
70 70
     }
71 71
 
72
-    public static function buy( $atts, $content = null ) {
73
-        $a = shortcode_atts( array(
72
+    public static function buy($atts, $content = null) {
73
+        $a = shortcode_atts(array(
74 74
             'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity
75
-            'title' => __('Buy Now', 'invoicing' ), // the button title
75
+            'title' => __('Buy Now', 'invoicing'), // the button title
76 76
             'post_id' => '', // any related post_id
77
-        ), $atts );
77
+        ), $atts);
78 78
         
79 79
         $post_id = isset($a['post_id']) ? (int)$a['post_id'] : '';
80 80
 
81 81
         $html = '<div class="wpi-buy-button-wrapper">';
82
-        $html .= '<input type="submit" name="submit" class="button button-primary wpi-buy-button" value="'.$a['title'].'" onclick="wpi_buy(\''.$a['items'].'\','.$post_id.');" />';
83
-        $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false );
82
+        $html .= '<input type="submit" name="submit" class="button button-primary wpi-buy-button" value="' . $a['title'] . '" onclick="wpi_buy(\'' . $a['items'] . '\',' . $post_id . ');" />';
83
+        $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false);
84 84
         $html .= '</div>';
85 85
 
86 86
 
Please login to merge, or discard this patch.
templates/wpinv-invoice-history.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( !( $user_id = get_current_user_id() ) ) {
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 		<tbody>
32 32
 			<?php foreach ( $user_invoices->invoices as $invoice ) {
33
-				?>
33
+                ?>
34 34
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
35 35
 					<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
36 36
 						<td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
@@ -53,31 +53,31 @@  discard block
 block discarded – undo
53 53
 
54 54
 							<?php elseif ( 'invoice-actions' === $column_id ) : ?>
55 55
 								<?php
56
-									$actions = array(
57
-										'pay'    => array(
58
-											'url'  => $invoice->get_checkout_payment_url(),
59
-											'name' => __( 'Pay Now', 'invoicing' ),
56
+                                    $actions = array(
57
+                                        'pay'    => array(
58
+                                            'url'  => $invoice->get_checkout_payment_url(),
59
+                                            'name' => __( 'Pay Now', 'invoicing' ),
60 60
                                             'class' => 'btn-success'
61
-										),
61
+                                        ),
62 62
                                         'print'   => array(
63
-											'url'  => $invoice->get_view_url(),
64
-											'name' => __( 'Print', 'invoicing' ),
63
+                                            'url'  => $invoice->get_view_url(),
64
+                                            'name' => __( 'Print', 'invoicing' ),
65 65
                                             'class' => 'btn-primary',
66 66
                                             'attrs' => 'target="_blank"'
67
-										)
68
-									);
67
+                                        )
68
+                                    );
69 69
 
70
-									if ( ! $invoice->needs_payment() ) {
71
-										unset( $actions['pay'] );
72
-									}
70
+                                    if ( ! $invoice->needs_payment() ) {
71
+                                        unset( $actions['pay'] );
72
+                                    }
73 73
 
74
-									if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
75
-										foreach ( $actions as $key => $action ) {
76
-											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
74
+                                    if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
75
+                                        foreach ( $actions as $key => $action ) {
76
+                                            $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
77 77
                                             echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
78
-										}
79
-									}
80
-								?>
78
+                                        }
79
+                                    }
80
+                                ?>
81 81
 							<?php endif; ?>
82 82
 						</td>
83 83
 					<?php endforeach; ?>
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 	<?php if ( 1 < $user_invoices->max_num_pages ) : ?>
92 92
 		<div class="invoicing-Pagination">
93 93
 			<?php
94
-			$big = 999999;
95
-
96
-			if (get_query_var('paged'))
97
-				$current_page = get_query_var('paged');
98
-			elseif (get_query_var('page'))
99
-				$current_page = get_query_var('page');
100
-			else
101
-				$current_page = 1;
102
-
103
-			echo paginate_links( array(
104
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
105
-				'format'  => '?paged=%#%',
106
-				'current' => max( 1, $current_page ),
107
-				'total'   => $user_invoices->max_num_pages,
108
-			) );
109
-			?>
94
+            $big = 999999;
95
+
96
+            if (get_query_var('paged'))
97
+                $current_page = get_query_var('paged');
98
+            elseif (get_query_var('page'))
99
+                $current_page = get_query_var('page');
100
+            else
101
+                $current_page = 1;
102
+
103
+            echo paginate_links( array(
104
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
105
+                'format'  => '?paged=%#%',
106
+                'current' => max( 1, $current_page ),
107
+                'total'   => $user_invoices->max_num_pages,
108
+            ) );
109
+            ?>
110 110
 		</div>
111 111
 	<?php endif; ?>
112 112
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,80 +1,80 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( !( $user_id = get_current_user_id() ) ) {
6
+if (!($user_id = get_current_user_id())) {
7 7
     ?>
8
-    <div class="wpinv-empty alert alert-error"><?php _e( 'You are not allowed to access this section', 'invoicing' ) ;?></div>
8
+    <div class="wpinv-empty alert alert-error"><?php _e('You are not allowed to access this section', 'invoicing'); ?></div>
9 9
     <?php
10 10
     return;
11 11
 }
12 12
 
13 13
 global $current_page;
14
-$current_page   = empty( $current_page ) ? 1 : absint( $current_page );
15
-$query          = apply_filters( 'wpinv_user_invoices_query', array( 'user' => $user_id, 'page' => $current_page, 'paginate' => true ) );
16
-$user_invoices  = wpinv_get_invoices( $query );
14
+$current_page   = empty($current_page) ? 1 : absint($current_page);
15
+$query          = apply_filters('wpinv_user_invoices_query', array('user' => $user_id, 'page' => $current_page, 'paginate' => true));
16
+$user_invoices  = wpinv_get_invoices($query);
17 17
 $has_invoices   = 0 < $user_invoices->total;
18 18
     
19
-do_action( 'wpinv_before_user_invoices', $has_invoices ); ?>
19
+do_action('wpinv_before_user_invoices', $has_invoices); ?>
20 20
 
21
-<?php if ( $has_invoices ) { ?>
21
+<?php if ($has_invoices) { ?>
22 22
 	<table class="table table-bordered table-hover wpi-user-invoices">
23 23
 		<thead>
24 24
 			<tr>
25
-				<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
26
-					<th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
25
+				<?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
26
+					<th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
27 27
 				<?php endforeach; ?>
28 28
 			</tr>
29 29
 		</thead>
30 30
 
31 31
 		<tbody>
32
-			<?php foreach ( $user_invoices->invoices as $invoice ) {
32
+			<?php foreach ($user_invoices->invoices as $invoice) {
33 33
 				?>
34 34
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
35
-					<?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
36
-						<td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
37
-							<?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
38
-								<?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
39
-
40
-							<?php elseif ( 'invoice-number' === $column_id ) : ?>
41
-								<a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
42
-									<?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
35
+					<?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
36
+						<td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
37
+							<?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
38
+								<?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
39
+
40
+							<?php elseif ('invoice-number' === $column_id) : ?>
41
+								<a href="<?php echo esc_url($invoice->get_view_url()); ?>">
42
+									<?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
43 43
 								</a>
44 44
 
45
-							<?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?>
46
-								<time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
45
+							<?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?>
46
+								<time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
47 47
 
48
-							<?php elseif ( 'invoice-status' === $column_id ) : ?>
49
-								<?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
48
+							<?php elseif ('invoice-status' === $column_id) : ?>
49
+								<?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
50 50
 
51
-							<?php elseif ( 'invoice-total' === $column_id ) : ?>
52
-								<?php echo $invoice->get_total( true ); ?>
51
+							<?php elseif ('invoice-total' === $column_id) : ?>
52
+								<?php echo $invoice->get_total(true); ?>
53 53
 
54
-							<?php elseif ( 'invoice-actions' === $column_id ) : ?>
54
+							<?php elseif ('invoice-actions' === $column_id) : ?>
55 55
 								<?php
56 56
 									$actions = array(
57 57
 										'pay'    => array(
58 58
 											'url'  => $invoice->get_checkout_payment_url(),
59
-											'name' => __( 'Pay Now', 'invoicing' ),
59
+											'name' => __('Pay Now', 'invoicing'),
60 60
                                             'class' => 'btn-success'
61 61
 										),
62 62
                                         'print'   => array(
63 63
 											'url'  => $invoice->get_view_url(),
64
-											'name' => __( 'Print', 'invoicing' ),
64
+											'name' => __('Print', 'invoicing'),
65 65
                                             'class' => 'btn-primary',
66 66
                                             'attrs' => 'target="_blank"'
67 67
 										)
68 68
 									);
69 69
 
70
-									if ( ! $invoice->needs_payment() ) {
71
-										unset( $actions['pay'] );
70
+									if (!$invoice->needs_payment()) {
71
+										unset($actions['pay']);
72 72
 									}
73 73
 
74
-									if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
75
-										foreach ( $actions as $key => $action ) {
74
+									if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
75
+										foreach ($actions as $key => $action) {
76 76
 											$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
77
-                                            echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
77
+                                            echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
78 78
 										}
79 79
 									}
80 80
 								?>
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 		</tbody>
87 87
 	</table>
88 88
 
89
-	<?php do_action( 'wpinv_before_user_invoices_pagination' ); ?>
89
+	<?php do_action('wpinv_before_user_invoices_pagination'); ?>
90 90
 
91
-	<?php if ( 1 < $user_invoices->max_num_pages ) : ?>
91
+	<?php if (1 < $user_invoices->max_num_pages) : ?>
92 92
 		<div class="invoicing-Pagination">
93 93
 			<?php
94 94
 			$big = 999999;
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
 			else
101 101
 				$current_page = 1;
102 102
 
103
-			echo paginate_links( array(
104
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
103
+			echo paginate_links(array(
104
+				'base'    => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
105 105
 				'format'  => '?paged=%#%',
106
-				'current' => max( 1, $current_page ),
106
+				'current' => max(1, $current_page),
107 107
 				'total'   => $user_invoices->max_num_pages,
108
-			) );
108
+			));
109 109
 			?>
110 110
 		</div>
111 111
 	<?php endif; ?>
112 112
 
113 113
 <?php } else { ?>
114 114
 	<div class="wpinv-empty alert-info">
115
-		<?php _e( 'No invoice has been made yet.', 'invoicing' ); ?>
115
+		<?php _e('No invoice has been made yet.', 'invoicing'); ?>
116 116
 	</div>
117 117
 <?php } ?>
118 118
 
119
-<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?>
119
+<?php do_action('wpinv_after_user_invoices', $has_invoices); ?>
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,12 +93,13 @@
 block discarded – undo
93 93
 			<?php
94 94
 			$big = 999999;
95 95
 
96
-			if (get_query_var('paged'))
97
-				$current_page = get_query_var('paged');
98
-			elseif (get_query_var('page'))
99
-				$current_page = get_query_var('page');
100
-			else
101
-				$current_page = 1;
96
+			if (get_query_var('paged')) {
97
+							$current_page = get_query_var('paged');
98
+			} elseif (get_query_var('page')) {
99
+							$current_page = get_query_var('page');
100
+			} else {
101
+							$current_page = 1;
102
+			}
102 103
 
103 104
 			echo paginate_links( array(
104 105
 				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,45 +11,45 @@
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
     
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    update_option( 'wpinv_version', WPINV_VERSION );
24
+    update_option('wpinv_version', WPINV_VERSION);
25 25
 }
26
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
26
+add_action('admin_init', 'wpinv_automatic_upgrade');
27 27
 
28 28
 function wpinv_v005_upgrades() {
29 29
     global $wpdb;
30 30
     
31 31
     // Invoices status
32
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
33
-    if ( !empty( $results ) ) {
34
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
32
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
33
+    if (!empty($results)) {
34
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
35 35
         
36 36
         // Clean post cache
37
-        foreach ( $results as $row ) {
38
-            clean_post_cache( $row->ID );
37
+        foreach ($results as $row) {
38
+            clean_post_cache($row->ID);
39 39
         }
40 40
     }
41 41
     
42 42
     // Item meta key changes
43 43
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
44
-    $results = $wpdb->get_results( $query );
44
+    $results = $wpdb->get_results($query);
45 45
     
46
-    if ( !empty( $results ) ) {
47
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
48
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
49
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
46
+    if (!empty($results)) {
47
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
48
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
49
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
50 50
         
51
-        foreach ( $results as $row ) {
52
-            clean_post_cache( $row->post_id );
51
+        foreach ($results as $row) {
52
+            clean_post_cache($row->post_id);
53 53
         }
54 54
     }
55 55
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $invoice->is_refunded() ) {
42
+        if ($invoice->is_refunded()) {
43 43
             $class .= ' wpinv-refunded';
44 44
         }
45
-        if ( $is_recurring ) {
45
+        if ($is_recurring) {
46 46
             $class .= ' wpi-recurring';
47 47
         }
48 48
         ?>
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
51 51
                 <thead>
52 52
                     <tr>
53
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
54
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
55
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
56
-                        <?php if ( $item_quantities ) { ?>
57
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
53
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
54
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
55
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
56
+                        <?php if ($item_quantities) { ?>
57
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
58 58
                         <?php } ?>
59
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
60
-                        <?php if ( $use_taxes ) { ?>
61
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
59
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
60
+                        <?php if ($use_taxes) { ?>
61
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
62 62
                         <?php } ?>
63 63
                         <th class="action"></th>
64 64
                     </tr>
65 65
                 </thead>
66 66
                 <tbody class="wpinv-line-items">
67
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
67
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
68 68
                 </tbody>
69 69
                 <tfoot class="wpinv-totals">
70 70
                     <tr>
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
                                         </td>
77 77
                                         <td class="title">
78 78
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
79
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
79
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
80 80
                                             <div class="wp-clearfix">
81 81
                                                 <label class="wpi-vat-rule">
82
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
82
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
83 83
                                                     <span class="input-text-wrap">
84
-                                                        <?php echo wpinv_html_select( array(
84
+                                                        <?php echo wpinv_html_select(array(
85 85
                                                             'options'          => $wpinv_euvat->get_rules(),
86 86
                                                             'name'             => '_wpinv_quick[vat_rule]',
87 87
                                                             'id'               => '_wpinv_quick_vat_rule',
88 88
                                                             'show_option_all'  => false,
89 89
                                                             'show_option_none' => false,
90 90
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
91
-                                                        ) ); ?>
91
+                                                        )); ?>
92 92
                                                     </span>
93 93
                                                 </label>
94 94
                                             </div>
95
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
95
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
96 96
                                             <div class="wp-clearfix">
97 97
                                                 <label class="wpi-vat-class">
98
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
98
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
99 99
                                                     <span class="input-text-wrap">
100
-                                                        <?php echo wpinv_html_select( array(
100
+                                                        <?php echo wpinv_html_select(array(
101 101
                                                             'options'          => $wpinv_euvat->get_all_classes(),
102 102
                                                             'name'             => '_wpinv_quick[vat_class]',
103 103
                                                             'id'               => '_wpinv_quick_vat_class',
104 104
                                                             'show_option_all'  => false,
105 105
                                                             'show_option_none' => false,
106 106
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
107
-                                                        ) ); ?>
107
+                                                        )); ?>
108 108
                                                     </span>
109 109
                                                 </label>
110 110
                                             </div>
111 111
                                             <?php } ?>
112 112
                                             <div class="wp-clearfix">
113 113
                                                 <label class="wpi-item-type">
114
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
114
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
115 115
                                                     <span class="input-text-wrap">
116
-                                                        <?php echo wpinv_html_select( array(
116
+                                                        <?php echo wpinv_html_select(array(
117 117
                                                             'options'          => $item_types,
118 118
                                                             'name'             => '_wpinv_quick[type]',
119 119
                                                             'id'               => '_wpinv_quick_type',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                             'show_option_all'  => false,
122 122
                                                             'show_option_none' => false,
123 123
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
124
-                                                        ) ); ?>
124
+                                                        )); ?>
125 125
                                                     </span>
126 126
                                                 </label>
127 127
                                             </div>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
                                             </div>
135 135
                                         </td>
136 136
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
137
-                                        <?php if ( $item_quantities ) { ?>
137
+                                        <?php if ($item_quantities) { ?>
138 138
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
139 139
                                         <?php } ?>
140 140
                                         <td class="total"></td>
141
-                                        <?php if ( $use_taxes ) { ?>
141
+                                        <?php if ($use_taxes) { ?>
142 142
                                         <td class="tax"></td>
143 143
                                         <?php } ?>
144 144
                                         <td class="action"></td>
@@ -151,29 +151,29 @@  discard block
 block discarded – undo
151 151
                         <td colspan="<?php echo $cols; ?>"></td>
152 152
                     </tr>
153 153
                     <tr class="totals">
154
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
154
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
155 155
                         <td colspan="4">
156 156
                             <table cellspacing="0" cellpadding="0">
157 157
                                 <tr class="subtotal">
158
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
159
-                                    <td class="total"><?php echo $subtotal;?></td>
158
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
159
+                                    <td class="total"><?php echo $subtotal; ?></td>
160 160
                                     <td class="action"></td>
161 161
                                 </tr>
162 162
                                 <tr class="discount">
163
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
164
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
163
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
164
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
165 165
                                     <td class="action"></td>
166 166
                                 </tr>
167
-                                <?php if ( $use_taxes ) { ?>
167
+                                <?php if ($use_taxes) { ?>
168 168
                                 <tr class="tax">
169
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
170
-                                    <td class="total"><?php echo $tax;?></td>
169
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
170
+                                    <td class="total"><?php echo $tax; ?></td>
171 171
                                     <td class="action"></td>
172 172
                                 </tr>
173 173
                                 <?php } ?>
174 174
                                 <tr class="total">
175
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
176
-                                    <td class="total"><?php echo $total;?></td>
175
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
176
+                                    <td class="total"><?php echo $total; ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179 179
                             </table>
@@ -183,89 +183,89 @@  discard block
 block discarded – undo
183 183
             </table>
184 184
             <div class="wpinv-actions">
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                    if ( !$invoice->is_recurring() ) {
188
-                    echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                    if (!$invoice->is_recurring()) {
188
+                    echo wpinv_item_dropdown(array(
189 189
                         'name'             => 'wpinv_invoice_item',
190 190
                         'id'               => 'wpinv_invoice_item',
191 191
                         'with_packages'    => false,
192 192
                         'show_recurring'   => true,
193
-                    ) );
193
+                    ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198 198
             </div>
199 199
         </div>
200 200
         <?php
201 201
     }
202 202
     
203
-    public static function prices( $post ) {        
203
+    public static function prices($post) {        
204 204
         $symbol         = wpinv_currency_symbol();
205 205
         $position       = wpinv_currency_position();
206
-        $item           = new WPInv_Item( $post->ID );
206
+        $item           = new WPInv_Item($post->ID);
207 207
         
208 208
         $price          = $item->get_price();
209 209
         $is_recurring   = $item->is_recurring();
210 210
         $period         = $item->get_recurring_period();
211
-        $interval       = absint( $item->get_recurring_interval() );
212
-        $times          = absint( $item->get_recurring_limit() );
211
+        $interval       = absint($item->get_recurring_interval());
212
+        $times          = absint($item->get_recurring_limit());
213 213
         $free_trial     = $item->has_free_trial();
214 214
         $trial_interval = $item->get_trial_interval();
215 215
         $trial_period   = $item->get_trial_period();
216 216
         
217 217
         $intervals      = array();
218
-        for ( $i = 1; $i <= 90; $i++ ) {
218
+        for ($i = 1; $i <= 90; $i++) {
219 219
             $intervals[$i] = $i;
220 220
         }
221 221
         
222
-        $interval       = $interval > 0 ? $interval : 1;
222
+        $interval = $interval > 0 ? $interval : 1;
223 223
         
224 224
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
225 225
         ?>
226
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
227
-        <?php if ( $item->is_package() ) { ?>
228
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
226
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
227
+        <?php if ($item->is_package()) { ?>
228
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
229 229
         <?php } ?>
230 230
         </p>
231 231
         <p class="wpinv-row-is-recurring">
232 232
             <label for="wpinv_is_recurring">
233
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
234
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
233
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
234
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
235 235
             </label>
236 236
         </p>
237
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
238
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
239
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
237
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
238
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
239
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
240 240
                     'options'          => $intervals,
241 241
                     'name'             => 'wpinv_recurring_interval',
242 242
                     'id'               => 'wpinv_recurring_interval',
243 243
                     'selected'         => $interval,
244 244
                     'show_option_all'  => false,
245 245
                     'show_option_none' => false
246
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
247
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
246
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
247
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
248 248
                 <span class="clear wpi-trial-clr"></span>
249 249
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
250
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
251
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
250
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
251
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
252 252
                 </label>
253 253
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
254
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
254
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
255 255
                 </label>
256 256
         </p>
257
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
258
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
257
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
258
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
259 259
         <?php
260 260
     }
261 261
     
262
-    public static function vat_rules( $post ) {
262
+    public static function vat_rules($post) {
263 263
         global $wpinv_euvat;
264 264
         
265
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
265
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
266 266
         ?>
267
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
268
-        <?php echo wpinv_html_select( array(
267
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
268
+        <?php echo wpinv_html_select(array(
269 269
                     'options'          => $wpinv_euvat->get_rules(),
270 270
                     'name'             => 'wpinv_vat_rules',
271 271
                     'id'               => 'wpinv_vat_rules',
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
                     'show_option_all'  => false,
274 274
                     'show_option_none' => false,
275 275
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
276
-                ) ); ?>
276
+                )); ?>
277 277
         </p>
278
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
279
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
278
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
279
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
280 280
         <?php
281 281
     }
282 282
     
283
-    public static function vat_classes( $post ) {
283
+    public static function vat_classes($post) {
284 284
         global $wpinv_euvat;
285 285
         
286
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
286
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
287 287
         ?>
288
-        <p><?php echo wpinv_html_select( array(
288
+        <p><?php echo wpinv_html_select(array(
289 289
                     'options'          => $wpinv_euvat->get_all_classes(),
290 290
                     'name'             => 'wpinv_vat_class',
291 291
                     'id'               => 'wpinv_vat_class',
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
                     'show_option_all'  => false,
294 294
                     'show_option_none' => false,
295 295
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
296
-                ) ); ?>
296
+                )); ?>
297 297
         </p>
298
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
298
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
299 299
         <?php
300 300
     }
301 301
     
302
-    public static function item_info( $post ) {
303
-        $item_type = wpinv_get_item_type( $post->ID );
304
-        do_action( 'wpinv_item_info_metabox_before', $post );
302
+    public static function item_info($post) {
303
+        $item_type = wpinv_get_item_type($post->ID);
304
+        do_action('wpinv_item_info_metabox_before', $post);
305 305
         ?>
306
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
307
-        <?php echo wpinv_html_select( array(
306
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
307
+        <?php echo wpinv_html_select(array(
308 308
                     'options'          => wpinv_get_item_types(),
309 309
                     'name'             => 'wpinv_item_type',
310 310
                     'id'               => 'wpinv_item_type',
@@ -313,114 +313,114 @@  discard block
 block discarded – undo
313 313
                     'show_option_none' => false,
314 314
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
315 315
                     //'disabled'         => $item_type == 'package' ? true : false,
316
-                ) ); ?>
316
+                )); ?>
317 317
         </p>
318
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
318
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
319 319
         <?php
320
-        do_action( 'wpinv_item_info_metabox_after', $post );
320
+        do_action('wpinv_item_info_metabox_after', $post);
321 321
     }
322 322
     
323
-    public static function meta_values( $post ) {
324
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
323
+    public static function meta_values($post) {
324
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
325 325
             'type',
326 326
             'custom_id'
327
-        ) );
327
+        ));
328 328
         
329
-        if ( empty( $meta_keys ) ) {
329
+        if (empty($meta_keys)) {
330 330
             return;
331 331
         }
332 332
         
333
-        do_action( 'wpinv_meta_values_metabox_before', $post );
333
+        do_action('wpinv_meta_values_metabox_before', $post);
334 334
         
335
-        foreach ( $meta_keys as $meta_key ) {
335
+        foreach ($meta_keys as $meta_key) {
336 336
             ?>
337
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
337
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
338 338
             <?php 
339 339
         }
340 340
         
341
-        do_action( 'wpinv_meta_values_metabox_after', $post );
341
+        do_action('wpinv_meta_values_metabox_after', $post);
342 342
     }
343 343
     
344
-    public static function save( $post_id, $data, $post ) {
345
-        $invoice        = new WPInv_Invoice( $post_id );
344
+    public static function save($post_id, $data, $post) {
345
+        $invoice        = new WPInv_Invoice($post_id);
346 346
         
347 347
         // Billing
348
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
349
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
350
-        $company        = sanitize_text_field( $data['wpinv_company'] );
351
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
352
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
353
-        $address        = sanitize_text_field( $data['wpinv_address'] );
354
-        $city           = sanitize_text_field( $data['wpinv_city'] );
355
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
356
-        $country        = sanitize_text_field( $data['wpinv_country'] );
357
-        $state          = sanitize_text_field( $data['wpinv_state'] );
348
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
349
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
350
+        $company        = sanitize_text_field($data['wpinv_company']);
351
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
352
+        $phone          = sanitize_text_field($data['wpinv_phone']);
353
+        $address        = sanitize_text_field($data['wpinv_address']);
354
+        $city           = sanitize_text_field($data['wpinv_city']);
355
+        $zip            = sanitize_text_field($data['wpinv_zip']);
356
+        $country        = sanitize_text_field($data['wpinv_country']);
357
+        $state          = sanitize_text_field($data['wpinv_state']);
358 358
         
359 359
         // Details
360
-        $status         = sanitize_text_field( $data['wpinv_status'] );
361
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
362
-        $number         = sanitize_text_field( $data['wpinv_number'] );
363
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
360
+        $status         = sanitize_text_field($data['wpinv_status']);
361
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
362
+        $number         = sanitize_text_field($data['wpinv_number']);
363
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
364 364
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
365 365
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
366 366
         
367
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
367
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
368 368
         
369
-        $invoice->set( 'due_date', $due_date );
370
-        $invoice->set( 'first_name', $first_name );
371
-        $invoice->set( 'last_name', $last_name );
372
-        $invoice->set( 'company', $company );
373
-        $invoice->set( 'vat_number', $vat_number );
374
-        $invoice->set( 'phone', $phone );
375
-        $invoice->set( 'address', $address );
376
-        $invoice->set( 'city', $city );
377
-        $invoice->set( 'zip', $zip );
378
-        $invoice->set( 'country', $country );
379
-        $invoice->set( 'state', $state );
380
-        $invoice->set( 'status', $status );
369
+        $invoice->set('due_date', $due_date);
370
+        $invoice->set('first_name', $first_name);
371
+        $invoice->set('last_name', $last_name);
372
+        $invoice->set('company', $company);
373
+        $invoice->set('vat_number', $vat_number);
374
+        $invoice->set('phone', $phone);
375
+        $invoice->set('address', $address);
376
+        $invoice->set('city', $city);
377
+        $invoice->set('zip', $zip);
378
+        $invoice->set('country', $country);
379
+        $invoice->set('state', $state);
380
+        $invoice->set('status', $status);
381 381
         //$invoice->set( 'number', $number );
382 382
         //$invoice->set( 'discounts', $discounts );
383 383
         //$invoice->set( 'discount', $discount );
384
-        $invoice->set( 'ip', $ip );
384
+        $invoice->set('ip', $ip);
385 385
         $invoice->old_status = $_POST['original_post_status'];
386 386
         $invoice->currency = wpinv_get_currency();
387
-        if ( !empty( $data['wpinv_gateway'] ) ) {
388
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
387
+        if (!empty($data['wpinv_gateway'])) {
388
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
389 389
         }
390 390
         $saved = $invoice->save();
391 391
         
392 392
         // Check for payment notes
393
-        if ( !empty( $data['invoice_note'] ) ) {
394
-            $note               = wp_kses( $data['invoice_note'], array() );
395
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
393
+        if (!empty($data['invoice_note'])) {
394
+            $note               = wp_kses($data['invoice_note'], array());
395
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
396 396
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
397 397
         
398
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
398
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
399 399
         }
400 400
         
401 401
         // Update user address if empty.
402
-        if ( $saved && !empty( $invoice ) ) {
403
-            if ( $user_id = $invoice->get_user_id() ) {
404
-                $user_address = wpinv_get_user_address( $user_id, false );
402
+        if ($saved && !empty($invoice)) {
403
+            if ($user_id = $invoice->get_user_id()) {
404
+                $user_address = wpinv_get_user_address($user_id, false);
405 405
                 
406 406
                 if (empty($user_address['first_name'])) {
407
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
408
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
408
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
409 409
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
410
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
410
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
411 411
                 }
412 412
                 
413 413
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
414
-                    update_user_meta( $user_id, '_wpinv_address', $address );
415
-                    update_user_meta( $user_id, '_wpinv_city', $city );
416
-                    update_user_meta( $user_id, '_wpinv_state', $state );
417
-                    update_user_meta( $user_id, '_wpinv_country', $country );
418
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
419
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
414
+                    update_user_meta($user_id, '_wpinv_address', $address);
415
+                    update_user_meta($user_id, '_wpinv_city', $city);
416
+                    update_user_meta($user_id, '_wpinv_state', $state);
417
+                    update_user_meta($user_id, '_wpinv_country', $country);
418
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
419
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
420 420
                 }
421 421
             }
422 422
             
423
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
423
+            do_action('wpinv_invoice_metabox_saved', $invoice);
424 424
         }
425 425
         
426 426
         return $saved;
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Spacing   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Ajax {
15 15
     public static function init() {
16
-        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
17
-        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
16
+        add_action('init', array(__CLASS__, 'define_ajax'), 0);
17
+        add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
18 18
         self::add_ajax_events();
19 19
     }
20 20
 
21 21
     public static function define_ajax() {
22
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
23
-            if ( ! defined( 'DOING_AJAX' ) ) {
24
-                define( 'DOING_AJAX', true );
22
+        if (!empty($_GET['wpinv-ajax'])) {
23
+            if (!defined('DOING_AJAX')) {
24
+                define('DOING_AJAX', true);
25 25
             }
26
-            if ( ! defined( 'WC_DOING_AJAX' ) ) {
27
-                define( 'WC_DOING_AJAX', true );
26
+            if (!defined('WC_DOING_AJAX')) {
27
+                define('WC_DOING_AJAX', true);
28 28
             }
29 29
             // Turn off display_errors during AJAX events to prevent malformed JSON
30
-            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
31
-                @ini_set( 'display_errors', 0 );
30
+            if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
31
+                @ini_set('display_errors', 0);
32 32
             }
33 33
             $GLOBALS['wpdb']->hide_errors();
34 34
         }
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
     public static function do_wpinv_ajax() {
38 38
         global $wp_query;
39 39
 
40
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
41
-            $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) );
40
+        if (!empty($_GET['wpinv-ajax'])) {
41
+            $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax']));
42 42
         }
43 43
 
44
-        if ( $action = $wp_query->get( 'wpinv-ajax' ) ) {
44
+        if ($action = $wp_query->get('wpinv-ajax')) {
45 45
             self::wpinv_ajax_headers();
46
-            do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) );
46
+            do_action('wpinv_ajax_' . sanitize_text_field($action));
47 47
             die();
48 48
         }
49 49
     }
50 50
     
51 51
     private static function wpinv_ajax_headers() {
52 52
         send_origin_headers();
53
-        @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
54
-        @header( 'X-Robots-Tag: noindex' );
53
+        @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
54
+        @header('X-Robots-Tag: noindex');
55 55
         send_nosniff_header();
56 56
         nocache_headers();
57
-        status_header( 200 );
57
+        status_header(200);
58 58
     }
59 59
     
60 60
     public static function add_ajax_events() {
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
             'buy_items' => true,
78 78
         );
79 79
 
80
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
81
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
80
+        foreach ($ajax_events as $ajax_event => $nopriv) {
81
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
82 82
             
83
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
84
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
83
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
84
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
85 85
             }
86 86
 
87
-            if ( $nopriv ) {
88
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
87
+            if ($nopriv) {
88
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
89 89
 
90
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
90
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
91 91
             }
92 92
         }
93 93
     }
94 94
     
95 95
     public static function add_note() {
96
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
96
+        check_ajax_referer('add-invoice-note', '_nonce');
97 97
 
98
-        if ( !current_user_can( 'manage_options' ) ) {
98
+        if (!current_user_can('manage_options')) {
99 99
             die(-1);
100 100
         }
101 101
 
102
-        $post_id   = absint( $_POST['post_id'] );
103
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
104
-        $note_type = sanitize_text_field( $_POST['note_type'] );
102
+        $post_id   = absint($_POST['post_id']);
103
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
104
+        $note_type = sanitize_text_field($_POST['note_type']);
105 105
 
106 106
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
107 107
 
108
-        if ( $post_id > 0 ) {
109
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
108
+        if ($post_id > 0) {
109
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
110 110
 
111
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
112
-                wpinv_get_invoice_note_line_item( $note_id );
111
+            if ($note_id > 0 && !is_wp_error($note_id)) {
112
+                wpinv_get_invoice_note_line_item($note_id);
113 113
             }
114 114
         }
115 115
 
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
     public static function delete_note() {
120
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
120
+        check_ajax_referer('delete-invoice-note', '_nonce');
121 121
 
122
-        if ( !current_user_can( 'manage_options' ) ) {
122
+        if (!current_user_can('manage_options')) {
123 123
             die(-1);
124 124
         }
125 125
 
126 126
         $note_id = (int)$_POST['note_id'];
127 127
 
128
-        if ( $note_id > 0 ) {
129
-            wp_delete_comment( $note_id, true );
128
+        if ($note_id > 0) {
129
+            wp_delete_comment($note_id, true);
130 130
         }
131 131
 
132 132
         die();
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
     }
140 140
     
141 141
     public static function checkout() {
142
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
143
-            define( 'WPINV_CHECKOUT', true );
142
+        if (!defined('WPINV_CHECKOUT')) {
143
+            define('WPINV_CHECKOUT', true);
144 144
         }
145 145
 
146 146
         wpinv_process_checkout();
@@ -149,53 +149,53 @@  discard block
 block discarded – undo
149 149
     
150 150
     public static function add_invoice_item() {
151 151
         global $wpi_userID, $wpinv_ip_address_country;
152
-        check_ajax_referer( 'invoice-item', '_nonce' );
153
-        if ( !current_user_can( 'manage_options' ) ) {
152
+        check_ajax_referer('invoice-item', '_nonce');
153
+        if (!current_user_can('manage_options')) {
154 154
             die(-1);
155 155
         }
156 156
         
157
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
158
-        $invoice_id = absint( $_POST['invoice_id'] );
157
+        $item_id    = sanitize_text_field($_POST['item_id']);
158
+        $invoice_id = absint($_POST['invoice_id']);
159 159
         
160
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
160
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
161 161
             die();
162 162
         }
163 163
         
164
-        $invoice    = wpinv_get_invoice( $invoice_id );
165
-        if ( empty( $invoice ) ) {
164
+        $invoice = wpinv_get_invoice($invoice_id);
165
+        if (empty($invoice)) {
166 166
             die();
167 167
         }
168 168
         
169
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
169
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
170 170
             die(); // Don't allow modify items for paid invoice.
171 171
         }
172 172
         
173
-        if ( !empty( $_POST['user_id'] ) ) {
174
-            $wpi_userID = absint( $_POST['user_id'] ); 
173
+        if (!empty($_POST['user_id'])) {
174
+            $wpi_userID = absint($_POST['user_id']); 
175 175
         }
176 176
 
177
-        $item = new WPInv_Item( $item_id );
178
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
177
+        $item = new WPInv_Item($item_id);
178
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
179 179
             die();
180 180
         }
181 181
         
182 182
         // Validate item before adding to invoice because recurring item must be paid individually.
183
-        if ( !empty( $invoice->cart_details ) ) {
183
+        if (!empty($invoice->cart_details)) {
184 184
             $valid = true;
185 185
             
186
-            if ( $recurring_item = $invoice->get_recurring() ) {
187
-                if ( $recurring_item != $item_id ) {
186
+            if ($recurring_item = $invoice->get_recurring()) {
187
+                if ($recurring_item != $item_id) {
188 188
                     $valid = false;
189 189
                 }
190
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
190
+            } else if (wpinv_is_recurring_item($item_id)) {
191 191
                 $valid = false;
192 192
             }
193 193
             
194
-            if ( !$valid ) {
194
+            if (!$valid) {
195 195
                 $response               = array();
196 196
                 $response['success']    = false;
197
-                $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
198
-                wp_send_json( $response );
197
+                $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
198
+                wp_send_json($response);
199 199
             }
200 200
         }
201 201
         
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         
204 204
         $data                   = array();
205 205
         $data['invoice_id']     = $invoice_id;
206
-        $data['cart_discounts'] = $invoice->get_discounts( true );
206
+        $data['cart_discounts'] = $invoice->get_discounts(true);
207 207
         
208
-        wpinv_set_checkout_session( $data );
208
+        wpinv_set_checkout_session($data);
209 209
         
210 210
         $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
211 211
 
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
             'fees'          => array()
221 221
         );
222 222
 
223
-        $invoice->add_item( $item_id, $args );
223
+        $invoice->add_item($item_id, $args);
224 224
         $invoice->save();
225 225
         
226
-        if ( empty( $_POST['country'] ) ) {
226
+        if (empty($_POST['country'])) {
227 227
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
228 228
         }
229
-        if ( empty( $_POST['state'] ) ) {
229
+        if (empty($_POST['state'])) {
230 230
             $_POST['state'] = $invoice->state;
231 231
         }
232 232
          
233
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
234
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
233
+        $invoice->country   = sanitize_text_field($_POST['country']);
234
+        $invoice->state     = sanitize_text_field($_POST['state']);
235 235
         
236
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
237
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
236
+        $invoice->set('country', sanitize_text_field($_POST['country']));
237
+        $invoice->set('state', sanitize_text_field($_POST['state']));
238 238
         
239 239
         $wpinv_ip_address_country = $invoice->country;
240 240
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         
243 243
         $response                       = array();
244 244
         $response['success']            = true;
245
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
245
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
246 246
         $response['data']['subtotal']   = $invoice->get_subtotal();
247 247
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
248 248
         $response['data']['tax']        = $invoice->get_tax();
@@ -254,40 +254,40 @@  discard block
 block discarded – undo
254 254
         
255 255
         wpinv_set_checkout_session($checkout_session);
256 256
         
257
-        wp_send_json( $response );
257
+        wp_send_json($response);
258 258
     }
259 259
     
260 260
     public static function remove_invoice_item() {
261 261
         global $wpi_userID, $wpinv_ip_address_country;
262 262
         
263
-        check_ajax_referer( 'invoice-item', '_nonce' );
264
-        if ( !current_user_can( 'manage_options' ) ) {
263
+        check_ajax_referer('invoice-item', '_nonce');
264
+        if (!current_user_can('manage_options')) {
265 265
             die(-1);
266 266
         }
267 267
         
268
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
269
-        $invoice_id = absint( $_POST['invoice_id'] );
270
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
268
+        $item_id    = sanitize_text_field($_POST['item_id']);
269
+        $invoice_id = absint($_POST['invoice_id']);
270
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
271 271
         
272
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
272
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
273 273
             die();
274 274
         }
275 275
 
276
-        $invoice    = wpinv_get_invoice( $invoice_id );
277
-        if ( empty( $invoice ) ) {
276
+        $invoice = wpinv_get_invoice($invoice_id);
277
+        if (empty($invoice)) {
278 278
             die();
279 279
         }
280 280
         
281
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
281
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
282 282
             die(); // Don't allow modify items for paid invoice.
283 283
         }
284 284
         
285
-        if ( !empty( $_POST['user_id'] ) ) {
286
-            $wpi_userID = absint( $_POST['user_id'] ); 
285
+        if (!empty($_POST['user_id'])) {
286
+            $wpi_userID = absint($_POST['user_id']); 
287 287
         }
288 288
 
289
-        $item       = new WPInv_Item( $item_id );
290
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
289
+        $item = new WPInv_Item($item_id);
290
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
291 291
             die();
292 292
         }
293 293
         
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
         
296 296
         $data                   = array();
297 297
         $data['invoice_id']     = $invoice_id;
298
-        $data['cart_discounts'] = $invoice->get_discounts( true );
298
+        $data['cart_discounts'] = $invoice->get_discounts(true);
299 299
         
300
-        wpinv_set_checkout_session( $data );
300
+        wpinv_set_checkout_session($data);
301 301
 
302 302
         $args = array(
303 303
             'id'         => $item_id,
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
             'cart_index' => $cart_index
306 306
         );
307 307
 
308
-        $invoice->remove_item( $item_id, $args );
308
+        $invoice->remove_item($item_id, $args);
309 309
         $invoice->save();
310 310
         
311
-        if ( empty( $_POST['country'] ) ) {
311
+        if (empty($_POST['country'])) {
312 312
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
313 313
         }
314
-        if ( empty( $_POST['state'] ) ) {
314
+        if (empty($_POST['state'])) {
315 315
             $_POST['state'] = $invoice->state;
316 316
         }
317 317
          
318
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
319
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
318
+        $invoice->country   = sanitize_text_field($_POST['country']);
319
+        $invoice->state     = sanitize_text_field($_POST['state']);
320 320
         
321
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
322
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
321
+        $invoice->set('country', sanitize_text_field($_POST['country']));
322
+        $invoice->set('state', sanitize_text_field($_POST['state']));
323 323
         
324 324
         $wpinv_ip_address_country = $invoice->country;
325 325
         
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         
328 328
         $response                       = array();
329 329
         $response['success']            = true;
330
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
330
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
331 331
         $response['data']['subtotal']   = $invoice->get_subtotal();
332 332
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
333 333
         $response['data']['tax']        = $invoice->get_tax();
@@ -339,40 +339,40 @@  discard block
 block discarded – undo
339 339
         
340 340
         wpinv_set_checkout_session($checkout_session);
341 341
         
342
-        wp_send_json( $response );
342
+        wp_send_json($response);
343 343
     }
344 344
     
345 345
     public static function create_invoice_item() {
346
-        check_ajax_referer( 'invoice-item', '_nonce' );
347
-        if ( !current_user_can( 'manage_options' ) ) {
346
+        check_ajax_referer('invoice-item', '_nonce');
347
+        if (!current_user_can('manage_options')) {
348 348
             die(-1);
349 349
         }
350 350
         
351
-        $invoice_id = absint( $_POST['invoice_id'] );
351
+        $invoice_id = absint($_POST['invoice_id']);
352 352
 
353 353
         // Find the item
354
-        if ( !is_numeric( $invoice_id ) ) {
354
+        if (!is_numeric($invoice_id)) {
355 355
             die();
356 356
         }        
357 357
         
358
-        $invoice     = wpinv_get_invoice( $invoice_id );
359
-        if ( empty( $invoice ) ) {
358
+        $invoice = wpinv_get_invoice($invoice_id);
359
+        if (empty($invoice)) {
360 360
             die();
361 361
         }
362 362
         
363 363
         // Validate item before adding to invoice because recurring item must be paid individually.
364
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
364
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
365 365
             $response               = array();
366 366
             $response['success']    = false;
367
-            $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
368
-            wp_send_json( $response );
367
+            $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
368
+            wp_send_json($response);
369 369
         }        
370 370
         
371 371
         $save_item = $_POST['_wpinv_quick'];
372 372
         
373 373
         $meta               = array();
374 374
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
375
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
375
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
376 376
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
377 377
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
378 378
         
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
         $data['meta']           = $meta;
383 383
         
384 384
         $item = new WPInv_Item();
385
-        $item->create( $data );
385
+        $item->create($data);
386 386
         
387
-        if ( !empty( $item ) ) {
387
+        if (!empty($item)) {
388 388
             $_POST['item_id']   = $item->ID;
389 389
             $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
390 390
             
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
     }
395 395
     
396 396
     public static function get_billing_details() {
397
-        check_ajax_referer( 'get-billing-details', '_nonce' );
397
+        check_ajax_referer('get-billing-details', '_nonce');
398 398
         
399
-        if ( !current_user_can( 'manage_options' ) ) {
399
+        if (!current_user_can('manage_options')) {
400 400
             die(-1);
401 401
         }
402 402
 
403 403
         $user_id            = (int)$_POST['user_id'];
404 404
         $billing_details    = wpinv_get_user_address($user_id);
405
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
405
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
406 406
         
407 407
         if (isset($billing_details['user_id'])) {
408 408
             unset($billing_details['user_id']);
@@ -416,20 +416,20 @@  discard block
 block discarded – undo
416 416
         $response['success']                    = true;
417 417
         $response['data']['billing_details']    = $billing_details;
418 418
         
419
-        wp_send_json( $response );
419
+        wp_send_json($response);
420 420
     }
421 421
     
422 422
     public static function admin_recalculate_totals() {
423 423
         global $wpi_userID, $wpinv_ip_address_country;
424 424
         
425
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
426
-        if ( !current_user_can( 'manage_options' ) ) {
425
+        check_ajax_referer('wpinv-nonce', '_nonce');
426
+        if (!current_user_can('manage_options')) {
427 427
             die(-1);
428 428
         }
429 429
         
430
-        $invoice_id = absint( $_POST['invoice_id'] );        
431
-        $invoice    = wpinv_get_invoice( $invoice_id );
432
-        if ( empty( $invoice ) ) {
430
+        $invoice_id = absint($_POST['invoice_id']);        
431
+        $invoice    = wpinv_get_invoice($invoice_id);
432
+        if (empty($invoice)) {
433 433
             die();
434 434
         }
435 435
         
@@ -437,23 +437,23 @@  discard block
 block discarded – undo
437 437
         
438 438
         $data                   = array();
439 439
         $data['invoice_id']     = $invoice_id;
440
-        $data['cart_discounts'] = $invoice->get_discounts( true );
440
+        $data['cart_discounts'] = $invoice->get_discounts(true);
441 441
         
442
-        wpinv_set_checkout_session( $data );
442
+        wpinv_set_checkout_session($data);
443 443
         
444
-        if ( !empty( $_POST['user_id'] ) ) {
445
-            $wpi_userID = absint( $_POST['user_id'] ); 
444
+        if (!empty($_POST['user_id'])) {
445
+            $wpi_userID = absint($_POST['user_id']); 
446 446
         }
447 447
         
448
-        if ( empty( $_POST['country'] ) ) {
448
+        if (empty($_POST['country'])) {
449 449
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
450 450
         }
451 451
             
452
-        $invoice->country = sanitize_text_field( $_POST['country'] );
453
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
454
-        if ( isset( $_POST['state'] ) ) {
455
-            $invoice->state = sanitize_text_field( $_POST['state'] );
456
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
452
+        $invoice->country = sanitize_text_field($_POST['country']);
453
+        $invoice->set('country', sanitize_text_field($_POST['country']));
454
+        if (isset($_POST['state'])) {
455
+            $invoice->state = sanitize_text_field($_POST['state']);
456
+            $invoice->set('state', sanitize_text_field($_POST['state']));
457 457
         }
458 458
         
459 459
         $wpinv_ip_address_country = $invoice->country;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         
463 463
         $response                       = array();
464 464
         $response['success']            = true;
465
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
465
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
466 466
         $response['data']['subtotal']   = $invoice->get_subtotal();
467 467
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
468 468
         $response['data']['tax']        = $invoice->get_tax();
@@ -474,25 +474,25 @@  discard block
 block discarded – undo
474 474
         
475 475
         wpinv_set_checkout_session($checkout_session);
476 476
         
477
-        wp_send_json( $response );
477
+        wp_send_json($response);
478 478
     }
479 479
     
480 480
     public static function admin_apply_discount() {
481 481
         global $wpi_userID;
482 482
         
483
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
484
-        if ( !current_user_can( 'manage_options' ) ) {
483
+        check_ajax_referer('wpinv-nonce', '_nonce');
484
+        if (!current_user_can('manage_options')) {
485 485
             die(-1);
486 486
         }
487 487
         
488
-        $invoice_id = absint( $_POST['invoice_id'] );
489
-        $discount_code = sanitize_text_field( $_POST['code'] );
490
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
488
+        $invoice_id = absint($_POST['invoice_id']);
489
+        $discount_code = sanitize_text_field($_POST['code']);
490
+        if (empty($invoice_id) || empty($discount_code)) {
491 491
             die();
492 492
         }
493 493
         
494
-        $invoice = wpinv_get_invoice( $invoice_id );
495
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
494
+        $invoice = wpinv_get_invoice($invoice_id);
495
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
496 496
             die();
497 497
         }
498 498
         
@@ -500,49 +500,49 @@  discard block
 block discarded – undo
500 500
         
501 501
         $data                   = array();
502 502
         $data['invoice_id']     = $invoice_id;
503
-        $data['cart_discounts'] = $invoice->get_discounts( true );
503
+        $data['cart_discounts'] = $invoice->get_discounts(true);
504 504
         
505
-        wpinv_set_checkout_session( $data );
505
+        wpinv_set_checkout_session($data);
506 506
         
507 507
         $response               = array();
508 508
         $response['success']    = false;
509
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
509
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
510 510
         $response['data']['code'] = $discount_code;
511 511
         
512
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
513
-            $discounts = wpinv_set_cart_discount( $discount_code );
512
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
513
+            $discounts = wpinv_set_cart_discount($discount_code);
514 514
             
515 515
             $response['success'] = true;
516
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
517
-        }  else {
516
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
517
+        } else {
518 518
             $errors = wpinv_get_errors();
519
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
519
+            if (!empty($errors['wpinv-discount-error'])) {
520 520
                 $response['msg'] = $errors['wpinv-discount-error'];
521 521
             }
522
-            wpinv_unset_error( 'wpinv-discount-error' );
522
+            wpinv_unset_error('wpinv-discount-error');
523 523
         }
524 524
         
525 525
         wpinv_set_checkout_session($checkout_session);
526 526
         
527
-        wp_send_json( $response );
527
+        wp_send_json($response);
528 528
     }
529 529
     
530 530
     public static function admin_remove_discount() {
531 531
         global $wpi_userID;
532 532
         
533
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
534
-        if ( !current_user_can( 'manage_options' ) ) {
533
+        check_ajax_referer('wpinv-nonce', '_nonce');
534
+        if (!current_user_can('manage_options')) {
535 535
             die(-1);
536 536
         }
537 537
         
538
-        $invoice_id = absint( $_POST['invoice_id'] );
539
-        $discount_code = sanitize_text_field( $_POST['code'] );
540
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
538
+        $invoice_id = absint($_POST['invoice_id']);
539
+        $discount_code = sanitize_text_field($_POST['code']);
540
+        if (empty($invoice_id) || empty($discount_code)) {
541 541
             die();
542 542
         }
543 543
         
544
-        $invoice = wpinv_get_invoice( $invoice_id );
545
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
544
+        $invoice = wpinv_get_invoice($invoice_id);
545
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
546 546
             die();
547 547
         }
548 548
         
@@ -550,38 +550,38 @@  discard block
 block discarded – undo
550 550
         
551 551
         $data                   = array();
552 552
         $data['invoice_id']     = $invoice_id;
553
-        $data['cart_discounts'] = $invoice->get_discounts( true );
553
+        $data['cart_discounts'] = $invoice->get_discounts(true);
554 554
         
555
-        wpinv_set_checkout_session( $data );
555
+        wpinv_set_checkout_session($data);
556 556
         
557 557
         $response               = array();
558 558
         $response['success']    = false;
559 559
         $response['msg']        = NULL;
560 560
         
561
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
561
+        $discounts = wpinv_unset_cart_discount($discount_code);
562 562
         $response['success'] = true;
563
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
563
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
564 564
         
565 565
         wpinv_set_checkout_session($checkout_session);
566 566
         
567
-        wp_send_json( $response );
567
+        wp_send_json($response);
568 568
     }
569 569
     
570 570
     public static function check_email() {
571
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
572
-        if ( !current_user_can( 'manage_options' ) ) {
571
+        check_ajax_referer('wpinv-nonce', '_nonce');
572
+        if (!current_user_can('manage_options')) {
573 573
             die(-1);
574 574
         }
575 575
         
576
-        $email = sanitize_text_field( $_POST['email'] );
576
+        $email = sanitize_text_field($_POST['email']);
577 577
         
578 578
         $response = array();
579
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
579
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
580 580
             $user_id            = $user_data->ID;
581 581
             $user_login         = $user_data->user_login;
582 582
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
583 583
             $billing_details    = wpinv_get_user_address($user_id);
584
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
584
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
585 585
             
586 586
             if (isset($billing_details['user_id'])) {
587 587
                 unset($billing_details['user_id']);
@@ -597,54 +597,54 @@  discard block
 block discarded – undo
597 597
             $response['data']['billing_details']    = $billing_details;
598 598
         }
599 599
         
600
-        wp_send_json( $response );
600
+        wp_send_json($response);
601 601
     }
602 602
     
603 603
     public static function run_tool() {
604
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
605
-        if ( !current_user_can( 'manage_options' ) ) {
604
+        check_ajax_referer('wpinv-nonce', '_nonce');
605
+        if (!current_user_can('manage_options')) {
606 606
             die(-1);
607 607
         }
608 608
         
609
-        $tool = sanitize_text_field( $_POST['tool'] );
609
+        $tool = sanitize_text_field($_POST['tool']);
610 610
         
611
-        do_action( 'wpinv_run_tool' );
611
+        do_action('wpinv_run_tool');
612 612
         
613
-        if ( !empty( $tool ) ) {
614
-            do_action( 'wpinv_tool_' . $tool );
613
+        if (!empty($tool)) {
614
+            do_action('wpinv_tool_' . $tool);
615 615
         }
616 616
     }
617 617
     
618 618
     public static function apply_discount() {
619 619
         global $wpi_userID;
620 620
         
621
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
621
+        check_ajax_referer('wpinv-nonce', '_nonce');
622 622
         
623 623
         $response = array();
624 624
         
625
-        if ( isset( $_POST['code'] ) ) {
626
-            $discount_code = sanitize_text_field( $_POST['code'] );
625
+        if (isset($_POST['code'])) {
626
+            $discount_code = sanitize_text_field($_POST['code']);
627 627
 
628 628
             $response['success']        = false;
629 629
             $response['msg']            = '';
630 630
             $response['data']['code']   = $discount_code;
631 631
             
632 632
             $invoice = wpinv_get_invoice_cart();
633
-            if ( empty( $invoice->ID ) ) {
634
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
635
-                wp_send_json( $response );
633
+            if (empty($invoice->ID)) {
634
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
635
+                wp_send_json($response);
636 636
             }
637 637
 
638 638
             $wpi_userID = $invoice->get_user_id();
639 639
 
640
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
641
-                $discount       = wpinv_get_discount_by_code( $discount_code );
642
-                $discounts      = wpinv_set_cart_discount( $discount_code );
643
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
644
-                $total          = wpinv_get_cart_total( null, $discounts );
645
-                $cart_totals    = wpinv_recalculate_tax( true );
640
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
641
+                $discount       = wpinv_get_discount_by_code($discount_code);
642
+                $discounts      = wpinv_set_cart_discount($discount_code);
643
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
644
+                $total          = wpinv_get_cart_total(null, $discounts);
645
+                $cart_totals    = wpinv_recalculate_tax(true);
646 646
             
647
-                if ( !empty( $cart_totals ) ) {
647
+                if (!empty($cart_totals)) {
648 648
                     $response['success']        = true;
649 649
                     $response['data']           = $cart_totals;
650 650
                     $response['data']['code']   = $discount_code;
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
                 }
654 654
             } else {
655 655
                 $errors = wpinv_get_errors();
656
-                $response['msg']  = $errors['wpinv-discount-error'];
657
-                wpinv_unset_error( 'wpinv-discount-error' );
656
+                $response['msg'] = $errors['wpinv-discount-error'];
657
+                wpinv_unset_error('wpinv-discount-error');
658 658
             }
659 659
 
660 660
             // Allow for custom discount code handling
661
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
661
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
662 662
         }
663 663
         
664
-        wp_send_json( $response );
664
+        wp_send_json($response);
665 665
     }
666 666
     
667 667
     public static function remove_discount() {
668
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
668
+        check_ajax_referer('wpinv-nonce', '_nonce');
669 669
         
670 670
         $response = array();
671 671
         
672
-        if ( isset( $_POST['code'] ) ) {
673
-            $discount_code  = sanitize_text_field( $_POST['code'] );
674
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
675
-            $total          = wpinv_get_cart_total( null, $discounts );
676
-            $cart_totals    = wpinv_recalculate_tax( true );
672
+        if (isset($_POST['code'])) {
673
+            $discount_code  = sanitize_text_field($_POST['code']);
674
+            $discounts      = wpinv_unset_cart_discount($discount_code);
675
+            $total          = wpinv_get_cart_total(null, $discounts);
676
+            $cart_totals    = wpinv_recalculate_tax(true);
677 677
             
678
-            if ( !empty( $cart_totals ) ) {
678
+            if (!empty($cart_totals)) {
679 679
                 $response['success']        = true;
680 680
                 $response['data']           = $cart_totals;
681 681
                 $response['data']['code']   = $discount_code;
@@ -684,10 +684,10 @@  discard block
 block discarded – undo
684 684
             }
685 685
             
686 686
             // Allow for custom discount code handling
687
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
687
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
688 688
         }
689 689
         
690
-        wp_send_json( $response );
690
+        wp_send_json($response);
691 691
     }
692 692
 
693 693
 
@@ -696,20 +696,20 @@  discard block
 block discarded – undo
696 696
      *
697 697
      * @since 1.0.0
698 698
      */
699
-    public function buy_items(){
699
+    public function buy_items() {
700 700
 
701 701
         $user_id = get_current_user_id();
702
-        if(!$user_id ){ // if not logged in then lets redirect to the login page
702
+        if (!$user_id) { // if not logged in then lets redirect to the login page
703 703
 
704 704
             wp_send_json(array(
705
-                'success' => wp_login_url( wp_get_referer() )
705
+                'success' => wp_login_url(wp_get_referer())
706 706
             ));
707
-        }else{
707
+        } else {
708 708
 
709 709
             // only check nonce if logged in as it could be cached when logged out.
710
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
710
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
711 711
                 wp_send_json(array(
712
-                    'error' => __('Security checks failed.','invoicing')
712
+                    'error' => __('Security checks failed.', 'invoicing')
713 713
                 ));
714 714
                 wp_die();
715 715
             }
@@ -717,36 +717,36 @@  discard block
 block discarded – undo
717 717
             // allow to set a custom price through post_id
718 718
             $items = $_POST['items'];
719 719
             $related_post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : 0;
720
-            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id,'_wpi_custom_price',true)) : 0;
720
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
721 721
 
722 722
 
723 723
             $cart_items = array();
724
-            if($items){
725
-                $items = explode(',',$items);
726
-                foreach($items as $item){
724
+            if ($items) {
725
+                $items = explode(',', $items);
726
+                foreach ($items as $item) {
727 727
                     $item_id = $item;
728 728
                     $quantity = 1;
729 729
                     if (strpos($item, '|') !== false) {
730
-                        $item_parts = explode('|',$item);
730
+                        $item_parts = explode('|', $item);
731 731
                         $item_id = $item_parts[0];
732 732
                         $quantity = $item_parts[1];
733 733
                     }
734 734
 
735
-                    if($item_id && $quantity){
735
+                    if ($item_id && $quantity) {
736 736
                         $cart_items_arr = array(
737 737
                             'id'            => (int)$item_id,
738 738
                             'quantity'      => (int)$quantity
739 739
                         );
740 740
 
741 741
                         // if there is a related post id then add it to meta
742
-                        if($related_post_id){
742
+                        if ($related_post_id) {
743 743
                             $cart_items_arr['meta'] = array(
744 744
                                 'post_id'   => $related_post_id
745 745
                             );
746 746
                         }
747 747
 
748 748
                         // if there is a custom price then set it.
749
-                        if($custom_item_price){
749
+                        if ($custom_item_price) {
750 750
                             $cart_items_arr['custom_price'] = $custom_item_price;
751 751
 
752 752
                         }
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
              * @param int $related_post_id The related post id if any.
766 766
              * @since 1.0.0
767 767
              */
768
-            $cart_items = apply_filters('wpinv_buy_cart_items',$cart_items,$related_post_id);
768
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
769 769
 
770 770
 
771 771
             //make sure its not in the cart already, if it is then redirect to checkout.
772 772
             $cart_invoice = wpinv_get_invoice_cart();
773
-            if(isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items)==serialize($cart_items) ){
773
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
774 774
                 wp_send_json(array(
775 775
                     'success' =>  $cart_invoice->get_checkout_payment_url()
776 776
                 ));
@@ -779,25 +779,25 @@  discard block
 block discarded – undo
779 779
 
780 780
 
781 781
             // check if user has invoice with same items waiting to be paid.
782
-            $user_invoices = wpinv_get_users_invoices( $user_id , 1 , false , 'pending' );
783
-            if(!empty($user_invoices)){
782
+            $user_invoices = wpinv_get_users_invoices($user_id, 1, false, 'pending');
783
+            if (!empty($user_invoices)) {
784 784
 
785
-                foreach($user_invoices as $user_invoice){
785
+                foreach ($user_invoices as $user_invoice) {
786 786
                     $user_cart_details = array();
787
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
787
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
788 788
                     $cart_details = $invoice->get_cart_details();
789
-                    if(!empty($cart_details)){
790
-                        foreach($cart_details as $invoice_item){
789
+                    if (!empty($cart_details)) {
790
+                        foreach ($cart_details as $invoice_item) {
791 791
 
792 792
                             $ii_arr = array();
793 793
                             $ii_arr['id'] = (int)$invoice_item['id'];
794 794
                             $ii_arr['quantity'] = (int)$invoice_item['quantity'];
795 795
 
796
-                            if(isset($invoice_item['meta']) && !empty($invoice_item['meta'])){
796
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
797 797
                                 $ii_arr['meta'] = $invoice_item['meta'];
798 798
                             }
799 799
 
800
-                            if(isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])){
800
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
801 801
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
802 802
                             }
803 803
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
                         }
807 807
                     }
808 808
 
809
-                    if(!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)){
809
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
810 810
                         wp_send_json(array(
811 811
                             'success' =>  $invoice->get_checkout_payment_url()
812 812
                         ));
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 
820 820
 
821 821
             // Create invoice and send user to checkout
822
-            if(!empty($cart_items)){
822
+            if (!empty($cart_items)) {
823 823
 
824 824
                 $invoice_data = array(
825 825
                     'status'        =>  'wpi-pending',
@@ -829,26 +829,26 @@  discard block
 block discarded – undo
829 829
                 );
830 830
 
831 831
                 // default invoice args
832
-                $invoice_data['status']  = !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'pending';
833
-                $invoice_data['user_id'] = !empty( $invoice_data['user_id'] ) ? (int)$invoice_data['user_id'] : get_current_user_id();
832
+                $invoice_data['status']  = !empty($invoice_data['status']) ? $invoice_data['status'] : 'pending';
833
+                $invoice_data['user_id'] = !empty($invoice_data['user_id']) ? (int)$invoice_data['user_id'] : get_current_user_id();
834 834
 
835
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
835
+                $invoice = wpinv_insert_invoice($invoice_data, true);
836 836
 
837
-                if(isset($invoice->ID)){
837
+                if (isset($invoice->ID)) {
838 838
 
839 839
                     wp_send_json(array(
840 840
                         'success' =>  $invoice->get_checkout_payment_url()
841 841
                     ));
842 842
 
843
-                }else{
843
+                } else {
844 844
                     wp_send_json(array(
845
-                        'error' => __('Invoice failed to create','invoicing')
845
+                        'error' => __('Invoice failed to create', 'invoicing')
846 846
                     ));
847 847
                 }
848 848
 
849
-            }else{
849
+            } else {
850 850
                 wp_send_json(array(
851
-                    'error' => __('Items not valid.','invoicing')
851
+                    'error' => __('Items not valid.', 'invoicing')
852 852
                 ));
853 853
             }
854 854
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             
515 515
             $response['success'] = true;
516 516
             $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
517
-        }  else {
517
+        } else {
518 518
             $errors = wpinv_get_errors();
519 519
             if ( !empty( $errors['wpinv-discount-error'] ) ) {
520 520
                 $response['msg'] = $errors['wpinv-discount-error'];
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             wp_send_json(array(
705 705
                 'success' => wp_login_url( wp_get_referer() )
706 706
             ));
707
-        }else{
707
+        } else{
708 708
 
709 709
             // only check nonce if logged in as it could be cached when logged out.
710 710
             if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
                         'success' =>  $invoice->get_checkout_payment_url()
841 841
                     ));
842 842
 
843
-                }else{
843
+                } else{
844 844
                     wp_send_json(array(
845 845
                         'error' => __('Invoice failed to create','invoicing')
846 846
                     ));
847 847
                 }
848 848
 
849
-            }else{
849
+            } else{
850 850
                 wp_send_json(array(
851 851
                     'error' => __('Items not valid.','invoicing')
852 852
                 ));
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
48
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_filter( 'geodir_googlemap_script_extra', array( &$this,'add_google_maps_places_lib'), 101, 1 );
54
+        add_filter('geodir_googlemap_script_extra', array(&$this, 'add_google_maps_places_lib'), 101, 1);
55 55
 
56
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
56
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
57 57
         
58
-        if ( is_admin() ) {
59
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
60
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
58
+        if (is_admin()) {
59
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
60
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
61 61
         } else {
62
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
62
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
63 63
         }
64 64
         
65 65
         /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
          *
70 70
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
71 71
          */
72
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
72
+        do_action_ref_array('wpinv_actions', array(&$this));
73 73
 
74
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
74
+        add_action('admin_init', array(&$this, 'activation_redirect'));
75 75
     }
76 76
     
77 77
     public function plugins_loaded() {
@@ -85,157 +85,157 @@  discard block
 block discarded – undo
85 85
      * @since 1.0
86 86
      */
87 87
     public function load_textdomain() {
88
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
88
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
89 89
         
90
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
91
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
90
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
91
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
92 92
         
93 93
         /**
94 94
          * Define language constants.
95 95
          */
96
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
96
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
97 97
     }
98 98
         
99 99
     public function includes() {
100 100
         global $wpinv_options;
101 101
         
102
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
102
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
103 103
         $wpinv_options = wpinv_get_settings();
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
120 120
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
121 121
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123 123
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
131
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
132
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
131
+        if (!class_exists('Geodir_EUVat')) {
132
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
133 133
         }
134 134
         
135
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
136
-        if ( !empty( $gateways ) ) {
137
-            foreach ( $gateways as $gateway ) {
138
-                if ( $gateway == 'manual' ) {
135
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
136
+        if (!empty($gateways)) {
137
+            foreach ($gateways as $gateway) {
138
+                if ($gateway == 'manual') {
139 139
                     continue;
140 140
                 }
141 141
                 
142 142
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
143 143
                 
144
-                if ( file_exists( $gateway_file ) ) {
145
-                    require_once( $gateway_file );
144
+                if (file_exists($gateway_file)) {
145
+                    require_once($gateway_file);
146 146
                 }
147 147
             }
148 148
         }
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
150 150
         
151
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
151
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
155 155
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
156
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
157
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
159
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
160
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
156
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
157
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
159
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
160
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
161 161
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
162 162
         }
163 163
         
164 164
         // include css inliner
165
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
166
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
165
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
166
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
167 167
         }
168 168
         
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
170 170
     }
171 171
     
172 172
     public function init() {
173 173
     }
174 174
     
175 175
     public function admin_init() {
176
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
176
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
177 177
         }
178 178
         
179
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
179
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
180 180
     }
181 181
 
182 182
     public function activation_redirect() {
183 183
         // Bail if no activation redirect
184
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
184
+        if (!get_transient('_wpinv_activation_redirect')) {
185 185
             return;
186 186
         }
187 187
 
188 188
         // Delete the redirect transient
189
-        delete_transient( '_wpinv_activation_redirect' );
189
+        delete_transient('_wpinv_activation_redirect');
190 190
 
191 191
         // Bail if activating from network, or bulk
192
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
192
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
193 193
             return;
194 194
         }
195 195
 
196
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
196
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
197 197
         exit;
198 198
     }
199 199
     
200 200
     public function enqueue_scripts() {
201
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
201
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
202 202
         
203
-        wp_deregister_style( 'font-awesome' );
204
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
205
-        wp_enqueue_style( 'font-awesome' );
203
+        wp_deregister_style('font-awesome');
204
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
205
+        wp_enqueue_style('font-awesome');
206 206
         
207
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
208
-        wp_enqueue_style( 'wpinv_front_style' );
207
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
208
+        wp_enqueue_style('wpinv_front_style');
209 209
                
210 210
         // Register scripts
211
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
212
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
211
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
212
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
213 213
         
214 214
         $localize                         = array();
215
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
216
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
215
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
216
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
217 217
         $localize['currency_symbol']      = wpinv_currency_symbol();
218 218
         $localize['currency_pos']         = wpinv_currency_position();
219 219
         $localize['thousand_sep']         = wpinv_thousands_separator();
220 220
         $localize['decimal_sep']          = wpinv_decimal_separator();
221 221
         $localize['decimals']             = wpinv_decimals();
222 222
         
223
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
223
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
224 224
         
225
-        wp_enqueue_script( 'jquery-blockui' );
225
+        wp_enqueue_script('jquery-blockui');
226 226
         $autofill_api = wpinv_get_option('address_autofill_api');
227 227
         $autofill_active = wpinv_get_option('address_autofill_active');
228 228
         if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
229 229
 
230 230
             // we don't need this if GD is installed.
231
-            if(!function_exists('geodir_templates_scripts')){
231
+            if (!function_exists('geodir_templates_scripts')) {
232 232
                 wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
233 233
             }
234
-            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery','google-maps-api'), '', true);
234
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
235 235
             
236 236
         }
237
-        wp_enqueue_script( 'wpinv-front-script' );
238
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
237
+        wp_enqueue_script('wpinv-front-script');
238
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
239 239
     }
240 240
 
241 241
     /**
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
      * @since 1.0.0
246 246
      * @return string
247 247
      */
248
-    public function add_google_maps_places_lib( $extra ) {
248
+    public function add_google_maps_places_lib($extra) {
249 249
 
250
-        if ( wpinv_is_checkout() && ! str_replace( 'libraries=places', '', $extra ) ) {
250
+        if (wpinv_is_checkout() && !str_replace('libraries=places', '', $extra)) {
251 251
             $extra .= "&amp;libraries=places";
252 252
         }
253 253
 
@@ -258,35 +258,35 @@  discard block
 block discarded – undo
258 258
         global $post, $pagenow;
259 259
         
260 260
         $post_type  = wpinv_admin_post_type();
261
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
261
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
262 262
         
263
-        wp_deregister_style( 'font-awesome' );
264
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
265
-        wp_enqueue_style( 'font-awesome' );
263
+        wp_deregister_style('font-awesome');
264
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
265
+        wp_enqueue_style('font-awesome');
266 266
         
267
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
268
-        wp_enqueue_style( 'jquery-ui-css' );
267
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
268
+        wp_enqueue_style('jquery-ui-css');
269 269
         
270
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
271
-        wp_enqueue_style( 'jquery-chosen' );
270
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
271
+        wp_enqueue_style('jquery-chosen');
272 272
 
273
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
274
-        wp_enqueue_script( 'jquery-chosen' );
273
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
274
+        wp_enqueue_script('jquery-chosen');
275 275
         
276
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
277
-        wp_enqueue_style( 'wpinv_meta_box_style' );
276
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
277
+        wp_enqueue_style('wpinv_meta_box_style');
278 278
         
279
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
280
-        wp_enqueue_style( 'wpinv_admin_style' );
279
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
280
+        wp_enqueue_style('wpinv_admin_style');
281 281
         
282
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
283
-            wp_enqueue_script( 'jquery-ui-datepicker' );
282
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
283
+            wp_enqueue_script('jquery-ui-datepicker');
284 284
         }
285 285
 
286
-        wp_enqueue_style( 'wp-color-picker' );
287
-        wp_enqueue_script( 'wp-color-picker' );
286
+        wp_enqueue_style('wp-color-picker');
287
+        wp_enqueue_script('wp-color-picker');
288 288
         
289
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
289
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
290 290
 
291 291
         if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
292 292
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
             }
298 298
         }
299 299
 
300
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
301
-        wp_enqueue_script( 'wpinv-admin-script' );
300
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
301
+        wp_enqueue_script('wpinv-admin-script');
302 302
         
303 303
         $localize                               = array();
304
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
305
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
306
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
307
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
308
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
309
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
310
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
304
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
305
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
306
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
307
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
308
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
309
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
310
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
311 311
         $localize['tax']                        = wpinv_tax_amount();
312 312
         $localize['discount']                   = wpinv_discount_amount();
313 313
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -315,65 +315,65 @@  discard block
 block discarded – undo
315 315
         $localize['thousand_sep']               = wpinv_thousands_separator();
316 316
         $localize['decimal_sep']                = wpinv_decimal_separator();
317 317
         $localize['decimals']                   = wpinv_decimals();
318
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
319
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
320
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
321
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
322
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
323
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
324
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
325
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
326
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
318
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
319
+        $localize['status_publish']             = wpinv_status_nicename('publish');
320
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
321
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
322
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
323
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
324
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
325
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
326
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
327 327
         $localize['hasGD']                      = wpinv_gd_active();
328 328
         $localize['hasPM']                      = wpinv_pm_active();
329
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
330
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
331
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
332
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
329
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
330
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
331
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
332
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
333 333
 
334
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
334
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
335 335
 
336
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
336
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
337 337
     }
338 338
     
339
-    public function admin_body_class( $classes ) {
339
+    public function admin_body_class($classes) {
340 340
         global $pagenow, $post, $current_screen;
341 341
         
342
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
342
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
343 343
             $classes .= ' wpinv-cpt';
344 344
         }
345 345
         
346
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
346
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
347 347
 
348 348
         $add_class = false;
349
-        if ( $pagenow == 'admin.php' && $page ) {
350
-            $add_class = strpos( $page, 'wpinv-' );
349
+        if ($pagenow == 'admin.php' && $page) {
350
+            $add_class = strpos($page, 'wpinv-');
351 351
         }
352 352
         
353 353
         $settings_class = array();
354
-        if ( $page == 'wpinv-settings' ) {
355
-            if ( !empty( $_REQUEST['tab'] ) ) {
356
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
354
+        if ($page == 'wpinv-settings') {
355
+            if (!empty($_REQUEST['tab'])) {
356
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
357 357
             }
358 358
             
359
-            if ( !empty( $_REQUEST['section'] ) ) {
360
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
359
+            if (!empty($_REQUEST['section'])) {
360
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
361 361
             }
362 362
             
363
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
363
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
364 364
         }
365 365
         
366
-        if ( !empty( $settings_class ) ) {
367
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
366
+        if (!empty($settings_class)) {
367
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
368 368
         }
369 369
         
370 370
         $post_type = wpinv_admin_post_type();
371 371
 
372
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
372
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
373 373
             return $classes .= ' wpinv';
374 374
         }
375 375
         
376
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
376
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
377 377
             $classes .= ' wpi-editable-n';
378 378
         }
379 379
 
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
     }
386 386
     
387 387
     public function wpinv_actions() {
388
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
389
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+        if (isset($_REQUEST['wpi_action'])) {
389
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
390 390
         }
391 391
     }
392 392
     
393
-    public function pre_get_posts( $wp_query ) {
394
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
395
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
393
+    public function pre_get_posts($wp_query) {
394
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
395
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
396 396
         }
397 397
         
398 398
         return $wp_query;
399 399
     }
400 400
     
401 401
     public function bp_invoicing_init() {
402
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
402
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
403 403
     }
404 404
 }
405 405
\ No newline at end of file
Please login to merge, or discard this patch.