@@ -664,6 +664,9 @@ discard block |
||
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 |
||
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; |
@@ -7,12 +7,12 @@ discard block |
||
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_pending_to_processing', |
17 | 17 | 'wpinv_status_pending_to_publish', |
18 | 18 | 'wpinv_status_pending_to_cancelled', |
@@ -28,79 +28,79 @@ discard block |
||
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_pending_to_processing_notification', 'wpinv_new_invoice_notification' ); |
|
41 | -add_action( 'wpinv_status_pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
42 | -add_action( 'wpinv_status_pending_to_onhold_notification', 'wpinv_new_invoice_notification' ); |
|
43 | -add_action( 'wpinv_status_failed_to_processing_notification', 'wpinv_new_invoice_notification' ); |
|
44 | -add_action( 'wpinv_status_failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
45 | -add_action( 'wpinv_status_failed_to_onhold_notification', 'wpinv_new_invoice_notification' ); |
|
40 | +add_action('wpinv_status_pending_to_processing_notification', 'wpinv_new_invoice_notification'); |
|
41 | +add_action('wpinv_status_pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
42 | +add_action('wpinv_status_pending_to_onhold_notification', 'wpinv_new_invoice_notification'); |
|
43 | +add_action('wpinv_status_failed_to_processing_notification', 'wpinv_new_invoice_notification'); |
|
44 | +add_action('wpinv_status_failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
45 | +add_action('wpinv_status_failed_to_onhold_notification', 'wpinv_new_invoice_notification'); |
|
46 | 46 | |
47 | 47 | // Cancelled invoice email |
48 | -add_action( 'wpinv_status_pending_to_cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
49 | -add_action( 'wpinv_status_onhold_to_cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
48 | +add_action('wpinv_status_pending_to_cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
49 | +add_action('wpinv_status_onhold_to_cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
50 | 50 | |
51 | 51 | // Failed invoice email |
52 | -add_action( 'wpinv_status_pending_to_failed_notification', 'wpinv_failed_invoice_notification' ); |
|
53 | -add_action( 'wpinv_status_onhold_to_failed_notification', 'wpinv_failed_invoice_notification' ); |
|
52 | +add_action('wpinv_status_pending_to_failed_notification', 'wpinv_failed_invoice_notification'); |
|
53 | +add_action('wpinv_status_onhold_to_failed_notification', 'wpinv_failed_invoice_notification'); |
|
54 | 54 | |
55 | 55 | // On hold invoice email |
56 | -add_action( 'wpinv_status_pending_to_onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
57 | -add_action( 'wpinv_status_failed_to_onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
56 | +add_action('wpinv_status_pending_to_onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
57 | +add_action('wpinv_status_failed_to_onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
58 | 58 | |
59 | 59 | // Processing invoice email |
60 | -add_action( 'wpinv_status_pending_to_processing_notification', 'wpinv_processing_invoice_notification' ); |
|
60 | +add_action('wpinv_status_pending_to_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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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_pay_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_pay_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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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']= $invoice->get_checkout_payment_url( false, true ); |
|
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'] = $invoice->get_checkout_payment_url(false, true); |
|
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 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | ?> |
8 | 8 | |
9 | -<p><?php printf( __( 'You have received payment from %s. The invoice is as follows:', 'invoicing' ), $invoice->get_user_full_name() ); ?></p> |
|
9 | +<p><?php printf(__('You have received payment from %s. The invoice is as follows:', 'invoicing'), $invoice->get_user_full_name()); ?></p> |
|
10 | 10 | |
11 | 11 | <?php |
12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
19 | 18 | \ No newline at end of file |
19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | \ No newline at end of file |
@@ -1,72 +1,72 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | 6 | global $wpinv_euvat; |
7 | 7 | |
8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
9 | -if ( $sent_to_admin ) { |
|
10 | - $invoice_url = get_edit_post_link( $invoice->ID ); |
|
8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
9 | +if ($sent_to_admin) { |
|
10 | + $invoice_url = get_edit_post_link($invoice->ID); |
|
11 | 11 | } else { |
12 | - $secret = !empty( $email_type ) && $email_type == 'user_invoice' ? true : false; |
|
13 | - $invoice_url = $invoice->get_view_url( $secret ); |
|
12 | + $secret = !empty($email_type) && $email_type == 'user_invoice' ? true : false; |
|
13 | + $invoice_url = $invoice->get_view_url($secret); |
|
14 | 14 | } |
15 | 15 | $use_taxes = wpinv_use_taxes(); |
16 | 16 | $vat_name = $wpinv_euvat->get_vat_name(); |
17 | 17 | |
18 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
18 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
19 | 19 | <div id="wpinv-email-details"> |
20 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3> |
|
20 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3> |
|
21 | 21 | <table class="table table-bordered table-sm"> |
22 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
22 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
23 | 23 | <tr> |
24 | - <td><?php echo apply_filters( 'wpinv_email_details_number', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td> |
|
25 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
24 | + <td><?php echo apply_filters('wpinv_email_details_number', __('Invoice Number', 'invoicing'), $invoice); ?></td> |
|
25 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
26 | 26 | </tr> |
27 | 27 | <?php } ?> |
28 | 28 | <tr> |
29 | - <td><?php echo apply_filters( 'wpinv_email_details_status', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td> |
|
30 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
29 | + <td><?php echo apply_filters('wpinv_email_details_status', __('Invoice Status', 'invoicing'), $invoice); ?></td> |
|
30 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
31 | 31 | </tr> |
32 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
32 | + <?php if ($invoice->is_renewal()) { ?> |
|
33 | 33 | <tr> |
34 | - <td><?php _e( 'Parent Invoice', 'invoicing' ); ?></td> |
|
35 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
34 | + <td><?php _e('Parent Invoice', 'invoicing'); ?></td> |
|
35 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
36 | 36 | </tr> |
37 | 37 | <?php } ?> |
38 | 38 | <tr> |
39 | - <td><?php _e( 'Payment Method', 'invoicing' ); ?></td> |
|
39 | + <td><?php _e('Payment Method', 'invoicing'); ?></td> |
|
40 | 40 | <td><?php echo $invoice->get_gateway_title(); ?></td> |
41 | 41 | </tr> |
42 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
42 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
43 | 43 | <tr> |
44 | - <td><?php echo apply_filters( 'wpinv_email_details_date', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td> |
|
45 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
44 | + <td><?php echo apply_filters('wpinv_email_details_date', __('Invoice Date', 'invoicing'), $invoice); ?></td> |
|
45 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
46 | 46 | </tr> |
47 | 47 | <?php } ?> |
48 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
48 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
49 | 49 | <tr> |
50 | - <td><?php _e( 'Due Date', 'invoicing' ); ?></td> |
|
51 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
50 | + <td><?php _e('Due Date', 'invoicing'); ?></td> |
|
51 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
52 | 52 | </tr> |
53 | 53 | <?php } ?> |
54 | - <?php if ( empty( $sent_to_admin ) && $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
54 | + <?php if (empty($sent_to_admin) && $owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
55 | 55 | <tr> |
56 | - <td><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></td> |
|
56 | + <td><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></td> |
|
57 | 57 | <td><?php echo $owner_vat_number; ?></td> |
58 | 58 | </tr> |
59 | 59 | <?php } ?> |
60 | - <?php if ( $use_taxes && $user_vat_number = $invoice->vat_number ) { ?> |
|
60 | + <?php if ($use_taxes && $user_vat_number = $invoice->vat_number) { ?> |
|
61 | 61 | <tr> |
62 | - <td><?php echo wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ); ?></td> |
|
62 | + <td><?php echo wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name); ?></td> |
|
63 | 63 | <td><?php echo $user_vat_number; ?></td> |
64 | 64 | </tr> |
65 | 65 | <?php } ?> |
66 | 66 | <tr class="table-active"> |
67 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
68 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
67 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
68 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
69 | 69 | </tr> |
70 | 70 | </table> |
71 | 71 | </div> |
72 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
73 | 72 | \ No newline at end of file |
73 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
74 | 74 | \ No newline at end of file |
@@ -7,239 +7,239 @@ discard block |
||
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() && $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() && $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,156 +249,156 @@ discard block |
||
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( $post_id ) { |
|
342 | +function wpinv_send_invoice_after_save($post_id) { |
|
343 | 343 | // If this is just a revision, don't send the email. |
344 | - if ( wp_is_post_revision( $post_id ) ) { |
|
344 | + if (wp_is_post_revision($post_id)) { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - if ( !current_user_can( 'manage_options' ) || !('wpi_invoice' == get_post_type( $post_id )) ) { |
|
348 | + if (!current_user_can('manage_options') || !('wpi_invoice' == get_post_type($post_id))) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - if ( !empty( $_POST['wpi_save_send'] ) ) { |
|
353 | - wpinv_user_invoice_notification( $post_id ); |
|
352 | + if (!empty($_POST['wpi_save_send'])) { |
|
353 | + wpinv_user_invoice_notification($post_id); |
|
354 | 354 | } |
355 | 355 | } |
356 | -add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
356 | +add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1); |
|
357 | 357 | |
358 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
359 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
360 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
361 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
358 | +function wpinv_send_register_new_user($data, $postarr) { |
|
359 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
360 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
361 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
362 | 362 | |
363 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
364 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
365 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
366 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
367 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
368 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
363 | + if ($is_new_user && $email && !email_exists($email)) { |
|
364 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
365 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
366 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
367 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
368 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
369 | 369 | |
370 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
371 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
370 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
371 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
372 | 372 | $new_user_login = strstr($email, '@', true); |
373 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
374 | - $user_login = sanitize_user($new_user_login, true ); |
|
373 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
374 | + $user_login = sanitize_user($new_user_login, true); |
|
375 | 375 | } |
376 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
377 | - $user_append_text = rand(10,1000); |
|
378 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
376 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
377 | + $user_append_text = rand(10, 1000); |
|
378 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
381 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
382 | 382 | $user_login = $email; |
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
386 | 386 | $userdata = array( |
387 | 387 | 'user_login' => $user_login, |
388 | - 'user_pass' => wp_generate_password( 12, false ), |
|
389 | - 'user_email' => sanitize_text_field( $email ), |
|
388 | + 'user_pass' => wp_generate_password(12, false), |
|
389 | + 'user_email' => sanitize_text_field($email), |
|
390 | 390 | 'first_name' => $first_name, |
391 | 391 | 'last_name' => $last_name, |
392 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
392 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
393 | 393 | 'nickname' => $display_name, |
394 | 394 | 'display_name' => $display_name, |
395 | 395 | ); |
396 | 396 | |
397 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
397 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
398 | 398 | |
399 | - $new_user_id = wp_insert_user( $userdata ); |
|
399 | + $new_user_id = wp_insert_user($userdata); |
|
400 | 400 | |
401 | - if ( !is_wp_error( $new_user_id ) ) { |
|
401 | + if (!is_wp_error($new_user_id)) { |
|
402 | 402 | $data['post_author'] = $new_user_id; |
403 | 403 | $_POST['post_author'] = $new_user_id; |
404 | 404 | $_POST['post_author_override'] = $new_user_id; |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | |
420 | 420 | $meta = array(); |
421 | 421 | ///$meta['_wpinv_user_id'] = $new_user_id; |
422 | - foreach ( $meta_fields as $field ) { |
|
423 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
422 | + foreach ($meta_fields as $field) { |
|
423 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
424 | 424 | } |
425 | 425 | |
426 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
426 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
427 | 427 | |
428 | 428 | // Update user meta. |
429 | - foreach ( $meta as $key => $value ) { |
|
430 | - update_user_meta( $new_user_id, $key, $value ); |
|
429 | + foreach ($meta as $key => $value) { |
|
430 | + update_user_meta($new_user_id, $key, $value); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
433 | + if (function_exists('wp_send_new_user_notifications')) { |
|
434 | 434 | // Send email notifications related to the creation of new user. |
435 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
435 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
436 | 436 | } |
437 | 437 | } else { |
438 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
438 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | 443 | return $data; |
444 | 444 | } |
445 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
446 | 445 | \ No newline at end of file |
446 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
447 | 447 | \ No newline at end of file |
@@ -1,22 +1,22 @@ discard block |
||
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,17 +29,17 @@ discard block |
||
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 ( $is_recurring ) { |
|
42 | + if ($is_recurring) { |
|
43 | 43 | $class .= ' wpi-recurring'; |
44 | 44 | } |
45 | 45 | ?> |
@@ -47,21 +47,21 @@ discard block |
||
47 | 47 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
48 | 48 | <thead> |
49 | 49 | <tr> |
50 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
51 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
52 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
53 | - <?php if ( $item_quantities ) { ?> |
|
54 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
50 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
51 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
52 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
53 | + <?php if ($item_quantities) { ?> |
|
54 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
55 | 55 | <?php } ?> |
56 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
57 | - <?php if ( $use_taxes ) { ?> |
|
58 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
56 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
57 | + <?php if ($use_taxes) { ?> |
|
58 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
59 | 59 | <?php } ?> |
60 | 60 | <th class="action"></th> |
61 | 61 | </tr> |
62 | 62 | </thead> |
63 | 63 | <tbody class="wpinv-line-items"> |
64 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
64 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
65 | 65 | </tbody> |
66 | 66 | <tfoot class="wpinv-totals"> |
67 | 67 | <tr> |
@@ -73,44 +73,44 @@ discard block |
||
73 | 73 | </td> |
74 | 74 | <td class="title"> |
75 | 75 | <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]"> |
76 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
76 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
77 | 77 | <div class="wp-clearfix"> |
78 | 78 | <label class="wpi-vat-rule"> |
79 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
79 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
80 | 80 | <span class="input-text-wrap"> |
81 | - <?php echo wpinv_html_select( array( |
|
81 | + <?php echo wpinv_html_select(array( |
|
82 | 82 | 'options' => $wpinv_euvat->get_rules(), |
83 | 83 | 'name' => '_wpinv_quick[vat_rule]', |
84 | 84 | 'id' => '_wpinv_quick_vat_rule', |
85 | 85 | 'show_option_all' => false, |
86 | 86 | 'show_option_none' => false, |
87 | 87 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
88 | - ) ); ?> |
|
88 | + )); ?> |
|
89 | 89 | </span> |
90 | 90 | </label> |
91 | 91 | </div> |
92 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
92 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
93 | 93 | <div class="wp-clearfix"> |
94 | 94 | <label class="wpi-vat-class"> |
95 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
95 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
96 | 96 | <span class="input-text-wrap"> |
97 | - <?php echo wpinv_html_select( array( |
|
97 | + <?php echo wpinv_html_select(array( |
|
98 | 98 | 'options' => $wpinv_euvat->get_all_classes(), |
99 | 99 | 'name' => '_wpinv_quick[vat_class]', |
100 | 100 | 'id' => '_wpinv_quick_vat_class', |
101 | 101 | 'show_option_all' => false, |
102 | 102 | 'show_option_none' => false, |
103 | 103 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
104 | - ) ); ?> |
|
104 | + )); ?> |
|
105 | 105 | </span> |
106 | 106 | </label> |
107 | 107 | </div> |
108 | 108 | <?php } ?> |
109 | 109 | <div class="wp-clearfix"> |
110 | 110 | <label class="wpi-item-type"> |
111 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
111 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
112 | 112 | <span class="input-text-wrap"> |
113 | - <?php echo wpinv_html_select( array( |
|
113 | + <?php echo wpinv_html_select(array( |
|
114 | 114 | 'options' => $item_types, |
115 | 115 | 'name' => '_wpinv_quick[type]', |
116 | 116 | 'id' => '_wpinv_quick_type', |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'show_option_all' => false, |
119 | 119 | 'show_option_none' => false, |
120 | 120 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
121 | - ) ); ?> |
|
121 | + )); ?> |
|
122 | 122 | </span> |
123 | 123 | </label> |
124 | 124 | </div> |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | </div> |
132 | 132 | </td> |
133 | 133 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
134 | - <?php if ( $item_quantities ) { ?> |
|
134 | + <?php if ($item_quantities) { ?> |
|
135 | 135 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
136 | 136 | <?php } ?> |
137 | 137 | <td class="total"></td> |
138 | - <?php if ( $use_taxes ) { ?> |
|
138 | + <?php if ($use_taxes) { ?> |
|
139 | 139 | <td class="tax"></td> |
140 | 140 | <?php } ?> |
141 | 141 | <td class="action"></td> |
@@ -148,29 +148,29 @@ discard block |
||
148 | 148 | <td colspan="<?php echo $cols; ?>"></td> |
149 | 149 | </tr> |
150 | 150 | <tr class="totals"> |
151 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
151 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
152 | 152 | <td colspan="4"> |
153 | 153 | <table cellspacing="0" cellpadding="0"> |
154 | 154 | <tr class="subtotal"> |
155 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
156 | - <td class="total"><?php echo $subtotal;?></td> |
|
155 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
156 | + <td class="total"><?php echo $subtotal; ?></td> |
|
157 | 157 | <td class="action"></td> |
158 | 158 | </tr> |
159 | 159 | <tr class="discount"> |
160 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
161 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
160 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
161 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
162 | 162 | <td class="action"></td> |
163 | 163 | </tr> |
164 | - <?php if ( $use_taxes ) { ?> |
|
164 | + <?php if ($use_taxes) { ?> |
|
165 | 165 | <tr class="tax"> |
166 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
167 | - <td class="total"><?php echo $tax;?></td> |
|
166 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
167 | + <td class="total"><?php echo $tax; ?></td> |
|
168 | 168 | <td class="action"></td> |
169 | 169 | </tr> |
170 | 170 | <?php } ?> |
171 | 171 | <tr class="total"> |
172 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
173 | - <td class="total"><?php echo $total;?></td> |
|
172 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
173 | + <td class="total"><?php echo $total; ?></td> |
|
174 | 174 | <td class="action"></td> |
175 | 175 | </tr> |
176 | 176 | </table> |
@@ -180,89 +180,89 @@ discard block |
||
180 | 180 | </table> |
181 | 181 | <div class="wpinv-actions"> |
182 | 182 | <?php |
183 | - if ( !$invoice->is_paid() ) { |
|
184 | - if ( !$invoice->is_recurring() ) { |
|
185 | - echo wpinv_item_dropdown( array( |
|
183 | + if (!$invoice->is_paid()) { |
|
184 | + if (!$invoice->is_recurring()) { |
|
185 | + echo wpinv_item_dropdown(array( |
|
186 | 186 | 'name' => 'wpinv_invoice_item', |
187 | 187 | 'id' => 'wpinv_invoice_item', |
188 | 188 | 'with_packages' => false, |
189 | 189 | 'show_recurring' => true, |
190 | - ) ); |
|
190 | + )); |
|
191 | 191 | ?> |
192 | - <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"> |
|
192 | + <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"> |
|
193 | 193 | <?php } ?> |
194 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
194 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
195 | 195 | </div> |
196 | 196 | </div> |
197 | 197 | <?php |
198 | 198 | } |
199 | 199 | |
200 | - public static function prices( $post ) { |
|
200 | + public static function prices($post) { |
|
201 | 201 | $symbol = wpinv_currency_symbol(); |
202 | 202 | $position = wpinv_currency_position(); |
203 | - $item = new WPInv_Item( $post->ID ); |
|
203 | + $item = new WPInv_Item($post->ID); |
|
204 | 204 | |
205 | 205 | $price = $item->get_price(); |
206 | 206 | $is_recurring = $item->is_recurring(); |
207 | 207 | $period = $item->get_recurring_period(); |
208 | - $interval = absint( $item->get_recurring_interval() ); |
|
209 | - $times = absint( $item->get_recurring_limit() ); |
|
208 | + $interval = absint($item->get_recurring_interval()); |
|
209 | + $times = absint($item->get_recurring_limit()); |
|
210 | 210 | $free_trial = $item->has_free_trial(); |
211 | 211 | $trial_interval = $item->get_trial_interval(); |
212 | 212 | $trial_period = $item->get_trial_period(); |
213 | 213 | |
214 | 214 | $intervals = array(); |
215 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
215 | + for ($i = 1; $i <= 90; $i++) { |
|
216 | 216 | $intervals[$i] = $i; |
217 | 217 | } |
218 | 218 | |
219 | - $interval = $interval > 0 ? $interval : 1; |
|
219 | + $interval = $interval > 0 ? $interval : 1; |
|
220 | 220 | |
221 | 221 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
222 | 222 | ?> |
223 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><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' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
224 | - <?php if ( $item->is_package() ) { ?> |
|
225 | - <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span> |
|
223 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><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' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
224 | + <?php if ($item->is_package()) { ?> |
|
225 | + <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span> |
|
226 | 226 | <?php } ?> |
227 | 227 | </p> |
228 | 228 | <p class="wpinv-row-is-recurring"> |
229 | 229 | <label for="wpinv_is_recurring"> |
230 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
231 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
230 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
231 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
232 | 232 | </label> |
233 | 233 | </p> |
234 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
235 | - <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> |
|
236 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
234 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
235 | + <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> |
|
236 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
237 | 237 | 'options' => $intervals, |
238 | 238 | 'name' => 'wpinv_recurring_interval', |
239 | 239 | 'id' => 'wpinv_recurring_interval', |
240 | 240 | 'selected' => $interval, |
241 | 241 | 'show_option_all' => false, |
242 | 242 | 'show_option_none' => false |
243 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
244 | - <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> |
|
243 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
244 | + <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> |
|
245 | 245 | <span class="clear wpi-trial-clr"></span> |
246 | 246 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
247 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
248 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
247 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
248 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
249 | 249 | </label> |
250 | 250 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
251 | - <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> |
|
251 | + <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> |
|
252 | 252 | </label> |
253 | 253 | </p> |
254 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
255 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
254 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
255 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
256 | 256 | <?php |
257 | 257 | } |
258 | 258 | |
259 | - public static function vat_rules( $post ) { |
|
259 | + public static function vat_rules($post) { |
|
260 | 260 | global $wpinv_euvat; |
261 | 261 | |
262 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
262 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
263 | 263 | ?> |
264 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
265 | - <?php echo wpinv_html_select( array( |
|
264 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
265 | + <?php echo wpinv_html_select(array( |
|
266 | 266 | 'options' => $wpinv_euvat->get_rules(), |
267 | 267 | 'name' => 'wpinv_vat_rules', |
268 | 268 | 'id' => 'wpinv_vat_rules', |
@@ -270,19 +270,19 @@ discard block |
||
270 | 270 | 'show_option_all' => false, |
271 | 271 | 'show_option_none' => false, |
272 | 272 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
273 | - ) ); ?> |
|
273 | + )); ?> |
|
274 | 274 | </p> |
275 | - <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> |
|
276 | - <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> |
|
275 | + <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> |
|
276 | + <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> |
|
277 | 277 | <?php |
278 | 278 | } |
279 | 279 | |
280 | - public static function vat_classes( $post ) { |
|
280 | + public static function vat_classes($post) { |
|
281 | 281 | global $wpinv_euvat; |
282 | 282 | |
283 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
283 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
284 | 284 | ?> |
285 | - <p><?php echo wpinv_html_select( array( |
|
285 | + <p><?php echo wpinv_html_select(array( |
|
286 | 286 | 'options' => $wpinv_euvat->get_all_classes(), |
287 | 287 | 'name' => 'wpinv_vat_class', |
288 | 288 | 'id' => 'wpinv_vat_class', |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | 'show_option_all' => false, |
291 | 291 | 'show_option_none' => false, |
292 | 292 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
293 | - ) ); ?> |
|
293 | + )); ?> |
|
294 | 294 | </p> |
295 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
295 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
296 | 296 | <?php |
297 | 297 | } |
298 | 298 | |
299 | - public static function item_info( $post ) { |
|
300 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
301 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
299 | + public static function item_info($post) { |
|
300 | + $item_type = wpinv_get_item_type($post->ID); |
|
301 | + do_action('wpinv_item_info_metabox_before', $post); |
|
302 | 302 | ?> |
303 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
304 | - <?php echo wpinv_html_select( array( |
|
303 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
304 | + <?php echo wpinv_html_select(array( |
|
305 | 305 | 'options' => wpinv_get_item_types(), |
306 | 306 | 'name' => 'wpinv_item_type', |
307 | 307 | 'id' => 'wpinv_item_type', |
@@ -310,114 +310,114 @@ discard block |
||
310 | 310 | 'show_option_none' => false, |
311 | 311 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
312 | 312 | //'disabled' => $item_type == 'package' ? true : false, |
313 | - ) ); ?> |
|
313 | + )); ?> |
|
314 | 314 | </p> |
315 | - <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> |
|
315 | + <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> |
|
316 | 316 | <?php |
317 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
317 | + do_action('wpinv_item_info_metabox_after', $post); |
|
318 | 318 | } |
319 | 319 | |
320 | - public static function meta_values( $post ) { |
|
321 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
320 | + public static function meta_values($post) { |
|
321 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
322 | 322 | 'type', |
323 | 323 | 'custom_id' |
324 | - ) ); |
|
324 | + )); |
|
325 | 325 | |
326 | - if ( empty( $meta_keys ) ) { |
|
326 | + if (empty($meta_keys)) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
330 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
331 | 331 | |
332 | - foreach ( $meta_keys as $meta_key ) { |
|
332 | + foreach ($meta_keys as $meta_key) { |
|
333 | 333 | ?> |
334 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
334 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
335 | 335 | <?php |
336 | 336 | } |
337 | 337 | |
338 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
338 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
339 | 339 | } |
340 | 340 | |
341 | - public static function save( $post_id, $data, $post ) { |
|
342 | - $invoice = new WPInv_Invoice( $post_id ); |
|
341 | + public static function save($post_id, $data, $post) { |
|
342 | + $invoice = new WPInv_Invoice($post_id); |
|
343 | 343 | |
344 | 344 | // Billing |
345 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
346 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
347 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
348 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
349 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
350 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
351 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
352 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
353 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
354 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
345 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
346 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
347 | + $company = sanitize_text_field($data['wpinv_company']); |
|
348 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
349 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
350 | + $address = sanitize_text_field($data['wpinv_address']); |
|
351 | + $city = sanitize_text_field($data['wpinv_city']); |
|
352 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
353 | + $country = sanitize_text_field($data['wpinv_country']); |
|
354 | + $state = sanitize_text_field($data['wpinv_state']); |
|
355 | 355 | |
356 | 356 | // Details |
357 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
358 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
359 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
360 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
357 | + $status = sanitize_text_field($data['wpinv_status']); |
|
358 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
359 | + $number = sanitize_text_field($data['wpinv_number']); |
|
360 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
361 | 361 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
362 | 362 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
363 | 363 | |
364 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
364 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
365 | 365 | |
366 | - $invoice->set( 'due_date', $due_date ); |
|
367 | - $invoice->set( 'first_name', $first_name ); |
|
368 | - $invoice->set( 'last_name', $last_name ); |
|
369 | - $invoice->set( 'company', $company ); |
|
370 | - $invoice->set( 'vat_number', $vat_number ); |
|
371 | - $invoice->set( 'phone', $phone ); |
|
372 | - $invoice->set( 'address', $address ); |
|
373 | - $invoice->set( 'city', $city ); |
|
374 | - $invoice->set( 'zip', $zip ); |
|
375 | - $invoice->set( 'country', $country ); |
|
376 | - $invoice->set( 'state', $state ); |
|
377 | - $invoice->set( 'status', $status ); |
|
366 | + $invoice->set('due_date', $due_date); |
|
367 | + $invoice->set('first_name', $first_name); |
|
368 | + $invoice->set('last_name', $last_name); |
|
369 | + $invoice->set('company', $company); |
|
370 | + $invoice->set('vat_number', $vat_number); |
|
371 | + $invoice->set('phone', $phone); |
|
372 | + $invoice->set('address', $address); |
|
373 | + $invoice->set('city', $city); |
|
374 | + $invoice->set('zip', $zip); |
|
375 | + $invoice->set('country', $country); |
|
376 | + $invoice->set('state', $state); |
|
377 | + $invoice->set('status', $status); |
|
378 | 378 | //$invoice->set( 'number', $number ); |
379 | 379 | //$invoice->set( 'discounts', $discounts ); |
380 | 380 | //$invoice->set( 'discount', $discount ); |
381 | - $invoice->set( 'ip', $ip ); |
|
381 | + $invoice->set('ip', $ip); |
|
382 | 382 | $invoice->old_status = $_POST['original_post_status']; |
383 | 383 | $invoice->currency = wpinv_get_currency(); |
384 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
385 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
384 | + if (!empty($data['wpinv_gateway'])) { |
|
385 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
386 | 386 | } |
387 | 387 | $saved = $invoice->save(); |
388 | 388 | |
389 | 389 | // Check for payment notes |
390 | - if ( !empty( $data['invoice_note'] ) ) { |
|
391 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
392 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
390 | + if (!empty($data['invoice_note'])) { |
|
391 | + $note = wp_kses($data['invoice_note'], array()); |
|
392 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
393 | 393 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
394 | 394 | |
395 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
395 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | // Update user address if empty. |
399 | - if ( $saved && !empty( $invoice ) ) { |
|
400 | - if ( $user_id = $invoice->get_user_id() ) { |
|
401 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
399 | + if ($saved && !empty($invoice)) { |
|
400 | + if ($user_id = $invoice->get_user_id()) { |
|
401 | + $user_address = wpinv_get_user_address($user_id, false); |
|
402 | 402 | |
403 | 403 | if (empty($user_address['first_name'])) { |
404 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
405 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
404 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
405 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
406 | 406 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
407 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
407 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
411 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
412 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
413 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
414 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
415 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
416 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
411 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
412 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
413 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
414 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
415 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
416 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
420 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | return $saved; |
@@ -1,30 +1,30 @@ discard block |
||
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_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | 10 | $statuses = wpinv_get_invoice_statuses(); |
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
28 | 28 | |
29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | <div class="gdmbx2-wrap form-table"> |
35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
39 | 39 | </div> |
40 | - <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
40 | + <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | <?php } ?> |
48 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
48 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
49 | 49 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
50 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
51 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
50 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
51 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
52 | 52 | </div> |
53 | 53 | <?php } ?> |
54 | 54 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
55 | 55 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
56 | 56 | <div class="gdmbx-td"> |
57 | 57 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
58 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
59 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
58 | + <?php foreach ($statuses as $value => $label) { ?> |
|
59 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
60 | 60 | <?php } ?> |
61 | 61 | </select> |
62 | 62 | </div> |
@@ -64,107 +64,107 @@ discard block |
||
64 | 64 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
65 | 65 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
66 | 66 | <div class="gdmbx-td"> |
67 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
67 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?> |
|
71 | - <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?> |
|
70 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); ?> |
|
71 | + <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?> |
|
72 | 72 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
73 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
73 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
74 | 74 | <div class="gdmbx-td"> |
75 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
75 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
76 | 76 | </div> |
77 | 77 | </div> |
78 | 78 | <?php } ?> |
79 | 79 | </div> |
80 | 80 | </div> |
81 | 81 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
82 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
82 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
83 | 83 | <select id="wpi_save_send" name="wpi_save_send"> |
84 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
85 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
84 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
85 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
86 | 86 | </select> |
87 | 87 | </p> |
88 | 88 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
89 | 89 | </div> |
90 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
90 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
91 | 91 | <?php |
92 | 92 | } |
93 | 93 | |
94 | - public static function resend_invoice( $post ) { |
|
94 | + public static function resend_invoice($post) { |
|
95 | 95 | global $wpi_mb_invoice; |
96 | 96 | |
97 | - if ( empty( $wpi_mb_invoice ) ) { |
|
97 | + if (empty($wpi_mb_invoice)) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
101 | 101 | $text = array( |
102 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
103 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
102 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
103 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
107 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
107 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
108 | 108 | |
109 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
109 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
110 | 110 | $email_actions = array(); |
111 | - $email_actions['email_url'] = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ); |
|
112 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
111 | + $email_actions['email_url'] = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)); |
|
112 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
113 | 113 | |
114 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
114 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
115 | 115 | ?> |
116 | 116 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
117 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
118 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
119 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
117 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
118 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
119 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
120 | 120 | <?php } ?> |
121 | 121 | <?php |
122 | 122 | } |
123 | 123 | |
124 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
124 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
125 | 125 | } |
126 | 126 | |
127 | - public static function subscriptions( $post ) { |
|
127 | + public static function subscriptions($post) { |
|
128 | 128 | global $wpi_mb_invoice; |
129 | 129 | |
130 | 130 | $invoice = $wpi_mb_invoice; |
131 | 131 | |
132 | - if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
132 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
133 | 133 | $payments = $invoice->get_child_payments(); |
134 | 134 | |
135 | 135 | $total_payments = (int)$invoice->get_total_payments(); |
136 | 136 | $subscription = $invoice->get_subscription_data(); |
137 | 137 | |
138 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
139 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
138 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
139 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
140 | 140 | $subscription_status = $invoice->get_subscription_status(); |
141 | 141 | ?> |
142 | - <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p> |
|
143 | - <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?> |
|
144 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p> |
|
142 | + <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
|
143 | + <?php if ($subscription_id = $invoice->get_subscription_id()) { ?> |
|
144 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p> |
|
145 | 145 | <?php } ?> |
146 | - <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p> |
|
147 | - <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p> |
|
148 | - <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?> |
|
149 | - <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
150 | - <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
151 | - <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?> |
|
152 | - <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p> |
|
146 | + <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p> |
|
147 | + <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p> |
|
148 | + <?php if (!empty($payments) || $invoice->is_paid()) { ?> |
|
149 | + <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
150 | + <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
151 | + <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?> |
|
152 | + <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p> |
|
153 | 153 | <?php } ?> |
154 | - <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?> |
|
155 | - <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p> |
|
154 | + <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?> |
|
155 | + <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p> |
|
156 | 156 | <?php } ?> |
157 | - <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?> |
|
158 | - <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p> |
|
157 | + <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?> |
|
158 | + <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p> |
|
159 | 159 | <?php } ?> |
160 | - <?php if ( !empty( $payments ) ) { ?> |
|
161 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
160 | + <?php if (!empty($payments)) { ?> |
|
161 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
162 | 162 | <ul id="wpi-sub-payments"> |
163 | - <?php foreach ( $payments as $invoice_id ) { ?> |
|
163 | + <?php foreach ($payments as $invoice_id) { ?> |
|
164 | 164 | <li> |
165 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
166 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
167 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
165 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
166 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
167 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
168 | 168 | </li> |
169 | 169 | <?php } ?> |
170 | 170 | </ul> |
@@ -172,47 +172,47 @@ discard block |
||
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | - public static function renewals( $post ) { |
|
175 | + public static function renewals($post) { |
|
176 | 176 | global $wpi_mb_invoice; |
177 | 177 | |
178 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
179 | - $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice ); |
|
180 | - $parent_id = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice ); |
|
178 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
179 | + $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice); |
|
180 | + $parent_id = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice); |
|
181 | 181 | ?> |
182 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
183 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
182 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
183 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
184 | 184 | <?php |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - public static function payment_meta( $post ) { |
|
188 | + public static function payment_meta($post) { |
|
189 | 189 | global $wpi_mb_invoice; |
190 | 190 | |
191 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
192 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) { |
|
191 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
192 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) { |
|
193 | 193 | $set_dateway = true; |
194 | 194 | } |
195 | 195 | |
196 | 196 | ?> |
197 | 197 | <p class="wpi-meta-row"> |
198 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
199 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
198 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
199 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
200 | 200 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
201 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
202 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
201 | + <?php foreach ($gateways as $name => $gateway) { |
|
202 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | ?> |
206 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
206 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
207 | 207 | <?php } ?> |
208 | 208 | </select> |
209 | 209 | <?php } else { |
210 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) ); |
|
210 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway)); |
|
211 | 211 | } ?> |
212 | 212 | </p> |
213 | - <?php if ( $wpi_mb_invoice->is_paid() ) { ?> |
|
214 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p> |
|
215 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
213 | + <?php if ($wpi_mb_invoice->is_paid()) { ?> |
|
214 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p> |
|
215 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
216 | 216 | <?php } ?> |
217 | 217 | <?php |
218 | 218 | } |
@@ -1,65 +1,65 @@ discard block |
||
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 |
||
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 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | class WPInv_EUVat { |
6 | 6 | private static $is_ajax = false; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | private static $instance = false; |
9 | 9 | |
10 | 10 | public static function get_instance() { |
11 | - if ( !self::$instance ) { |
|
11 | + if (!self::$instance) { |
|
12 | 12 | self::$instance = new self(); |
13 | 13 | self::$instance->actions(); |
14 | 14 | } |
@@ -17,132 +17,132 @@ discard block |
||
17 | 17 | } |
18 | 18 | |
19 | 19 | public function __construct() { |
20 | - self::$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
20 | + self::$is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
21 | 21 | self::$default_country = wpinv_get_default_country(); |
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function actions() { |
25 | - if ( is_admin() ) { |
|
26 | - add_action( 'admin_enqueue_scripts', array( self::$instance, 'enqueue_admin_scripts' ) ); |
|
27 | - add_action( 'wpinv_settings_sections_taxes', array( self::$instance, 'section_vat_settings' ) ); |
|
28 | - add_action( 'wpinv_settings_taxes', array( self::$instance, 'vat_settings' ) ); |
|
29 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( self::$instance, 'sanitize_vat_settings' ) ); |
|
30 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( self::$instance, 'sanitize_vat_rates' ) ); |
|
31 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
32 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
33 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
34 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
35 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
36 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
37 | - add_action( 'wp_ajax_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
38 | - add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
39 | - } |
|
40 | - |
|
41 | - add_action( 'wp_enqueue_scripts', array( self::$instance, 'enqueue_vat_scripts' ) ); |
|
42 | - add_filter( 'wpinv_default_billing_country', array( self::$instance, 'get_user_country' ), 10 ); |
|
43 | - add_filter( 'wpinv_get_user_country', array( self::$instance, 'set_user_country' ), 10 ); |
|
44 | - add_action( 'wp_ajax_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
45 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
46 | - add_action( 'wp_ajax_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
47 | - add_action( 'wp_ajax_nopriv_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
48 | - add_action( 'wpinv_invoice_print_after_line_items', array( self::$instance, 'show_vat_notice' ), 999, 1 ); |
|
49 | - if ( wpinv_use_taxes() ) { |
|
50 | - add_action( 'wpinv_after_billing_fields', array( self::$instance, 'checkout_vat_fields' ) ); |
|
51 | - if ( self::allow_vat_rules() ) { |
|
52 | - add_action( 'wpinv_checkout_error_checks', array( self::$instance, 'checkout_vat_validate' ), 10, 2 ); |
|
53 | - add_filter( 'wpinv_tax_rate', array( self::$instance, 'get_rate' ), 10, 4 ); |
|
25 | + if (is_admin()) { |
|
26 | + add_action('admin_enqueue_scripts', array(self::$instance, 'enqueue_admin_scripts')); |
|
27 | + add_action('wpinv_settings_sections_taxes', array(self::$instance, 'section_vat_settings')); |
|
28 | + add_action('wpinv_settings_taxes', array(self::$instance, 'vat_settings')); |
|
29 | + add_filter('wpinv_settings_taxes-vat_sanitize', array(self::$instance, 'sanitize_vat_settings')); |
|
30 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array(self::$instance, 'sanitize_vat_rates')); |
|
31 | + add_action('wp_ajax_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
32 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
33 | + add_action('wp_ajax_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
34 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
35 | + add_action('wp_ajax_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
36 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
37 | + add_action('wp_ajax_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
38 | + add_action('wp_ajax_nopriv_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
39 | + } |
|
40 | + |
|
41 | + add_action('wp_enqueue_scripts', array(self::$instance, 'enqueue_vat_scripts')); |
|
42 | + add_filter('wpinv_default_billing_country', array(self::$instance, 'get_user_country'), 10); |
|
43 | + add_filter('wpinv_get_user_country', array(self::$instance, 'set_user_country'), 10); |
|
44 | + add_action('wp_ajax_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
45 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
46 | + add_action('wp_ajax_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
47 | + add_action('wp_ajax_nopriv_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
48 | + add_action('wpinv_invoice_print_after_line_items', array(self::$instance, 'show_vat_notice'), 999, 1); |
|
49 | + if (wpinv_use_taxes()) { |
|
50 | + add_action('wpinv_after_billing_fields', array(self::$instance, 'checkout_vat_fields')); |
|
51 | + if (self::allow_vat_rules()) { |
|
52 | + add_action('wpinv_checkout_error_checks', array(self::$instance, 'checkout_vat_validate'), 10, 2); |
|
53 | + add_filter('wpinv_tax_rate', array(self::$instance, 'get_rate'), 10, 4); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - public static function get_eu_states( $sort = true ) { |
|
59 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
60 | - if ( $sort ) { |
|
61 | - $sort = sort( $eu_states ); |
|
58 | + public static function get_eu_states($sort = true) { |
|
59 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
60 | + if ($sort) { |
|
61 | + $sort = sort($eu_states); |
|
62 | 62 | } |
63 | 63 | |
64 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
64 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
65 | 65 | } |
66 | 66 | |
67 | - public static function get_gst_countries( $sort = true ) { |
|
68 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
67 | + public static function get_gst_countries($sort = true) { |
|
68 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
69 | 69 | |
70 | - if ( $sort ) { |
|
71 | - $sort = sort( $gst_countries ); |
|
70 | + if ($sort) { |
|
71 | + $sort = sort($gst_countries); |
|
72 | 72 | } |
73 | 73 | |
74 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
74 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function is_eu_state( $country_code ) { |
|
78 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
77 | + public static function is_eu_state($country_code) { |
|
78 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
79 | 79 | |
80 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
80 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
81 | 81 | } |
82 | 82 | |
83 | - public static function is_gst_country( $country_code ) { |
|
84 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
83 | + public static function is_gst_country($country_code) { |
|
84 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
85 | 85 | |
86 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
86 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | public static function enqueue_vat_scripts() { |
90 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
90 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
91 | 91 | |
92 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
93 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
92 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
93 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
94 | 94 | |
95 | - $vat_name = self::get_vat_name(); |
|
95 | + $vat_name = self::get_vat_name(); |
|
96 | 96 | |
97 | 97 | $vars = array(); |
98 | 98 | $vars['UseTaxes'] = wpinv_use_taxes(); |
99 | 99 | $vars['EUStates'] = self::get_eu_states(); |
100 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
101 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
102 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
103 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
104 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
105 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
106 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
107 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
100 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
101 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
102 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
103 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
104 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
105 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
106 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
107 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
108 | 108 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
109 | 109 | $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true; |
110 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
111 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
112 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
113 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
114 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
115 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
116 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
117 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
118 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
119 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
120 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
121 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
122 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
110 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
111 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
112 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
113 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
114 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
115 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
116 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
117 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
118 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
119 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
120 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
121 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
122 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
123 | 123 | $vars['isFront'] = is_admin() ? false : true; |
124 | - $vars['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
124 | + $vars['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
125 | 125 | $vars['baseCountry'] = wpinv_get_default_country(); |
126 | - $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false ); |
|
127 | - $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false; |
|
126 | + $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false); |
|
127 | + $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false; |
|
128 | 128 | |
129 | - wp_enqueue_script( 'wpinv-vat-validation-script' ); |
|
130 | - wp_enqueue_script( 'wpinv-vat-script' ); |
|
131 | - wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars ); |
|
129 | + wp_enqueue_script('wpinv-vat-validation-script'); |
|
130 | + wp_enqueue_script('wpinv-vat-script'); |
|
131 | + wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function enqueue_admin_scripts() { |
135 | - if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
|
135 | + if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) { |
|
136 | 136 | self::enqueue_vat_scripts(); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - public static function section_vat_settings( $sections ) { |
|
141 | - if ( !empty( $sections ) ) { |
|
142 | - $sections['vat'] = __( 'EU VAT Settings', 'invoicing' ); |
|
140 | + public static function section_vat_settings($sections) { |
|
141 | + if (!empty($sections)) { |
|
142 | + $sections['vat'] = __('EU VAT Settings', 'invoicing'); |
|
143 | 143 | |
144 | - if ( self::allow_vat_classes() ) { |
|
145 | - $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' ); |
|
144 | + if (self::allow_vat_classes()) { |
|
145 | + $sections['vat_rates'] = __('EU VAT Rates', 'invoicing'); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | return $sections; |
@@ -151,52 +151,52 @@ discard block |
||
151 | 151 | public static function vat_rates_settings() { |
152 | 152 | $vat_classes = self::get_rate_classes(); |
153 | 153 | $vat_rates = array(); |
154 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new'; |
|
155 | - $current_url = remove_query_arg( 'wpi_sub' ); |
|
154 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new'; |
|
155 | + $current_url = remove_query_arg('wpi_sub'); |
|
156 | 156 | |
157 | 157 | $vat_rates['vat_rates_header'] = array( |
158 | 158 | 'id' => 'vat_rates_header', |
159 | - 'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>', |
|
159 | + 'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>', |
|
160 | 160 | 'desc' => '', |
161 | 161 | 'type' => 'header', |
162 | 162 | 'size' => 'regular' |
163 | 163 | ); |
164 | 164 | $vat_rates['vat_rates_class'] = array( |
165 | 165 | 'id' => 'vat_rates_class', |
166 | - 'name' => __( 'Edit VAT Rates', 'invoicing' ), |
|
167 | - 'desc' => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ), |
|
166 | + 'name' => __('Edit VAT Rates', 'invoicing'), |
|
167 | + 'desc' => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'), |
|
168 | 168 | 'type' => 'select', |
169 | - 'options' => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ), |
|
169 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
170 | 170 | 'chosen' => true, |
171 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
171 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
172 | 172 | 'selected' => $vat_class, |
173 | 173 | 'onchange' => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;', |
174 | 174 | ); |
175 | 175 | |
176 | - if ( $vat_class != '_standard' && $vat_class != '_new' ) { |
|
176 | + if ($vat_class != '_standard' && $vat_class != '_new') { |
|
177 | 177 | $vat_rates['vat_rate_delete'] = array( |
178 | 178 | 'id' => 'vat_rate_delete', |
179 | 179 | 'type' => 'vat_rate_delete', |
180 | 180 | ); |
181 | 181 | } |
182 | 182 | |
183 | - if ( $vat_class == '_new' ) { |
|
183 | + if ($vat_class == '_new') { |
|
184 | 184 | $vat_rates['vat_rates_settings'] = array( |
185 | 185 | 'id' => 'vat_rates_settings', |
186 | - 'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>', |
|
186 | + 'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>', |
|
187 | 187 | 'type' => 'header', |
188 | 188 | ); |
189 | 189 | $vat_rates['vat_rate_name'] = array( |
190 | 190 | 'id' => 'vat_rate_name', |
191 | - 'name' => __( 'Name', 'invoicing' ), |
|
192 | - 'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ), |
|
191 | + 'name' => __('Name', 'invoicing'), |
|
192 | + 'desc' => __('A short name for the new VAT Rate class', 'invoicing'), |
|
193 | 193 | 'type' => 'text', |
194 | 194 | 'size' => 'regular', |
195 | 195 | ); |
196 | 196 | $vat_rates['vat_rate_desc'] = array( |
197 | 197 | 'id' => 'vat_rate_desc', |
198 | - 'name' => __( 'Description', 'invoicing' ), |
|
199 | - 'desc' => __( 'Manage VAT Rate class', 'invoicing' ), |
|
198 | + 'name' => __('Description', 'invoicing'), |
|
199 | + 'desc' => __('Manage VAT Rate class', 'invoicing'), |
|
200 | 200 | 'type' => 'text', |
201 | 201 | 'size' => 'regular', |
202 | 202 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $vat_rates['vat_rates'] = array( |
209 | 209 | 'id' => 'vat_rates', |
210 | 210 | 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>', |
211 | - 'desc' => self::get_class_desc( $vat_class ), |
|
211 | + 'desc' => self::get_class_desc($vat_class), |
|
212 | 212 | 'type' => 'vat_rates', |
213 | 213 | ); |
214 | 214 | } |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | return $vat_rates; |
217 | 217 | } |
218 | 218 | |
219 | - public static function vat_settings( $settings ) { |
|
220 | - if ( !empty( $settings ) ) { |
|
219 | + public static function vat_settings($settings) { |
|
220 | + if (!empty($settings)) { |
|
221 | 221 | $vat_settings = array(); |
222 | 222 | $vat_settings['vat_company_title'] = array( |
223 | 223 | 'id' => 'vat_company_title', |
224 | - 'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>', |
|
224 | + 'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>', |
|
225 | 225 | 'desc' => '', |
226 | 226 | 'type' => 'header', |
227 | 227 | 'size' => 'regular' |
@@ -229,22 +229,22 @@ discard block |
||
229 | 229 | |
230 | 230 | $vat_settings['vat_company_name'] = array( |
231 | 231 | 'id' => 'vat_company_name', |
232 | - 'name' => __( 'Your Company Name', 'invoicing' ), |
|
233 | - 'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
232 | + 'name' => __('Your Company Name', 'invoicing'), |
|
233 | + 'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
234 | 234 | 'type' => 'text', |
235 | 235 | 'size' => 'regular', |
236 | 236 | ); |
237 | 237 | |
238 | 238 | $vat_settings['vat_number'] = array( |
239 | 239 | 'id' => 'vat_number', |
240 | - 'name' => __( 'Your VAT Number', 'invoicing' ), |
|
240 | + 'name' => __('Your VAT Number', 'invoicing'), |
|
241 | 241 | 'type' => 'vat_number', |
242 | 242 | 'size' => 'regular', |
243 | 243 | ); |
244 | 244 | |
245 | 245 | $vat_settings['vat_settings_title'] = array( |
246 | 246 | 'id' => 'vat_settings_title', |
247 | - 'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>', |
|
247 | + 'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>', |
|
248 | 248 | 'desc' => '', |
249 | 249 | 'type' => 'header', |
250 | 250 | 'size' => 'regular' |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | |
253 | 253 | $vat_settings['apply_vat_rules'] = array( |
254 | 254 | 'id' => 'apply_vat_rules', |
255 | - 'name' => __( 'Enable VAT Rules', 'invoicing' ), |
|
256 | - 'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>', |
|
255 | + 'name' => __('Enable VAT Rules', 'invoicing'), |
|
256 | + 'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>', |
|
257 | 257 | 'type' => 'checkbox', |
258 | 258 | 'std' => '1' |
259 | 259 | ); |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | |
270 | 270 | $vat_settings['vat_prevent_b2c_purchase'] = array( |
271 | 271 | 'id' => 'vat_prevent_b2c_purchase', |
272 | - 'name' => __( 'Prevent EU B2C Sales', 'invoicing' ), |
|
273 | - 'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ), |
|
272 | + 'name' => __('Prevent EU B2C Sales', 'invoicing'), |
|
273 | + 'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'), |
|
274 | 274 | 'type' => 'checkbox' |
275 | 275 | ); |
276 | 276 | |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | |
279 | 279 | $vat_settings['vat_same_country_rule'] = array( |
280 | 280 | 'id' => 'vat_same_country_rule', |
281 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
282 | - 'desc' => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ), |
|
281 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
282 | + 'desc' => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'), |
|
283 | 283 | 'type' => 'select', |
284 | 284 | 'options' => array( |
285 | - '' => __( 'Normal', 'invoicing' ), |
|
286 | - 'no' => __( 'No VAT', 'invoicing' ), |
|
287 | - 'always' => __( 'Always apply VAT', 'invoicing' ), |
|
285 | + '' => __('Normal', 'invoicing'), |
|
286 | + 'no' => __('No VAT', 'invoicing'), |
|
287 | + 'always' => __('Always apply VAT', 'invoicing'), |
|
288 | 288 | ), |
289 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
289 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
290 | 290 | 'std' => '' |
291 | 291 | ); |
292 | 292 | |
293 | 293 | $vat_settings['vat_checkout_title'] = array( |
294 | 294 | 'id' => 'vat_checkout_title', |
295 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
295 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
296 | 296 | 'desc' => '', |
297 | 297 | 'type' => 'header', |
298 | 298 | 'size' => 'regular' |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | |
301 | 301 | $vat_settings['vat_disable_fields'] = array( |
302 | 302 | 'id' => 'vat_disable_fields', |
303 | - 'name' => __( 'Disable VAT Fields', 'invoicing' ), |
|
304 | - 'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>', |
|
303 | + 'name' => __('Disable VAT Fields', 'invoicing'), |
|
304 | + 'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>', |
|
305 | 305 | 'type' => 'checkbox' |
306 | 306 | ); |
307 | 307 | |
308 | 308 | $vat_settings['vat_ip_lookup'] = array( |
309 | 309 | 'id' => 'vat_ip_lookup', |
310 | - 'name' => __( 'IP Country Look-up', 'invoicing' ), |
|
310 | + 'name' => __('IP Country Look-up', 'invoicing'), |
|
311 | 311 | 'type' => 'vat_ip_lookup', |
312 | 312 | 'size' => 'regular', |
313 | 313 | 'std' => 'default' |
@@ -315,21 +315,21 @@ discard block |
||
315 | 315 | |
316 | 316 | $vat_settings['hide_ip_address'] = array( |
317 | 317 | 'id' => 'hide_ip_address', |
318 | - 'name' => __( 'Hide IP Info at Checkout', 'invoicing' ), |
|
319 | - 'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ), |
|
318 | + 'name' => __('Hide IP Info at Checkout', 'invoicing'), |
|
319 | + 'desc' => __('Hide the user IP info at checkout.', 'invoicing'), |
|
320 | 320 | 'type' => 'checkbox' |
321 | 321 | ); |
322 | 322 | |
323 | 323 | $vat_settings['vat_ip_country_default'] = array( |
324 | 324 | 'id' => 'vat_ip_country_default', |
325 | - 'name' => __( 'Enable IP Country as Default', 'invoicing' ), |
|
326 | - 'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ), |
|
325 | + 'name' => __('Enable IP Country as Default', 'invoicing'), |
|
326 | + 'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'), |
|
327 | 327 | 'type' => 'checkbox' |
328 | 328 | ); |
329 | 329 | |
330 | 330 | $vat_settings['vies_validation_title'] = array( |
331 | 331 | 'id' => 'vies_validation_title', |
332 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
332 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
333 | 333 | 'desc' => '', |
334 | 334 | 'type' => 'header', |
335 | 335 | 'size' => 'regular' |
@@ -337,37 +337,37 @@ discard block |
||
337 | 337 | |
338 | 338 | $vat_settings['vat_vies_check'] = array( |
339 | 339 | 'id' => 'vat_vies_check', |
340 | - 'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ), |
|
341 | - 'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
340 | + 'name' => __('Disable VIES VAT ID Check', 'invoicing'), |
|
341 | + 'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
342 | 342 | 'type' => 'checkbox' |
343 | 343 | ); |
344 | 344 | |
345 | 345 | $vat_settings['vat_disable_company_name_check'] = array( |
346 | 346 | 'id' => 'vat_disable_company_name_check', |
347 | - 'name' => __( 'Disable VIES Name Check', 'invoicing' ), |
|
348 | - 'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
347 | + 'name' => __('Disable VIES Name Check', 'invoicing'), |
|
348 | + 'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
349 | 349 | 'type' => 'checkbox' |
350 | 350 | ); |
351 | 351 | |
352 | 352 | $vat_settings['vat_offline_check'] = array( |
353 | 353 | 'id' => 'vat_offline_check', |
354 | - 'name' => __( 'Disable Basic Checks', 'invoicing' ), |
|
355 | - 'desc' => __( 'This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing' ), |
|
354 | + 'name' => __('Disable Basic Checks', 'invoicing'), |
|
355 | + 'desc' => __('This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing'), |
|
356 | 356 | 'type' => 'checkbox' |
357 | 357 | ); |
358 | 358 | |
359 | 359 | |
360 | 360 | $settings['vat'] = $vat_settings; |
361 | 361 | |
362 | - if ( self::allow_vat_classes() ) { |
|
362 | + if (self::allow_vat_classes()) { |
|
363 | 363 | $settings['vat_rates'] = self::vat_rates_settings(); |
364 | 364 | } |
365 | 365 | |
366 | 366 | $eu_fallback_rate = array( |
367 | 367 | 'id' => 'eu_fallback_rate', |
368 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
368 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
369 | 369 | 'type' => 'eu_fallback_rate', |
370 | - 'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ), |
|
370 | + 'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'), |
|
371 | 371 | 'std' => '20', |
372 | 372 | 'size' => 'small' |
373 | 373 | ); |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | $database_url = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/'; |
384 | 384 | $destination_dir = $upload_dir['basedir'] . '/invoicing'; |
385 | 385 | |
386 | - if ( !is_dir( $destination_dir ) ) { |
|
387 | - mkdir( $destination_dir ); |
|
386 | + if (!is_dir($destination_dir)) { |
|
387 | + mkdir($destination_dir); |
|
388 | 388 | } |
389 | 389 | |
390 | - $database_files = array( |
|
390 | + $database_files = array( |
|
391 | 391 | 'country' => array( |
392 | 392 | 'source' => $database_url . 'GeoLite2-Country.mmdb.gz', |
393 | 393 | 'destination' => $destination_dir . '/GeoLite2-Country.mmdb', |
@@ -398,57 +398,57 @@ discard block |
||
398 | 398 | ) |
399 | 399 | ); |
400 | 400 | |
401 | - foreach( $database_files as $database => $files ) { |
|
402 | - $result = self::geoip2_download_file( $files['source'], $files['destination'] ); |
|
401 | + foreach ($database_files as $database => $files) { |
|
402 | + $result = self::geoip2_download_file($files['source'], $files['destination']); |
|
403 | 403 | |
404 | - if ( empty( $result['success'] ) ) { |
|
404 | + if (empty($result['success'])) { |
|
405 | 405 | echo $result['message']; |
406 | 406 | exit; |
407 | 407 | } |
408 | 408 | |
409 | - wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
|
410 | - echo sprintf(__( 'GeoIp2 %s database updated successfully.', 'invoicing' ), $database ) . ' '; |
|
409 | + wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp')); |
|
410 | + echo sprintf(__('GeoIp2 %s database updated successfully.', 'invoicing'), $database) . ' '; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | exit; |
414 | 414 | } |
415 | 415 | |
416 | - public static function geoip2_download_file( $source_url, $destination_file ) { |
|
416 | + public static function geoip2_download_file($source_url, $destination_file) { |
|
417 | 417 | $success = false; |
418 | 418 | $message = ''; |
419 | 419 | |
420 | - if ( !function_exists( 'download_url' ) ) { |
|
421 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
420 | + if (!function_exists('download_url')) { |
|
421 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
422 | 422 | } |
423 | 423 | |
424 | - $temp_file = download_url( $source_url ); |
|
424 | + $temp_file = download_url($source_url); |
|
425 | 425 | |
426 | - if ( is_wp_error( $temp_file ) ) { |
|
427 | - $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() ); |
|
426 | + if (is_wp_error($temp_file)) { |
|
427 | + $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message()); |
|
428 | 428 | } else { |
429 | - $handle = gzopen( $temp_file, 'rb' ); |
|
429 | + $handle = gzopen($temp_file, 'rb'); |
|
430 | 430 | |
431 | - if ( $handle ) { |
|
432 | - $fopen = fopen( $destination_file, 'wb' ); |
|
433 | - if ( $fopen ) { |
|
434 | - while ( ( $data = gzread( $handle, 4096 ) ) != false ) { |
|
435 | - fwrite( $fopen, $data ); |
|
431 | + if ($handle) { |
|
432 | + $fopen = fopen($destination_file, 'wb'); |
|
433 | + if ($fopen) { |
|
434 | + while (($data = gzread($handle, 4096)) != false) { |
|
435 | + fwrite($fopen, $data); |
|
436 | 436 | } |
437 | 437 | |
438 | - gzclose( $handle ); |
|
439 | - fclose( $fopen ); |
|
438 | + gzclose($handle); |
|
439 | + fclose($fopen); |
|
440 | 440 | |
441 | 441 | $success = true; |
442 | 442 | } else { |
443 | - gzclose( $handle ); |
|
444 | - $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file ); |
|
443 | + gzclose($handle); |
|
444 | + $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file); |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file ); |
|
447 | + $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file); |
|
448 | 448 | } |
449 | 449 | |
450 | - if ( file_exists( $temp_file ) ) { |
|
451 | - unlink( $temp_file ); |
|
450 | + if (file_exists($temp_file)) { |
|
451 | + unlink($temp_file); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | public static function load_geoip2() { |
463 | - if ( defined( 'WPINV_GEOIP2_LODDED' ) ) { |
|
463 | + if (defined('WPINV_GEOIP2_LODDED')) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | 466 | |
467 | - if ( !class_exists( '\MaxMind\Db\Reader' ) ) { |
|
467 | + if (!class_exists('\MaxMind\Db\Reader')) { |
|
468 | 468 | $maxmind_db_files = array( |
469 | 469 | 'Reader/Decoder.php', |
470 | 470 | 'Reader/InvalidDatabaseException.php', |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | 'Reader.php', |
474 | 474 | ); |
475 | 475 | |
476 | - foreach ( $maxmind_db_files as $key => $file ) { |
|
477 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file ); |
|
476 | + foreach ($maxmind_db_files as $key => $file) { |
|
477 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file); |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
481 | - if ( !class_exists( '\GeoIp2\Database\Reader' ) ) { |
|
481 | + if (!class_exists('\GeoIp2\Database\Reader')) { |
|
482 | 482 | $geoip2_files = array( |
483 | 483 | 'ProviderInterface.php', |
484 | 484 | 'Compat/JsonSerializable.php', |
@@ -512,23 +512,23 @@ discard block |
||
512 | 512 | 'WebService/Client.php', |
513 | 513 | ); |
514 | 514 | |
515 | - foreach ( $geoip2_files as $key => $file ) { |
|
516 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file ); |
|
515 | + foreach ($geoip2_files as $key => $file) { |
|
516 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file); |
|
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
520 | - define( 'WPINV_GEOIP2_LODDED', true ); |
|
520 | + define('WPINV_GEOIP2_LODDED', true); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | public static function geoip2_country_dbfile() { |
524 | 524 | $upload_dir = wp_upload_dir(); |
525 | 525 | |
526 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
526 | + if (!isset($upload_dir['basedir'])) { |
|
527 | 527 | return false; |
528 | 528 | } |
529 | 529 | |
530 | 530 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb'; |
531 | - if ( !file_exists( $filename ) ) { |
|
531 | + if (!file_exists($filename)) { |
|
532 | 532 | return false; |
533 | 533 | } |
534 | 534 | |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | public static function geoip2_city_dbfile() { |
539 | 539 | $upload_dir = wp_upload_dir(); |
540 | 540 | |
541 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
541 | + if (!isset($upload_dir['basedir'])) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | 545 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb'; |
546 | - if ( !file_exists( $filename ) ) { |
|
546 | + if (!file_exists($filename)) { |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | try { |
555 | 555 | self::load_geoip2(); |
556 | 556 | |
557 | - if ( $filename = self::geoip2_country_dbfile() ) { |
|
558 | - return new \GeoIp2\Database\Reader( $filename ); |
|
557 | + if ($filename = self::geoip2_country_dbfile()) { |
|
558 | + return new \GeoIp2\Database\Reader($filename); |
|
559 | 559 | } |
560 | - } catch( Exception $e ) { |
|
560 | + } catch (Exception $e) { |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | |
@@ -568,173 +568,173 @@ discard block |
||
568 | 568 | try { |
569 | 569 | self::load_geoip2(); |
570 | 570 | |
571 | - if ( $filename = self::geoip2_city_dbfile() ) { |
|
572 | - return new \GeoIp2\Database\Reader( $filename ); |
|
571 | + if ($filename = self::geoip2_city_dbfile()) { |
|
572 | + return new \GeoIp2\Database\Reader($filename); |
|
573 | 573 | } |
574 | - } catch( Exception $e ) { |
|
574 | + } catch (Exception $e) { |
|
575 | 575 | return false; |
576 | 576 | } |
577 | 577 | |
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | |
581 | - public static function geoip2_country_record( $ip_address ) { |
|
581 | + public static function geoip2_country_record($ip_address) { |
|
582 | 582 | try { |
583 | 583 | $reader = self::geoip2_country_reader(); |
584 | 584 | |
585 | - if ( $reader ) { |
|
586 | - $record = $reader->country( $ip_address ); |
|
585 | + if ($reader) { |
|
586 | + $record = $reader->country($ip_address); |
|
587 | 587 | |
588 | - if ( !empty( $record->country->isoCode ) ) { |
|
588 | + if (!empty($record->country->isoCode)) { |
|
589 | 589 | return $record; |
590 | 590 | } |
591 | 591 | } |
592 | - } catch(\InvalidArgumentException $e) { |
|
593 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
592 | + } catch (\InvalidArgumentException $e) { |
|
593 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
594 | 594 | |
595 | 595 | return false; |
596 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
597 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
596 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
597 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
598 | 598 | |
599 | 599 | return false; |
600 | - } catch( Exception $e ) { |
|
600 | + } catch (Exception $e) { |
|
601 | 601 | return false; |
602 | 602 | } |
603 | 603 | |
604 | 604 | return false; |
605 | 605 | } |
606 | 606 | |
607 | - public static function geoip2_city_record( $ip_address ) { |
|
607 | + public static function geoip2_city_record($ip_address) { |
|
608 | 608 | try { |
609 | 609 | $reader = self::geoip2_city_reader(); |
610 | 610 | |
611 | - if ( $reader ) { |
|
612 | - $record = $reader->city( $ip_address ); |
|
611 | + if ($reader) { |
|
612 | + $record = $reader->city($ip_address); |
|
613 | 613 | |
614 | - if ( !empty( $record->country->isoCode ) ) { |
|
614 | + if (!empty($record->country->isoCode)) { |
|
615 | 615 | return $record; |
616 | 616 | } |
617 | 617 | } |
618 | - } catch(\InvalidArgumentException $e) { |
|
619 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
618 | + } catch (\InvalidArgumentException $e) { |
|
619 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
620 | 620 | |
621 | 621 | return false; |
622 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
623 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
622 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
623 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
624 | 624 | |
625 | 625 | return false; |
626 | - } catch( Exception $e ) { |
|
626 | + } catch (Exception $e) { |
|
627 | 627 | return false; |
628 | 628 | } |
629 | 629 | |
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | |
633 | - public static function geoip2_country_code( $ip_address ) { |
|
634 | - $record = self::geoip2_country_record( $ip_address ); |
|
635 | - return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country(); |
|
633 | + public static function geoip2_country_code($ip_address) { |
|
634 | + $record = self::geoip2_country_record($ip_address); |
|
635 | + return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country(); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | // Find country by IP address. |
639 | - public static function get_country_by_ip( $ip = '' ) { |
|
639 | + public static function get_country_by_ip($ip = '') { |
|
640 | 640 | global $wpinv_ip_address_country; |
641 | 641 | |
642 | - if ( !empty( $wpinv_ip_address_country ) ) { |
|
642 | + if (!empty($wpinv_ip_address_country)) { |
|
643 | 643 | return $wpinv_ip_address_country; |
644 | 644 | } |
645 | 645 | |
646 | - if ( empty( $ip ) ) { |
|
646 | + if (empty($ip)) { |
|
647 | 647 | $ip = wpinv_get_ip(); |
648 | 648 | } |
649 | 649 | |
650 | - $ip_country_service = wpinv_get_option( 'vat_ip_lookup' ); |
|
651 | - $is_default = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false; |
|
650 | + $ip_country_service = wpinv_get_option('vat_ip_lookup'); |
|
651 | + $is_default = empty($ip_country_service) || $ip_country_service === 'default' ? true : false; |
|
652 | 652 | |
653 | - if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country. |
|
654 | - if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) { |
|
653 | + if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country. |
|
654 | + if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) { |
|
655 | 655 | try { |
656 | - $wpinv_ip_address_country = geoip_country_code_by_name( $ip ); |
|
657 | - } catch( Exception $e ) { |
|
658 | - wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' ); |
|
656 | + $wpinv_ip_address_country = geoip_country_code_by_name($ip); |
|
657 | + } catch (Exception $e) { |
|
658 | + wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )'); |
|
659 | 659 | } |
660 | - } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) { |
|
661 | - $wpinv_ip_address_country = self::geoip2_country_code( $ip ); |
|
662 | - } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) { |
|
663 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
660 | + } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) { |
|
661 | + $wpinv_ip_address_country = self::geoip2_country_code($ip); |
|
662 | + } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) { |
|
663 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
664 | 664 | |
665 | - if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
|
665 | + if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) { |
|
666 | 666 | $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
667 | 667 | } |
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
671 | - if ( empty( $wpinv_ip_address_country ) ) { |
|
671 | + if (empty($wpinv_ip_address_country)) { |
|
672 | 672 | $wpinv_ip_address_country = wpinv_get_default_country(); |
673 | 673 | } |
674 | 674 | |
675 | 675 | return $wpinv_ip_address_country; |
676 | 676 | } |
677 | 677 | |
678 | - public static function sanitize_vat_settings( $input ) { |
|
678 | + public static function sanitize_vat_settings($input) { |
|
679 | 679 | global $wpinv_options; |
680 | 680 | |
681 | 681 | $valid = false; |
682 | 682 | $message = ''; |
683 | 683 | |
684 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
685 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
686 | - $valid = self::offline_check( $input['vat_number'] ); |
|
684 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
685 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
686 | + $valid = self::offline_check($input['vat_number']); |
|
687 | 687 | } else { |
688 | 688 | $valid = true; |
689 | 689 | } |
690 | 690 | |
691 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
691 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
692 | 692 | } else { |
693 | - $result = self::check_vat( $input['vat_number'] ); |
|
693 | + $result = self::check_vat($input['vat_number']); |
|
694 | 694 | |
695 | - if ( empty( $result['valid'] ) ) { |
|
695 | + if (empty($result['valid'])) { |
|
696 | 696 | $valid = false; |
697 | 697 | $message = $result['message']; |
698 | 698 | } else { |
699 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
700 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
699 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
700 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
705 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
704 | + if ($message && self::is_vat_validated() != $valid) { |
|
705 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | $input['vat_valid'] = $valid; |
709 | 709 | return $input; |
710 | 710 | } |
711 | 711 | |
712 | - public static function sanitize_vat_rates( $input ) { |
|
713 | - if( !current_user_can( 'manage_options' ) ) { |
|
714 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
712 | + public static function sanitize_vat_rates($input) { |
|
713 | + if (!current_user_can('manage_options')) { |
|
714 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
715 | 715 | return $input; |
716 | 716 | } |
717 | 717 | |
718 | 718 | $vat_classes = self::get_rate_classes(); |
719 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
719 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
720 | 720 | |
721 | - if ( empty( $vat_class ) ) { |
|
722 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
721 | + if (empty($vat_class)) { |
|
722 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
723 | 723 | |
724 | 724 | return $input; |
725 | 725 | } |
726 | 726 | |
727 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
727 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
728 | 728 | |
729 | - if ( $vat_class === '_standard' ) { |
|
729 | + if ($vat_class === '_standard') { |
|
730 | 730 | // Save the active rates in the invoice settings |
731 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
731 | + update_option('wpinv_tax_rates', $new_rates); |
|
732 | 732 | } else { |
733 | 733 | // Get the existing set of rates |
734 | 734 | $rates = self::get_non_standard_rates(); |
735 | 735 | $rates[$vat_class] = $new_rates; |
736 | 736 | |
737 | - update_option( 'wpinv_vat_rates', $rates ); |
|
737 | + update_option('wpinv_vat_rates', $rates); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | return $input; |
@@ -744,71 +744,71 @@ discard block |
||
744 | 744 | $response = array(); |
745 | 745 | $response['success'] = false; |
746 | 746 | |
747 | - if ( !current_user_can( 'manage_options' ) ) { |
|
748 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
749 | - wp_send_json( $response ); |
|
747 | + if (!current_user_can('manage_options')) { |
|
748 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
749 | + wp_send_json($response); |
|
750 | 750 | } |
751 | 751 | |
752 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
753 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
752 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
753 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
754 | 754 | |
755 | - if ( empty( $vat_class_name ) ) { |
|
756 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
757 | - wp_send_json( $response ); |
|
755 | + if (empty($vat_class_name)) { |
|
756 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
757 | + wp_send_json($response); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | $vat_classes = (array)self::get_rate_classes(); |
761 | 761 | |
762 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
763 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
764 | - wp_send_json( $response ); |
|
762 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
763 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
764 | + wp_send_json($response); |
|
765 | 765 | } |
766 | 766 | |
767 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
768 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
767 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
768 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
769 | 769 | |
770 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
771 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
770 | + $vat_classes = (array)self::get_rate_classes(true); |
|
771 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
772 | 772 | |
773 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
773 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
774 | 774 | |
775 | 775 | $response['success'] = true; |
776 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
776 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
777 | 777 | |
778 | - wp_send_json( $response ); |
|
778 | + wp_send_json($response); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | public static function delete_class() { |
782 | 782 | $response = array(); |
783 | 783 | $response['success'] = false; |
784 | 784 | |
785 | - if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) { |
|
786 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
787 | - wp_send_json( $response ); |
|
785 | + if (!current_user_can('manage_options') || !isset($_POST['class'])) { |
|
786 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
787 | + wp_send_json($response); |
|
788 | 788 | } |
789 | 789 | |
790 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
790 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
791 | 791 | $vat_classes = (array)self::get_rate_classes(); |
792 | 792 | |
793 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
794 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
795 | - wp_send_json( $response ); |
|
793 | + if (!isset($vat_classes[$vat_class])) { |
|
794 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
795 | + wp_send_json($response); |
|
796 | 796 | } |
797 | 797 | |
798 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
799 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
800 | - wp_send_json( $response ); |
|
798 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
799 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
800 | + wp_send_json($response); |
|
801 | 801 | } |
802 | 802 | |
803 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
804 | - unset( $vat_classes[$vat_class] ); |
|
803 | + $vat_classes = (array)self::get_rate_classes(true); |
|
804 | + unset($vat_classes[$vat_class]); |
|
805 | 805 | |
806 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
806 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
807 | 807 | |
808 | 808 | $response['success'] = true; |
809 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
809 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
810 | 810 | |
811 | - wp_send_json( $response ); |
|
811 | + wp_send_json($response); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | public static function update_eu_rates() { |
@@ -817,72 +817,72 @@ discard block |
||
817 | 817 | $response['error'] = null; |
818 | 818 | $response['data'] = null; |
819 | 819 | |
820 | - if ( !current_user_can( 'manage_options' ) ) { |
|
821 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
822 | - wp_send_json( $response ); |
|
820 | + if (!current_user_can('manage_options')) { |
|
821 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
822 | + wp_send_json($response); |
|
823 | 823 | } |
824 | 824 | |
825 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
826 | - $euvatrates = self::request_euvatrates( $group ); |
|
825 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
826 | + $euvatrates = self::request_euvatrates($group); |
|
827 | 827 | |
828 | - if ( !empty( $euvatrates ) ) { |
|
829 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
828 | + if (!empty($euvatrates)) { |
|
829 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
830 | 830 | $response['success'] = true; |
831 | 831 | $response['data']['rates'] = $euvatrates['rates']; |
832 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
832 | + } else if (!empty($euvatrates['error'])) { |
|
833 | 833 | $response['error'] = $euvatrates['error']; |
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
837 | - wp_send_json( $response ); |
|
837 | + wp_send_json($response); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | public static function hide_vat_fields() { |
841 | - $hide = wpinv_get_option( 'vat_disable_fields' ); |
|
841 | + $hide = wpinv_get_option('vat_disable_fields'); |
|
842 | 842 | |
843 | - return apply_filters( 'wpinv_hide_vat_fields', $hide ); |
|
843 | + return apply_filters('wpinv_hide_vat_fields', $hide); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | public static function same_country_rule() { |
847 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
847 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
848 | 848 | |
849 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
849 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | public static function get_vat_name() { |
853 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
854 | - $vat_name = !empty( $vat_name ) ? $vat_name : 'VAT'; |
|
853 | + $vat_name = wpinv_get_option('vat_name'); |
|
854 | + $vat_name = !empty($vat_name) ? $vat_name : 'VAT'; |
|
855 | 855 | |
856 | - return apply_filters( 'wpinv_get_owner_vat_name', $vat_name ); |
|
856 | + return apply_filters('wpinv_get_owner_vat_name', $vat_name); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | public static function get_company_name() { |
860 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
860 | + $company_name = wpinv_get_option('vat_company_name'); |
|
861 | 861 | |
862 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
862 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | public static function get_vat_number() { |
866 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
866 | + $vat_number = wpinv_get_option('vat_number'); |
|
867 | 867 | |
868 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
868 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | public static function is_vat_validated() { |
872 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
872 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
873 | 873 | |
874 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
874 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
875 | 875 | } |
876 | 876 | |
877 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
878 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
877 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
878 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
879 | 879 | |
880 | - if ( empty( $country_code ) ) { |
|
881 | - $country_code = substr( $vat_number, 0, 2 ); |
|
880 | + if (empty($country_code)) { |
|
881 | + $country_code = substr($vat_number, 0, 2); |
|
882 | 882 | } |
883 | 883 | |
884 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
885 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
884 | + if (strpos($vat_number, $country_code) === 0) { |
|
885 | + $vat = str_replace($country_code, '', $vat_number); |
|
886 | 886 | } else { |
887 | 887 | $vat = $country_code . $vat_number; |
888 | 888 | } |
@@ -895,140 +895,140 @@ discard block |
||
895 | 895 | return $return; |
896 | 896 | } |
897 | 897 | |
898 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
899 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
898 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
899 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
900 | 900 | $vat_number = $vat['vat_number']; |
901 | 901 | $country_code = $vat['iso']; |
902 | 902 | $regex = array(); |
903 | 903 | |
904 | - switch ( $country_code ) { |
|
904 | + switch ($country_code) { |
|
905 | 905 | case 'AT': |
906 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
906 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
907 | 907 | break; |
908 | 908 | case 'BE': |
909 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
909 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
910 | 910 | break; |
911 | 911 | case 'BG': |
912 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
912 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
913 | 913 | break; |
914 | 914 | case 'CH': |
915 | 915 | case 'CHE': |
916 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
916 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
917 | 917 | break; |
918 | 918 | case 'CY': |
919 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
919 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
920 | 920 | break; |
921 | 921 | case 'CZ': |
922 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
922 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
923 | 923 | break; |
924 | 924 | case 'DE': |
925 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
925 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
926 | 926 | break; |
927 | 927 | case 'DK': |
928 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
928 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
929 | 929 | break; |
930 | 930 | case 'EE': |
931 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
931 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
932 | 932 | break; |
933 | 933 | case 'EL': |
934 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
934 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
935 | 935 | break; |
936 | 936 | case 'ES': |
937 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
938 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
939 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
940 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
937 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
938 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
939 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
940 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
941 | 941 | break; |
942 | 942 | case 'EU': |
943 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
943 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
944 | 944 | break; |
945 | 945 | case 'FI': |
946 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
946 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
947 | 947 | break; |
948 | 948 | case 'FR': |
949 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
950 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
951 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
952 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
949 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
950 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
951 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
952 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
953 | 953 | break; |
954 | 954 | case 'GB': |
955 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
956 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
957 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
958 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
955 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
956 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
957 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
958 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
959 | 959 | break; |
960 | 960 | case 'GR': |
961 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
961 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
962 | 962 | break; |
963 | 963 | case 'HR': |
964 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
964 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
965 | 965 | break; |
966 | 966 | case 'HU': |
967 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
967 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
968 | 968 | break; |
969 | 969 | case 'IE': |
970 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
971 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
972 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
970 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
971 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
972 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
973 | 973 | break; |
974 | 974 | case 'IT': |
975 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
975 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
976 | 976 | break; |
977 | 977 | case 'LV': |
978 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
978 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
979 | 979 | break; |
980 | 980 | case 'LT': |
981 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
981 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
982 | 982 | break; |
983 | 983 | case 'LU': |
984 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
984 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
985 | 985 | break; |
986 | 986 | case 'MT': |
987 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
987 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
988 | 988 | break; |
989 | 989 | case 'NL': |
990 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
990 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
991 | 991 | break; |
992 | 992 | case 'NO': |
993 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
993 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
994 | 994 | break; |
995 | 995 | case 'PL': |
996 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
996 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
997 | 997 | break; |
998 | 998 | case 'PT': |
999 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
999 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
1000 | 1000 | break; |
1001 | 1001 | case 'RO': |
1002 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
1002 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
1003 | 1003 | break; |
1004 | 1004 | case 'RS': |
1005 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
1005 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
1006 | 1006 | break; |
1007 | 1007 | case 'SI': |
1008 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
1008 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
1009 | 1009 | break; |
1010 | 1010 | case 'SK': |
1011 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
1011 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
1012 | 1012 | break; |
1013 | 1013 | case 'SE': |
1014 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
1014 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
1015 | 1015 | break; |
1016 | 1016 | default: |
1017 | 1017 | $regex = array(); |
1018 | 1018 | break; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( empty( $regex ) ) { |
|
1021 | + if (empty($regex)) { |
|
1022 | 1022 | return false; |
1023 | 1023 | } |
1024 | 1024 | |
1025 | - foreach ( $regex as $pattern ) { |
|
1025 | + foreach ($regex as $pattern) { |
|
1026 | 1026 | $matches = null; |
1027 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
1027 | + preg_match_all($pattern, $vat_number, $matches); |
|
1028 | 1028 | |
1029 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
1030 | - if ( $formatted ) { |
|
1031 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
1029 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
1030 | + if ($formatted) { |
|
1031 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
1032 | 1032 | } else { |
1033 | 1033 | return true; |
1034 | 1034 | } |
@@ -1038,75 +1038,75 @@ discard block |
||
1038 | 1038 | return false; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
1042 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
1041 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
1042 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
1043 | 1043 | $vat_number = $vat['vat']; |
1044 | 1044 | $iso = $vat['iso']; |
1045 | 1045 | |
1046 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
1046 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
1047 | 1047 | |
1048 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
1049 | - $response = file_get_contents( $url ); |
|
1050 | - } else if ( function_exists( 'curl_init' ) ) { |
|
1048 | + if (ini_get('allow_url_fopen')) { |
|
1049 | + $response = file_get_contents($url); |
|
1050 | + } else if (function_exists('curl_init')) { |
|
1051 | 1051 | $ch = curl_init(); |
1052 | 1052 | |
1053 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
1054 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
1055 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
1056 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
1057 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
1053 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1054 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
1055 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
1056 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
1057 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
1058 | 1058 | |
1059 | - $response = curl_exec( $ch ); |
|
1059 | + $response = curl_exec($ch); |
|
1060 | 1060 | |
1061 | - if ( curl_errno( $ch ) ) { |
|
1062 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
1061 | + if (curl_errno($ch)) { |
|
1062 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
1063 | 1063 | $response = ''; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - curl_close( $ch ); |
|
1066 | + curl_close($ch); |
|
1067 | 1067 | } else { |
1068 | - wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' ); |
|
1068 | + wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR'); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | - if ( empty( $response ) ) { |
|
1071 | + if (empty($response)) { |
|
1072 | 1072 | return $result; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
1075 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
1076 | 1076 | return false; |
1077 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
1078 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
1077 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
1078 | + $content = explode("valid VAT number", htmlentities($response)); |
|
1079 | 1079 | |
1080 | - if ( !empty( $content[1] ) ) { |
|
1081 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
1080 | + if (!empty($content[1])) { |
|
1081 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
1082 | 1082 | |
1083 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
1083 | + if (!empty($matches[2]) && $matches[3]) { |
|
1084 | 1084 | $return = array(); |
1085 | 1085 | |
1086 | - foreach ( $matches[2] as $key => $label ) { |
|
1087 | - $label = trim( $label ); |
|
1086 | + foreach ($matches[2] as $key => $label) { |
|
1087 | + $label = trim($label); |
|
1088 | 1088 | |
1089 | - switch ( strtolower( $label ) ) { |
|
1089 | + switch (strtolower($label)) { |
|
1090 | 1090 | case 'member state': |
1091 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1091 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
1092 | 1092 | break; |
1093 | 1093 | case 'vat number': |
1094 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1094 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
1095 | 1095 | break; |
1096 | 1096 | case 'name': |
1097 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1097 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
1098 | 1098 | break; |
1099 | 1099 | case 'address': |
1100 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
1101 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
1100 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
1101 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
1102 | 1102 | break; |
1103 | 1103 | case 'consultation number': |
1104 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1104 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
1105 | 1105 | break; |
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
1109 | - if ( !empty( $return ) ) { |
|
1109 | + if (!empty($return)) { |
|
1110 | 1110 | return $return; |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1118,55 +1118,55 @@ discard block |
||
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
1121 | + public static function check_vat($vat_number, $country_code = '') { |
|
1122 | 1122 | $vat_name = self::get_vat_name(); |
1123 | 1123 | |
1124 | 1124 | $return = array(); |
1125 | 1125 | $return['valid'] = false; |
1126 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
1126 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
1127 | 1127 | |
1128 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
1128 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
1129 | 1129 | return $return; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | - $response = self::vies_check( $vat_number, $country_code ); |
|
1132 | + $response = self::vies_check($vat_number, $country_code); |
|
1133 | 1133 | |
1134 | - if ( $response ) { |
|
1135 | - $return['valid'] = true; |
|
1134 | + if ($response) { |
|
1135 | + $return['valid'] = true; |
|
1136 | 1136 | |
1137 | - if ( is_array( $response ) ) { |
|
1138 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
1139 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
1137 | + if (is_array($response)) { |
|
1138 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
1139 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
1140 | 1140 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
1141 | 1141 | } |
1142 | 1142 | } else { |
1143 | 1143 | $return['valid'] = false; |
1144 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
1144 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | return $return; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - public static function request_euvatrates( $group ) { |
|
1150 | + public static function request_euvatrates($group) { |
|
1151 | 1151 | $response = array(); |
1152 | 1152 | $response['success'] = false; |
1153 | 1153 | $response['error'] = null; |
1154 | 1154 | $response['eurates'] = null; |
1155 | 1155 | |
1156 | 1156 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
1157 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
1158 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
1157 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
1158 | + $api_response = wp_remote_get($euvatrates_url); |
|
1159 | 1159 | |
1160 | 1160 | try { |
1161 | - if ( is_wp_error( $api_response ) ) { |
|
1162 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
1161 | + if (is_wp_error($api_response)) { |
|
1162 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
1163 | 1163 | } else { |
1164 | - $body = json_decode( $api_response['body'] ); |
|
1164 | + $body = json_decode($api_response['body']); |
|
1165 | 1165 | |
1166 | - if ( isset( $body->rates ) ) { |
|
1166 | + if (isset($body->rates)) { |
|
1167 | 1167 | $rates = array(); |
1168 | 1168 | |
1169 | - foreach ( $body->rates as $country_code => $rate ) { |
|
1169 | + foreach ($body->rates as $country_code => $rate) { |
|
1170 | 1170 | $vat_rate = array(); |
1171 | 1171 | $vat_rate['country'] = $rate->country; |
1172 | 1172 | $vat_rate['standard'] = (float)$rate->standard_rate; |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
1175 | 1175 | $vat_rate['parking'] = (float)$rate->parking_rate; |
1176 | 1176 | |
1177 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
1177 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
1178 | 1178 | $vat_rate_group = array(); |
1179 | 1179 | $vat_rate_group['country'] = $rate->country; |
1180 | 1180 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -1186,79 +1186,79 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | $response['success'] = true; |
1189 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
1189 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
1190 | 1190 | } else { |
1191 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
1191 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
1192 | 1192 | } |
1193 | 1193 | } |
1194 | - } catch ( Exception $e ) { |
|
1195 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
1194 | + } catch (Exception $e) { |
|
1195 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
1198 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
1201 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
1202 | 1202 | global $wpi_item_id, $wpi_country; |
1203 | 1203 | |
1204 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
1205 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
1206 | - } else if ( !empty( $_POST['country'] ) ) { |
|
1207 | - $country_code = trim( $_POST['country'] ); |
|
1208 | - } else if ( !empty( $wpi_country ) ) { |
|
1204 | + if (!empty($_POST['wpinv_country'])) { |
|
1205 | + $country_code = trim($_POST['wpinv_country']); |
|
1206 | + } else if (!empty($_POST['country'])) { |
|
1207 | + $country_code = trim($_POST['country']); |
|
1208 | + } else if (!empty($wpi_country)) { |
|
1209 | 1209 | $country_code = $wpi_country; |
1210 | 1210 | } else { |
1211 | - $country_code = self::get_user_country( '', $user_id ); |
|
1211 | + $country_code = self::get_user_country('', $user_id); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | - if ( $is_digital === null && $wpi_item_id ) { |
|
1215 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
1214 | + if ($is_digital === null && $wpi_item_id) { |
|
1215 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - if ( !empty( $country_code ) ) { |
|
1219 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( self::$default_country ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( self::$default_country ) ); |
|
1218 | + if (!empty($country_code)) { |
|
1219 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(self::$default_country) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(self::$default_country)); |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
1222 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | - public static function tax_label( $label = '' ) { |
|
1225 | + public static function tax_label($label = '') { |
|
1226 | 1226 | global $wpi_requires_vat; |
1227 | 1227 | |
1228 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
1229 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
1228 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
1229 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
1232 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | public static function standard_rates_label() { |
1236 | - return __( 'Standard Rates', 'invoicing' ); |
|
1236 | + return __('Standard Rates', 'invoicing'); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | - public static function get_rate_classes( $with_desc = false ) { |
|
1240 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
1241 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
1239 | + public static function get_rate_classes($with_desc = false) { |
|
1240 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
1241 | + $classes = maybe_unserialize($rate_classes_option); |
|
1242 | 1242 | |
1243 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
1243 | + if (empty($classes) || !is_array($classes)) { |
|
1244 | 1244 | $classes = array(); |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $rate_classes = array(); |
1248 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
1249 | - if ( $with_desc ) { |
|
1250 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
1248 | + if (!array_key_exists('_standard', $classes)) { |
|
1249 | + if ($with_desc) { |
|
1250 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
1251 | 1251 | } else { |
1252 | 1252 | $rate_classes['_standard'] = self::standard_rates_label(); |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - foreach ( $classes as $key => $class ) { |
|
1257 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
1258 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
1256 | + foreach ($classes as $key => $class) { |
|
1257 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
1258 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
1259 | 1259 | |
1260 | - if ( $with_desc ) { |
|
1261 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
1260 | + if ($with_desc) { |
|
1261 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
1262 | 1262 | } else { |
1263 | 1263 | $rate_classes[$key] = $name; |
1264 | 1264 | } |
@@ -1269,15 +1269,15 @@ discard block |
||
1269 | 1269 | |
1270 | 1270 | public static function get_all_classes() { |
1271 | 1271 | $classes = self::get_rate_classes(); |
1272 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
1272 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
1273 | 1273 | |
1274 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
1274 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | - public static function get_class_desc( $rate_class ) { |
|
1278 | - $rate_classes = self::get_rate_classes( true ); |
|
1277 | + public static function get_class_desc($rate_class) { |
|
1278 | + $rate_classes = self::get_rate_classes(true); |
|
1279 | 1279 | |
1280 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
1280 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
1281 | 1281 | return $rate_classes[$rate_class]['desc']; |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1293,106 +1293,106 @@ discard block |
||
1293 | 1293 | 'increased' => 'Increased' |
1294 | 1294 | ); |
1295 | 1295 | |
1296 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
1296 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | public static function get_rules() { |
1300 | 1300 | $vat_rules = array( |
1301 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
1302 | - 'physical' => __( 'Physical Product', 'invoicing' ) |
|
1301 | + 'digital' => __('Digital Product', 'invoicing'), |
|
1302 | + 'physical' => __('Physical Product', 'invoicing') |
|
1303 | 1303 | ); |
1304 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
1304 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | - public static function get_vat_rates( $class ) { |
|
1308 | - if ( $class === '_standard' ) { |
|
1307 | + public static function get_vat_rates($class) { |
|
1308 | + if ($class === '_standard') { |
|
1309 | 1309 | return wpinv_get_tax_rates(); |
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | $rates = self::get_non_standard_rates(); |
1313 | 1313 | |
1314 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
1314 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | public static function get_non_standard_rates() { |
1318 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
1319 | - return is_array( $option ) ? $option : array(); |
|
1318 | + $option = get_option('wpinv_vat_rates', array()); |
|
1319 | + return is_array($option) ? $option : array(); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | public static function allow_vat_rules() { |
1323 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
1323 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | public static function allow_vat_classes() { |
1327 | 1327 | return false; // TODO |
1328 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
1328 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | - public static function get_item_class( $postID ) { |
|
1332 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
1331 | + public static function get_item_class($postID) { |
|
1332 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
1333 | 1333 | |
1334 | - if ( empty( $class ) ) { |
|
1334 | + if (empty($class)) { |
|
1335 | 1335 | $class = '_standard'; |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
1338 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | - public static function item_class_label( $postID ) { |
|
1341 | + public static function item_class_label($postID) { |
|
1342 | 1342 | $vat_classes = self::get_all_classes(); |
1343 | 1343 | |
1344 | - $class = self::get_item_class( $postID ); |
|
1345 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
1344 | + $class = self::get_item_class($postID); |
|
1345 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
1346 | 1346 | |
1347 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
1347 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | - public static function get_item_rule( $postID ) { |
|
1351 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
1350 | + public static function get_item_rule($postID) { |
|
1351 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
1352 | 1352 | |
1353 | - if ( empty( $rule_type ) ) { |
|
1353 | + if (empty($rule_type)) { |
|
1354 | 1354 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
1357 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | - public static function item_rule_label( $postID ) { |
|
1360 | + public static function item_rule_label($postID) { |
|
1361 | 1361 | $vat_rules = self::get_rules(); |
1362 | - $vat_rule = self::get_item_rule( $postID ); |
|
1363 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1362 | + $vat_rule = self::get_item_rule($postID); |
|
1363 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1364 | 1364 | |
1365 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
1365 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
1369 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
1368 | + public static function item_has_digital_rule($item_id = 0) { |
|
1369 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
1373 | - if ( !self::allow_vat_rules() ) { |
|
1372 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
1373 | + if (!self::allow_vat_rules()) { |
|
1374 | 1374 | return false; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - if ( empty( $invoice ) ) { |
|
1377 | + if (empty($invoice)) { |
|
1378 | 1378 | return true; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - if ( is_int( $invoice ) ) { |
|
1382 | - $invoice = new WPInv_Invoice( $invoice ); |
|
1381 | + if (is_int($invoice)) { |
|
1382 | + $invoice = new WPInv_Invoice($invoice); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
1385 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
1386 | 1386 | return true; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | - $cart_items = $invoice->get_cart_details(); |
|
1389 | + $cart_items = $invoice->get_cart_details(); |
|
1390 | 1390 | |
1391 | - if ( !empty( $cart_items ) ) { |
|
1391 | + if (!empty($cart_items)) { |
|
1392 | 1392 | $has_digital_rule = false; |
1393 | 1393 | |
1394 | - foreach ( $cart_items as $key => $item ) { |
|
1395 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
1394 | + foreach ($cart_items as $key => $item) { |
|
1395 | + if (self::item_has_digital_rule($item['id'])) { |
|
1396 | 1396 | $has_digital_rule = true; |
1397 | 1397 | break; |
1398 | 1398 | } |
@@ -1404,67 +1404,67 @@ discard block |
||
1404 | 1404 | return $has_digital_rule; |
1405 | 1405 | } |
1406 | 1406 | |
1407 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
1408 | - if ( !wpinv_use_taxes() ) { |
|
1407 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
1408 | + if (!wpinv_use_taxes()) { |
|
1409 | 1409 | return false; |
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | $is_taxable = true; |
1413 | 1413 | |
1414 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
1414 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
1415 | 1415 | $is_taxable = false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
1418 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
1421 | + public static function find_rate($country, $state, $rate, $class) { |
|
1422 | 1422 | global $wpi_zero_tax; |
1423 | 1423 | |
1424 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1424 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1425 | 1425 | return 0; |
1426 | 1426 | } |
1427 | 1427 | |
1428 | - $tax_rates = wpinv_get_tax_rates(); |
|
1428 | + $tax_rates = wpinv_get_tax_rates(); |
|
1429 | 1429 | |
1430 | - if ( $class !== '_standard' ) { |
|
1431 | - $class_rates = self::get_vat_rates( $class ); |
|
1430 | + if ($class !== '_standard') { |
|
1431 | + $class_rates = self::get_vat_rates($class); |
|
1432 | 1432 | |
1433 | - if ( is_array( $class_rates ) ) { |
|
1433 | + if (is_array($class_rates)) { |
|
1434 | 1434 | $indexed_class_rates = array(); |
1435 | 1435 | |
1436 | - foreach ( $class_rates as $key => $cr ) { |
|
1436 | + foreach ($class_rates as $key => $cr) { |
|
1437 | 1437 | $indexed_class_rates[$cr['country']] = $cr; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
1440 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
1441 | 1441 | $tr_country = $tr['country']; |
1442 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
1442 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
1443 | 1443 | return $tr; |
1444 | 1444 | } |
1445 | 1445 | $icr = $indexed_class_rates[$tr_country]; |
1446 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
1446 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
1447 | 1447 | |
1448 | - }, $tax_rates, $class_rates ); |
|
1448 | + }, $tax_rates, $class_rates); |
|
1449 | 1449 | } |
1450 | 1450 | } |
1451 | 1451 | |
1452 | - if ( !empty( $tax_rates ) ) { |
|
1453 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
1454 | - if ( $country != $tax_rate['country'] ) |
|
1452 | + if (!empty($tax_rates)) { |
|
1453 | + foreach ($tax_rates as $key => $tax_rate) { |
|
1454 | + if ($country != $tax_rate['country']) |
|
1455 | 1455 | continue; |
1456 | 1456 | |
1457 | - if ( !empty( $tax_rate['global'] ) ) { |
|
1458 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
1459 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
1457 | + if (!empty($tax_rate['global'])) { |
|
1458 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
1459 | + $rate = number_format($tax_rate['rate'], 4); |
|
1460 | 1460 | } |
1461 | 1461 | } else { |
1462 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
1462 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
1463 | 1463 | continue; |
1464 | 1464 | |
1465 | 1465 | $state_rate = $tax_rate['rate']; |
1466 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
1467 | - $rate = number_format( $state_rate, 4 ); |
|
1466 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
1467 | + $rate = number_format($state_rate, 4); |
|
1468 | 1468 | } |
1469 | 1469 | } |
1470 | 1470 | } |
@@ -1473,84 +1473,84 @@ discard block |
||
1473 | 1473 | return $rate; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
1476 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
1477 | 1477 | global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax; |
1478 | 1478 | |
1479 | 1479 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
1480 | 1480 | $allow_vat_classes = self::allow_vat_classes(); |
1481 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
1481 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
1482 | 1482 | |
1483 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1483 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1484 | 1484 | return 0; |
1485 | - } else if ( !$allow_vat_classes ) { |
|
1485 | + } else if (!$allow_vat_classes) { |
|
1486 | 1486 | $class = '_standard'; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
1489 | + if (!empty($_POST['wpinv_country'])) { |
|
1490 | 1490 | $post_country = $_POST['wpinv_country']; |
1491 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
1491 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
1492 | 1492 | $post_country = $_POST['wpinv_country']; |
1493 | - } elseif( !empty( $_POST['country'] ) ) { |
|
1493 | + } elseif (!empty($_POST['country'])) { |
|
1494 | 1494 | $post_country = $_POST['country']; |
1495 | 1495 | } else { |
1496 | 1496 | $post_country = ''; |
1497 | 1497 | } |
1498 | 1498 | |
1499 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
1500 | - $base_country = wpinv_is_base_country( $country ); |
|
1499 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
1500 | + $base_country = wpinv_is_base_country($country); |
|
1501 | 1501 | |
1502 | - $requires_vat = self::requires_vat( 0, false ); |
|
1503 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
1504 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1502 | + $requires_vat = self::requires_vat(0, false); |
|
1503 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
1504 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1505 | 1505 | |
1506 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
1506 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
1507 | 1507 | $rate = 0; |
1508 | - } else if ( $requires_vat ) { |
|
1509 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
1508 | + } else if ($requires_vat) { |
|
1509 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
1510 | 1510 | $vat_info = self::current_vat_data(); |
1511 | 1511 | |
1512 | - if ( is_array( $vat_info ) ) { |
|
1513 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
1512 | + if (is_array($vat_info)) { |
|
1513 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | - if ( $country == 'UK' ) { |
|
1516 | + if ($country == 'UK') { |
|
1517 | 1517 | $country = 'GB'; |
1518 | 1518 | } |
1519 | 1519 | |
1520 | - if ( !empty( $vat_number ) ) { |
|
1520 | + if (!empty($vat_number)) { |
|
1521 | 1521 | $rate = 0; |
1522 | 1522 | } else { |
1523 | - $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
1523 | + $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
1527 | - if ( $base_country ) { |
|
1528 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
1526 | + if (empty($vat_number) && !$is_digital) { |
|
1527 | + if ($base_country) { |
|
1528 | + $rate = self::find_rate($country, null, $rate, $class); |
|
1529 | 1529 | } else { |
1530 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1530 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1531 | 1531 | $rate = $wpinv_options['eu_fallback_rate']; |
1532 | - } else if( !empty( $country ) ) { |
|
1533 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1532 | + } else if (!empty($country)) { |
|
1533 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
1537 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1536 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
1537 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1538 | 1538 | $rate = $wpinv_options['eu_fallback_rate']; |
1539 | - } else if( !empty( $country ) ) { |
|
1540 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1539 | + } else if (!empty($country)) { |
|
1540 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | } else { |
1544 | - if ( $is_digital ) { |
|
1544 | + if ($is_digital) { |
|
1545 | 1545 | $ip_country_code = self::get_country_by_ip(); |
1546 | 1546 | |
1547 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
1548 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
1547 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
1548 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
1549 | 1549 | } else { |
1550 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1550 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1551 | 1551 | } |
1552 | 1552 | } else { |
1553 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1553 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1554 | 1554 | } |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1560,48 +1560,48 @@ discard block |
||
1560 | 1560 | public static function current_vat_data() { |
1561 | 1561 | global $wpi_session; |
1562 | 1562 | |
1563 | - return $wpi_session->get( 'user_vat_data' ); |
|
1563 | + return $wpi_session->get('user_vat_data'); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
1567 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
1566 | + public static function get_user_country($country = '', $user_id = 0) { |
|
1567 | + $user_address = wpinv_get_user_address($user_id, false); |
|
1568 | 1568 | |
1569 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
1569 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
1570 | 1570 | $country = ''; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
1574 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
1573 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
1574 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
1575 | 1575 | |
1576 | - if ( empty( $result ) ) { |
|
1576 | + if (empty($result)) { |
|
1577 | 1577 | $result = self::get_country_by_ip(); |
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | return $result; |
1581 | 1581 | } |
1582 | 1582 | |
1583 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
1583 | + public static function set_user_country($country = '', $user_id = 0) { |
|
1584 | 1584 | global $wpi_userID; |
1585 | 1585 | |
1586 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
1586 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
1587 | 1587 | $country = wpinv_get_default_country(); |
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | return $country; |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
1593 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
1594 | 1594 | global $wpi_current_id, $wpi_userID; |
1595 | 1595 | |
1596 | - if ( !empty( $_POST['new_user'] ) ) { |
|
1596 | + if (!empty($_POST['new_user'])) { |
|
1597 | 1597 | return ''; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | - if ( empty( $user_id ) ) { |
|
1601 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
1600 | + if (empty($user_id)) { |
|
1601 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
1604 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
1605 | 1605 | |
1606 | 1606 | /* TODO |
1607 | 1607 | if ( $is_valid && $vat_number ) { |
@@ -1612,36 +1612,36 @@ discard block |
||
1612 | 1612 | } |
1613 | 1613 | */ |
1614 | 1614 | |
1615 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
1615 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
1616 | 1616 | } |
1617 | 1617 | |
1618 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
1619 | - if ( empty( $user_id ) ) { |
|
1618 | + public static function get_user_company($company = '', $user_id = 0) { |
|
1619 | + if (empty($user_id)) { |
|
1620 | 1620 | $user_id = get_current_user_id(); |
1621 | 1621 | } |
1622 | 1622 | |
1623 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
1623 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
1624 | 1624 | |
1625 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
1625 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
1629 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
1628 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
1629 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
1630 | 1630 | |
1631 | - if ( is_user_logged_in() && $save ) { |
|
1631 | + if (is_user_logged_in() && $save) { |
|
1632 | 1632 | $user_id = get_current_user_id(); |
1633 | 1633 | |
1634 | - if ( !empty( $vat_number ) ) { |
|
1635 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
1634 | + if (!empty($vat_number)) { |
|
1635 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
1636 | 1636 | } else { |
1637 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1637 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | - if ( !empty( $company ) ) { |
|
1641 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
1640 | + if (!empty($company)) { |
|
1641 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
1642 | 1642 | } else { |
1643 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
1644 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1643 | + delete_user_meta($user_id, '_wpinv_company'); |
|
1644 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | |
@@ -1651,113 +1651,113 @@ discard block |
||
1651 | 1651 | public static function ajax_vat_validate() { |
1652 | 1652 | global $wpinv_options, $wpi_session; |
1653 | 1653 | |
1654 | - $is_checkout = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false; |
|
1654 | + $is_checkout = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false; |
|
1655 | 1655 | $response = array(); |
1656 | 1656 | $response['success'] = false; |
1657 | 1657 | |
1658 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
1659 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
1660 | - wp_send_json( $response ); |
|
1658 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
1659 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
1660 | + wp_send_json($response); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | - $vat_name = self::get_vat_name(); |
|
1663 | + $vat_name = self::get_vat_name(); |
|
1664 | 1664 | |
1665 | - if ( $is_checkout ) { |
|
1665 | + if ($is_checkout) { |
|
1666 | 1666 | $invoice = wpinv_get_invoice_cart(); |
1667 | 1667 | |
1668 | - if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) { |
|
1668 | + if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) { |
|
1669 | 1669 | $vat_info = array(); |
1670 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1670 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1671 | 1671 | |
1672 | 1672 | self::save_user_vat_details(); |
1673 | 1673 | |
1674 | 1674 | $response['success'] = true; |
1675 | - $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name ); |
|
1676 | - wp_send_json( $response ); |
|
1675 | + $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name); |
|
1676 | + wp_send_json($response); |
|
1677 | 1677 | } |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
1681 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
1680 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
1681 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
1682 | 1682 | |
1683 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1684 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
1685 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
1683 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1684 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
1685 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
1686 | 1686 | } |
1687 | 1687 | |
1688 | - if ( empty( $vat_number ) ) { |
|
1689 | - if ( $is_checkout ) { |
|
1688 | + if (empty($vat_number)) { |
|
1689 | + if ($is_checkout) { |
|
1690 | 1690 | $response['success'] = true; |
1691 | - $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name ); |
|
1691 | + $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name); |
|
1692 | 1692 | |
1693 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1693 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1694 | 1694 | $vat_info['number'] = ""; |
1695 | 1695 | $vat_info['valid'] = true; |
1696 | 1696 | |
1697 | - self::save_user_vat_details( $company ); |
|
1697 | + self::save_user_vat_details($company); |
|
1698 | 1698 | } else { |
1699 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
1699 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
1700 | 1700 | |
1701 | 1701 | $vat_info['valid'] = false; |
1702 | 1702 | } |
1703 | 1703 | |
1704 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1705 | - wp_send_json( $response ); |
|
1704 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1705 | + wp_send_json($response); |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if ( empty( $company ) ) { |
|
1708 | + if (empty($company)) { |
|
1709 | 1709 | $vat_info['valid'] = false; |
1710 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1710 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1711 | 1711 | |
1712 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
1713 | - wp_send_json( $response ); |
|
1712 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
1713 | + wp_send_json($response); |
|
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1717 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
1716 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1717 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
1718 | 1718 | $vat_info['valid'] = false; |
1719 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1719 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1720 | 1720 | |
1721 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
1722 | - wp_send_json( $response ); |
|
1721 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
1722 | + wp_send_json($response); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | $response['success'] = true; |
1726 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1726 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1727 | 1727 | } else { |
1728 | - $result = self::check_vat( $vat_number ); |
|
1728 | + $result = self::check_vat($vat_number); |
|
1729 | 1729 | |
1730 | - if ( empty( $result['valid'] ) ) { |
|
1730 | + if (empty($result['valid'])) { |
|
1731 | 1731 | $response['error'] = $result['message']; |
1732 | - wp_send_json( $response ); |
|
1732 | + wp_send_json($response); |
|
1733 | 1733 | } |
1734 | 1734 | |
1735 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
1736 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1735 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1736 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1737 | 1737 | |
1738 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1738 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1739 | 1739 | |
1740 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
1740 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
1741 | 1741 | $response['success'] = true; |
1742 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1742 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1743 | 1743 | } else { |
1744 | 1744 | $vat_info['valid'] = false; |
1745 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1745 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1746 | 1746 | |
1747 | 1747 | $response['success'] = false; |
1748 | - $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
1749 | - wp_send_json( $response ); |
|
1748 | + $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
1749 | + wp_send_json($response); |
|
1750 | 1750 | } |
1751 | 1751 | } |
1752 | 1752 | |
1753 | - if ( $is_checkout ) { |
|
1754 | - self::save_user_vat_details( $company, $vat_number ); |
|
1753 | + if ($is_checkout) { |
|
1754 | + self::save_user_vat_details($company, $vat_number); |
|
1755 | 1755 | |
1756 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true ); |
|
1757 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1756 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true); |
|
1757 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1758 | 1758 | } |
1759 | 1759 | |
1760 | - wp_send_json( $response ); |
|
1760 | + wp_send_json($response); |
|
1761 | 1761 | } |
1762 | 1762 | |
1763 | 1763 | public static function ajax_vat_reset() { |
@@ -1766,161 +1766,161 @@ discard block |
||
1766 | 1766 | $company = is_user_logged_in() ? self::get_user_company() : ''; |
1767 | 1767 | $vat_number = self::get_user_vat_number(); |
1768 | 1768 | |
1769 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false ); |
|
1770 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1769 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false); |
|
1770 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1771 | 1771 | |
1772 | 1772 | $response = array(); |
1773 | 1773 | $response['success'] = true; |
1774 | 1774 | $response['data']['company'] = $company; |
1775 | 1775 | $response['data']['number'] = $vat_number; |
1776 | 1776 | |
1777 | - wp_send_json( $response ); |
|
1777 | + wp_send_json($response); |
|
1778 | 1778 | } |
1779 | 1779 | |
1780 | - public static function checkout_vat_validate( $valid_data, $post ) { |
|
1780 | + public static function checkout_vat_validate($valid_data, $post) { |
|
1781 | 1781 | global $wpinv_options, $wpi_session; |
1782 | 1782 | |
1783 | - $vat_name = __( self::get_vat_name(), 'invoicing' ); |
|
1783 | + $vat_name = __(self::get_vat_name(), 'invoicing'); |
|
1784 | 1784 | |
1785 | - if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) { |
|
1786 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) ); |
|
1785 | + if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) { |
|
1786 | + wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name)); |
|
1787 | 1787 | return; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $vat_saved = $wpi_session->get( 'user_vat_data' ); |
|
1791 | - $wpi_session->set( 'user_vat_data', null ); |
|
1790 | + $vat_saved = $wpi_session->get('user_vat_data'); |
|
1791 | + $wpi_session->set('user_vat_data', null); |
|
1792 | 1792 | |
1793 | 1793 | $invoice = wpinv_get_invoice_cart(); |
1794 | 1794 | $amount = $invoice->get_total(); |
1795 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
1796 | - $no_vat = !self::requires_vat( 0, false, $is_digital ); |
|
1795 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
1796 | + $no_vat = !self::requires_vat(0, false, $is_digital); |
|
1797 | 1797 | |
1798 | - $company = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null; |
|
1799 | - $vat_number = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null; |
|
1800 | - $country = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country; |
|
1801 | - if ( empty( $country ) ) { |
|
1798 | + $company = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null; |
|
1799 | + $vat_number = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null; |
|
1800 | + $country = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country; |
|
1801 | + if (empty($country)) { |
|
1802 | 1802 | $country = wpinv_default_billing_country(); |
1803 | 1803 | } |
1804 | 1804 | |
1805 | - if ( !$is_digital && $no_vat ) { |
|
1805 | + if (!$is_digital && $no_vat) { |
|
1806 | 1806 | return; |
1807 | 1807 | } |
1808 | 1808 | |
1809 | - $vat_data = array( 'company' => '', 'number' => '', 'valid' => false ); |
|
1809 | + $vat_data = array('company' => '', 'number' => '', 'valid' => false); |
|
1810 | 1810 | |
1811 | 1811 | $ip_country_code = self::get_country_by_ip(); |
1812 | - $is_eu_state = self::is_eu_state( $country ); |
|
1813 | - $is_eu_state_ip = self::is_eu_state( $ip_country_code ); |
|
1812 | + $is_eu_state = self::is_eu_state($country); |
|
1813 | + $is_eu_state_ip = self::is_eu_state($ip_country_code); |
|
1814 | 1814 | $is_non_eu_user = !$is_eu_state && !$is_eu_state_ip; |
1815 | 1815 | |
1816 | - if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) { |
|
1816 | + if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) { |
|
1817 | 1817 | $vat_data['adddress_confirmed'] = false; |
1818 | 1818 | |
1819 | - if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) { |
|
1820 | - if ( $ip_country_code != $country ) { |
|
1821 | - wpinv_set_error( 'vat_validation', sprintf( __( 'The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing' ), '<a href="#wpinv_adddress_confirm">', '</a>' ) ); |
|
1819 | + if (!isset($_POST['wpinv_adddress_confirmed'])) { |
|
1820 | + if ($ip_country_code != $country) { |
|
1821 | + wpinv_set_error('vat_validation', sprintf(__('The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing'), '<a href="#wpinv_adddress_confirm">', '</a>')); |
|
1822 | 1822 | } |
1823 | 1823 | } else { |
1824 | 1824 | $vat_data['adddress_confirmed'] = true; |
1825 | 1825 | } |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) { |
|
1829 | - if ( $is_eu_state ) { |
|
1830 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing' ), $vat_name ) ); |
|
1831 | - } else if ( $is_digital && $is_eu_state_ip ) { |
|
1832 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) ); |
|
1828 | + if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) { |
|
1829 | + if ($is_eu_state) { |
|
1830 | + wpinv_set_error('vat_validation', wp_sprintf(__('Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing'), $vat_name)); |
|
1831 | + } else if ($is_digital && $is_eu_state_ip) { |
|
1832 | + wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name)); |
|
1833 | 1833 | } |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) { |
|
1836 | + if (!$is_eu_state || $no_vat || empty($vat_number)) { |
|
1837 | 1837 | return; |
1838 | 1838 | } |
1839 | 1839 | |
1840 | - if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) { |
|
1841 | - $vat_data['valid'] = $vat_saved['valid']; |
|
1840 | + if (!empty($vat_saved) && isset($vat_saved['valid'])) { |
|
1841 | + $vat_data['valid'] = $vat_saved['valid']; |
|
1842 | 1842 | } |
1843 | 1843 | |
1844 | - if ( $company !== null ) { |
|
1844 | + if ($company !== null) { |
|
1845 | 1845 | $vat_data['company'] = $company; |
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | $message = ''; |
1849 | - if ( $vat_number !== null ) { |
|
1849 | + if ($vat_number !== null) { |
|
1850 | 1850 | $vat_data['number'] = $vat_number; |
1851 | 1851 | |
1852 | - if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) { |
|
1853 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1854 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
1852 | + if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) { |
|
1853 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1854 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
1855 | 1855 | $vat_data['valid'] = false; |
1856 | 1856 | } |
1857 | 1857 | } else { |
1858 | - $result = self::check_vat( $vat_number ); |
|
1858 | + $result = self::check_vat($vat_number); |
|
1859 | 1859 | |
1860 | - if ( !empty( $result['valid'] ) ) { |
|
1860 | + if (!empty($result['valid'])) { |
|
1861 | 1861 | $vat_data['valid'] = true; |
1862 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
1863 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1862 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1863 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1864 | 1864 | |
1865 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1865 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1866 | 1866 | |
1867 | - if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) { |
|
1867 | + if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) { |
|
1868 | 1868 | $vat_data['valid'] = false; |
1869 | 1869 | |
1870 | - $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
1870 | + $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
1871 | 1871 | } |
1872 | 1872 | } else { |
1873 | - $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
1873 | + $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
1874 | 1874 | } |
1875 | 1875 | } |
1876 | 1876 | |
1877 | - if ( !$vat_data['valid'] ) { |
|
1878 | - $error = wp_sprintf( __( 'The %s %s number %s you have entered has not been validated', 'invoicing' ), '<a href="#wpi-vat-details">', $vat_name, '</a>' ) . ( $message ? ' ( ' . $message . ' )' : '' ); |
|
1879 | - wpinv_set_error( 'vat_validation', $error ); |
|
1877 | + if (!$vat_data['valid']) { |
|
1878 | + $error = wp_sprintf(__('The %s %s number %s you have entered has not been validated', 'invoicing'), '<a href="#wpi-vat-details">', $vat_name, '</a>') . ($message ? ' ( ' . $message . ' )' : ''); |
|
1879 | + wpinv_set_error('vat_validation', $error); |
|
1880 | 1880 | } |
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | |
1884 | - $wpi_session->set( 'user_vat_data', $vat_data ); |
|
1884 | + $wpi_session->set('user_vat_data', $vat_data); |
|
1885 | 1885 | } |
1886 | 1886 | |
1887 | - public static function checkout_vat_fields( $billing_details ) { |
|
1887 | + public static function checkout_vat_fields($billing_details) { |
|
1888 | 1888 | global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat; |
1889 | 1889 | |
1890 | 1890 | $ip_address = wpinv_get_ip(); |
1891 | 1891 | $ip_country_code = self::get_country_by_ip(); |
1892 | 1892 | |
1893 | - $tax_label = __( self::get_vat_name(), 'invoicing' ); |
|
1893 | + $tax_label = __(self::get_vat_name(), 'invoicing'); |
|
1894 | 1894 | $invoice = wpinv_get_invoice_cart(); |
1895 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
1895 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
1896 | 1896 | $wpi_country = $invoice->country; |
1897 | 1897 | |
1898 | - $requires_vat = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat( 0, false, $is_digital ); |
|
1898 | + $requires_vat = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat(0, false, $is_digital); |
|
1899 | 1899 | $wpi_requires_vat = $requires_vat; |
1900 | 1900 | |
1901 | 1901 | $company = is_user_logged_in() ? self::get_user_company() : ''; |
1902 | 1902 | $vat_number = self::get_user_vat_number(); |
1903 | 1903 | |
1904 | - $validated = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1; |
|
1905 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1904 | + $validated = $vat_number ? self::get_user_vat_number('', 0, true) : 1; |
|
1905 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1906 | 1906 | |
1907 | - if ( is_array( $vat_info ) ) { |
|
1908 | - $company = isset( $vat_info['company'] ) ? $vat_info['company'] : ''; |
|
1909 | - $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : ''; |
|
1910 | - $validated = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false; |
|
1907 | + if (is_array($vat_info)) { |
|
1908 | + $company = isset($vat_info['company']) ? $vat_info['company'] : ''; |
|
1909 | + $vat_number = isset($vat_info['number']) ? $vat_info['number'] : ''; |
|
1910 | + $validated = isset($vat_info['valid']) ? $vat_info['valid'] : false; |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country(); |
1914 | 1914 | |
1915 | - if ( $ip_country_code == 'UK' ) { |
|
1915 | + if ($ip_country_code == 'UK') { |
|
1916 | 1916 | $ip_country_code = 'GB'; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if ( $selected_country == 'UK' ) { |
|
1919 | + if ($selected_country == 'UK') { |
|
1920 | 1920 | $selected_country = 'GB'; |
1921 | 1921 | } |
1922 | 1922 | |
1923 | - if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) { |
|
1923 | + if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) { |
|
1924 | 1924 | $requires_vat = false; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1928,52 +1928,52 @@ discard block |
||
1928 | 1928 | $display_validate_btn = 'none'; |
1929 | 1929 | $display_reset_btn = 'none'; |
1930 | 1930 | |
1931 | - if ( !empty( $vat_number ) && $validated ) { |
|
1932 | - $vat_vailidated_text = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label ); |
|
1931 | + if (!empty($vat_number) && $validated) { |
|
1932 | + $vat_vailidated_text = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label); |
|
1933 | 1933 | $vat_vailidated_class = 'wpinv-vat-stat-1'; |
1934 | 1934 | $display_reset_btn = 'block'; |
1935 | 1935 | } else { |
1936 | - $vat_vailidated_text = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label ); |
|
1937 | - $vat_vailidated_class = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0'; |
|
1936 | + $vat_vailidated_text = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label); |
|
1937 | + $vat_vailidated_class = empty($vat_number) ? '' : 'wpinv-vat-stat-0'; |
|
1938 | 1938 | $display_validate_btn = 'block'; |
1939 | 1939 | } |
1940 | 1940 | |
1941 | - $show_ip_country = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
1941 | + $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
1942 | 1942 | ?> |
1943 | 1943 | <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>"> |
1944 | 1944 | <div id="wpi_vat_info" class="clearfix panel panel-default"> |
1945 | - <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div> |
|
1945 | + <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div> |
|
1946 | 1946 | <div id="wpinv-fields-box" class="panel-body"> |
1947 | 1947 | <p id="wpi_show_vat_note"> |
1948 | - <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?> |
|
1948 | + <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?> |
|
1949 | 1949 | </p> |
1950 | 1950 | <div id="wpi_vat_fields" class="wpi_vat_info"> |
1951 | 1951 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1952 | - <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label> |
|
1952 | + <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
|
1953 | 1953 | <?php |
1954 | - echo wpinv_html_text( array( |
|
1954 | + echo wpinv_html_text(array( |
|
1955 | 1955 | 'id' => 'wpinv_company', |
1956 | 1956 | 'name' => 'wpinv_company', |
1957 | 1957 | 'value' => $company, |
1958 | 1958 | 'class' => 'wpi-input form-control', |
1959 | - 'placeholder' => __( 'Company name', 'invoicing' ), |
|
1960 | - ) ); |
|
1959 | + 'placeholder' => __('Company name', 'invoicing'), |
|
1960 | + )); |
|
1961 | 1961 | ?> |
1962 | 1962 | </p> |
1963 | 1963 | <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat"> |
1964 | - <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label> |
|
1964 | + <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label> |
|
1965 | 1965 | <span id="wpinv_vat_number-wrap"> |
1966 | 1966 | <label for="wpinv_vat_number" class="wpinv-label"></label> |
1967 | - <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr( wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ) );?>" value="<?php esc_attr_e( $vat_number );?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
1968 | - <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text;?></font></span> |
|
1967 | + <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr(wp_sprintf(__('%s number', 'invoicing'), $tax_label)); ?>" value="<?php esc_attr_e($vat_number); ?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
1968 | + <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text; ?></font></span> |
|
1969 | 1969 | </span> |
1970 | 1970 | </p> |
1971 | 1971 | <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions"> |
1972 | - <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf( __("Validate %s Number", 'invoicing'), $tax_label ); ?></button> |
|
1973 | - <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf( __("Reset %s", 'invoicing'), $tax_label ); ?></button> |
|
1972 | + <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf(__("Validate %s Number", 'invoicing'), $tax_label); ?></button> |
|
1973 | + <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf(__("Reset %s", 'invoicing'), $tax_label); ?></button> |
|
1974 | 1974 | <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span> |
1975 | 1975 | <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span> |
1976 | - <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" /> |
|
1976 | + <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" /> |
|
1977 | 1977 | </p> |
1978 | 1978 | </div> |
1979 | 1979 | </div> |
@@ -1987,32 +1987,32 @@ discard block |
||
1987 | 1987 | </span> |
1988 | 1988 | </div> |
1989 | 1989 | </div> |
1990 | - <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { |
|
1991 | - $ip_link = '<a title="' . esc_attr( __( 'View more details on map', 'invoicing' ) ) . '" target="_blank" href="' . esc_url( admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address ) ) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
1990 | + <?php if (empty($wpinv_options['hide_ip_address'])) { |
|
1991 | + $ip_link = '<a title="' . esc_attr(__('View more details on map', 'invoicing')) . '" target="_blank" href="' . esc_url(admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address)) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
1992 | 1992 | ?> |
1993 | 1993 | <div class="wpi-ip-info clearfix panel panel-info"> |
1994 | 1994 | <div id="wpinv-fields-box" class="panel-body"> |
1995 | - <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span> |
|
1995 | + <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span> |
|
1996 | 1996 | </div> |
1997 | 1997 | </div> |
1998 | 1998 | <?php } |
1999 | 1999 | } |
2000 | 2000 | |
2001 | - public static function show_vat_notice( $invoice ) { |
|
2002 | - if ( empty( $invoice ) ) { |
|
2001 | + public static function show_vat_notice($invoice) { |
|
2002 | + if (empty($invoice)) { |
|
2003 | 2003 | return NULL; |
2004 | 2004 | } |
2005 | 2005 | |
2006 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
2007 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
2008 | - if ( $label || $notice ) { |
|
2006 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
2007 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
2008 | + if ($label || $notice) { |
|
2009 | 2009 | ?> |
2010 | 2010 | <div class="row wpinv-vat-notice"> |
2011 | 2011 | <div class="col-sm-12"> |
2012 | - <?php if ( $label ) { ?> |
|
2013 | - <strong><?php _e( $label, 'invoicing' ); ?></strong> |
|
2014 | - <?php } if ( $notice ) { ?> |
|
2015 | - <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?> |
|
2012 | + <?php if ($label) { ?> |
|
2013 | + <strong><?php _e($label, 'invoicing'); ?></strong> |
|
2014 | + <?php } if ($notice) { ?> |
|
2015 | + <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?> |
|
2016 | 2016 | <?php } ?> |
2017 | 2017 | </div> |
2018 | 2018 | </div> |
@@ -1,66 +1,66 @@ discard block |
||
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_get_option( $key = '', $default = false ) { |
|
7 | +function wpinv_get_option($key = '', $default = false) { |
|
8 | 8 | global $wpinv_options; |
9 | 9 | |
10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
12 | 12 | |
13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
14 | 14 | } |
15 | 15 | |
16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
16 | +function wpinv_update_option($key = '', $value = false) { |
|
17 | 17 | // If no key, exit |
18 | - if ( empty( $key ) ) { |
|
18 | + if (empty($key)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - if ( empty( $value ) ) { |
|
23 | - $remove_option = wpinv_delete_option( $key ); |
|
22 | + if (empty($value)) { |
|
23 | + $remove_option = wpinv_delete_option($key); |
|
24 | 24 | return $remove_option; |
25 | 25 | } |
26 | 26 | |
27 | 27 | // First let's grab the current settings |
28 | - $options = get_option( 'wpinv_settings' ); |
|
28 | + $options = get_option('wpinv_settings'); |
|
29 | 29 | |
30 | 30 | // Let's let devs alter that value coming in |
31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
32 | 32 | |
33 | 33 | // Next let's try to update the value |
34 | - $options[ $key ] = $value; |
|
35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
34 | + $options[$key] = $value; |
|
35 | + $did_update = update_option('wpinv_settings', $options); |
|
36 | 36 | |
37 | 37 | // If it updated, let's update the global variable |
38 | - if ( $did_update ) { |
|
38 | + if ($did_update) { |
|
39 | 39 | global $wpinv_options; |
40 | - $wpinv_options[ $key ] = $value; |
|
40 | + $wpinv_options[$key] = $value; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $did_update; |
44 | 44 | } |
45 | 45 | |
46 | -function wpinv_delete_option( $key = '' ) { |
|
46 | +function wpinv_delete_option($key = '') { |
|
47 | 47 | // If no key, exit |
48 | - if ( empty( $key ) ) { |
|
48 | + if (empty($key)) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // First let's grab the current settings |
53 | - $options = get_option( 'wpinv_settings' ); |
|
53 | + $options = get_option('wpinv_settings'); |
|
54 | 54 | |
55 | 55 | // Next let's try to update the value |
56 | - if( isset( $options[ $key ] ) ) { |
|
57 | - unset( $options[ $key ] ); |
|
56 | + if (isset($options[$key])) { |
|
57 | + unset($options[$key]); |
|
58 | 58 | } |
59 | 59 | |
60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
60 | + $did_update = update_option('wpinv_settings', $options); |
|
61 | 61 | |
62 | 62 | // If it updated, let's update the global variable |
63 | - if ( $did_update ){ |
|
63 | + if ($did_update) { |
|
64 | 64 | global $wpinv_options; |
65 | 65 | $wpinv_options = $options; |
66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_get_settings() { |
72 | - $settings = get_option( 'wpinv_settings' ); |
|
72 | + $settings = get_option('wpinv_settings'); |
|
73 | 73 | |
74 | - if ( empty( $settings ) ) { |
|
74 | + if (empty($settings)) { |
|
75 | 75 | // Update old settings with new single option |
76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
82 | 82 | |
83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
84 | 84 | |
85 | - update_option( 'wpinv_settings', $settings ); |
|
85 | + update_option('wpinv_settings', $settings); |
|
86 | 86 | |
87 | 87 | } |
88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
88 | + return apply_filters('wpinv_get_settings', $settings); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_register_settings() { |
92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
93 | - add_option( 'wpinv_settings' ); |
|
92 | + if (false == get_option('wpinv_settings')) { |
|
93 | + add_option('wpinv_settings'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $register_settings = wpinv_get_registered_settings(); |
97 | 97 | |
98 | - foreach ( $register_settings as $tab => $sections ) { |
|
99 | - foreach ( $sections as $section => $settings) { |
|
98 | + foreach ($register_settings as $tab => $sections) { |
|
99 | + foreach ($sections as $section => $settings) { |
|
100 | 100 | // Check for backwards compatibility |
101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
103 | 103 | $section = 'main'; |
104 | 104 | $settings = $sections; |
105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
112 | 112 | ); |
113 | 113 | |
114 | - foreach ( $settings as $option ) { |
|
114 | + foreach ($settings as $option) { |
|
115 | 115 | // For backwards compatibility |
116 | - if ( empty( $option['id'] ) ) { |
|
116 | + if (empty($option['id'])) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
121 | 121 | |
122 | 122 | add_settings_field( |
123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
124 | 124 | $name, |
125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
128 | 128 | array( |
129 | 129 | 'section' => $section, |
130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Creates our settings in the options table |
157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
158 | 158 | } |
159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
160 | 160 | |
161 | 161 | function wpinv_get_registered_settings() { |
162 | - $pages = wpinv_get_pages( true ); |
|
162 | + $pages = wpinv_get_pages(true); |
|
163 | 163 | |
164 | 164 | $due_payment_options = array(); |
165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
166 | + for ($i = 1; $i <= 30; $i++) { |
|
167 | 167 | $due_payment_options[$i] = $i; |
168 | 168 | } |
169 | 169 | |
170 | 170 | $invoice_number_padd_options = array(); |
171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
171 | + for ($i = 0; $i <= 20; $i++) { |
|
172 | 172 | $invoice_number_padd_options[$i] = $i; |
173 | 173 | } |
174 | 174 | |
@@ -177,141 +177,141 @@ discard block |
||
177 | 177 | $alert_wrapper_start = '<p style="color: #F00">'; |
178 | 178 | $alert_wrapper_close = '</p>'; |
179 | 179 | $wpinv_settings = array( |
180 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
180 | + 'general' => apply_filters('wpinv_settings_general', |
|
181 | 181 | array( |
182 | 182 | 'main' => array( |
183 | 183 | 'location_settings' => array( |
184 | 184 | 'id' => 'location_settings', |
185 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
185 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
186 | 186 | 'desc' => '', |
187 | 187 | 'type' => 'header', |
188 | 188 | ), |
189 | 189 | 'default_country' => array( |
190 | 190 | 'id' => 'default_country', |
191 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
192 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
191 | + 'name' => __('Default Country', 'invoicing'), |
|
192 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
193 | 193 | 'type' => 'select', |
194 | 194 | 'options' => wpinv_get_country_list(), |
195 | 195 | 'std' => 'GB', |
196 | 196 | 'chosen' => true, |
197 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
197 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
198 | 198 | ), |
199 | 199 | 'default_state' => array( |
200 | 200 | 'id' => 'default_state', |
201 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
202 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
201 | + 'name' => __('Default State / Province', 'invoicing'), |
|
202 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
203 | 203 | 'type' => 'country_states', |
204 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
204 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | 'store_name' => array( |
207 | 207 | 'id' => 'store_name', |
208 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
209 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
208 | + 'name' => __('Store Name', 'invoicing'), |
|
209 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
210 | 210 | 'std' => get_option('blogname'), |
211 | 211 | 'type' => 'text', |
212 | 212 | ), |
213 | 213 | 'logo' => array( |
214 | 214 | 'id' => 'logo', |
215 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
216 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
215 | + 'name' => __('Logo URL', 'invoicing'), |
|
216 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
217 | 217 | 'type' => 'text', |
218 | 218 | ), |
219 | 219 | 'store_address' => array( |
220 | 220 | 'id' => 'store_address', |
221 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
222 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
221 | + 'name' => __('Store Address', 'invoicing'), |
|
222 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
223 | 223 | 'type' => 'textarea', |
224 | 224 | ), |
225 | 225 | 'page_settings' => array( |
226 | 226 | 'id' => 'page_settings', |
227 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
227 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
228 | 228 | 'desc' => '', |
229 | 229 | 'type' => 'header', |
230 | 230 | ), |
231 | 231 | 'checkout_page' => array( |
232 | 232 | 'id' => 'checkout_page', |
233 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
234 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
233 | + 'name' => __('Checkout Page', 'invoicing'), |
|
234 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
235 | 235 | 'type' => 'select', |
236 | 236 | 'options' => $pages, |
237 | 237 | 'chosen' => true, |
238 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
238 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
239 | 239 | ), |
240 | 240 | 'success_page' => array( |
241 | 241 | 'id' => 'success_page', |
242 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
243 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
242 | + 'name' => __('Success Page', 'invoicing'), |
|
243 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
244 | 244 | 'type' => 'select', |
245 | 245 | 'options' => $pages, |
246 | 246 | 'chosen' => true, |
247 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
247 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
248 | 248 | ), |
249 | 249 | 'failure_page' => array( |
250 | 250 | 'id' => 'failure_page', |
251 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
252 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
251 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
252 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
253 | 253 | 'type' => 'select', |
254 | 254 | 'options' => $pages, |
255 | 255 | 'chosen' => true, |
256 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
256 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
257 | 257 | ), |
258 | 258 | 'invoice_history_page' => array( |
259 | 259 | 'id' => 'invoice_history_page', |
260 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
261 | - 'desc' => __( 'This page shows an invoice history for the current user', 'invoicing' ), |
|
260 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
261 | + 'desc' => __('This page shows an invoice history for the current user', 'invoicing'), |
|
262 | 262 | 'type' => 'select', |
263 | 263 | 'options' => $pages, |
264 | 264 | 'chosen' => true, |
265 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
265 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
266 | 266 | ) |
267 | 267 | ), |
268 | 268 | 'currency_section' => array( |
269 | 269 | 'currency_settings' => array( |
270 | 270 | 'id' => 'currency_settings', |
271 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
271 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
272 | 272 | 'desc' => '', |
273 | 273 | 'type' => 'header', |
274 | 274 | ), |
275 | 275 | 'currency' => array( |
276 | 276 | 'id' => 'currency', |
277 | - 'name' => __( 'Currency', 'invoicing' ), |
|
278 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
277 | + 'name' => __('Currency', 'invoicing'), |
|
278 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
279 | 279 | 'type' => 'select', |
280 | 280 | 'options' => wpinv_get_currencies(), |
281 | 281 | 'chosen' => true, |
282 | 282 | ), |
283 | 283 | 'currency_position' => array( |
284 | 284 | 'id' => 'currency_position', |
285 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
286 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
285 | + 'name' => __('Currency Position', 'invoicing'), |
|
286 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
287 | 287 | 'type' => 'select', |
288 | 288 | 'options' => array( |
289 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
290 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
291 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
292 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
289 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
290 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
291 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
292 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
293 | 293 | ) |
294 | 294 | ), |
295 | 295 | 'thousands_separator' => array( |
296 | 296 | 'id' => 'thousands_separator', |
297 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
298 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
297 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
298 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
299 | 299 | 'type' => 'text', |
300 | 300 | 'size' => 'small', |
301 | 301 | 'std' => ',', |
302 | 302 | ), |
303 | 303 | 'decimal_separator' => array( |
304 | 304 | 'id' => 'decimal_separator', |
305 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
306 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
305 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
306 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
307 | 307 | 'type' => 'text', |
308 | 308 | 'size' => 'small', |
309 | 309 | 'std' => '.', |
310 | 310 | ), |
311 | 311 | 'decimals' => array( |
312 | 312 | 'id' => 'decimals', |
313 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
314 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
313 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
314 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
315 | 315 | 'type' => 'number', |
316 | 316 | 'size' => 'small', |
317 | 317 | 'std' => '2', |
@@ -323,29 +323,29 @@ discard block |
||
323 | 323 | 'labels' => array( |
324 | 324 | 'labels' => array( |
325 | 325 | 'id' => 'labels_settings', |
326 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
326 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
327 | 327 | 'desc' => '', |
328 | 328 | 'type' => 'header', |
329 | 329 | ), |
330 | 330 | 'vat_name' => array( |
331 | 331 | 'id' => 'vat_name', |
332 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
333 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
332 | + 'name' => __('VAT Name', 'invoicing'), |
|
333 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
334 | 334 | 'type' => 'text', |
335 | 335 | 'size' => 'regular', |
336 | 336 | 'std' => 'VAT' |
337 | 337 | ), |
338 | 338 | 'vat_invoice_notice_label' => array( |
339 | 339 | 'id' => 'vat_invoice_notice_label', |
340 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
341 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
340 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
341 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
342 | 342 | 'type' => 'text', |
343 | 343 | 'size' => 'regular', |
344 | 344 | ), |
345 | 345 | 'vat_invoice_notice' => array( |
346 | 346 | 'id' => 'vat_invoice_notice', |
347 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
348 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
347 | + 'name' => __('Invoice notice', 'invoicing'), |
|
348 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
349 | 349 | 'type' => 'text', |
350 | 350 | 'size' => 'regular', |
351 | 351 | ) |
@@ -357,22 +357,22 @@ discard block |
||
357 | 357 | 'main' => array( |
358 | 358 | 'gateway_settings' => array( |
359 | 359 | 'id' => 'api_header', |
360 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
360 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
361 | 361 | 'desc' => '', |
362 | 362 | 'type' => 'header', |
363 | 363 | ), |
364 | 364 | 'gateways' => array( |
365 | 365 | 'id' => 'gateways', |
366 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
367 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
366 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
367 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
368 | 368 | 'type' => 'gateways', |
369 | 369 | 'std' => array('manual'=>1), |
370 | 370 | 'options' => wpinv_get_payment_gateways(), |
371 | 371 | ), |
372 | 372 | 'default_gateway' => array( |
373 | 373 | 'id' => 'default_gateway', |
374 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
375 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
374 | + 'name' => __('Default Gateway', 'invoicing'), |
|
375 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
376 | 376 | 'type' => 'gateway_select', |
377 | 377 | 'std' => 'manual', |
378 | 378 | 'options' => wpinv_get_payment_gateways(), |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | 'main' => array( |
387 | 387 | 'tax_settings' => array( |
388 | 388 | 'id' => 'tax_settings', |
389 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
389 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
390 | 390 | 'type' => 'header', |
391 | 391 | ), |
392 | 392 | 'enable_taxes' => array( |
393 | 393 | 'id' => 'enable_taxes', |
394 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
395 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
394 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
395 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
396 | 396 | 'type' => 'checkbox', |
397 | 397 | ), |
398 | 398 | 'tax_rate' => array( |
399 | 399 | 'id' => 'tax_rate', |
400 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
401 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
400 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
401 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
402 | 402 | 'type' => 'number', |
403 | 403 | 'size' => 'small', |
404 | 404 | 'min' => '0', |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | 'rates' => array( |
411 | 411 | 'tax_rates' => array( |
412 | 412 | 'id' => 'tax_rates', |
413 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
414 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
413 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
414 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
415 | 415 | 'type' => 'tax_rates', |
416 | 416 | ), |
417 | 417 | ) |
@@ -423,62 +423,62 @@ discard block |
||
423 | 423 | 'main' => array( |
424 | 424 | 'email_settings_header' => array( |
425 | 425 | 'id' => 'email_settings_header', |
426 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
426 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
427 | 427 | 'type' => 'header', |
428 | 428 | ), |
429 | 429 | 'email_from_name' => array( |
430 | 430 | 'id' => 'email_from_name', |
431 | - 'name' => __( 'From Name', 'invoicing' ), |
|
432 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
433 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
431 | + 'name' => __('From Name', 'invoicing'), |
|
432 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
433 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
434 | 434 | 'type' => 'text', |
435 | 435 | ), |
436 | 436 | 'email_from' => array( |
437 | 437 | 'id' => 'email_from', |
438 | - 'name' => __( 'From Email', 'invoicing' ), |
|
439 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
440 | - 'std' => get_option( 'admin_email' ), |
|
438 | + 'name' => __('From Email', 'invoicing'), |
|
439 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
440 | + 'std' => get_option('admin_email'), |
|
441 | 441 | 'type' => 'text', |
442 | 442 | ), |
443 | 443 | 'overdue_settings_header' => array( |
444 | 444 | 'id' => 'overdue_settings_header', |
445 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
445 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
446 | 446 | 'type' => 'header', |
447 | 447 | ), |
448 | 448 | 'overdue_active' => array( |
449 | 449 | 'id' => 'overdue_active', |
450 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
451 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
450 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
451 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
452 | 452 | 'type' => 'checkbox', |
453 | 453 | 'std' => false, |
454 | 454 | ), |
455 | 455 | 'overdue_days' => array( |
456 | 456 | 'id' => 'overdue_days', |
457 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
458 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
457 | + 'name' => __('Default Due Date', 'invoicing'), |
|
458 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
459 | 459 | 'type' => 'select', |
460 | 460 | 'options' => $due_payment_options, |
461 | 461 | 'chosen' => true, |
462 | 462 | 'std' => 0, |
463 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
463 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
464 | 464 | ), |
465 | 465 | 'email_template_header' => array( |
466 | 466 | 'id' => 'email_template_header', |
467 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
467 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
468 | 468 | 'type' => 'header', |
469 | 469 | ), |
470 | 470 | 'email_header_image' => array( |
471 | 471 | 'id' => 'email_header_image', |
472 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
473 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
472 | + 'name' => __('Header Image', 'invoicing'), |
|
473 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
474 | 474 | 'std' => '', |
475 | 475 | 'type' => 'text', |
476 | 476 | ), |
477 | 477 | 'email_footer_text' => array( |
478 | 478 | 'id' => 'email_footer_text', |
479 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
480 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
481 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
479 | + 'name' => __('Footer Text', 'invoicing'), |
|
480 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
481 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
482 | 482 | 'type' => 'textarea', |
483 | 483 | 'class' => 'regular-text', |
484 | 484 | 'rows' => 2, |
@@ -486,29 +486,29 @@ discard block |
||
486 | 486 | ), |
487 | 487 | 'email_base_color' => array( |
488 | 488 | 'id' => 'email_base_color', |
489 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
490 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
489 | + 'name' => __('Base Color', 'invoicing'), |
|
490 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
491 | 491 | 'std' => '#557da2', |
492 | 492 | 'type' => 'color', |
493 | 493 | ), |
494 | 494 | 'email_background_color' => array( |
495 | 495 | 'id' => 'email_background_color', |
496 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
497 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
496 | + 'name' => __('Background Color', 'invoicing'), |
|
497 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
498 | 498 | 'std' => '#f5f5f5', |
499 | 499 | 'type' => 'color', |
500 | 500 | ), |
501 | 501 | 'email_body_background_color' => array( |
502 | 502 | 'id' => 'email_body_background_color', |
503 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
504 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
503 | + 'name' => __('Body Background Color', 'invoicing'), |
|
504 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
505 | 505 | 'std' => '#fdfdfd', |
506 | 506 | 'type' => 'color', |
507 | 507 | ), |
508 | 508 | 'email_text_color' => array( |
509 | 509 | 'id' => 'email_text_color', |
510 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
511 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
510 | + 'name' => __('Body Text Color', 'invoicing'), |
|
511 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
512 | 512 | 'std' => '#505050', |
513 | 513 | 'type' => 'color', |
514 | 514 | ), |
@@ -527,73 +527,73 @@ discard block |
||
527 | 527 | 'main' => array( |
528 | 528 | 'fields_settings' => array( |
529 | 529 | 'id' => 'fields_settings', |
530 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
531 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
530 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
531 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
532 | 532 | 'type' => 'header', |
533 | 533 | ), |
534 | 534 | 'fname_mandatory' => array( |
535 | 535 | 'id' => 'fname_mandatory', |
536 | - 'name' => __( 'First Name', 'invoicing' ), |
|
536 | + 'name' => __('First Name', 'invoicing'), |
|
537 | 537 | 'type' => 'checkbox', |
538 | 538 | 'std' => true, |
539 | 539 | ), |
540 | 540 | 'lname_mandatory' => array( |
541 | 541 | 'id' => 'lname_mandatory', |
542 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
542 | + 'name' => __('Last Name', 'invoicing'), |
|
543 | 543 | 'type' => 'checkbox', |
544 | 544 | 'std' => true, |
545 | 545 | ), |
546 | 546 | 'address_mandatory' => array( |
547 | 547 | 'id' => 'address_mandatory', |
548 | - 'name' => __( 'Address', 'invoicing' ), |
|
548 | + 'name' => __('Address', 'invoicing'), |
|
549 | 549 | 'type' => 'checkbox', |
550 | 550 | 'std' => true, |
551 | 551 | ), |
552 | 552 | 'city_mandatory' => array( |
553 | 553 | 'id' => 'city_mandatory', |
554 | - 'name' => __( 'City', 'invoicing' ), |
|
554 | + 'name' => __('City', 'invoicing'), |
|
555 | 555 | 'type' => 'checkbox', |
556 | 556 | 'std' => true, |
557 | 557 | ), |
558 | 558 | 'country_mandatory' => array( |
559 | 559 | 'id' => 'country_mandatory', |
560 | - 'name' => __( 'Country', 'invoicing' ), |
|
560 | + 'name' => __('Country', 'invoicing'), |
|
561 | 561 | 'type' => 'checkbox', |
562 | 562 | 'std' => true, |
563 | 563 | ), |
564 | 564 | 'state_mandatory' => array( |
565 | 565 | 'id' => 'state_mandatory', |
566 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
566 | + 'name' => __('State / Province', 'invoicing'), |
|
567 | 567 | 'type' => 'checkbox', |
568 | 568 | 'std' => true, |
569 | 569 | ), |
570 | 570 | 'zip_mandatory' => array( |
571 | 571 | 'id' => 'zip_mandatory', |
572 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
572 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
573 | 573 | 'type' => 'checkbox', |
574 | 574 | 'std' => true, |
575 | 575 | ), |
576 | 576 | 'phone_mandatory' => array( |
577 | 577 | 'id' => 'phone_mandatory', |
578 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
578 | + 'name' => __('Phone Number', 'invoicing'), |
|
579 | 579 | 'type' => 'checkbox', |
580 | 580 | 'std' => true, |
581 | 581 | ), |
582 | 582 | 'invoice_number_format_settings' => array( |
583 | 583 | 'id' => 'invoice_number_format_settings', |
584 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
584 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
585 | 585 | 'type' => 'header', |
586 | 586 | ), |
587 | 587 | 'sequential_invoice_number' => array( |
588 | 588 | 'id' => 'sequential_invoice_number', |
589 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
590 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
589 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
590 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
591 | 591 | 'type' => 'checkbox', |
592 | 592 | ), |
593 | 593 | 'invoice_sequence_start' => array( |
594 | 594 | 'id' => 'invoice_sequence_start', |
595 | - 'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ), |
|
596 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ), |
|
595 | + 'name' => __('Sequential Starting Number', 'easy-digital-downloads'), |
|
596 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'), |
|
597 | 597 | 'type' => 'number', |
598 | 598 | 'size' => 'small', |
599 | 599 | 'std' => '1', |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | ), |
602 | 602 | 'invoice_number_padd' => array( |
603 | 603 | 'id' => 'invoice_number_padd', |
604 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
605 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
604 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
605 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
606 | 606 | 'type' => 'select', |
607 | 607 | 'options' => $invoice_number_padd_options, |
608 | 608 | 'std' => 5, |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | ), |
611 | 611 | 'invoice_number_prefix' => array( |
612 | 612 | 'id' => 'invoice_number_prefix', |
613 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
614 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
613 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
614 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
615 | 615 | 'type' => 'text', |
616 | 616 | 'size' => 'regular', |
617 | 617 | 'std' => 'WPINV-', |
@@ -619,25 +619,25 @@ discard block |
||
619 | 619 | ), |
620 | 620 | 'invoice_number_postfix' => array( |
621 | 621 | 'id' => 'invoice_number_postfix', |
622 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
623 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
622 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
623 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
624 | 624 | 'type' => 'text', |
625 | 625 | 'size' => 'regular', |
626 | 626 | 'std' => '' |
627 | 627 | ), |
628 | 628 | 'guest_checkout_settings' => array( |
629 | 629 | 'id' => 'guest_checkout_settings', |
630 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
630 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
631 | 631 | 'type' => 'header', |
632 | 632 | ), |
633 | 633 | 'guest_checkout' => array( |
634 | 634 | 'type' => 'radio', |
635 | 635 | 'id' => 'guest_checkout', |
636 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
637 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing' ), |
|
636 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
637 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing'), |
|
638 | 638 | 'options' => array( |
639 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
640 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
639 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
640 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
641 | 641 | ), |
642 | 642 | 'std' => 0, |
643 | 643 | ), |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | 'main' => array( |
651 | 651 | 'tool_settings' => array( |
652 | 652 | 'id' => 'tool_settings', |
653 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
654 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
653 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
654 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
655 | 655 | 'type' => 'tools', |
656 | 656 | ), |
657 | 657 | ), |
@@ -659,135 +659,135 @@ discard block |
||
659 | 659 | ) |
660 | 660 | ); |
661 | 661 | |
662 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
662 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
663 | 663 | } |
664 | 664 | |
665 | -function wpinv_settings_sanitize( $input = array() ) { |
|
665 | +function wpinv_settings_sanitize($input = array()) { |
|
666 | 666 | global $wpinv_options; |
667 | 667 | |
668 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
668 | + if (empty($_POST['_wp_http_referer'])) { |
|
669 | 669 | return $input; |
670 | 670 | } |
671 | 671 | |
672 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
672 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
673 | 673 | |
674 | 674 | $settings = wpinv_get_registered_settings(); |
675 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
676 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
675 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
676 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
677 | 677 | |
678 | 678 | $input = $input ? $input : array(); |
679 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
680 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
679 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
680 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
681 | 681 | |
682 | 682 | // Loop through each setting being saved and pass it through a sanitization filter |
683 | - foreach ( $input as $key => $value ) { |
|
683 | + foreach ($input as $key => $value) { |
|
684 | 684 | // Get the setting type (checkbox, select, etc) |
685 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
685 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
686 | 686 | |
687 | - if ( $type ) { |
|
687 | + if ($type) { |
|
688 | 688 | // Field type specific filter |
689 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
689 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // General filter |
693 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
693 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | // Loop through the whitelist and unset any that are empty for the tab being saved |
697 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
698 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
697 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
698 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
699 | 699 | |
700 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
700 | + $found_settings = array_merge($main_settings, $section_settings); |
|
701 | 701 | |
702 | - if ( ! empty( $found_settings ) ) { |
|
703 | - foreach ( $found_settings as $key => $value ) { |
|
702 | + if (!empty($found_settings)) { |
|
703 | + foreach ($found_settings as $key => $value) { |
|
704 | 704 | |
705 | 705 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
706 | - if ( is_numeric( $key ) ) { |
|
706 | + if (is_numeric($key)) { |
|
707 | 707 | $key = $value['id']; |
708 | 708 | } |
709 | 709 | |
710 | - if ( empty( $input[ $key ] ) ) { |
|
711 | - unset( $wpinv_options[ $key ] ); |
|
710 | + if (empty($input[$key])) { |
|
711 | + unset($wpinv_options[$key]); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
716 | 716 | // Merge our new settings with the existing |
717 | - $output = array_merge( $wpinv_options, $input ); |
|
717 | + $output = array_merge($wpinv_options, $input); |
|
718 | 718 | |
719 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
719 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
720 | 720 | |
721 | 721 | return $output; |
722 | 722 | } |
723 | 723 | |
724 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
724 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
725 | 725 | global $wpinv_options, $wpi_session; |
726 | 726 | |
727 | - if ( !current_user_can( 'manage_options' ) ) { |
|
727 | + if (!current_user_can('manage_options')) { |
|
728 | 728 | return $input; |
729 | 729 | } |
730 | 730 | |
731 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
731 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
732 | 732 | // Shows an admin notice about upgrading previous order numbers |
733 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
733 | + $wpi_session->set('upgrade_sequential', '1'); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | return $input; |
737 | 737 | } |
738 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
738 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
739 | 739 | |
740 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
741 | - if( !current_user_can( 'manage_options' ) ) { |
|
740 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
741 | + if (!current_user_can('manage_options')) { |
|
742 | 742 | return $input; |
743 | 743 | } |
744 | 744 | |
745 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
745 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
746 | 746 | |
747 | 747 | $tax_rates = array(); |
748 | 748 | |
749 | - if ( !empty( $new_rates ) ) { |
|
750 | - foreach ( $new_rates as $rate ) { |
|
751 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
749 | + if (!empty($new_rates)) { |
|
750 | + foreach ($new_rates as $rate) { |
|
751 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
752 | 752 | continue; |
753 | 753 | } |
754 | 754 | |
755 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
755 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
756 | 756 | |
757 | 757 | $tax_rates[] = $rate; |
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
761 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
761 | + update_option('wpinv_tax_rates', $tax_rates); |
|
762 | 762 | |
763 | 763 | return $input; |
764 | 764 | } |
765 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
765 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
766 | 766 | |
767 | -function wpinv_sanitize_text_field( $input ) { |
|
768 | - return trim( $input ); |
|
767 | +function wpinv_sanitize_text_field($input) { |
|
768 | + return trim($input); |
|
769 | 769 | } |
770 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
770 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
771 | 771 | |
772 | 772 | function wpinv_get_settings_tabs() { |
773 | 773 | $tabs = array(); |
774 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
775 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
776 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
777 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
778 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
779 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
780 | - |
|
781 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
774 | + $tabs['general'] = __('General', 'invoicing'); |
|
775 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
776 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
777 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
778 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
779 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
780 | + |
|
781 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
782 | 782 | } |
783 | 783 | |
784 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
784 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
785 | 785 | $tabs = false; |
786 | 786 | $sections = wpinv_get_registered_settings_sections(); |
787 | 787 | |
788 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
789 | - $tabs = $sections[ $tab ]; |
|
790 | - } else if ( $tab ) { |
|
788 | + if ($tab && !empty($sections[$tab])) { |
|
789 | + $tabs = $sections[$tab]; |
|
790 | + } else if ($tab) { |
|
791 | 791 | $tabs = false; |
792 | 792 | } |
793 | 793 | |
@@ -797,135 +797,135 @@ discard block |
||
797 | 797 | function wpinv_get_registered_settings_sections() { |
798 | 798 | static $sections = false; |
799 | 799 | |
800 | - if ( false !== $sections ) { |
|
800 | + if (false !== $sections) { |
|
801 | 801 | return $sections; |
802 | 802 | } |
803 | 803 | |
804 | 804 | $sections = array( |
805 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
806 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
807 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
808 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
809 | - ) ), |
|
810 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
811 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
812 | - ) ), |
|
813 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
814 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
815 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
816 | - ) ), |
|
817 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
818 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
819 | - ) ), |
|
820 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
821 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
822 | - ) ), |
|
823 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
824 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
825 | - ) ), |
|
805 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
806 | + 'main' => __('General Settings', 'invoicing'), |
|
807 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
808 | + 'labels' => __('Label Texts', 'invoicing'), |
|
809 | + )), |
|
810 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
811 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
812 | + )), |
|
813 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
814 | + 'main' => __('Tax Settings', 'invoicing'), |
|
815 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
816 | + )), |
|
817 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
818 | + 'main' => __('Email Settings', 'invoicing'), |
|
819 | + )), |
|
820 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
821 | + 'main' => __('Misc Settings', 'invoicing'), |
|
822 | + )), |
|
823 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
824 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
825 | + )), |
|
826 | 826 | ); |
827 | 827 | |
828 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
828 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
829 | 829 | |
830 | 830 | return $sections; |
831 | 831 | } |
832 | 832 | |
833 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
833 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
834 | 834 | $pages_options = array(); |
835 | 835 | |
836 | - if( $default_label !== NULL && $default_label !== false ) { |
|
837 | - $pages_options = array( '' => $default_label ); // Blank option |
|
836 | + if ($default_label !== NULL && $default_label !== false) { |
|
837 | + $pages_options = array('' => $default_label); // Blank option |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | $pages = get_pages(); |
841 | - if ( $pages ) { |
|
842 | - foreach ( $pages as $page ) { |
|
841 | + if ($pages) { |
|
842 | + foreach ($pages as $page) { |
|
843 | 843 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
844 | - $pages_options[ $page->ID ] = $title; |
|
844 | + $pages_options[$page->ID] = $title; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
848 | 848 | return $pages_options; |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_header_callback( $args ) { |
|
852 | - if ( !empty( $args['desc'] ) ) { |
|
851 | +function wpinv_header_callback($args) { |
|
852 | + if (!empty($args['desc'])) { |
|
853 | 853 | echo $args['desc']; |
854 | 854 | } |
855 | 855 | } |
856 | 856 | |
857 | -function wpinv_hidden_callback( $args ) { |
|
857 | +function wpinv_hidden_callback($args) { |
|
858 | 858 | global $wpinv_options; |
859 | 859 | |
860 | - if ( isset( $args['set_value'] ) ) { |
|
860 | + if (isset($args['set_value'])) { |
|
861 | 861 | $value = $args['set_value']; |
862 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
863 | - $value = $wpinv_options[ $args['id'] ]; |
|
862 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
863 | + $value = $wpinv_options[$args['id']]; |
|
864 | 864 | } else { |
865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
865 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
866 | 866 | } |
867 | 867 | |
868 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
868 | + if (isset($args['faux']) && true === $args['faux']) { |
|
869 | 869 | $args['readonly'] = true; |
870 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
870 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
871 | 871 | $name = ''; |
872 | 872 | } else { |
873 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
873 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
874 | 874 | } |
875 | 875 | |
876 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
876 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
877 | 877 | |
878 | 878 | echo $html; |
879 | 879 | } |
880 | 880 | |
881 | -function wpinv_checkbox_callback( $args ) { |
|
881 | +function wpinv_checkbox_callback($args) { |
|
882 | 882 | global $wpinv_options; |
883 | 883 | |
884 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
884 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
885 | 885 | |
886 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
886 | + if (isset($args['faux']) && true === $args['faux']) { |
|
887 | 887 | $name = ''; |
888 | 888 | } else { |
889 | 889 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
890 | 890 | } |
891 | 891 | |
892 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
892 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
893 | 893 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
894 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
894 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
895 | 895 | |
896 | 896 | echo $html; |
897 | 897 | } |
898 | 898 | |
899 | -function wpinv_multicheck_callback( $args ) { |
|
899 | +function wpinv_multicheck_callback($args) { |
|
900 | 900 | global $wpinv_options; |
901 | 901 | |
902 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
902 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
903 | 903 | |
904 | - if ( ! empty( $args['options'] ) ) { |
|
905 | - foreach( $args['options'] as $key => $option ): |
|
906 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
907 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
904 | + if (!empty($args['options'])) { |
|
905 | + foreach ($args['options'] as $key => $option): |
|
906 | + $sanitize_key = wpinv_sanitize_key($key); |
|
907 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
908 | 908 | $enabled = $sanitize_key; |
909 | 909 | } else { |
910 | 910 | $enabled = NULL; |
911 | 911 | } |
912 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
913 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
912 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
913 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
914 | 914 | endforeach; |
915 | 915 | echo '<p class="description">' . $args['desc'] . '</p>'; |
916 | 916 | } |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_payment_icons_callback( $args ) { |
|
919 | +function wpinv_payment_icons_callback($args) { |
|
920 | 920 | global $wpinv_options; |
921 | 921 | |
922 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
922 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
923 | 923 | |
924 | - if ( ! empty( $args['options'] ) ) { |
|
925 | - foreach( $args['options'] as $key => $option ) { |
|
926 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
924 | + if (!empty($args['options'])) { |
|
925 | + foreach ($args['options'] as $key => $option) { |
|
926 | + $sanitize_key = wpinv_sanitize_key($key); |
|
927 | 927 | |
928 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
928 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
929 | 929 | $enabled = $option; |
930 | 930 | } else { |
931 | 931 | $enabled = NULL; |
@@ -933,196 +933,196 @@ discard block |
||
933 | 933 | |
934 | 934 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
935 | 935 | |
936 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
936 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
937 | 937 | |
938 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
939 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
938 | + if (wpinv_string_is_image_url($key)) { |
|
939 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
940 | 940 | } else { |
941 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
941 | + $card = strtolower(str_replace(' ', '', $option)); |
|
942 | 942 | |
943 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
944 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
943 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
944 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
945 | 945 | } else { |
946 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
946 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
947 | 947 | $content_dir = WP_CONTENT_DIR; |
948 | 948 | |
949 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
949 | + if (function_exists('wp_normalize_path')) { |
|
950 | 950 | // Replaces backslashes with forward slashes for Windows systems |
951 | - $image = wp_normalize_path( $image ); |
|
952 | - $content_dir = wp_normalize_path( $content_dir ); |
|
951 | + $image = wp_normalize_path($image); |
|
952 | + $content_dir = wp_normalize_path($content_dir); |
|
953 | 953 | } |
954 | 954 | |
955 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
955 | + $image = str_replace($content_dir, content_url(), $image); |
|
956 | 956 | } |
957 | 957 | |
958 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
958 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
959 | 959 | } |
960 | 960 | echo $option . '</label>'; |
961 | 961 | } |
962 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
962 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
966 | -function wpinv_radio_callback( $args ) { |
|
966 | +function wpinv_radio_callback($args) { |
|
967 | 967 | global $wpinv_options; |
968 | 968 | |
969 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
969 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
970 | 970 | |
971 | - foreach ( $args['options'] as $key => $option ) : |
|
972 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
971 | + foreach ($args['options'] as $key => $option) : |
|
972 | + $sanitize_key = wpinv_sanitize_key($key); |
|
973 | 973 | |
974 | 974 | $checked = false; |
975 | 975 | |
976 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
976 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
977 | 977 | $checked = true; |
978 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
978 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
979 | 979 | $checked = true; |
980 | 980 | |
981 | 981 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
982 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
982 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
983 | 983 | endforeach; |
984 | 984 | |
985 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
985 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_gateways_callback( $args ) { |
|
988 | +function wpinv_gateways_callback($args) { |
|
989 | 989 | global $wpinv_options; |
990 | 990 | |
991 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
991 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
992 | 992 | |
993 | - foreach ( $args['options'] as $key => $option ) : |
|
994 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
993 | + foreach ($args['options'] as $key => $option) : |
|
994 | + $sanitize_key = wpinv_sanitize_key($key); |
|
995 | 995 | |
996 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
996 | + if (isset($wpinv_options['gateways'][$key])) |
|
997 | 997 | $enabled = '1'; |
998 | 998 | else |
999 | 999 | $enabled = null; |
1000 | 1000 | |
1001 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1002 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1001 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1002 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
1003 | 1003 | endforeach; |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | function wpinv_gateway_select_callback($args) { |
1007 | 1007 | global $wpinv_options; |
1008 | 1008 | |
1009 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1009 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1010 | 1010 | |
1011 | 1011 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
1012 | 1012 | |
1013 | - foreach ( $args['options'] as $key => $option ) : |
|
1014 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1015 | - $selected = selected( $key, $args['selected'], false ); |
|
1013 | + foreach ($args['options'] as $key => $option) : |
|
1014 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1015 | + $selected = selected($key, $args['selected'], false); |
|
1016 | 1016 | } else { |
1017 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
1017 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
1018 | 1018 | } |
1019 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1019 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
1020 | 1020 | endforeach; |
1021 | 1021 | |
1022 | 1022 | echo '</select>'; |
1023 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1023 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | -function wpinv_text_callback( $args ) { |
|
1026 | +function wpinv_text_callback($args) { |
|
1027 | 1027 | global $wpinv_options; |
1028 | 1028 | |
1029 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1029 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1030 | 1030 | |
1031 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1032 | - $value = $wpinv_options[ $args['id'] ]; |
|
1031 | + if (isset($wpinv_options[$args['id']])) { |
|
1032 | + $value = $wpinv_options[$args['id']]; |
|
1033 | 1033 | } else { |
1034 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1034 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1037 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1038 | 1038 | $args['readonly'] = true; |
1039 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1039 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1040 | 1040 | $name = ''; |
1041 | 1041 | } else { |
1042 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1042 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1043 | 1043 | } |
1044 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1044 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1045 | 1045 | |
1046 | 1046 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
1047 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1048 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1049 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1047 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1048 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
1049 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1050 | 1050 | |
1051 | 1051 | echo $html; |
1052 | 1052 | } |
1053 | 1053 | |
1054 | -function wpinv_number_callback( $args ) { |
|
1054 | +function wpinv_number_callback($args) { |
|
1055 | 1055 | global $wpinv_options; |
1056 | 1056 | |
1057 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1057 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1058 | 1058 | |
1059 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1060 | - $value = $wpinv_options[ $args['id'] ]; |
|
1059 | + if (isset($wpinv_options[$args['id']])) { |
|
1060 | + $value = $wpinv_options[$args['id']]; |
|
1061 | 1061 | } else { |
1062 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1062 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1065 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1066 | 1066 | $args['readonly'] = true; |
1067 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1067 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1068 | 1068 | $name = ''; |
1069 | 1069 | } else { |
1070 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1070 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1074 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1075 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1076 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1073 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
1074 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
1075 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
1076 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1077 | 1077 | |
1078 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1079 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1080 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1078 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1079 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1080 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1081 | 1081 | |
1082 | 1082 | echo $html; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | -function wpinv_textarea_callback( $args ) { |
|
1085 | +function wpinv_textarea_callback($args) { |
|
1086 | 1086 | global $wpinv_options; |
1087 | 1087 | |
1088 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1088 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1089 | 1089 | |
1090 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1091 | - $value = $wpinv_options[ $args['id'] ]; |
|
1090 | + if (isset($wpinv_options[$args['id']])) { |
|
1091 | + $value = $wpinv_options[$args['id']]; |
|
1092 | 1092 | } else { |
1093 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1093 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1097 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
1096 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1097 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
1098 | 1098 | |
1099 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1100 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1099 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1100 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1101 | 1101 | |
1102 | 1102 | echo $html; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | -function wpinv_password_callback( $args ) { |
|
1105 | +function wpinv_password_callback($args) { |
|
1106 | 1106 | global $wpinv_options; |
1107 | 1107 | |
1108 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1108 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1109 | 1109 | |
1110 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1111 | - $value = $wpinv_options[ $args['id'] ]; |
|
1110 | + if (isset($wpinv_options[$args['id']])) { |
|
1111 | + $value = $wpinv_options[$args['id']]; |
|
1112 | 1112 | } else { |
1113 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1113 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1117 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1118 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1116 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1117 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
1118 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1119 | 1119 | |
1120 | 1120 | echo $html; |
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | function wpinv_missing_callback($args) { |
1124 | 1124 | printf( |
1125 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1125 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
1126 | 1126 | '<strong>' . $args['id'] . '</strong>' |
1127 | 1127 | ); |
1128 | 1128 | } |
@@ -1130,137 +1130,137 @@ discard block |
||
1130 | 1130 | function wpinv_select_callback($args) { |
1131 | 1131 | global $wpinv_options; |
1132 | 1132 | |
1133 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1133 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1134 | 1134 | |
1135 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1136 | - $value = $wpinv_options[ $args['id'] ]; |
|
1135 | + if (isset($wpinv_options[$args['id']])) { |
|
1136 | + $value = $wpinv_options[$args['id']]; |
|
1137 | 1137 | } else { |
1138 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1138 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1141 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1142 | 1142 | $value = $args['selected']; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - if ( isset( $args['placeholder'] ) ) { |
|
1145 | + if (isset($args['placeholder'])) { |
|
1146 | 1146 | $placeholder = $args['placeholder']; |
1147 | 1147 | } else { |
1148 | 1148 | $placeholder = ''; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | - if ( isset( $args['chosen'] ) ) { |
|
1151 | + if (isset($args['chosen'])) { |
|
1152 | 1152 | $chosen = 'class="wpinv-chosen"'; |
1153 | 1153 | } else { |
1154 | 1154 | $chosen = ''; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - if( !empty( $args['onchange'] ) ) { |
|
1158 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
1157 | + if (!empty($args['onchange'])) { |
|
1158 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
1159 | 1159 | } else { |
1160 | 1160 | $onchange = ''; |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1163 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
1164 | 1164 | |
1165 | - foreach ( $args['options'] as $option => $name ) { |
|
1166 | - $selected = selected( $option, $value, false ); |
|
1167 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1165 | + foreach ($args['options'] as $option => $name) { |
|
1166 | + $selected = selected($option, $value, false); |
|
1167 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | $html .= '</select>'; |
1171 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1171 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1172 | 1172 | |
1173 | 1173 | echo $html; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | -function wpinv_color_select_callback( $args ) { |
|
1176 | +function wpinv_color_select_callback($args) { |
|
1177 | 1177 | global $wpinv_options; |
1178 | 1178 | |
1179 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1179 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1180 | 1180 | |
1181 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1182 | - $value = $wpinv_options[ $args['id'] ]; |
|
1181 | + if (isset($wpinv_options[$args['id']])) { |
|
1182 | + $value = $wpinv_options[$args['id']]; |
|
1183 | 1183 | } else { |
1184 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1184 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1187 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
1188 | 1188 | |
1189 | - foreach ( $args['options'] as $option => $color ) { |
|
1190 | - $selected = selected( $option, $value, false ); |
|
1191 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1189 | + foreach ($args['options'] as $option => $color) { |
|
1190 | + $selected = selected($option, $value, false); |
|
1191 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | $html .= '</select>'; |
1195 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1195 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1196 | 1196 | |
1197 | 1197 | echo $html; |
1198 | 1198 | } |
1199 | 1199 | |
1200 | -function wpinv_rich_editor_callback( $args ) { |
|
1200 | +function wpinv_rich_editor_callback($args) { |
|
1201 | 1201 | global $wpinv_options, $wp_version; |
1202 | 1202 | |
1203 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1203 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1204 | 1204 | |
1205 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1206 | - $value = $wpinv_options[ $args['id'] ]; |
|
1205 | + if (isset($wpinv_options[$args['id']])) { |
|
1206 | + $value = $wpinv_options[$args['id']]; |
|
1207 | 1207 | |
1208 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1209 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1208 | + if (empty($args['allow_blank']) && empty($value)) { |
|
1209 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1210 | 1210 | } |
1211 | 1211 | } else { |
1212 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1212 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1215 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
1216 | 1216 | |
1217 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1217 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
1218 | 1218 | ob_start(); |
1219 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1219 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
1220 | 1220 | $html = ob_get_clean(); |
1221 | 1221 | } else { |
1222 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1222 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1225 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1226 | 1226 | |
1227 | 1227 | echo $html; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | -function wpinv_upload_callback( $args ) { |
|
1230 | +function wpinv_upload_callback($args) { |
|
1231 | 1231 | global $wpinv_options; |
1232 | 1232 | |
1233 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1233 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1234 | 1234 | |
1235 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1235 | + if (isset($wpinv_options[$args['id']])) { |
|
1236 | 1236 | $value = $wpinv_options[$args['id']]; |
1237 | 1237 | } else { |
1238 | 1238 | $value = isset($args['std']) ? $args['std'] : ''; |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1242 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1243 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1244 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1241 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1242 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1243 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
1244 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1245 | 1245 | |
1246 | 1246 | echo $html; |
1247 | 1247 | } |
1248 | 1248 | |
1249 | -function wpinv_color_callback( $args ) { |
|
1249 | +function wpinv_color_callback($args) { |
|
1250 | 1250 | global $wpinv_options; |
1251 | 1251 | |
1252 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1252 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1253 | 1253 | |
1254 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1255 | - $value = $wpinv_options[ $args['id'] ]; |
|
1254 | + if (isset($wpinv_options[$args['id']])) { |
|
1255 | + $value = $wpinv_options[$args['id']]; |
|
1256 | 1256 | } else { |
1257 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1257 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1260 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
1261 | 1261 | |
1262 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1263 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1262 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
1263 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1264 | 1264 | |
1265 | 1265 | echo $html; |
1266 | 1266 | } |
@@ -1268,9 +1268,9 @@ discard block |
||
1268 | 1268 | function wpinv_country_states_callback($args) { |
1269 | 1269 | global $wpinv_options; |
1270 | 1270 | |
1271 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1271 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1272 | 1272 | |
1273 | - if ( isset( $args['placeholder'] ) ) { |
|
1273 | + if (isset($args['placeholder'])) { |
|
1274 | 1274 | $placeholder = $args['placeholder']; |
1275 | 1275 | } else { |
1276 | 1276 | $placeholder = ''; |
@@ -1278,17 +1278,17 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | $states = wpinv_get_country_states(); |
1280 | 1280 | |
1281 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
1282 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1283 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1281 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
1282 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1283 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
1284 | 1284 | |
1285 | - foreach ( $states as $option => $name ) { |
|
1286 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1287 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1285 | + foreach ($states as $option => $name) { |
|
1286 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
1287 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | $html .= '</select>'; |
1291 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1291 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1292 | 1292 | |
1293 | 1293 | echo $html; |
1294 | 1294 | } |
@@ -1303,25 +1303,25 @@ discard block |
||
1303 | 1303 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
1304 | 1304 | <thead> |
1305 | 1305 | <tr> |
1306 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
1307 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
1308 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
1309 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
1310 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
1311 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
1306 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
1307 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
1308 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
1309 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
1310 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
1311 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
1312 | 1312 | </tr> |
1313 | 1313 | </thead> |
1314 | 1314 | <tbody> |
1315 | - <?php if( !empty( $rates ) ) : ?> |
|
1316 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
1315 | + <?php if (!empty($rates)) : ?> |
|
1316 | + <?php foreach ($rates as $key => $rate) : ?> |
|
1317 | 1317 | <?php |
1318 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
1318 | + $sanitized_key = wpinv_sanitize_key($key); |
|
1319 | 1319 | ?> |
1320 | 1320 | <tr> |
1321 | 1321 | <td class="wpinv_tax_country"> |
1322 | 1322 | <?php |
1323 | - echo wpinv_html_select( array( |
|
1324 | - 'options' => wpinv_get_country_list( true ), |
|
1323 | + echo wpinv_html_select(array( |
|
1324 | + 'options' => wpinv_get_country_list(true), |
|
1325 | 1325 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
1326 | 1326 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1327 | 1327 | 'selected' => $rate['country'], |
@@ -1329,72 +1329,72 @@ discard block |
||
1329 | 1329 | 'show_option_none' => false, |
1330 | 1330 | 'class' => 'wpinv-tax-country', |
1331 | 1331 | 'chosen' => false, |
1332 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1333 | - ) ); |
|
1332 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1333 | + )); |
|
1334 | 1334 | ?> |
1335 | 1335 | </td> |
1336 | 1336 | <td class="wpinv_tax_state"> |
1337 | 1337 | <?php |
1338 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1339 | - if( !empty( $states ) ) { |
|
1340 | - echo wpinv_html_select( array( |
|
1341 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1338 | + $states = wpinv_get_country_states($rate['country']); |
|
1339 | + if (!empty($states)) { |
|
1340 | + echo wpinv_html_select(array( |
|
1341 | + 'options' => array_merge(array('' => ''), $states), |
|
1342 | 1342 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
1343 | 1343 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1344 | 1344 | 'selected' => $rate['state'], |
1345 | 1345 | 'show_option_all' => false, |
1346 | 1346 | 'show_option_none' => false, |
1347 | 1347 | 'chosen' => false, |
1348 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1349 | - ) ); |
|
1348 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
1349 | + )); |
|
1350 | 1350 | } else { |
1351 | - echo wpinv_html_text( array( |
|
1351 | + echo wpinv_html_text(array( |
|
1352 | 1352 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
1353 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1353 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
1354 | 1354 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1355 | - ) ); |
|
1355 | + )); |
|
1356 | 1356 | } |
1357 | 1357 | ?> |
1358 | 1358 | </td> |
1359 | 1359 | <td class="wpinv_tax_global"> |
1360 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
1361 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1360 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
1361 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1362 | 1362 | </td> |
1363 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
1364 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
1365 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1363 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
1364 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
1365 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1366 | 1366 | </tr> |
1367 | 1367 | <?php endforeach; ?> |
1368 | 1368 | <?php else : ?> |
1369 | 1369 | <tr> |
1370 | 1370 | <td class="wpinv_tax_country"> |
1371 | 1371 | <?php |
1372 | - echo wpinv_html_select( array( |
|
1373 | - 'options' => wpinv_get_country_list( true ), |
|
1372 | + echo wpinv_html_select(array( |
|
1373 | + 'options' => wpinv_get_country_list(true), |
|
1374 | 1374 | 'name' => 'tax_rates[0][country]', |
1375 | 1375 | 'show_option_all' => false, |
1376 | 1376 | 'show_option_none' => false, |
1377 | 1377 | 'class' => 'wpinv-tax-country', |
1378 | 1378 | 'chosen' => false, |
1379 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1380 | - ) ); ?> |
|
1379 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1380 | + )); ?> |
|
1381 | 1381 | </td> |
1382 | 1382 | <td class="wpinv_tax_state"> |
1383 | - <?php echo wpinv_html_text( array( |
|
1383 | + <?php echo wpinv_html_text(array( |
|
1384 | 1384 | 'name' => 'tax_rates[0][state]' |
1385 | - ) ); ?> |
|
1385 | + )); ?> |
|
1386 | 1386 | </td> |
1387 | 1387 | <td class="wpinv_tax_global"> |
1388 | 1388 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
1389 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1389 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1390 | 1390 | </td> |
1391 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
1391 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
1392 | 1392 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
1393 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1393 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1394 | 1394 | </tr> |
1395 | 1395 | <?php endif; ?> |
1396 | 1396 | </tbody> |
1397 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
1397 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
1398 | 1398 | </table> |
1399 | 1399 | <?php |
1400 | 1400 | echo ob_get_clean(); |
@@ -1405,44 +1405,44 @@ discard block |
||
1405 | 1405 | ob_start(); ?> |
1406 | 1406 | </td><tr> |
1407 | 1407 | <td colspan="2" class="wpinv_tools_tdbox"> |
1408 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1409 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1408 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1409 | + <?php do_action('wpinv_tools_before'); ?> |
|
1410 | 1410 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1411 | 1411 | <thead> |
1412 | 1412 | <tr> |
1413 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1414 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1415 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1413 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1414 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1415 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1416 | 1416 | </tr> |
1417 | 1417 | </thead> |
1418 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1418 | + <?php do_action('wpinv_tools_row'); ?> |
|
1419 | 1419 | <tbody> |
1420 | 1420 | </tbody> |
1421 | 1421 | </table> |
1422 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1422 | + <?php do_action('wpinv_tools_after'); ?> |
|
1423 | 1423 | <?php |
1424 | 1424 | echo ob_get_clean(); |
1425 | 1425 | } |
1426 | 1426 | |
1427 | -function wpinv_descriptive_text_callback( $args ) { |
|
1428 | - echo wp_kses_post( $args['desc'] ); |
|
1427 | +function wpinv_descriptive_text_callback($args) { |
|
1428 | + echo wp_kses_post($args['desc']); |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | -function wpinv_hook_callback( $args ) { |
|
1432 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1431 | +function wpinv_hook_callback($args) { |
|
1432 | + do_action('wpinv_' . $args['id'], $args); |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | function wpinv_set_settings_cap() { |
1436 | 1436 | return 'manage_options'; |
1437 | 1437 | } |
1438 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1438 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1439 | 1439 | |
1440 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1441 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1442 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1440 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1441 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1442 | + $value = wpinv_sanitize_amount($value, 4); |
|
1443 | 1443 | $value = $value >= 100 ? 99 : $value; |
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | return $value; |
1447 | 1447 | } |
1448 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1449 | 1448 | \ No newline at end of file |
1449 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1450 | 1450 | \ No newline at end of file |