@@ -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_wpi-pending_to_wpi-processing', |
17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -30,238 +30,238 @@ discard block |
||
30 | 30 | 'wpinv_fully_refunded', |
31 | 31 | 'wpinv_partially_refunded', |
32 | 32 | 'wpinv_new_invoice_note' |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | |
35 | - foreach ( $email_actions as $action ) { |
|
36 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
35 | + foreach ($email_actions as $action) { |
|
36 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
39 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
40 | 40 | |
41 | 41 | // New invoice email |
42 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
43 | -add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
44 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
45 | -add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
46 | -add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
47 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
42 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
43 | +add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
44 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
45 | +add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
46 | +add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
47 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
48 | 48 | |
49 | 49 | // Cancelled invoice email |
50 | -add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
51 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
50 | +add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
51 | +add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
52 | 52 | |
53 | 53 | // Failed invoice email |
54 | -add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
55 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
54 | +add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
55 | +add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
56 | 56 | |
57 | 57 | // On hold invoice email |
58 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
59 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
58 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
59 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
60 | 60 | |
61 | 61 | // Processing invoice email |
62 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' ); |
|
62 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification'); |
|
63 | 63 | |
64 | 64 | // Paid invoice email |
65 | -add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' ); |
|
65 | +add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification'); |
|
66 | 66 | |
67 | 67 | // Refunded invoice email |
68 | -add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
69 | -add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' ); |
|
70 | -add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
71 | -add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
68 | +add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification'); |
|
69 | +add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification'); |
|
70 | +add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
71 | +add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
72 | 72 | |
73 | 73 | // Invoice note |
74 | -add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' ); |
|
74 | +add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification'); |
|
75 | 75 | |
76 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
77 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
78 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
79 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
80 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
76 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
77 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
78 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
79 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
80 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
81 | 81 | |
82 | 82 | function wpinv_send_transactional_email() { |
83 | 83 | $args = func_get_args(); |
84 | 84 | $function = current_filter() . '_notification'; |
85 | - do_action_ref_array( $function, $args ); |
|
85 | + do_action_ref_array($function, $args); |
|
86 | 86 | } |
87 | 87 | |
88 | -function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) { |
|
88 | +function wpinv_new_invoice_notification($invoice_id, $new_status = '') { |
|
89 | 89 | $email_type = 'new_invoice'; |
90 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
90 | + if (!wpinv_email_is_enabled($email_type)) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
95 | - if ( empty( $invoice ) ) { |
|
94 | + $invoice = wpinv_get_invoice($invoice_id); |
|
95 | + if (empty($invoice)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
99 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
104 | - if ( !is_email( $recipient ) ) { |
|
103 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
104 | + if (!is_email($recipient)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
109 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
110 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
111 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
112 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
108 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
109 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
110 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
111 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
112 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
113 | 113 | |
114 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
114 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
115 | 115 | 'invoice' => $invoice, |
116 | 116 | 'email_type' => $email_type, |
117 | 117 | 'email_heading' => $email_heading, |
118 | 118 | 'sent_to_admin' => true, |
119 | 119 | 'plain_text' => false, |
120 | 120 | 'message_body' => $message_body, |
121 | - ) ); |
|
121 | + )); |
|
122 | 122 | |
123 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
123 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
124 | 124 | } |
125 | 125 | |
126 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
126 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
127 | 127 | $email_type = 'cancelled_invoice'; |
128 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
128 | + if (!wpinv_email_is_enabled($email_type)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
133 | - if ( empty( $invoice ) ) { |
|
132 | + $invoice = wpinv_get_invoice($invoice_id); |
|
133 | + if (empty($invoice)) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | |
137 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
137 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
142 | - if ( !is_email( $recipient ) ) { |
|
141 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
142 | + if (!is_email($recipient)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
147 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
148 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
149 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
150 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
146 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
147 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
148 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
149 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
150 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
151 | 151 | |
152 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
152 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
153 | 153 | 'invoice' => $invoice, |
154 | 154 | 'email_type' => $email_type, |
155 | 155 | 'email_heading' => $email_heading, |
156 | 156 | 'sent_to_admin' => true, |
157 | 157 | 'plain_text' => false, |
158 | 158 | 'message_body' => $message_body, |
159 | - ) ); |
|
159 | + )); |
|
160 | 160 | |
161 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
161 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
164 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
165 | 165 | $email_type = 'failed_invoice'; |
166 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
166 | + if (!wpinv_email_is_enabled($email_type)) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
171 | - if ( empty( $invoice ) ) { |
|
170 | + $invoice = wpinv_get_invoice($invoice_id); |
|
171 | + if (empty($invoice)) { |
|
172 | 172 | return false; |
173 | 173 | } |
174 | 174 | |
175 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
175 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
180 | - if ( !is_email( $recipient ) ) { |
|
179 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
180 | + if (!is_email($recipient)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
185 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
186 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
187 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
188 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
184 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
185 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
186 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
187 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
188 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
189 | 189 | |
190 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
190 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
191 | 191 | 'invoice' => $invoice, |
192 | 192 | 'email_type' => $email_type, |
193 | 193 | 'email_heading' => $email_heading, |
194 | 194 | 'sent_to_admin' => true, |
195 | 195 | 'plain_text' => false, |
196 | 196 | 'message_body' => $message_body, |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | |
199 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
199 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
200 | 200 | } |
201 | 201 | |
202 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
202 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
203 | 203 | $email_type = 'onhold_invoice'; |
204 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
204 | + if (!wpinv_email_is_enabled($email_type)) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
208 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
209 | - if ( empty( $invoice ) ) { |
|
208 | + $invoice = wpinv_get_invoice($invoice_id); |
|
209 | + if (empty($invoice)) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
213 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
214 | 214 | return false; |
215 | 215 | } |
216 | 216 | |
217 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
218 | - if ( !is_email( $recipient ) ) { |
|
217 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
218 | + if (!is_email($recipient)) { |
|
219 | 219 | return false; |
220 | 220 | } |
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 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
226 | - $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 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
226 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
227 | 227 | |
228 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
228 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
229 | 229 | 'invoice' => $invoice, |
230 | 230 | 'email_type' => $email_type, |
231 | 231 | 'email_heading' => $email_heading, |
232 | 232 | 'sent_to_admin' => false, |
233 | 233 | 'plain_text' => false, |
234 | 234 | 'message_body' => $message_body, |
235 | - ) ); |
|
235 | + )); |
|
236 | 236 | |
237 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
237 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
238 | 238 | |
239 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
240 | - $recipient = wpinv_get_admin_email(); |
|
241 | - $subject .= ' - ADMIN BCC COPY'; |
|
242 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
239 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
240 | + $recipient = wpinv_get_admin_email(); |
|
241 | + $subject .= ' - ADMIN BCC COPY'; |
|
242 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return $sent; |
246 | 246 | } |
247 | 247 | |
248 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
248 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
249 | 249 | $email_type = 'processing_invoice'; |
250 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
250 | + if (!wpinv_email_is_enabled($email_type)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
255 | - if ( empty( $invoice ) ) { |
|
254 | + $invoice = wpinv_get_invoice($invoice_id); |
|
255 | + if (empty($invoice)) { |
|
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
259 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
259 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
260 | 260 | return false; |
261 | 261 | } |
262 | 262 | |
263 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
264 | - if ( !is_email( $recipient ) ) { |
|
263 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
264 | + if (!is_email($recipient)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
@@ -270,105 +270,105 @@ discard block |
||
270 | 270 | $search['invoice_date'] = '{invoice_date}'; |
271 | 271 | $search['name'] = '{name}'; |
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 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
277 | - $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 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
277 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
278 | 278 | |
279 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
279 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
280 | 280 | 'invoice' => $invoice, |
281 | 281 | 'email_type' => $email_type, |
282 | 282 | 'email_heading' => $email_heading, |
283 | 283 | 'sent_to_admin' => false, |
284 | 284 | 'plain_text' => false, |
285 | 285 | 'message_body' => $message_body, |
286 | - ) ); |
|
286 | + )); |
|
287 | 287 | |
288 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
288 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
289 | 289 | |
290 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
291 | - $recipient = wpinv_get_admin_email(); |
|
292 | - $subject .= ' - ADMIN BCC COPY'; |
|
293 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
290 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
291 | + $recipient = wpinv_get_admin_email(); |
|
292 | + $subject .= ' - ADMIN BCC COPY'; |
|
293 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return $sent; |
297 | 297 | } |
298 | 298 | |
299 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
299 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
300 | 300 | $email_type = 'completed_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 | |
319 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
320 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
321 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
322 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
323 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
319 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
320 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
321 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
322 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
323 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
324 | 324 | |
325 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
325 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
326 | 326 | 'invoice' => $invoice, |
327 | 327 | 'email_type' => $email_type, |
328 | 328 | 'email_heading' => $email_heading, |
329 | 329 | 'sent_to_admin' => false, |
330 | 330 | 'plain_text' => false, |
331 | 331 | 'message_body' => $message_body, |
332 | - ) ); |
|
332 | + )); |
|
333 | 333 | |
334 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
334 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
335 | 335 | |
336 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
337 | - $recipient = wpinv_get_admin_email(); |
|
338 | - $subject .= ' - ADMIN BCC COPY'; |
|
339 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
336 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
337 | + $recipient = wpinv_get_admin_email(); |
|
338 | + $subject .= ' - ADMIN BCC COPY'; |
|
339 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $sent; |
343 | 343 | } |
344 | 344 | |
345 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
345 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
346 | 346 | $email_type = 'refunded_invoice'; |
347 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
347 | + if (!wpinv_email_is_enabled($email_type)) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | |
351 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
352 | - if ( empty( $invoice ) ) { |
|
351 | + $invoice = wpinv_get_invoice($invoice_id); |
|
352 | + if (empty($invoice)) { |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | |
356 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
356 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
360 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
361 | - if ( !is_email( $recipient ) ) { |
|
360 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
361 | + if (!is_email($recipient)) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
365 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
366 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
367 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
368 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
369 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
365 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
366 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
367 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
368 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
369 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
370 | 370 | |
371 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
371 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
372 | 372 | 'invoice' => $invoice, |
373 | 373 | 'email_type' => $email_type, |
374 | 374 | 'email_heading' => $email_heading, |
@@ -376,46 +376,46 @@ discard block |
||
376 | 376 | 'plain_text' => false, |
377 | 377 | 'partial_refund' => false, |
378 | 378 | 'message_body' => $message_body, |
379 | - ) ); |
|
379 | + )); |
|
380 | 380 | |
381 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
381 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
382 | 382 | |
383 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
384 | - $recipient = wpinv_get_admin_email(); |
|
385 | - $subject .= ' - ADMIN BCC COPY'; |
|
386 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
383 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
384 | + $recipient = wpinv_get_admin_email(); |
|
385 | + $subject .= ' - ADMIN BCC COPY'; |
|
386 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | return $sent; |
390 | 390 | } |
391 | 391 | |
392 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
392 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
393 | 393 | $email_type = 'refunded_invoice'; |
394 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
394 | + if (!wpinv_email_is_enabled($email_type)) { |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
399 | - if ( empty( $invoice ) ) { |
|
398 | + $invoice = wpinv_get_invoice($invoice_id); |
|
399 | + if (empty($invoice)) { |
|
400 | 400 | return false; |
401 | 401 | } |
402 | 402 | |
403 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
403 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
408 | - if ( !is_email( $recipient ) ) { |
|
407 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
408 | + if (!is_email($recipient)) { |
|
409 | 409 | return false; |
410 | 410 | } |
411 | 411 | |
412 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
413 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
414 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
415 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
416 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
412 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
413 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
414 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
415 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
416 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
417 | 417 | |
418 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
418 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
419 | 419 | 'invoice' => $invoice, |
420 | 420 | 'email_type' => $email_type, |
421 | 421 | 'email_heading' => $email_heading, |
@@ -423,89 +423,89 @@ discard block |
||
423 | 423 | 'plain_text' => false, |
424 | 424 | 'partial_refund' => true, |
425 | 425 | 'message_body' => $message_body, |
426 | - ) ); |
|
426 | + )); |
|
427 | 427 | |
428 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
428 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
429 | 429 | |
430 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
431 | - $recipient = wpinv_get_admin_email(); |
|
432 | - $subject .= ' - ADMIN BCC COPY'; |
|
433 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
430 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
431 | + $recipient = wpinv_get_admin_email(); |
|
432 | + $subject .= ' - ADMIN BCC COPY'; |
|
433 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | return $sent; |
437 | 437 | } |
438 | 438 | |
439 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
439 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
440 | 440 | } |
441 | 441 | |
442 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
442 | +function wpinv_user_invoice_notification($invoice_id) { |
|
443 | 443 | $email_type = 'user_invoice'; |
444 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
444 | + if (!wpinv_email_is_enabled($email_type)) { |
|
445 | 445 | return -1; |
446 | 446 | } |
447 | 447 | |
448 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
449 | - if ( empty( $invoice ) ) { |
|
448 | + $invoice = wpinv_get_invoice($invoice_id); |
|
449 | + if (empty($invoice)) { |
|
450 | 450 | return false; |
451 | 451 | } |
452 | 452 | |
453 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
453 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
454 | 454 | return false; |
455 | 455 | } |
456 | 456 | |
457 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
458 | - if ( !is_email( $recipient ) ) { |
|
457 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
458 | + if (!is_email($recipient)) { |
|
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | |
462 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
463 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
464 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
465 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
466 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
462 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
463 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
464 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
465 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
466 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
467 | 467 | |
468 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
468 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
469 | 469 | 'invoice' => $invoice, |
470 | 470 | 'email_type' => $email_type, |
471 | 471 | 'email_heading' => $email_heading, |
472 | 472 | 'sent_to_admin' => false, |
473 | 473 | 'plain_text' => false, |
474 | 474 | 'message_body' => $message_body, |
475 | - ) ); |
|
475 | + )); |
|
476 | 476 | |
477 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
477 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
478 | 478 | |
479 | - if ( $sent ) { |
|
480 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
479 | + if ($sent) { |
|
480 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
481 | 481 | } else { |
482 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
482 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
483 | 483 | } |
484 | 484 | |
485 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
485 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
486 | 486 | |
487 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
488 | - $recipient = wpinv_get_admin_email(); |
|
489 | - $subject .= ' - ADMIN BCC COPY'; |
|
490 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
487 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
488 | + $recipient = wpinv_get_admin_email(); |
|
489 | + $subject .= ' - ADMIN BCC COPY'; |
|
490 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $sent; |
494 | 494 | } |
495 | 495 | |
496 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
496 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
497 | 497 | $email_type = 'user_note'; |
498 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
498 | + if (!wpinv_email_is_enabled($email_type)) { |
|
499 | 499 | return false; |
500 | 500 | } |
501 | 501 | |
502 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
503 | - if ( empty( $invoice ) ) { |
|
502 | + $invoice = wpinv_get_invoice($invoice_id); |
|
503 | + if (empty($invoice)) { |
|
504 | 504 | return false; |
505 | 505 | } |
506 | 506 | |
507 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
508 | - if ( !is_email( $recipient ) ) { |
|
507 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
508 | + if (!is_email($recipient)) { |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
@@ -513,17 +513,17 @@ discard block |
||
513 | 513 | 'user_note' => '' |
514 | 514 | ); |
515 | 515 | |
516 | - $args = wp_parse_args( $args, $defaults ); |
|
516 | + $args = wp_parse_args($args, $defaults); |
|
517 | 517 | |
518 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
519 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
520 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
521 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
522 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
518 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
519 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
520 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
521 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
522 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
523 | 523 | |
524 | - $message_body = str_replace( '{customer_note}', $args['user_note'], $message_body ); |
|
524 | + $message_body = str_replace('{customer_note}', $args['user_note'], $message_body); |
|
525 | 525 | |
526 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
526 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
527 | 527 | 'invoice' => $invoice, |
528 | 528 | 'email_type' => $email_type, |
529 | 529 | 'email_heading' => $email_heading, |
@@ -531,34 +531,34 @@ discard block |
||
531 | 531 | 'plain_text' => false, |
532 | 532 | 'message_body' => $message_body, |
533 | 533 | 'customer_note' => $args['user_note'] |
534 | - ) ); |
|
534 | + )); |
|
535 | 535 | |
536 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
536 | + $content = wpinv_email_format_text($content, $invoice); |
|
537 | 537 | |
538 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
538 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
539 | 539 | |
540 | 540 | return $sent; |
541 | 541 | } |
542 | 542 | |
543 | 543 | function wpinv_mail_get_from_address() { |
544 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
545 | - return sanitize_email( $from_address ); |
|
544 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
545 | + return sanitize_email($from_address); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | function wpinv_mail_get_from_name() { |
549 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
550 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
549 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
550 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
551 | 551 | } |
552 | 552 | |
553 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
554 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
555 | - return ( $active ? true : false ); |
|
553 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
554 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
555 | + return ($active ? true : false); |
|
556 | 556 | } |
557 | 557 | |
558 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
559 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
558 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
559 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
560 | 560 | |
561 | - switch ( $email_type ) { |
|
561 | + switch ($email_type) { |
|
562 | 562 | case 'html' : |
563 | 563 | $content_type = 'text/html'; |
564 | 564 | break; |
@@ -573,35 +573,35 @@ discard block |
||
573 | 573 | return $content_type; |
574 | 574 | } |
575 | 575 | |
576 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
577 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
578 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
579 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
576 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
577 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
578 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
579 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
580 | 580 | |
581 | - $message = wpinv_email_style_body( $message ); |
|
582 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
581 | + $message = wpinv_email_style_body($message); |
|
582 | + $message = apply_filters('wpinv_mail_content', $message); |
|
583 | 583 | |
584 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
584 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
585 | 585 | |
586 | - if ( !$sent ) { |
|
587 | - $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 ); |
|
588 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
586 | + if (!$sent) { |
|
587 | + $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); |
|
588 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
589 | 589 | } |
590 | 590 | |
591 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
592 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
593 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
591 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
592 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
593 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
594 | 594 | |
595 | 595 | return $sent; |
596 | 596 | } |
597 | 597 | |
598 | 598 | function wpinv_get_emails() { |
599 | 599 | $overdue_days_options = array(); |
600 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
601 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
600 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
601 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
602 | 602 | |
603 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
604 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
603 | + for ($i = 2; $i <= 10; $i++) { |
|
604 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | // Default, built-in gateways |
@@ -609,39 +609,39 @@ discard block |
||
609 | 609 | 'new_invoice' => array( |
610 | 610 | 'email_new_invoice_header' => array( |
611 | 611 | 'id' => 'email_new_invoice_header', |
612 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
613 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
612 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
613 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
614 | 614 | 'type' => 'header', |
615 | 615 | ), |
616 | 616 | 'email_new_invoice_active' => array( |
617 | 617 | 'id' => 'email_new_invoice_active', |
618 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
619 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
618 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
619 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
620 | 620 | 'type' => 'checkbox', |
621 | 621 | 'std' => 1 |
622 | 622 | ), |
623 | 623 | 'email_new_invoice_subject' => array( |
624 | 624 | 'id' => 'email_new_invoice_subject', |
625 | - 'name' => __( 'Subject', 'invoicing' ), |
|
626 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
625 | + 'name' => __('Subject', 'invoicing'), |
|
626 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
627 | 627 | 'type' => 'text', |
628 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
628 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
629 | 629 | 'size' => 'large' |
630 | 630 | ), |
631 | 631 | 'email_new_invoice_heading' => array( |
632 | 632 | 'id' => 'email_new_invoice_heading', |
633 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
634 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
633 | + 'name' => __('Email Heading', 'invoicing'), |
|
634 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
635 | 635 | 'type' => 'text', |
636 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
636 | + 'std' => __('New payment invoice', 'invoicing'), |
|
637 | 637 | 'size' => 'large' |
638 | 638 | ), |
639 | 639 | 'email_new_invoice_body' => array( |
640 | 640 | 'id' => 'email_new_invoice_body', |
641 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
642 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
641 | + 'name' => __('Email Content', 'invoicing'), |
|
642 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
643 | 643 | 'type' => 'rich_editor', |
644 | - 'std' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ), |
|
644 | + 'std' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'), |
|
645 | 645 | 'class' => 'large', |
646 | 646 | 'size' => '10' |
647 | 647 | ), |
@@ -649,39 +649,39 @@ discard block |
||
649 | 649 | 'cancelled_invoice' => array( |
650 | 650 | 'email_cancelled_invoice_header' => array( |
651 | 651 | 'id' => 'email_cancelled_invoice_header', |
652 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
653 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
652 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
653 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
654 | 654 | 'type' => 'header', |
655 | 655 | ), |
656 | 656 | 'email_cancelled_invoice_active' => array( |
657 | 657 | 'id' => 'email_cancelled_invoice_active', |
658 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
659 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
658 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
659 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
660 | 660 | 'type' => 'checkbox', |
661 | 661 | 'std' => 1 |
662 | 662 | ), |
663 | 663 | 'email_cancelled_invoice_subject' => array( |
664 | 664 | 'id' => 'email_cancelled_invoice_subject', |
665 | - 'name' => __( 'Subject', 'invoicing' ), |
|
666 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
665 | + 'name' => __('Subject', 'invoicing'), |
|
666 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
667 | 667 | 'type' => 'text', |
668 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
668 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
669 | 669 | 'size' => 'large' |
670 | 670 | ), |
671 | 671 | 'email_cancelled_invoice_heading' => array( |
672 | 672 | 'id' => 'email_cancelled_invoice_heading', |
673 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
674 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
673 | + 'name' => __('Email Heading', 'invoicing'), |
|
674 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
675 | 675 | 'type' => 'text', |
676 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
676 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
677 | 677 | 'size' => 'large' |
678 | 678 | ), |
679 | 679 | 'email_cancelled_invoice_body' => array( |
680 | 680 | 'id' => 'email_cancelled_invoice_body', |
681 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
682 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
681 | + 'name' => __('Email Content', 'invoicing'), |
|
682 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
683 | 683 | 'type' => 'rich_editor', |
684 | - 'std' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ), |
|
684 | + 'std' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'), |
|
685 | 685 | 'class' => 'large', |
686 | 686 | 'size' => '10' |
687 | 687 | ), |
@@ -689,39 +689,39 @@ discard block |
||
689 | 689 | 'failed_invoice' => array( |
690 | 690 | 'email_failed_invoice_header' => array( |
691 | 691 | 'id' => 'email_failed_invoice_header', |
692 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
693 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
692 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
693 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
694 | 694 | 'type' => 'header', |
695 | 695 | ), |
696 | 696 | 'email_failed_invoice_active' => array( |
697 | 697 | 'id' => 'email_failed_invoice_active', |
698 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
699 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
698 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
699 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
700 | 700 | 'type' => 'checkbox', |
701 | 701 | 'std' => 1 |
702 | 702 | ), |
703 | 703 | 'email_failed_invoice_subject' => array( |
704 | 704 | 'id' => 'email_failed_invoice_subject', |
705 | - 'name' => __( 'Subject', 'invoicing' ), |
|
706 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
705 | + 'name' => __('Subject', 'invoicing'), |
|
706 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
707 | 707 | 'type' => 'text', |
708 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
708 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
709 | 709 | 'size' => 'large' |
710 | 710 | ), |
711 | 711 | 'email_failed_invoice_heading' => array( |
712 | 712 | 'id' => 'email_failed_invoice_heading', |
713 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
714 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
713 | + 'name' => __('Email Heading', 'invoicing'), |
|
714 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
715 | 715 | 'type' => 'text', |
716 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
716 | + 'std' => __('Failed invoice', 'invoicing'), |
|
717 | 717 | 'size' => 'large' |
718 | 718 | ), |
719 | 719 | 'email_failed_invoice_body' => array( |
720 | 720 | 'id' => 'email_failed_invoice_body', |
721 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
722 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
721 | + 'name' => __('Email Content', 'invoicing'), |
|
722 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
723 | 723 | 'type' => 'rich_editor', |
724 | - 'std' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ), |
|
724 | + 'std' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'), |
|
725 | 725 | 'class' => 'large', |
726 | 726 | 'size' => '10' |
727 | 727 | ), |
@@ -729,46 +729,46 @@ discard block |
||
729 | 729 | 'onhold_invoice' => array( |
730 | 730 | 'email_onhold_invoice_header' => array( |
731 | 731 | 'id' => 'email_onhold_invoice_header', |
732 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
733 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
732 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
733 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
734 | 734 | 'type' => 'header', |
735 | 735 | ), |
736 | 736 | 'email_onhold_invoice_active' => array( |
737 | 737 | 'id' => 'email_onhold_invoice_active', |
738 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
739 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
738 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
739 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
740 | 740 | 'type' => 'checkbox', |
741 | 741 | 'std' => 1 |
742 | 742 | ), |
743 | 743 | 'email_onhold_invoice_subject' => array( |
744 | 744 | 'id' => 'email_onhold_invoice_subject', |
745 | - 'name' => __( 'Subject', 'invoicing' ), |
|
746 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
745 | + 'name' => __('Subject', 'invoicing'), |
|
746 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
747 | 747 | 'type' => 'text', |
748 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
748 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
749 | 749 | 'size' => 'large' |
750 | 750 | ), |
751 | 751 | 'email_onhold_invoice_heading' => array( |
752 | 752 | 'id' => 'email_onhold_invoice_heading', |
753 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
754 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
753 | + 'name' => __('Email Heading', 'invoicing'), |
|
754 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
755 | 755 | 'type' => 'text', |
756 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
756 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
757 | 757 | 'size' => 'large' |
758 | 758 | ), |
759 | 759 | 'email_onhold_invoice_admin_bcc' => array( |
760 | 760 | 'id' => 'email_onhold_invoice_admin_bcc', |
761 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
762 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
761 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
762 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
763 | 763 | 'type' => 'checkbox', |
764 | 764 | 'std' => 1 |
765 | 765 | ), |
766 | 766 | 'email_onhold_invoice_body' => array( |
767 | 767 | 'id' => 'email_onhold_invoice_body', |
768 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
769 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
768 | + 'name' => __('Email Content', 'invoicing'), |
|
769 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
770 | 770 | 'type' => 'rich_editor', |
771 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ), |
|
771 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'), |
|
772 | 772 | 'class' => 'large', |
773 | 773 | 'size' => '10' |
774 | 774 | ), |
@@ -776,46 +776,46 @@ discard block |
||
776 | 776 | 'processing_invoice' => array( |
777 | 777 | 'email_processing_invoice_header' => array( |
778 | 778 | 'id' => 'email_processing_invoice_header', |
779 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
780 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
779 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
780 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
781 | 781 | 'type' => 'header', |
782 | 782 | ), |
783 | 783 | 'email_processing_invoice_active' => array( |
784 | 784 | 'id' => 'email_processing_invoice_active', |
785 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
786 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
785 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
786 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
787 | 787 | 'type' => 'checkbox', |
788 | 788 | 'std' => 1 |
789 | 789 | ), |
790 | 790 | 'email_processing_invoice_subject' => array( |
791 | 791 | 'id' => 'email_processing_invoice_subject', |
792 | - 'name' => __( 'Subject', 'invoicing' ), |
|
793 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
792 | + 'name' => __('Subject', 'invoicing'), |
|
793 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
794 | 794 | 'type' => 'text', |
795 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
795 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
796 | 796 | 'size' => 'large' |
797 | 797 | ), |
798 | 798 | 'email_processing_invoice_heading' => array( |
799 | 799 | 'id' => 'email_processing_invoice_heading', |
800 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
801 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
800 | + 'name' => __('Email Heading', 'invoicing'), |
|
801 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
802 | 802 | 'type' => 'text', |
803 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
803 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
804 | 804 | 'size' => 'large' |
805 | 805 | ), |
806 | 806 | 'email_processing_invoice_admin_bcc' => array( |
807 | 807 | 'id' => 'email_processing_invoice_admin_bcc', |
808 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
809 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
808 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
809 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
810 | 810 | 'type' => 'checkbox', |
811 | 811 | 'std' => 1 |
812 | 812 | ), |
813 | 813 | 'email_processing_invoice_body' => array( |
814 | 814 | 'id' => 'email_processing_invoice_body', |
815 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
816 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
815 | + 'name' => __('Email Content', 'invoicing'), |
|
816 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
817 | 817 | 'type' => 'rich_editor', |
818 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ), |
|
818 | + 'std' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'), |
|
819 | 819 | 'class' => 'large', |
820 | 820 | 'size' => '10' |
821 | 821 | ), |
@@ -823,45 +823,45 @@ discard block |
||
823 | 823 | 'completed_invoice' => array( |
824 | 824 | 'email_completed_invoice_header' => array( |
825 | 825 | 'id' => 'email_completed_invoice_header', |
826 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
827 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
826 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
827 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
828 | 828 | 'type' => 'header', |
829 | 829 | ), |
830 | 830 | 'email_completed_invoice_active' => array( |
831 | 831 | 'id' => 'email_completed_invoice_active', |
832 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
833 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
832 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
833 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
834 | 834 | 'type' => 'checkbox', |
835 | 835 | 'std' => 1 |
836 | 836 | ), |
837 | 837 | 'email_completed_invoice_subject' => array( |
838 | 838 | 'id' => 'email_completed_invoice_subject', |
839 | - 'name' => __( 'Subject', 'invoicing' ), |
|
840 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
839 | + 'name' => __('Subject', 'invoicing'), |
|
840 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
841 | 841 | 'type' => 'text', |
842 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
842 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
843 | 843 | 'size' => 'large' |
844 | 844 | ), |
845 | 845 | 'email_completed_invoice_heading' => array( |
846 | 846 | 'id' => 'email_completed_invoice_heading', |
847 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
848 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
847 | + 'name' => __('Email Heading', 'invoicing'), |
|
848 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
849 | 849 | 'type' => 'text', |
850 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
850 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
851 | 851 | 'size' => 'large' |
852 | 852 | ), |
853 | 853 | 'email_completed_invoice_admin_bcc' => array( |
854 | 854 | 'id' => 'email_completed_invoice_admin_bcc', |
855 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
856 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
855 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
856 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
857 | 857 | 'type' => 'checkbox', |
858 | 858 | ), |
859 | 859 | 'email_completed_invoice_body' => array( |
860 | 860 | 'id' => 'email_completed_invoice_body', |
861 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
862 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
861 | + 'name' => __('Email Content', 'invoicing'), |
|
862 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
863 | 863 | 'type' => 'rich_editor', |
864 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ), |
|
864 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'), |
|
865 | 865 | 'class' => 'large', |
866 | 866 | 'size' => '10' |
867 | 867 | ), |
@@ -870,46 +870,46 @@ discard block |
||
870 | 870 | 'refunded_invoice' => array( |
871 | 871 | 'email_refunded_invoice_header' => array( |
872 | 872 | 'id' => 'email_refunded_invoice_header', |
873 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
874 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
873 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
874 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
875 | 875 | 'type' => 'header', |
876 | 876 | ), |
877 | 877 | 'email_refunded_invoice_active' => array( |
878 | 878 | 'id' => 'email_refunded_invoice_active', |
879 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
880 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
879 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
880 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
881 | 881 | 'type' => 'checkbox', |
882 | 882 | 'std' => 1 |
883 | 883 | ), |
884 | 884 | 'email_refunded_invoice_subject' => array( |
885 | 885 | 'id' => 'email_refunded_invoice_subject', |
886 | - 'name' => __( 'Subject', 'invoicing' ), |
|
887 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
886 | + 'name' => __('Subject', 'invoicing'), |
|
887 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
888 | 888 | 'type' => 'text', |
889 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
889 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
890 | 890 | 'size' => 'large' |
891 | 891 | ), |
892 | 892 | 'email_refunded_invoice_heading' => array( |
893 | 893 | 'id' => 'email_refunded_invoice_heading', |
894 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
895 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
894 | + 'name' => __('Email Heading', 'invoicing'), |
|
895 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
896 | 896 | 'type' => 'text', |
897 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
897 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
898 | 898 | 'size' => 'large' |
899 | 899 | ), |
900 | 900 | 'email_refunded_invoice_admin_bcc' => array( |
901 | 901 | 'id' => 'email_refunded_invoice_admin_bcc', |
902 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
903 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
902 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
903 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
904 | 904 | 'type' => 'checkbox', |
905 | 905 | 'std' => 1 |
906 | 906 | ), |
907 | 907 | 'email_refunded_invoice_body' => array( |
908 | 908 | 'id' => 'email_refunded_invoice_body', |
909 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
910 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
909 | + 'name' => __('Email Content', 'invoicing'), |
|
910 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
911 | 911 | 'type' => 'rich_editor', |
912 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
912 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
913 | 913 | 'class' => 'large', |
914 | 914 | 'size' => '10' |
915 | 915 | ), |
@@ -917,46 +917,46 @@ discard block |
||
917 | 917 | 'user_invoice' => array( |
918 | 918 | 'email_user_invoice_header' => array( |
919 | 919 | 'id' => 'email_user_invoice_header', |
920 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
921 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
920 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
921 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
922 | 922 | 'type' => 'header', |
923 | 923 | ), |
924 | 924 | 'email_user_invoice_active' => array( |
925 | 925 | 'id' => 'email_user_invoice_active', |
926 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
927 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
926 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
927 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
928 | 928 | 'type' => 'checkbox', |
929 | 929 | 'std' => 1 |
930 | 930 | ), |
931 | 931 | 'email_user_invoice_subject' => array( |
932 | 932 | 'id' => 'email_user_invoice_subject', |
933 | - 'name' => __( 'Subject', 'invoicing' ), |
|
934 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
933 | + 'name' => __('Subject', 'invoicing'), |
|
934 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
935 | 935 | 'type' => 'text', |
936 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
936 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
937 | 937 | 'size' => 'large' |
938 | 938 | ), |
939 | 939 | 'email_user_invoice_heading' => array( |
940 | 940 | 'id' => 'email_user_invoice_heading', |
941 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
942 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
941 | + 'name' => __('Email Heading', 'invoicing'), |
|
942 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
943 | 943 | 'type' => 'text', |
944 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
944 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
945 | 945 | 'size' => 'large' |
946 | 946 | ), |
947 | 947 | 'email_user_invoice_admin_bcc' => array( |
948 | 948 | 'id' => 'email_user_invoice_admin_bcc', |
949 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
950 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
949 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
950 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
951 | 951 | 'type' => 'checkbox', |
952 | 952 | 'std' => 1 |
953 | 953 | ), |
954 | 954 | 'email_user_invoice_body' => array( |
955 | 955 | 'id' => 'email_user_invoice_body', |
956 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
957 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
956 | + 'name' => __('Email Content', 'invoicing'), |
|
957 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
958 | 958 | 'type' => 'rich_editor', |
959 | - 'std' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
959 | + 'std' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
960 | 960 | 'class' => 'large', |
961 | 961 | 'size' => '10' |
962 | 962 | ), |
@@ -964,39 +964,39 @@ discard block |
||
964 | 964 | 'user_note' => array( |
965 | 965 | 'email_user_note_header' => array( |
966 | 966 | 'id' => 'email_user_note_header', |
967 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
968 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
967 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
968 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
969 | 969 | 'type' => 'header', |
970 | 970 | ), |
971 | 971 | 'email_user_note_active' => array( |
972 | 972 | 'id' => 'email_user_note_active', |
973 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
974 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
973 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
974 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
975 | 975 | 'type' => 'checkbox', |
976 | 976 | 'std' => 1 |
977 | 977 | ), |
978 | 978 | 'email_user_note_subject' => array( |
979 | 979 | 'id' => 'email_user_note_subject', |
980 | - 'name' => __( 'Subject', 'invoicing' ), |
|
981 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
980 | + 'name' => __('Subject', 'invoicing'), |
|
981 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
982 | 982 | 'type' => 'text', |
983 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
983 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
984 | 984 | 'size' => 'large' |
985 | 985 | ), |
986 | 986 | 'email_user_note_heading' => array( |
987 | 987 | 'id' => 'email_user_note_heading', |
988 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
989 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
988 | + 'name' => __('Email Heading', 'invoicing'), |
|
989 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
990 | 990 | 'type' => 'text', |
991 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
991 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
992 | 992 | 'size' => 'large' |
993 | 993 | ), |
994 | 994 | 'email_user_note_body' => array( |
995 | 995 | 'id' => 'email_user_note_body', |
996 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
997 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
996 | + 'name' => __('Email Content', 'invoicing'), |
|
997 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
998 | 998 | 'type' => 'rich_editor', |
999 | - 'std' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
999 | + 'std' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
1000 | 1000 | 'class' => 'large', |
1001 | 1001 | 'size' => '10' |
1002 | 1002 | ), |
@@ -1004,155 +1004,155 @@ discard block |
||
1004 | 1004 | 'overdue' => array( |
1005 | 1005 | 'email_overdue_header' => array( |
1006 | 1006 | 'id' => 'email_overdue_header', |
1007 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
1008 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
1007 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
1008 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
1009 | 1009 | 'type' => 'header', |
1010 | 1010 | ), |
1011 | 1011 | 'email_overdue_active' => array( |
1012 | 1012 | 'id' => 'email_overdue_active', |
1013 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1014 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1013 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1014 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1015 | 1015 | 'type' => 'checkbox', |
1016 | 1016 | 'std' => 1 |
1017 | 1017 | ), |
1018 | 1018 | 'email_due_reminder_days' => array( |
1019 | 1019 | 'id' => 'email_due_reminder_days', |
1020 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
1021 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
1020 | + 'name' => __('When to Send', 'invoicing'), |
|
1021 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
1022 | 1022 | 'default' => '', |
1023 | 1023 | 'type' => 'multicheck', |
1024 | 1024 | 'options' => $overdue_days_options, |
1025 | 1025 | ), |
1026 | 1026 | 'email_overdue_subject' => array( |
1027 | 1027 | 'id' => 'email_overdue_subject', |
1028 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1029 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1028 | + 'name' => __('Subject', 'invoicing'), |
|
1029 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1030 | 1030 | 'type' => 'text', |
1031 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
1031 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
1032 | 1032 | 'size' => 'large' |
1033 | 1033 | ), |
1034 | 1034 | 'email_overdue_heading' => array( |
1035 | 1035 | 'id' => 'email_overdue_heading', |
1036 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1037 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1036 | + 'name' => __('Email Heading', 'invoicing'), |
|
1037 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1038 | 1038 | 'type' => 'text', |
1039 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
1039 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
1040 | 1040 | 'size' => 'large' |
1041 | 1041 | ), |
1042 | 1042 | 'email_overdue_body' => array( |
1043 | 1043 | 'id' => 'email_overdue_body', |
1044 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1045 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
1044 | + 'name' => __('Email Content', 'invoicing'), |
|
1045 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
1046 | 1046 | 'type' => 'rich_editor', |
1047 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that 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 view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
1047 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that 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 view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
1048 | 1048 | 'class' => 'large', |
1049 | 1049 | 'size' => 10, |
1050 | 1050 | ), |
1051 | 1051 | ), |
1052 | 1052 | ); |
1053 | 1053 | |
1054 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
1054 | + return apply_filters('wpinv_get_emails', $emails); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | -function wpinv_settings_emails( $settings = array() ) { |
|
1057 | +function wpinv_settings_emails($settings = array()) { |
|
1058 | 1058 | $emails = wpinv_get_emails(); |
1059 | 1059 | |
1060 | - if ( !empty( $emails ) ) { |
|
1061 | - foreach ( $emails as $key => $email ) { |
|
1060 | + if (!empty($emails)) { |
|
1061 | + foreach ($emails as $key => $email) { |
|
1062 | 1062 | $settings[$key] = $email; |
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
1066 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
1067 | 1067 | } |
1068 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
1068 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
1069 | 1069 | |
1070 | -function wpinv_settings_sections_emails( $settings ) { |
|
1070 | +function wpinv_settings_sections_emails($settings) { |
|
1071 | 1071 | $emails = wpinv_get_emails(); |
1072 | 1072 | |
1073 | 1073 | if (!empty($emails)) { |
1074 | - foreach ($emails as $key => $email) { |
|
1075 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
1074 | + foreach ($emails as $key => $email) { |
|
1075 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
1076 | 1076 | } |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $settings; |
1080 | 1080 | } |
1081 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
1081 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
1082 | 1082 | |
1083 | -function wpinv_email_is_enabled( $email_type ) { |
|
1083 | +function wpinv_email_is_enabled($email_type) { |
|
1084 | 1084 | $emails = wpinv_get_emails(); |
1085 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
1085 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
1086 | 1086 | |
1087 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
1087 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1091 | - switch ( $email_type ) { |
|
1090 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1091 | + switch ($email_type) { |
|
1092 | 1092 | case 'new_invoice': |
1093 | 1093 | case 'cancelled_invoice': |
1094 | 1094 | case 'failed_invoice': |
1095 | 1095 | $recipient = wpinv_get_admin_email(); |
1096 | 1096 | break; |
1097 | 1097 | default: |
1098 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1099 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
1098 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1099 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
1100 | 1100 | break; |
1101 | 1101 | } |
1102 | 1102 | |
1103 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
1103 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1107 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
1106 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1107 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
1108 | 1108 | |
1109 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
1109 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
1110 | 1110 | |
1111 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
1111 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1115 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
1114 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1115 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
1116 | 1116 | |
1117 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
1117 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
1118 | 1118 | |
1119 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
1119 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1123 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
1122 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1123 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
1124 | 1124 | |
1125 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1125 | + $content = wpinv_email_format_text($content, $invoice); |
|
1126 | 1126 | |
1127 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
1127 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1130 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1131 | 1131 | $from_name = wpinv_mail_get_from_address(); |
1132 | 1132 | $from_email = wpinv_mail_get_from_address(); |
1133 | 1133 | |
1134 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1134 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1135 | 1135 | |
1136 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
1137 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
1136 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
1137 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
1138 | 1138 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
1139 | 1139 | |
1140 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
1140 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1143 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1144 | 1144 | $attachments = array(); |
1145 | 1145 | |
1146 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
1146 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | -function wpinv_email_format_text( $content, $invoice ) { |
|
1149 | +function wpinv_email_format_text($content, $invoice) { |
|
1150 | 1150 | $replace_array = array( |
1151 | 1151 | '{site_title}' => wpinv_get_blogname(), |
1152 | - '{date}' => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ), |
|
1152 | + '{date}' => date_i18n(get_option('date_format'), (int)current_time('timestamp')), |
|
1153 | 1153 | ); |
1154 | 1154 | |
1155 | - if ( !empty( $invoice->ID ) ) { |
|
1155 | + if (!empty($invoice->ID)) { |
|
1156 | 1156 | $replace_array = array_merge( |
1157 | 1157 | $replace_array, |
1158 | 1158 | array( |
@@ -1162,65 +1162,65 @@ discard block |
||
1162 | 1162 | '{last_name}' => $invoice->get_last_name(), |
1163 | 1163 | '{email}' => $invoice->get_email(), |
1164 | 1164 | '{invoice_number}' => $invoice->get_number(), |
1165 | - '{invoice_total}' => $invoice->get_total( true ), |
|
1166 | - '{invoice_link}' => $invoice->get_view_url( true ), |
|
1167 | - '{invoice_pay_link}'=> $invoice->get_view_url( true ), |
|
1168 | - '{invoice_date}' => $invoice->get_invoice_date( true ), |
|
1169 | - '{invoice_due_date}'=> $invoice->get_due_date( true ), |
|
1170 | - '{invoice_quote}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1171 | - '{invoice_label}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1172 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
1165 | + '{invoice_total}' => $invoice->get_total(true), |
|
1166 | + '{invoice_link}' => $invoice->get_view_url(true), |
|
1167 | + '{invoice_pay_link}'=> $invoice->get_view_url(true), |
|
1168 | + '{invoice_date}' => $invoice->get_invoice_date(true), |
|
1169 | + '{invoice_due_date}'=> $invoice->get_due_date(true), |
|
1170 | + '{invoice_quote}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1171 | + '{invoice_label}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1172 | + '{is_was}' => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
1173 | 1173 | ) |
1174 | 1174 | ); |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
1177 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
1178 | 1178 | |
1179 | - foreach ( $replace_array as $key => $value ) { |
|
1180 | - $content = str_replace( $key, $value, $content ); |
|
1179 | + foreach ($replace_array as $key => $value) { |
|
1180 | + $content = str_replace($key, $value, $content); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
1183 | + return apply_filters('wpinv_email_content_replace', $content); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | -function wpinv_email_style_body( $content ) { |
|
1186 | +function wpinv_email_style_body($content) { |
|
1187 | 1187 | // make sure we only inline CSS for html emails |
1188 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
1188 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
1189 | 1189 | ob_start(); |
1190 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
1191 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
1190 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
1191 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
1192 | 1192 | |
1193 | 1193 | // apply CSS styles inline for picky email clients |
1194 | 1194 | try { |
1195 | - $emogrifier = new Emogrifier( $content, $css ); |
|
1195 | + $emogrifier = new Emogrifier($content, $css); |
|
1196 | 1196 | $content = $emogrifier->emogrify(); |
1197 | - } catch ( Exception $e ) { |
|
1198 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
1197 | + } catch (Exception $e) { |
|
1198 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | return $content; |
1202 | 1202 | } |
1203 | 1203 | |
1204 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1205 | - 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 ) ); |
|
1204 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1205 | + 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)); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | /** |
1209 | 1209 | * Get the email footer. |
1210 | 1210 | */ |
1211 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1212 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1211 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1212 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | -function wpinv_email_wrap_message( $message ) { |
|
1215 | +function wpinv_email_wrap_message($message) { |
|
1216 | 1216 | // Buffer |
1217 | 1217 | ob_start(); |
1218 | 1218 | |
1219 | - do_action( 'wpinv_email_header' ); |
|
1219 | + do_action('wpinv_email_header'); |
|
1220 | 1220 | |
1221 | - echo wpautop( wptexturize( $message ) ); |
|
1221 | + echo wpautop(wptexturize($message)); |
|
1222 | 1222 | |
1223 | - do_action( 'wpinv_email_footer' ); |
|
1223 | + do_action('wpinv_email_footer'); |
|
1224 | 1224 | |
1225 | 1225 | // Get contents |
1226 | 1226 | $message = ob_get_clean(); |
@@ -1228,92 +1228,92 @@ discard block |
||
1228 | 1228 | return $message; |
1229 | 1229 | } |
1230 | 1230 | |
1231 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1232 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1231 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1232 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1236 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1235 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
1236 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1240 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1239 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1240 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
1244 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1243 | +function wpinv_send_customer_invoice($data = array()) { |
|
1244 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1245 | 1245 | |
1246 | - if ( empty( $invoice_id ) ) { |
|
1246 | + if (empty($invoice_id)) { |
|
1247 | 1247 | return; |
1248 | 1248 | } |
1249 | 1249 | |
1250 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1251 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1250 | + if (!current_user_can('manage_options')) { |
|
1251 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
1254 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
1255 | 1255 | |
1256 | 1256 | if ( -1 == $sent ) { |
1257 | 1257 | $status = 'email_disabled'; |
1258 | - } elseif ( $sent ) { |
|
1258 | + } elseif ($sent) { |
|
1259 | 1259 | $status = 'email_sent'; |
1260 | 1260 | } else { |
1261 | 1261 | $status = 'email_fail'; |
1262 | 1262 | } |
1263 | 1263 | |
1264 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1265 | - wp_redirect( $redirect ); |
|
1264 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1265 | + wp_redirect($redirect); |
|
1266 | 1266 | exit; |
1267 | 1267 | } |
1268 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
1268 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
1269 | 1269 | |
1270 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
1271 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1270 | +function wpinv_send_overdue_reminder($data = array()) { |
|
1271 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1272 | 1272 | |
1273 | - if ( empty( $invoice_id ) ) { |
|
1273 | + if (empty($invoice_id)) { |
|
1274 | 1274 | return; |
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1278 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1277 | + if (!current_user_can('manage_options')) { |
|
1278 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
1281 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
1282 | 1282 | |
1283 | 1283 | $status = $sent ? 'email_sent' : 'email_fail'; |
1284 | 1284 | |
1285 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1286 | - wp_redirect( $redirect ); |
|
1285 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1286 | + wp_redirect($redirect); |
|
1287 | 1287 | exit; |
1288 | 1288 | } |
1289 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
1289 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
1290 | 1290 | |
1291 | -function wpinv_send_customer_note_email( $data ) { |
|
1292 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1291 | +function wpinv_send_customer_note_email($data) { |
|
1292 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1293 | 1293 | |
1294 | - if ( empty( $invoice_id ) ) { |
|
1294 | + if (empty($invoice_id)) { |
|
1295 | 1295 | return; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
1298 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
1299 | 1299 | } |
1300 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
1300 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
1301 | 1301 | |
1302 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
1303 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
1304 | - $date_format = get_option( 'date_format' ); |
|
1305 | - $time_format = get_option( 'time_format' ); |
|
1302 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
1303 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
1304 | + $date_format = get_option('date_format'); |
|
1305 | + $time_format = get_option('time_format'); |
|
1306 | 1306 | ?> |
1307 | 1307 | <div id="wpinv-email-notes"> |
1308 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
1308 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
1309 | 1309 | <ol class="wpinv-notes-lists"> |
1310 | 1310 | <?php |
1311 | - foreach ( $invoice_notes as $note ) { |
|
1312 | - $note_time = strtotime( $note->comment_date ); |
|
1311 | + foreach ($invoice_notes as $note) { |
|
1312 | + $note_time = strtotime($note->comment_date); |
|
1313 | 1313 | ?> |
1314 | 1314 | <li class="comment wpinv-note"> |
1315 | - <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> |
|
1316 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
1315 | + <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> |
|
1316 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
1317 | 1317 | </li> |
1318 | 1318 | <?php |
1319 | 1319 | } |
@@ -1322,21 +1322,21 @@ discard block |
||
1322 | 1322 | <?php |
1323 | 1323 | } |
1324 | 1324 | } |
1325 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
1325 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
1326 | 1326 | |
1327 | 1327 | function wpinv_email_payment_reminders() { |
1328 | 1328 | global $wpi_auto_reminder; |
1329 | - if ( !wpinv_get_option( 'email_overdue_active' ) ) { |
|
1329 | + if (!wpinv_get_option('email_overdue_active')) { |
|
1330 | 1330 | return; |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
1334 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : ''; |
|
1333 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
1334 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : ''; |
|
1335 | 1335 | |
1336 | - if ( empty( $reminder_days ) ) { |
|
1336 | + if (empty($reminder_days)) { |
|
1337 | 1337 | return; |
1338 | 1338 | } |
1339 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
1339 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
1340 | 1340 | |
1341 | 1341 | $args = array( |
1342 | 1342 | 'post_type' => 'wpi_invoice', |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | 'meta_query' => array( |
1347 | 1347 | array( |
1348 | 1348 | 'key' => '_wpinv_due_date', |
1349 | - 'value' => array( '', 'none' ), |
|
1349 | + 'value' => array('', 'none'), |
|
1350 | 1350 | 'compare' => 'NOT IN', |
1351 | 1351 | ) |
1352 | 1352 | ), |
@@ -1355,109 +1355,109 @@ discard block |
||
1355 | 1355 | 'order' => 'ASC', |
1356 | 1356 | ); |
1357 | 1357 | |
1358 | - $invoices = get_posts( $args ); |
|
1358 | + $invoices = get_posts($args); |
|
1359 | 1359 | |
1360 | - if ( empty( $invoices ) ) { |
|
1360 | + if (empty($invoices)) { |
|
1361 | 1361 | return; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | - $date_to_send = array(); |
|
1364 | + $date_to_send = array(); |
|
1365 | 1365 | |
1366 | - foreach ( $invoices as $id ) { |
|
1367 | - $due_date = get_post_meta( $id, '_wpinv_due_date', true ); |
|
1366 | + foreach ($invoices as $id) { |
|
1367 | + $due_date = get_post_meta($id, '_wpinv_due_date', true); |
|
1368 | 1368 | |
1369 | - foreach ( $reminder_days as $key => $days ) { |
|
1370 | - if ( $days !== '' ) { |
|
1371 | - $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) ); |
|
1369 | + foreach ($reminder_days as $key => $days) { |
|
1370 | + if ($days !== '') { |
|
1371 | + $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS)); |
|
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - $today = date_i18n( 'Y-m-d' ); |
|
1376 | + $today = date_i18n('Y-m-d'); |
|
1377 | 1377 | $wpi_auto_reminder = true; |
1378 | 1378 | |
1379 | - foreach ( $date_to_send as $id => $values ) { |
|
1380 | - if ( in_array( $today, $values ) ) { |
|
1381 | - $sent = get_post_meta( $id, '_wpinv_reminder_sent', true ); |
|
1379 | + foreach ($date_to_send as $id => $values) { |
|
1380 | + if (in_array($today, $values)) { |
|
1381 | + $sent = get_post_meta($id, '_wpinv_reminder_sent', true); |
|
1382 | 1382 | |
1383 | - if ( isset( $sent ) && !empty( $sent ) ) { |
|
1384 | - if ( !in_array( $today, $sent ) ) { |
|
1385 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1383 | + if (isset($sent) && !empty($sent)) { |
|
1384 | + if (!in_array($today, $sent)) { |
|
1385 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1386 | 1386 | } |
1387 | 1387 | } else { |
1388 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1388 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1389 | 1389 | } |
1390 | 1390 | } |
1391 | 1391 | } |
1392 | 1392 | |
1393 | - $wpi_auto_reminder = false; |
|
1393 | + $wpi_auto_reminder = false; |
|
1394 | 1394 | } |
1395 | 1395 | } |
1396 | 1396 | |
1397 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
1397 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
1398 | 1398 | $email_type = 'overdue'; |
1399 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
1399 | + if (!wpinv_email_is_enabled($email_type)) { |
|
1400 | 1400 | return false; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1404 | - if ( empty( $invoice ) ) { |
|
1403 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1404 | + if (empty($invoice)) { |
|
1405 | 1405 | return false; |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - if ( !$invoice->needs_payment() ) { |
|
1408 | + if (!$invoice->needs_payment()) { |
|
1409 | 1409 | return false; |
1410 | 1410 | } |
1411 | 1411 | |
1412 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
1413 | - if ( !is_email( $recipient ) ) { |
|
1412 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
1413 | + if (!is_email($recipient)) { |
|
1414 | 1414 | return false; |
1415 | 1415 | } |
1416 | 1416 | |
1417 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
1418 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
1419 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
1420 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
1421 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
1417 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
1418 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
1419 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
1420 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
1421 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
1422 | 1422 | |
1423 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
1423 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
1424 | 1424 | 'invoice' => $invoice, |
1425 | 1425 | 'email_type' => $email_type, |
1426 | 1426 | 'email_heading' => $email_heading, |
1427 | 1427 | 'sent_to_admin' => false, |
1428 | 1428 | 'plain_text' => false, |
1429 | 1429 | 'message_body' => $message_body |
1430 | - ) ); |
|
1430 | + )); |
|
1431 | 1431 | |
1432 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1432 | + $content = wpinv_email_format_text($content, $invoice); |
|
1433 | 1433 | |
1434 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
1435 | - if ( $sent ) { |
|
1436 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
1434 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
1435 | + if ($sent) { |
|
1436 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | return $sent; |
1440 | 1440 | } |
1441 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
1441 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
1442 | 1442 | |
1443 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
1443 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
1444 | 1444 | global $wpi_auto_reminder; |
1445 | 1445 | |
1446 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
1446 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
1447 | 1447 | |
1448 | - if ( empty( $sent ) ) { |
|
1448 | + if (empty($sent)) { |
|
1449 | 1449 | $sent = array(); |
1450 | 1450 | } |
1451 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
1451 | + $sent[] = date_i18n('Y-m-d'); |
|
1452 | 1452 | |
1453 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
1453 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
1454 | 1454 | |
1455 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
1456 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1457 | - $invoice->add_note( $note, false, false, true ); |
|
1455 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
1456 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1457 | + $invoice->add_note($note, false, false, true); |
|
1458 | 1458 | } else { // Menual reminder note. |
1459 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1460 | - $invoice->add_note( $note ); |
|
1459 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1460 | + $invoice->add_note($note); |
|
1461 | 1461 | } |
1462 | 1462 | } |
1463 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
1463 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
@@ -1,73 +1,73 @@ 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 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
8 | 8 | function wpinv_add_options_link() { |
9 | 9 | global $menu; |
10 | 10 | |
11 | - if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) { |
|
11 | + if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | - $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' ); |
|
15 | + $capability = apply_filters('invoicing_capability', 'manage_invoicing'); |
|
16 | 16 | |
17 | - if ( current_user_can( 'manage_options' ) ) { |
|
18 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
17 | + if (current_user_can('manage_options')) { |
|
18 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
19 | 19 | } |
20 | 20 | |
21 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
21 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
22 | 22 | |
23 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
23 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
24 | 24 | |
25 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', 'wpinv_options_page' ); |
|
25 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', 'wpinv_options_page'); |
|
26 | 26 | } |
27 | 27 | |
28 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
28 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
29 | 29 | function wpinv_remove_admin_submenus() { |
30 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
30 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
34 | -function wpinv_discount_columns( $existing_columns ) { |
|
33 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
34 | +function wpinv_discount_columns($existing_columns) { |
|
35 | 35 | $columns = array(); |
36 | 36 | $columns['cb'] = $existing_columns['cb']; |
37 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
38 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
39 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
40 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
41 | - $columns['start_date'] = __( 'Start Date', 'invoicing' ); |
|
42 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
43 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
37 | + $columns['name'] = __('Name', 'invoicing'); |
|
38 | + $columns['code'] = __('Code', 'invoicing'); |
|
39 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
40 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
41 | + $columns['start_date'] = __('Start Date', 'invoicing'); |
|
42 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
43 | + $columns['status'] = __('Status', 'invoicing'); |
|
44 | 44 | |
45 | 45 | return $columns; |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
49 | -function wpinv_discount_custom_column( $column ) { |
|
48 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
49 | +function wpinv_discount_custom_column($column) { |
|
50 | 50 | global $post; |
51 | 51 | |
52 | 52 | $discount = $post; |
53 | 53 | |
54 | - switch ( $column ) { |
|
54 | + switch ($column) { |
|
55 | 55 | case 'name' : |
56 | - echo get_the_title( $discount->ID ); |
|
56 | + echo get_the_title($discount->ID); |
|
57 | 57 | break; |
58 | 58 | case 'code' : |
59 | - echo wpinv_get_discount_code( $discount->ID ); |
|
59 | + echo wpinv_get_discount_code($discount->ID); |
|
60 | 60 | break; |
61 | 61 | case 'amount' : |
62 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
62 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
63 | 63 | break; |
64 | 64 | case 'usage_limit' : |
65 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
65 | + echo wpinv_get_discount_uses($discount->ID); |
|
66 | 66 | break; |
67 | 67 | case 'usage' : |
68 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
69 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
70 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
68 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
69 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
70 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
71 | 71 | } else { |
72 | 72 | $usage .= ' ∞'; |
73 | 73 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | echo $usage; |
76 | 76 | break; |
77 | 77 | case 'start_date' : |
78 | - if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) { |
|
79 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) ); |
|
78 | + if ($start_date = wpinv_get_discount_start_date($discount->ID)) { |
|
79 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date)); |
|
80 | 80 | } else { |
81 | 81 | $value = '-'; |
82 | 82 | } |
@@ -84,163 +84,163 @@ discard block |
||
84 | 84 | echo $value; |
85 | 85 | break; |
86 | 86 | case 'expiry_date' : |
87 | - if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) { |
|
88 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) ); |
|
87 | + if ($expiration = wpinv_get_discount_expiration($discount->ID)) { |
|
88 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration)); |
|
89 | 89 | } else { |
90 | - $value = __( 'Never', 'invoicing' ); |
|
90 | + $value = __('Never', 'invoicing'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | echo $value; |
94 | 94 | break; |
95 | 95 | break; |
96 | 96 | case 'description' : |
97 | - echo wp_kses_post( $post->post_excerpt ); |
|
97 | + echo wp_kses_post($post->post_excerpt); |
|
98 | 98 | break; |
99 | 99 | case 'status' : |
100 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
100 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
101 | 101 | |
102 | - echo wpinv_discount_status( $status ); |
|
102 | + echo wpinv_discount_status($status); |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
108 | -function wpinv_post_row_actions( $actions, $post ) { |
|
109 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
107 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
108 | +function wpinv_post_row_actions($actions, $post) { |
|
109 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
110 | 110 | |
111 | - if ( $post_type == 'wpi_invoice' ) { |
|
111 | + if ($post_type == 'wpi_invoice') { |
|
112 | 112 | $actions = array(); |
113 | 113 | } |
114 | 114 | |
115 | - if ( $post_type == 'wpi_discount' ) { |
|
116 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
115 | + if ($post_type == 'wpi_discount') { |
|
116 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $actions; |
120 | 120 | } |
121 | 121 | |
122 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
123 | - $row_actions = array(); |
|
124 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
125 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
122 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
123 | + $row_actions = array(); |
|
124 | + $edit_link = get_edit_post_link($discount->ID); |
|
125 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
126 | 126 | |
127 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
128 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
129 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
130 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
127 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
128 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
129 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
130 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
134 | - if ( isset( $row_actions['delete'] ) ) { |
|
135 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
133 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
134 | + if (isset($row_actions['delete'])) { |
|
135 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
136 | 136 | } |
137 | 137 | } else { |
138 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
138 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
142 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
143 | 143 | |
144 | 144 | return $row_actions; |
145 | 145 | } |
146 | 146 | |
147 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
148 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
149 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
147 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
148 | +function wpinv_table_primary_column($default, $screen_id) { |
|
149 | + if ('edit-wpi_invoice' === $screen_id) { |
|
150 | 150 | return 'name'; |
151 | 151 | } |
152 | 152 | |
153 | 153 | return $default; |
154 | 154 | } |
155 | 155 | |
156 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
157 | - if ( !$display ) { |
|
156 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
157 | + if (!$display) { |
|
158 | 158 | return array(); |
159 | 159 | } |
160 | 160 | |
161 | 161 | $actions = array( |
162 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
163 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
164 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
162 | + 'activate' => __('Activate', 'invoicing'), |
|
163 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
164 | + 'delete' => __('Delete', 'invoicing'), |
|
165 | 165 | ); |
166 | 166 | $two = ''; |
167 | 167 | $which = 'top'; |
168 | 168 | echo '</div><div class="alignleft actions bulkactions">'; |
169 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
170 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
171 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
169 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
170 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
171 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
172 | 172 | |
173 | - foreach ( $actions as $name => $title ) { |
|
173 | + foreach ($actions as $name => $title) { |
|
174 | 174 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
175 | 175 | |
176 | 176 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
177 | 177 | } |
178 | 178 | echo "</select>"; |
179 | 179 | |
180 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
180 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
181 | 181 | |
182 | 182 | echo '</div><div class="alignleft actions">'; |
183 | 183 | } |
184 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
184 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
185 | 185 | |
186 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
187 | - if ( $post_type == 'wpi_discount' ) { |
|
186 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
187 | + if ($post_type == 'wpi_discount') { |
|
188 | 188 | $disable = true; |
189 | 189 | } |
190 | 190 | |
191 | 191 | return $disable; |
192 | 192 | } |
193 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
193 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
194 | 194 | |
195 | 195 | function wpinv_restrict_manage_posts() { |
196 | 196 | global $typenow; |
197 | 197 | |
198 | - if( 'wpi_discount' == $typenow ) { |
|
198 | + if ('wpi_discount' == $typenow) { |
|
199 | 199 | wpinv_discount_filters(); |
200 | 200 | } |
201 | 201 | } |
202 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
202 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
203 | 203 | |
204 | 204 | function wpinv_discount_filters() { |
205 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
205 | + echo wpinv_discount_bulk_actions(array(), true); |
|
206 | 206 | |
207 | 207 | ?> |
208 | 208 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
209 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
209 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
210 | 210 | <?php |
211 | 211 | $types = wpinv_get_discount_types(); |
212 | 212 | |
213 | - foreach ( $types as $name => $type ) { |
|
214 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
213 | + foreach ($types as $name => $type) { |
|
214 | + echo '<option value="' . esc_attr($name) . '"'; |
|
215 | 215 | |
216 | - if ( isset( $_GET['discount_type'] ) ) |
|
217 | - selected( $name, $_GET['discount_type'] ); |
|
216 | + if (isset($_GET['discount_type'])) |
|
217 | + selected($name, $_GET['discount_type']); |
|
218 | 218 | |
219 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
219 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
220 | 220 | } |
221 | 221 | ?> |
222 | 222 | </select> |
223 | 223 | <?php |
224 | 224 | } |
225 | 225 | |
226 | -function wpinv_request( $vars ) { |
|
226 | +function wpinv_request($vars) { |
|
227 | 227 | global $typenow, $wp_query, $wp_post_statuses; |
228 | 228 | |
229 | - if ( 'wpi_invoice' === $typenow ) { |
|
230 | - if ( !isset( $vars['post_status'] ) ) { |
|
229 | + if ('wpi_invoice' === $typenow) { |
|
230 | + if (!isset($vars['post_status'])) { |
|
231 | 231 | $post_statuses = wpinv_get_invoice_statuses(); |
232 | 232 | |
233 | - foreach ( $post_statuses as $status => $value ) { |
|
234 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
235 | - unset( $post_statuses[ $status ] ); |
|
233 | + foreach ($post_statuses as $status => $value) { |
|
234 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
235 | + unset($post_statuses[$status]); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
239 | + $vars['post_status'] = array_keys($post_statuses); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( isset( $vars['orderby'] ) ) { |
|
243 | - if ( 'amount' == $vars['orderby'] ) { |
|
242 | + if (isset($vars['orderby'])) { |
|
243 | + if ('amount' == $vars['orderby']) { |
|
244 | 244 | $vars = array_merge( |
245 | 245 | $vars, |
246 | 246 | array( |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | 'orderby' => 'meta_value_num' |
249 | 249 | ) |
250 | 250 | ); |
251 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
251 | + } else if ('customer' == $vars['orderby']) { |
|
252 | 252 | $vars = array_merge( |
253 | 253 | $vars, |
254 | 254 | array( |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'orderby' => 'meta_value' |
257 | 257 | ) |
258 | 258 | ); |
259 | - } else if ( 'number' == $vars['orderby'] ) { |
|
259 | + } else if ('number' == $vars['orderby']) { |
|
260 | 260 | $vars = array_merge( |
261 | 261 | $vars, |
262 | 262 | array( |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | 'orderby' => 'meta_value' |
265 | 265 | ) |
266 | 266 | ); |
267 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
267 | + } else if ('payment_date' == $vars['orderby']) { |
|
268 | 268 | $vars = array_merge( |
269 | 269 | $vars, |
270 | 270 | array( |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | ); |
275 | 275 | } |
276 | 276 | } |
277 | - } else if ( 'wpi_item' == $typenow ) { |
|
277 | + } else if ('wpi_item' == $typenow) { |
|
278 | 278 | // Check if 'orderby' is set to "price" |
279 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
279 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
280 | 280 | $vars = array_merge( |
281 | 281 | $vars, |
282 | 282 | array( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Check if "orderby" is set to "vat_rule" |
290 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
290 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
291 | 291 | $vars = array_merge( |
292 | 292 | $vars, |
293 | 293 | array( |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | // Check if "orderby" is set to "vat_class" |
301 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
301 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
302 | 302 | $vars = array_merge( |
303 | 303 | $vars, |
304 | 304 | array( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | // Check if "orderby" is set to "type" |
312 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
312 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
313 | 313 | $vars = array_merge( |
314 | 314 | $vars, |
315 | 315 | array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | // Check if "orderby" is set to "recurring" |
323 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
323 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
324 | 324 | $vars = array_merge( |
325 | 325 | $vars, |
326 | 326 | array( |
@@ -330,120 +330,120 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
333 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
334 | 334 | // Filter vat rule type |
335 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
335 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
336 | 336 | $meta_query[] = array( |
337 | 337 | 'key' => '_wpinv_vat_rule', |
338 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
338 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
339 | 339 | 'compare' => '=' |
340 | 340 | ); |
341 | 341 | } |
342 | 342 | |
343 | 343 | // Filter vat class |
344 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
344 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
345 | 345 | $meta_query[] = array( |
346 | 346 | 'key' => '_wpinv_vat_class', |
347 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
347 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
348 | 348 | 'compare' => '=' |
349 | 349 | ); |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Filter item type |
353 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
353 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
354 | 354 | $meta_query[] = array( |
355 | 355 | 'key' => '_wpinv_type', |
356 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
356 | + 'value' => sanitize_text_field($_GET['type']), |
|
357 | 357 | 'compare' => '=' |
358 | 358 | ); |
359 | 359 | } |
360 | 360 | |
361 | - if ( !empty( $meta_query ) ) { |
|
361 | + if (!empty($meta_query)) { |
|
362 | 362 | $vars['meta_query'] = $meta_query; |
363 | 363 | } |
364 | - } else if ( 'wpi_discount' == $typenow ) { |
|
365 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
364 | + } else if ('wpi_discount' == $typenow) { |
|
365 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
366 | 366 | // Filter vat rule type |
367 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
367 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
368 | 368 | $meta_query[] = array( |
369 | 369 | 'key' => '_wpi_discount_type', |
370 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
370 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
371 | 371 | 'compare' => '=' |
372 | 372 | ); |
373 | 373 | } |
374 | 374 | |
375 | - if ( !empty( $meta_query ) ) { |
|
375 | + if (!empty($meta_query)) { |
|
376 | 376 | $vars['meta_query'] = $meta_query; |
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | return $vars; |
381 | 381 | } |
382 | -add_filter( 'request', 'wpinv_request' ); |
|
382 | +add_filter('request', 'wpinv_request'); |
|
383 | 383 | |
384 | 384 | function wpinv_options_page() { |
385 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
385 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
386 | 386 | |
387 | - if ( $page !== 'wpinv-settings' ) { |
|
387 | + if ($page !== 'wpinv-settings') { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | 391 | $settings_tabs = wpinv_get_settings_tabs(); |
392 | 392 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
393 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
394 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
393 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
394 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
395 | 395 | $key = 'main'; |
396 | 396 | |
397 | - if ( is_array( $sections ) ) { |
|
398 | - $key = key( $sections ); |
|
397 | + if (is_array($sections)) { |
|
398 | + $key = key($sections); |
|
399 | 399 | } |
400 | 400 | |
401 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
402 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
401 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
402 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
403 | 403 | ob_start(); |
404 | 404 | ?> |
405 | 405 | <div class="wrap"> |
406 | 406 | <h1 class="nav-tab-wrapper"> |
407 | 407 | <?php |
408 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
409 | - $tab_url = add_query_arg( array( |
|
408 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
409 | + $tab_url = add_query_arg(array( |
|
410 | 410 | 'settings-updated' => false, |
411 | 411 | 'tab' => $tab_id, |
412 | - ) ); |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | // Remove the section from the tabs so we always end up at the main section |
415 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
416 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
415 | + $tab_url = remove_query_arg('section', $tab_url); |
|
416 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
417 | 417 | |
418 | 418 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
419 | 419 | |
420 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
421 | - echo esc_html( $tab_name ); |
|
420 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
421 | + echo esc_html($tab_name); |
|
422 | 422 | echo '</a>'; |
423 | 423 | } |
424 | 424 | ?> |
425 | 425 | </h1> |
426 | 426 | <?php |
427 | - $number_of_sections = count( $sections ); |
|
427 | + $number_of_sections = count($sections); |
|
428 | 428 | $number = 0; |
429 | - if ( $number_of_sections > 1 ) { |
|
429 | + if ($number_of_sections > 1) { |
|
430 | 430 | echo '<div><ul class="subsubsub">'; |
431 | - foreach( $sections as $section_id => $section_name ) { |
|
431 | + foreach ($sections as $section_id => $section_name) { |
|
432 | 432 | echo '<li>'; |
433 | 433 | $number++; |
434 | - $tab_url = add_query_arg( array( |
|
434 | + $tab_url = add_query_arg(array( |
|
435 | 435 | 'settings-updated' => false, |
436 | 436 | 'tab' => $active_tab, |
437 | 437 | 'section' => $section_id |
438 | - ) ); |
|
439 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
438 | + )); |
|
439 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
440 | 440 | $class = ''; |
441 | - if ( $section == $section_id ) { |
|
441 | + if ($section == $section_id) { |
|
442 | 442 | $class = 'current'; |
443 | 443 | } |
444 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
444 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
445 | 445 | |
446 | - if ( $number != $number_of_sections ) { |
|
446 | + if ($number != $number_of_sections) { |
|
447 | 447 | echo ' | '; |
448 | 448 | } |
449 | 449 | echo '</li>'; |
@@ -455,19 +455,19 @@ discard block |
||
455 | 455 | <form method="post" action="options.php"> |
456 | 456 | <table class="form-table"> |
457 | 457 | <?php |
458 | - settings_fields( 'wpinv_settings' ); |
|
458 | + settings_fields('wpinv_settings'); |
|
459 | 459 | |
460 | - if ( 'main' === $section ) { |
|
461 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
460 | + if ('main' === $section) { |
|
461 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
462 | 462 | } |
463 | 463 | |
464 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
465 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
466 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
464 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
465 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
466 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
467 | 467 | |
468 | 468 | // For backwards compatibility |
469 | - if ( 'main' === $section ) { |
|
470 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
469 | + if ('main' === $section) { |
|
470 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
471 | 471 | } |
472 | 472 | ?> |
473 | 473 | </table> |
@@ -480,53 +480,53 @@ discard block |
||
480 | 480 | echo $content; |
481 | 481 | } |
482 | 482 | |
483 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
483 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
484 | 484 | global $pagenow, $typenow; |
485 | 485 | |
486 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
487 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
488 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
486 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
487 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
488 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
489 | 489 | } |
490 | 490 | |
491 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
491 | + if (!wpinv_item_is_editable($post_id)) { |
|
492 | 492 | $classes[] = 'wpi-editable-n'; |
493 | 493 | } |
494 | 494 | } |
495 | 495 | return $classes; |
496 | 496 | } |
497 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
497 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
498 | 498 | |
499 | 499 | function wpinv_check_quick_edit() { |
500 | 500 | global $pagenow, $current_screen, $wpinv_item_screen; |
501 | 501 | |
502 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
503 | - if ( empty( $wpinv_item_screen ) ) { |
|
504 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
502 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
503 | + if (empty($wpinv_item_screen)) { |
|
504 | + if ($current_screen->post_type == 'wpi_item') { |
|
505 | 505 | $wpinv_item_screen = 'y'; |
506 | 506 | } else { |
507 | 507 | $wpinv_item_screen = 'n'; |
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
512 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
513 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
511 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
512 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
513 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |
517 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
517 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
518 | 518 | |
519 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
520 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
521 | - unset( $actions['inline hide-if-no-js'] ); |
|
519 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
520 | + if (isset($actions['inline hide-if-no-js'])) { |
|
521 | + unset($actions['inline hide-if-no-js']); |
|
522 | 522 | } |
523 | 523 | |
524 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
525 | - if ( isset( $actions['trash'] ) ) { |
|
526 | - unset( $actions['trash'] ); |
|
524 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
525 | + if (isset($actions['trash'])) { |
|
526 | + unset($actions['trash']); |
|
527 | 527 | } |
528 | - if ( isset( $actions['delete'] ) ) { |
|
529 | - unset( $actions['delete'] ); |
|
528 | + if (isset($actions['delete'])) { |
|
529 | + unset($actions['delete']); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | * @param int $post_parent (default: 0) Parent for the new page |
544 | 544 | * @return int page ID |
545 | 545 | */ |
546 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
546 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
547 | 547 | global $wpdb; |
548 | 548 | |
549 | - $option_value = wpinv_get_option( $option ); |
|
549 | + $option_value = wpinv_get_option($option); |
|
550 | 550 | |
551 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
552 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
551 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
552 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
553 | 553 | // Valid page is already in place |
554 | 554 | return $page_object->ID; |
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | - if(!empty($post_parent)){ |
|
558 | + if (!empty($post_parent)) { |
|
559 | 559 | $page = get_page_by_path($post_parent); |
560 | 560 | if ($page) { |
561 | 561 | $post_parent = $page->ID; |
@@ -564,40 +564,40 @@ discard block |
||
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - if ( strlen( $page_content ) > 0 ) { |
|
567 | + if (strlen($page_content) > 0) { |
|
568 | 568 | // Search for an existing page with the specified page content (typically a shortcode) |
569 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
569 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
570 | 570 | } else { |
571 | 571 | // Search for an existing page with the specified page slug |
572 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
572 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
573 | 573 | } |
574 | 574 | |
575 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
575 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
576 | 576 | |
577 | - if ( $valid_page_found ) { |
|
578 | - if ( $option ) { |
|
579 | - wpinv_update_option( $option, $valid_page_found ); |
|
577 | + if ($valid_page_found) { |
|
578 | + if ($option) { |
|
579 | + wpinv_update_option($option, $valid_page_found); |
|
580 | 580 | } |
581 | 581 | return $valid_page_found; |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Search for a matching valid trashed page |
585 | - if ( strlen( $page_content ) > 0 ) { |
|
585 | + if (strlen($page_content) > 0) { |
|
586 | 586 | // Search for an existing page with the specified page content (typically a shortcode) |
587 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
587 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
588 | 588 | } else { |
589 | 589 | // Search for an existing page with the specified page slug |
590 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
590 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
591 | 591 | } |
592 | 592 | |
593 | - if ( $trashed_page_found ) { |
|
593 | + if ($trashed_page_found) { |
|
594 | 594 | $page_id = $trashed_page_found; |
595 | 595 | $page_data = array( |
596 | 596 | 'ID' => $page_id, |
597 | 597 | 'post_status' => 'publish', |
598 | 598 | 'post_parent' => $post_parent, |
599 | 599 | ); |
600 | - wp_update_post( $page_data ); |
|
600 | + wp_update_post($page_data); |
|
601 | 601 | } else { |
602 | 602 | $page_data = array( |
603 | 603 | 'post_status' => 'publish', |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | 'post_parent' => $post_parent, |
610 | 610 | 'comment_status' => 'closed', |
611 | 611 | ); |
612 | - $page_id = wp_insert_post( $page_data ); |
|
612 | + $page_id = wp_insert_post($page_data); |
|
613 | 613 | } |
614 | 614 | |
615 | - if ( $option ) { |
|
616 | - wpinv_update_option( $option, (int)$page_id ); |
|
615 | + if ($option) { |
|
616 | + wpinv_update_option($option, (int)$page_id); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $page_id; |
@@ -11,49 +11,49 @@ discard block |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | - if ( $wpi_version == WPINV_VERSION ) { |
|
16 | + if ($wpi_version == WPINV_VERSION) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
20 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
21 | 21 | wpinv_v005_upgrades(); |
22 | 22 | } |
23 | 23 | |
24 | - if ( version_compare( $wpi_version, '1.0.3', '<' ) ) { |
|
24 | + if (version_compare($wpi_version, '1.0.3', '<')) { |
|
25 | 25 | wpinv_v103_upgrades(); |
26 | 26 | } |
27 | 27 | |
28 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
28 | + update_option('wpinv_version', WPINV_VERSION); |
|
29 | 29 | } |
30 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
30 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
31 | 31 | |
32 | 32 | function wpinv_v005_upgrades() { |
33 | 33 | global $wpdb; |
34 | 34 | |
35 | 35 | // Invoices status |
36 | - $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
37 | - if ( !empty( $results ) ) { |
|
38 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
36 | + $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
37 | + if (!empty($results)) { |
|
38 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
39 | 39 | |
40 | 40 | // Clean post cache |
41 | - foreach ( $results as $row ) { |
|
42 | - clean_post_cache( $row->ID ); |
|
41 | + foreach ($results as $row) { |
|
42 | + clean_post_cache($row->ID); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item meta key changes |
47 | 47 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
48 | - $results = $wpdb->get_results( $query ); |
|
48 | + $results = $wpdb->get_results($query); |
|
49 | 49 | |
50 | - if ( !empty( $results ) ) { |
|
51 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
52 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
53 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
50 | + if (!empty($results)) { |
|
51 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
52 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
53 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
54 | 54 | |
55 | - foreach ( $results as $row ) { |
|
56 | - clean_post_cache( $row->post_id ); |
|
55 | + foreach ($results as $row) { |
|
56 | + clean_post_cache($row->post_id); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -74,79 +74,79 @@ discard block |
||
74 | 74 | function wpinv_convert_old_subscriptions() { |
75 | 75 | global $wpdb; |
76 | 76 | |
77 | - $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1 AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC"; |
|
77 | + $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1 AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC"; |
|
78 | 78 | |
79 | - $results = $wpdb->get_results( $query ); |
|
79 | + $results = $wpdb->get_results($query); |
|
80 | 80 | |
81 | - if ( empty( $results ) ) { |
|
81 | + if (empty($results)) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - foreach ( $results as $row ) { |
|
86 | - $invoice = new WPInv_Invoice( $row->ID ); |
|
85 | + foreach ($results as $row) { |
|
86 | + $invoice = new WPInv_Invoice($row->ID); |
|
87 | 87 | |
88 | - if ( empty( $invoice->ID ) ) { |
|
88 | + if (empty($invoice->ID)) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - if ( $invoice->has_status( 'wpi-renewal' ) ) { |
|
92 | + if ($invoice->has_status('wpi-renewal')) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
96 | - $item = $invoice->get_recurring( true ); |
|
96 | + $item = $invoice->get_recurring(true); |
|
97 | 97 | |
98 | - if ( empty( $item ) ) { |
|
98 | + if (empty($item)) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $is_free_trial = $invoice->is_free_trial(); |
103 | - $profile_id = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true ); |
|
104 | - $subscription_status = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true ); |
|
103 | + $profile_id = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true); |
|
104 | + $subscription_status = get_post_meta($invoice->ID, '_wpinv_subscr_status', true); |
|
105 | 105 | $transaction_id = $invoice->get_transaction_id(); |
106 | 106 | |
107 | 107 | // Last invoice |
108 | - $query = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | - $last_payment = $wpdb->get_row( $query ); |
|
108 | + $query = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | + $last_payment = $wpdb->get_row($query); |
|
110 | 110 | |
111 | - if ( !empty( $last_payment ) ) { |
|
112 | - $invoice_date = $last_payment->post_date; |
|
111 | + if (!empty($last_payment)) { |
|
112 | + $invoice_date = $last_payment->post_date; |
|
113 | 113 | |
114 | - $meta_profile_id = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true ); |
|
115 | - $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true ); |
|
114 | + $meta_profile_id = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true); |
|
115 | + $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true); |
|
116 | 116 | |
117 | - if ( !empty( $meta_profile_id ) ) { |
|
118 | - $profile_id = $meta_profile_id; |
|
117 | + if (!empty($meta_profile_id)) { |
|
118 | + $profile_id = $meta_profile_id; |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( !empty( $meta_transaction_id ) ) { |
|
122 | - $transaction_id = $meta_transaction_id; |
|
121 | + if (!empty($meta_transaction_id)) { |
|
122 | + $transaction_id = $meta_transaction_id; |
|
123 | 123 | } |
124 | 124 | } else { |
125 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
125 | + $invoice_date = $invoice->get_invoice_date(false); |
|
126 | 126 | } |
127 | 127 | |
128 | - $profile_id = empty( $profile_id ) ? $invoice->ID : $profile_id; |
|
129 | - $status = empty( $subscription_status ) ? 'pending' : $subscription_status; |
|
128 | + $profile_id = empty($profile_id) ? $invoice->ID : $profile_id; |
|
129 | + $status = empty($subscription_status) ? 'pending' : $subscription_status; |
|
130 | 130 | |
131 | - $period = $item->get_recurring_period( true ); |
|
131 | + $period = $item->get_recurring_period(true); |
|
132 | 132 | $interval = $item->get_recurring_interval(); |
133 | 133 | $bill_times = (int)$item->get_recurring_limit(); |
134 | 134 | $add_period = $interval . ' ' . $period; |
135 | 135 | $trial_period = ''; |
136 | 136 | |
137 | - if ( $invoice->is_free_trial() ) { |
|
138 | - $trial_period = $item->get_trial_period( true ); |
|
137 | + if ($invoice->is_free_trial()) { |
|
138 | + $trial_period = $item->get_trial_period(true); |
|
139 | 139 | $free_interval = $item->get_trial_interval(); |
140 | 140 | $trial_period = $free_interval . ' ' . $trial_period; |
141 | 141 | |
142 | - if ( empty( $last_payment ) ) { |
|
142 | + if (empty($last_payment)) { |
|
143 | 143 | $add_period = $trial_period; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
148 | - if ( strtotime( $expiration ) < strtotime( date_i18n( 'Y-m-d' ) ) ) { |
|
149 | - if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) { |
|
147 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
148 | + if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) { |
|
149 | + if ($status == 'active' || $status == 'trialling' || $status == 'pending') { |
|
150 | 150 | $status = 'expired'; |
151 | 151 | } |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'frequency' => $interval, |
160 | 160 | 'period' => $period, |
161 | 161 | 'initial_amount' => $invoice->get_total(), |
162 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
162 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
163 | 163 | 'bill_times' => $bill_times, |
164 | 164 | 'created' => $invoice_date, |
165 | 165 | 'expiration' => $expiration, |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | $subs_db = new WPInv_Subscriptions_DB; |
172 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) ); |
|
173 | - $subscription = reset( $subs ); |
|
172 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1)); |
|
173 | + $subscription = reset($subs); |
|
174 | 174 | |
175 | - if ( empty( $subscription ) || $subscription->id <= 0 ) { |
|
175 | + if (empty($subscription) || $subscription->id <= 0) { |
|
176 | 176 | $subscription = new WPInv_Subscription(); |
177 | - $new_sub = $subscription->create( $args ); |
|
177 | + $new_sub = $subscription->create($args); |
|
178 | 178 | |
179 | - if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) { |
|
179 | + if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) { |
|
180 | 180 | $new_sub->complete(); // Mark completed if all times billed |
181 | 181 | } |
182 | 182 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | function wpinv_update_new_email_settings() { |
187 | 187 | global $wpinv_options; |
188 | 188 | |
189 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
189 | + $current_options = get_option('wpinv_settings', array()); |
|
190 | 190 | $options = array(); |
191 | 191 | |
192 | 192 | // Populate some default values |
193 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
194 | - foreach( $sections as $section => $settings) { |
|
193 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
194 | + foreach ($sections as $section => $settings) { |
|
195 | 195 | // Check for backwards compatibility |
196 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
197 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
196 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
197 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
198 | 198 | $section = 'main'; |
199 | 199 | $settings = $sections; |
200 | 200 | } |
201 | 201 | |
202 | - foreach ( $settings as $option ) { |
|
203 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
204 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
205 | - $options[ $option['id'] ] = '1'; |
|
206 | - } else if ( !empty( $option['std'] ) ) { |
|
207 | - $options[ $option['id'] ] = $option['std']; |
|
202 | + foreach ($settings as $option) { |
|
203 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
204 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
205 | + $options[$option['id']] = '1'; |
|
206 | + } else if (!empty($option['std'])) { |
|
207 | + $options[$option['id']] = $option['std']; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - $merged_options_current = array_merge( $wpinv_options, $options ); |
|
215 | - $merged_options = array_merge( $merged_options_current, $current_options ); |
|
214 | + $merged_options_current = array_merge($wpinv_options, $options); |
|
215 | + $merged_options = array_merge($merged_options_current, $current_options); |
|
216 | 216 | $wpinv_options = $merged_options; |
217 | 217 | |
218 | - update_option( 'wpinv_settings', $merged_options ); |
|
218 | + update_option('wpinv_settings', $merged_options); |
|
219 | 219 | } |
220 | 220 | \ No newline at end of file |
@@ -1,47 +1,47 @@ 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 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | 77 | <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]"> |
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,89 +183,89 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | ?> |
194 | - <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"> |
|
194 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | 195 | <?php } ?> |
196 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
197 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
196 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
197 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <?php |
201 | 201 | } |
202 | 202 | |
203 | - public static function prices( $post ) { |
|
203 | + public static function prices($post) { |
|
204 | 204 | $symbol = wpinv_currency_symbol(); |
205 | 205 | $position = wpinv_currency_position(); |
206 | - $item = new WPInv_Item( $post->ID ); |
|
206 | + $item = new WPInv_Item($post->ID); |
|
207 | 207 | |
208 | 208 | $price = $item->get_price(); |
209 | 209 | $is_recurring = $item->is_recurring(); |
210 | 210 | $period = $item->get_recurring_period(); |
211 | - $interval = absint( $item->get_recurring_interval() ); |
|
212 | - $times = absint( $item->get_recurring_limit() ); |
|
211 | + $interval = absint($item->get_recurring_interval()); |
|
212 | + $times = absint($item->get_recurring_limit()); |
|
213 | 213 | $free_trial = $item->has_free_trial(); |
214 | 214 | $trial_interval = $item->get_trial_interval(); |
215 | 215 | $trial_period = $item->get_trial_period(); |
216 | 216 | |
217 | 217 | $intervals = array(); |
218 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
218 | + for ($i = 1; $i <= 90; $i++) { |
|
219 | 219 | $intervals[$i] = $i; |
220 | 220 | } |
221 | 221 | |
222 | - $interval = $interval > 0 ? $interval : 1; |
|
222 | + $interval = $interval > 0 ? $interval : 1; |
|
223 | 223 | |
224 | 224 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
225 | 225 | ?> |
226 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><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_editable(), false ); ?> /><?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' ) ;?>" /> |
|
227 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
226 | + <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_editable(), false); ?> /><?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'); ?>" /> |
|
227 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
228 | 228 | </p> |
229 | 229 | <p class="wpinv-row-is-recurring"> |
230 | 230 | <label for="wpinv_is_recurring"> |
231 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
232 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
231 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
232 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
233 | 233 | </label> |
234 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
234 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
235 | 235 | </p> |
236 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
237 | - <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> |
|
238 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
236 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
237 | + <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> |
|
238 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
239 | 239 | 'options' => $intervals, |
240 | 240 | 'name' => 'wpinv_recurring_interval', |
241 | 241 | 'id' => 'wpinv_recurring_interval', |
242 | 242 | 'selected' => $interval, |
243 | 243 | 'show_option_all' => false, |
244 | 244 | 'show_option_none' => false |
245 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
246 | - <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 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
246 | + <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> |
|
247 | 247 | <span class="clear wpi-trial-clr"></span> |
248 | 248 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
249 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
250 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
249 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
250 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
251 | 251 | </label> |
252 | 252 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
253 | - <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> |
|
253 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
254 | 254 | </label> |
255 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
256 | 256 | </p> |
257 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
258 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
257 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
258 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
259 | 259 | <?php |
260 | 260 | } |
261 | 261 | |
262 | - public static function vat_rules( $post ) { |
|
262 | + public static function vat_rules($post) { |
|
263 | 263 | global $wpinv_euvat; |
264 | 264 | |
265 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
265 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
266 | 266 | ?> |
267 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
268 | - <?php echo wpinv_html_select( array( |
|
267 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
268 | + <?php echo wpinv_html_select(array( |
|
269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
270 | 270 | 'name' => 'wpinv_vat_rules', |
271 | 271 | 'id' => 'wpinv_vat_rules', |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | 'show_option_all' => false, |
274 | 274 | 'show_option_none' => false, |
275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
276 | - ) ); ?> |
|
276 | + )); ?> |
|
277 | 277 | </p> |
278 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
279 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
278 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
279 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
280 | 280 | <?php |
281 | 281 | } |
282 | 282 | |
283 | - public static function vat_classes( $post ) { |
|
283 | + public static function vat_classes($post) { |
|
284 | 284 | global $wpinv_euvat; |
285 | 285 | |
286 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
286 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
287 | 287 | ?> |
288 | - <p><?php echo wpinv_html_select( array( |
|
288 | + <p><?php echo wpinv_html_select(array( |
|
289 | 289 | 'options' => $wpinv_euvat->get_all_classes(), |
290 | 290 | 'name' => 'wpinv_vat_class', |
291 | 291 | 'id' => 'wpinv_vat_class', |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | 'show_option_all' => false, |
294 | 294 | 'show_option_none' => false, |
295 | 295 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
296 | - ) ); ?> |
|
296 | + )); ?> |
|
297 | 297 | </p> |
298 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
298 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
299 | 299 | <?php |
300 | 300 | } |
301 | 301 | |
302 | - public static function item_info( $post ) { |
|
303 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
304 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
302 | + public static function item_info($post) { |
|
303 | + $item_type = wpinv_get_item_type($post->ID); |
|
304 | + do_action('wpinv_item_info_metabox_before', $post); |
|
305 | 305 | ?> |
306 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
307 | - <?php echo wpinv_html_select( array( |
|
306 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
307 | + <?php echo wpinv_html_select(array( |
|
308 | 308 | 'options' => wpinv_get_item_types(), |
309 | 309 | 'name' => 'wpinv_item_type', |
310 | 310 | 'id' => 'wpinv_item_type', |
@@ -312,114 +312,114 @@ discard block |
||
312 | 312 | 'show_option_all' => false, |
313 | 313 | 'show_option_none' => false, |
314 | 314 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
315 | - ) ); ?> |
|
315 | + )); ?> |
|
316 | 316 | </p> |
317 | - <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> |
|
317 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
318 | 318 | <?php |
319 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
319 | + do_action('wpinv_item_info_metabox_after', $post); |
|
320 | 320 | } |
321 | 321 | |
322 | - public static function meta_values( $post ) { |
|
323 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
322 | + public static function meta_values($post) { |
|
323 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
324 | 324 | 'type', |
325 | 325 | 'custom_id' |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | |
328 | - if ( empty( $meta_keys ) ) { |
|
328 | + if (empty($meta_keys)) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
332 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
333 | 333 | |
334 | - foreach ( $meta_keys as $meta_key ) { |
|
334 | + foreach ($meta_keys as $meta_key) { |
|
335 | 335 | ?> |
336 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
336 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
337 | 337 | <?php |
338 | 338 | } |
339 | 339 | |
340 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
340 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
341 | 341 | } |
342 | 342 | |
343 | - public static function save( $post_id, $data, $post ) { |
|
344 | - $invoice = new WPInv_Invoice( $post_id ); |
|
343 | + public static function save($post_id, $data, $post) { |
|
344 | + $invoice = new WPInv_Invoice($post_id); |
|
345 | 345 | |
346 | 346 | // Billing |
347 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
348 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
349 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
350 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
351 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
352 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
353 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
354 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
355 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
356 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
347 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
348 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
349 | + $company = sanitize_text_field($data['wpinv_company']); |
|
350 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
351 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
352 | + $address = sanitize_text_field($data['wpinv_address']); |
|
353 | + $city = sanitize_text_field($data['wpinv_city']); |
|
354 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
355 | + $country = sanitize_text_field($data['wpinv_country']); |
|
356 | + $state = sanitize_text_field($data['wpinv_state']); |
|
357 | 357 | |
358 | 358 | // Details |
359 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
360 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
361 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
362 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
359 | + $status = sanitize_text_field($data['wpinv_status']); |
|
360 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
361 | + $number = sanitize_text_field($data['wpinv_number']); |
|
362 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
363 | 363 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
364 | 364 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
365 | 365 | |
366 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
366 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
367 | 367 | |
368 | - $invoice->set( 'due_date', $due_date ); |
|
369 | - $invoice->set( 'first_name', $first_name ); |
|
370 | - $invoice->set( 'last_name', $last_name ); |
|
371 | - $invoice->set( 'company', $company ); |
|
372 | - $invoice->set( 'vat_number', $vat_number ); |
|
373 | - $invoice->set( 'phone', $phone ); |
|
374 | - $invoice->set( 'address', $address ); |
|
375 | - $invoice->set( 'city', $city ); |
|
376 | - $invoice->set( 'zip', $zip ); |
|
377 | - $invoice->set( 'country', $country ); |
|
378 | - $invoice->set( 'state', $state ); |
|
379 | - $invoice->set( 'status', $status ); |
|
368 | + $invoice->set('due_date', $due_date); |
|
369 | + $invoice->set('first_name', $first_name); |
|
370 | + $invoice->set('last_name', $last_name); |
|
371 | + $invoice->set('company', $company); |
|
372 | + $invoice->set('vat_number', $vat_number); |
|
373 | + $invoice->set('phone', $phone); |
|
374 | + $invoice->set('address', $address); |
|
375 | + $invoice->set('city', $city); |
|
376 | + $invoice->set('zip', $zip); |
|
377 | + $invoice->set('country', $country); |
|
378 | + $invoice->set('state', $state); |
|
379 | + $invoice->set('status', $status); |
|
380 | 380 | //$invoice->set( 'number', $number ); |
381 | 381 | //$invoice->set( 'discounts', $discounts ); |
382 | 382 | //$invoice->set( 'discount', $discount ); |
383 | - $invoice->set( 'ip', $ip ); |
|
383 | + $invoice->set('ip', $ip); |
|
384 | 384 | $invoice->old_status = $_POST['original_post_status']; |
385 | 385 | $invoice->currency = wpinv_get_currency(); |
386 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
387 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
386 | + if (!empty($data['wpinv_gateway'])) { |
|
387 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
388 | 388 | } |
389 | 389 | $saved = $invoice->save(); |
390 | 390 | |
391 | 391 | // Check for payment notes |
392 | - if ( !empty( $data['invoice_note'] ) ) { |
|
393 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
394 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
392 | + if (!empty($data['invoice_note'])) { |
|
393 | + $note = wp_kses($data['invoice_note'], array()); |
|
394 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
395 | 395 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
396 | 396 | |
397 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
397 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | // Update user address if empty. |
401 | - if ( $saved && !empty( $invoice ) ) { |
|
402 | - if ( $user_id = $invoice->get_user_id() ) { |
|
403 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
401 | + if ($saved && !empty($invoice)) { |
|
402 | + if ($user_id = $invoice->get_user_id()) { |
|
403 | + $user_address = wpinv_get_user_address($user_id, false); |
|
404 | 404 | |
405 | 405 | if (empty($user_address['first_name'])) { |
406 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
407 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
406 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
407 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
408 | 408 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
409 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
409 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
413 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
414 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
415 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
416 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
417 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
418 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
413 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
414 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
415 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
416 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
417 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
418 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
422 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | 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,35 +34,35 @@ 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 ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
40 | + <?php if ($invoice->post_type == 'wpi_invoice' && 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 do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
49 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
48 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
49 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
50 | 50 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
51 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
52 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
51 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
52 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
53 | 53 | </div> |
54 | 54 | <?php } ?> |
55 | - <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?> |
|
55 | + <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?> |
|
56 | 56 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed"> |
57 | - <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div> |
|
58 | - <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div> |
|
57 | + <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div> |
|
58 | + <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div> |
|
59 | 59 | </div> |
60 | 60 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
61 | 61 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
62 | 62 | <div class="gdmbx-td"> |
63 | 63 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
64 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
65 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
64 | + <?php foreach ($statuses as $value => $label) { ?> |
|
65 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
66 | 66 | <?php } ?> |
67 | 67 | </select> |
68 | 68 | </div> |
@@ -70,117 +70,117 @@ discard block |
||
70 | 70 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
71 | 71 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
72 | 72 | <div class="gdmbx-td"> |
73 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
73 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
74 | 74 | </div> |
75 | 75 | </div> |
76 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); |
|
76 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); |
|
77 | 77 | $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id); |
78 | 78 | ?> |
79 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?> |
|
79 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?> |
|
80 | 80 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
81 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
81 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
82 | 82 | <div class="gdmbx-td"> |
83 | - <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 && !$disable_discount ) { ?><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 } ?> |
|
83 | + <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 && !$disable_discount) { ?><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 } ?> |
|
84 | 84 | </div> |
85 | 85 | </div> |
86 | 86 | <?php } ?> |
87 | 87 | </div> |
88 | 88 | </div> |
89 | 89 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
90 | - <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> |
|
90 | + <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> |
|
91 | 91 | <select id="wpi_save_send" name="wpi_save_send"> |
92 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
93 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
92 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
93 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
94 | 94 | </select> |
95 | 95 | </p> |
96 | 96 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
97 | 97 | </div> |
98 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
98 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
99 | 99 | <?php |
100 | 100 | } |
101 | 101 | |
102 | - public static function resend_invoice( $post ) { |
|
102 | + public static function resend_invoice($post) { |
|
103 | 103 | global $wpi_mb_invoice; |
104 | 104 | |
105 | - if ( empty( $wpi_mb_invoice ) ) { |
|
105 | + if (empty($wpi_mb_invoice)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $text = array( |
110 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
111 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
110 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
111 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
115 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
115 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
116 | 116 | |
117 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
117 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
118 | 118 | $email_actions = array(); |
119 | - $email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
120 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
119 | + $email_actions['email_url'] = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))); |
|
120 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
121 | 121 | |
122 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
122 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
123 | 123 | ?> |
124 | 124 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
125 | - <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> |
|
126 | - <?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() ) ) { ?> |
|
127 | - <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> |
|
125 | + <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> |
|
126 | + <?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())) { ?> |
|
127 | + <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> |
|
128 | 128 | <?php } ?> |
129 | 129 | <?php |
130 | 130 | } |
131 | 131 | |
132 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
132 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
133 | 133 | } |
134 | 134 | |
135 | - public static function subscriptions( $post ) { |
|
136 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
135 | + public static function subscriptions($post) { |
|
136 | + $invoice = wpinv_get_invoice($post->ID); |
|
137 | 137 | |
138 | - if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
139 | - $subscription = wpinv_get_subscription( $invoice ); |
|
138 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
139 | + $subscription = wpinv_get_subscription($invoice); |
|
140 | 140 | |
141 | - if ( empty( $subscription ) ) { |
|
141 | + if (empty($subscription)) { |
|
142 | 142 | ?> |
143 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
143 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p> |
|
144 | 144 | <?php |
145 | 145 | return; |
146 | 146 | } |
147 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
148 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
149 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
147 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
148 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
149 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
150 | 150 | $payments = $subscription->get_child_payments(); |
151 | 151 | ?> |
152 | 152 | <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
153 | - <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
153 | + <?php if (!empty($subscription) && !empty($subscription->id)) { ?> |
|
154 | 154 | <p class="wpi-meta-row wpi-sub-id"> |
155 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
155 | + <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
156 | 156 | <?php } ?> |
157 | 157 | <p class="wpi-meta-row wpi-bill-cycle"> |
158 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
158 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?> |
|
159 | 159 | </p> |
160 | 160 | <p class="wpi-meta-row wpi-billed-times"> |
161 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
161 | + <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
162 | 162 | </p> |
163 | 163 | <p class="wpi-meta-row wpi-start-date"> |
164 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
164 | + <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
165 | 165 | </p> |
166 | 166 | <p class="wpi-meta-row wpi-end-date"> |
167 | - <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
167 | + <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
168 | 168 | </p> |
169 | - <?php if ( $subscription->status ) { ?> |
|
169 | + <?php if ($subscription->status) { ?> |
|
170 | 170 | <p class="wpi-meta-row wpi-sub-status"> |
171 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
171 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
172 | 172 | </p> |
173 | 173 | <?php } ?> |
174 | - <?php if ( !empty( $payments ) ) { ?> |
|
175 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
174 | + <?php if (!empty($payments)) { ?> |
|
175 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
176 | 176 | <ul id="wpi-sub-payments"> |
177 | - <?php foreach ( $payments as $payment ) { |
|
177 | + <?php foreach ($payments as $payment) { |
|
178 | 178 | $invoice_id = $payment->ID; |
179 | 179 | ?> |
180 | 180 | <li> |
181 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
182 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
183 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
181 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
182 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
183 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
184 | 184 | </li> |
185 | 185 | <?php } ?> |
186 | 186 | </ul> |
@@ -188,50 +188,50 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - public static function renewals( $post ) { |
|
192 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
191 | + public static function renewals($post) { |
|
192 | + $invoice = wpinv_get_invoice($post->ID); |
|
193 | 193 | |
194 | - if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
195 | - $parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
196 | - $parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
197 | - $subscription = wpinv_get_subscription( $invoice ); |
|
194 | + if (wpinv_is_subscription_payment($invoice)) { |
|
195 | + $parent_url = get_edit_post_link($invoice->parent_invoice); |
|
196 | + $parent_id = wpinv_get_invoice_number($invoice->parent_invoice); |
|
197 | + $subscription = wpinv_get_subscription($invoice); |
|
198 | 198 | ?> |
199 | - <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | - <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> |
|
199 | + <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | + <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> |
|
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - public static function payment_meta( $post ) { |
|
205 | + public static function payment_meta($post) { |
|
206 | 206 | global $wpi_mb_invoice; |
207 | 207 | |
208 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
209 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
208 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
209 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
210 | 210 | $set_dateway = true; |
211 | 211 | } |
212 | 212 | |
213 | 213 | ?> |
214 | 214 | <p class="wpi-meta-row"> |
215 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
216 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
215 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
216 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
217 | 217 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
218 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
219 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
218 | + <?php foreach ($gateways as $name => $gateway) { |
|
219 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | ?> |
223 | - <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> |
|
223 | + <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> |
|
224 | 224 | <?php } ?> |
225 | 225 | </select> |
226 | 226 | <?php } else { |
227 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) ); |
|
227 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway)); |
|
228 | 228 | } ?> |
229 | 229 | </p> |
230 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
231 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
230 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
231 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
232 | 232 | <?php } ?> |
233 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
234 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
233 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
234 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
235 | 235 | <?php } ?> |
236 | 236 | <?php |
237 | 237 | } |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,58 +299,58 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | - $product_id = absint( $_POST['product_id'] ); |
|
322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | - $subscription->update( array( |
|
324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
325 | - 'expiration' => $expiration, |
|
326 | - 'profile_id' => $profile_id, |
|
327 | - 'product_id' => $product_id, |
|
328 | - 'transaction_id' => $transaction_id, |
|
329 | - ) ); |
|
318 | + $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | + $product_id = absint( $_POST['product_id'] ); |
|
322 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | + $subscription->update( array( |
|
324 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
325 | + 'expiration' => $expiration, |
|
326 | + 'profile_id' => $profile_id, |
|
327 | + 'product_id' => $product_id, |
|
328 | + 'transaction_id' => $transaction_id, |
|
329 | + ) ); |
|
330 | 330 | |
331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
331 | + $status = sanitize_text_field( $_POST['status'] ); |
|
332 | 332 | |
333 | - switch( $status ) { |
|
333 | + switch( $status ) { |
|
334 | 334 | |
335 | - case 'cancelled' : |
|
335 | + case 'cancelled' : |
|
336 | 336 | |
337 | - $subscription->cancel(); |
|
338 | - break; |
|
337 | + $subscription->cancel(); |
|
338 | + break; |
|
339 | 339 | |
340 | - case 'expired' : |
|
340 | + case 'expired' : |
|
341 | 341 | |
342 | - $subscription->expire(); |
|
343 | - break; |
|
342 | + $subscription->expire(); |
|
343 | + break; |
|
344 | 344 | |
345 | - case 'completed' : |
|
345 | + case 'completed' : |
|
346 | 346 | |
347 | - $subscription->complete(); |
|
348 | - break; |
|
347 | + $subscription->complete(); |
|
348 | + break; |
|
349 | 349 | |
350 | - } |
|
350 | + } |
|
351 | 351 | |
352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
353 | - exit; |
|
352 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
353 | + exit; |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -364,30 +364,30 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
366 | 366 | |
367 | - if( empty( $_POST['sub_id'] ) ) { |
|
368 | - return; |
|
369 | - } |
|
367 | + if( empty( $_POST['sub_id'] ) ) { |
|
368 | + return; |
|
369 | + } |
|
370 | 370 | |
371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
372 | - return; |
|
373 | - } |
|
371 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
372 | + return; |
|
373 | + } |
|
374 | 374 | |
375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
376 | - return; |
|
377 | - } |
|
375 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
376 | + return; |
|
377 | + } |
|
378 | 378 | |
379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
381 | - } |
|
379 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
381 | + } |
|
382 | 382 | |
383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
383 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
384 | 384 | |
385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
385 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
386 | 386 | |
387 | - $subscription->delete(); |
|
387 | + $subscription->delete(); |
|
388 | 388 | |
389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
390 | - exit; |
|
389 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
390 | + exit; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if (!empty($_GET['id'])) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
23 | 23 | </h1> |
24 | 24 | <?php |
25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <input type="hidden" name="post_type" value="download" /> |
32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
33 | 33 | <?php $subscribers_table->views(); ?> |
34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
35 | 35 | <?php $subscribers_table->display(); ?> |
36 | 36 | |
37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | $render = true; |
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
52 | + if (!current_user_can('manage_invoicing')) { |
|
53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
58 | 58 | } |
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int)$_GET['id']; |
|
61 | + $sub = new WPInv_Subscription($sub_id); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
63 | + if (empty($sub)) { |
|
64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | ?> |
68 | 68 | <div class="wrap"> |
69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
70 | 70 | |
71 | - <?php if ( $sub ) : ?> |
|
71 | + <?php if ($sub) : ?> |
|
72 | 72 | |
73 | 73 | <div id="wpinv-item-card-wrapper"> |
74 | 74 | |
75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
76 | 76 | |
77 | 77 | <div class="info-wrapper item-section"> |
78 | 78 | |
79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
80 | 80 | |
81 | 81 | <div class="item-info"> |
82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td class="row-title"> |
87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
99 | 99 | <td class="row-title"> |
100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
101 | 101 | </td> |
102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
103 | 103 | </tr> |
104 | 104 | <tr> |
105 | 105 | <td class="row-title"> |
106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
107 | 107 | </td> |
108 | 108 | <td> |
109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
110 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
110 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
111 | 111 | </td> |
112 | 112 | </tr> |
113 | 113 | <tr> |
114 | 114 | <td class="row-title"> |
115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
116 | 116 | </td> |
117 | 117 | <td> |
118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
119 | 119 | </tr> |
120 | 120 | <tr> |
121 | 121 | <td class="row-title"> |
122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
123 | 123 | </td> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - echo wpinv_item_dropdown( array( |
|
126 | + echo wpinv_item_dropdown(array( |
|
127 | 127 | 'name' => 'product_id', |
128 | 128 | 'id' => 'wpinv_invoice_item', |
129 | 129 | 'with_packages' => false, |
130 | 130 | 'show_recurring' => true, |
131 | 131 | 'selected' => $sub->product_id, |
132 | 132 | 'class' => 'wpinv-sub-product-id', |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | ?> |
136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
137 | 137 | 'post' => $sub->product_id, |
138 | 138 | 'action' => 'edit' |
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
143 | 143 | <td class="row-title"> |
144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
145 | 145 | </td> |
146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
147 | 147 | </tr> |
148 | 148 | <tr> |
149 | 149 | <td class="row-title"> |
150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
151 | 151 | </td> |
152 | 152 | <td> |
153 | 153 | <span class="wpinv-sub-profile-id"> |
154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
155 | 155 | </span> |
156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
157 | 157 | <span> – </span> |
158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | <tr> |
162 | 162 | <td class="row-title"> |
163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
164 | 164 | </td> |
165 | 165 | <td> |
166 | 166 | <span class="wpinv-sub-transaction-id"><?php echo $sub->get_transaction_id(); ?></span> |
167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
168 | 168 | <span> – </span> |
169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
170 | 170 | </td> |
171 | 171 | </tr> |
172 | 172 | <tr> |
173 | 173 | <td class="row-title"> |
174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
175 | 175 | </td> |
176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
177 | 177 | </tr> |
178 | 178 | <tr> |
179 | 179 | <td class="row-title"> |
180 | 180 | <label for="tablecell"> |
181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
181 | + <?php if ('trialling' == $sub->status) : ?> |
|
182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
183 | 183 | <?php else: ?> |
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
185 | 185 | <?php endif; ?> |
186 | 186 | </label> |
187 | 187 | </td> |
188 | 188 | <td> |
189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <td class="row-title"> |
194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
195 | 195 | </td> |
196 | 196 | <td> |
197 | 197 | <select name="status"> |
198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </td> |
207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
209 | 209 | </table> |
210 | 210 | </div> |
211 | 211 | <div id="wpinv-sub-notices"> |
212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
214 | 214 | </div> |
215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
219 | - <?php if( $sub->can_cancel() ) : ?> |
|
220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
219 | + <?php if ($sub->can_cancel()) : ?> |
|
220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
221 | 221 | <?php endif; ?> |
222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | </form> |
226 | 226 | </div> |
227 | 227 | |
228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
229 | 229 | |
230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
231 | 231 | |
232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
233 | 233 | |
234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
235 | 235 | |
236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
240 | 240 | <?php endif; ?> |
241 | 241 | <table class="wp-list-table widefat striped payments"> |
242 | 242 | <thead> |
243 | 243 | <tr> |
244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
250 | 250 | </tr> |
251 | 251 | </thead> |
252 | 252 | <tbody> |
253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
253 | + <?php if (!empty($payments)) : ?> |
|
254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
255 | 255 | <tr> |
256 | 256 | <td><?php echo $payment->ID; ?></td> |
257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
260 | 260 | <td> |
261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
263 | 263 | </td> |
264 | 264 | <td class="column-wpi_actions"> |
265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
266 | 266 | </a> |
267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <?php endforeach; ?> |
271 | 271 | <?php else: ?> |
272 | 272 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
274 | 274 | </tr> |
275 | 275 | <?php endif; ?> |
276 | 276 | </tbody> |
277 | 277 | <tfoot></tfoot> |
278 | 278 | </table> |
279 | 279 | |
280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -299,38 +299,38 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
302 | + if (empty($_POST['sub_id'])) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
310 | + if (!current_user_can('manage_invoicing')) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
316 | 316 | } |
317 | 317 | |
318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | - $product_id = absint( $_POST['product_id'] ); |
|
322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | - $subscription->update( array( |
|
324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
318 | + $expiration = date('Y-m-d 23:59:59', strtotime($_POST['expiration'])); |
|
319 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
320 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
321 | + $product_id = absint($_POST['product_id']); |
|
322 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
323 | + $subscription->update(array( |
|
324 | + 'status' => sanitize_text_field($_POST['status']), |
|
325 | 325 | 'expiration' => $expiration, |
326 | 326 | 'profile_id' => $profile_id, |
327 | 327 | 'product_id' => $product_id, |
328 | 328 | 'transaction_id' => $transaction_id, |
329 | - ) ); |
|
329 | + )); |
|
330 | 330 | |
331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
331 | + $status = sanitize_text_field($_POST['status']); |
|
332 | 332 | |
333 | - switch( $status ) { |
|
333 | + switch ($status) { |
|
334 | 334 | |
335 | 335 | case 'cancelled' : |
336 | 336 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
352 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
353 | 353 | exit; |
354 | 354 | |
355 | 355 | } |
356 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
356 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Handles subscription deletion |
@@ -364,30 +364,30 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
366 | 366 | |
367 | - if( empty( $_POST['sub_id'] ) ) { |
|
367 | + if (empty($_POST['sub_id'])) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
371 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
375 | + if (!current_user_can('manage_invoicing')) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
380 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
381 | 381 | } |
382 | 382 | |
383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
383 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
384 | 384 | |
385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
385 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
386 | 386 | |
387 | 387 | $subscription->delete(); |
388 | 388 | |
389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
389 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
390 | 390 | exit; |
391 | 391 | |
392 | 392 | } |
393 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
393 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -180,8 +180,11 @@ discard block |
||
180 | 180 | <label for="tablecell"> |
181 | 181 | <?php if( 'trialling' == $sub->status ) : ?> |
182 | 182 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
183 | - <?php else: ?> |
|
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
183 | + <?php else { |
|
184 | + : ?> |
|
185 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
186 | +} |
|
187 | +?> |
|
185 | 188 | <?php endif; ?> |
186 | 189 | </label> |
187 | 190 | </td> |
@@ -251,7 +254,10 @@ discard block |
||
251 | 254 | </thead> |
252 | 255 | <tbody> |
253 | 256 | <?php if ( ! empty( $payments ) ) : ?> |
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
257 | + <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) { |
|
258 | + continue; |
|
259 | +} |
|
260 | +?> |
|
255 | 261 | <tr> |
256 | 262 | <td><?php echo $payment->ID; ?></td> |
257 | 263 | <td><?php echo $invoice->get_total( true ); ?></td> |
@@ -268,9 +274,12 @@ discard block |
||
268 | 274 | </td> |
269 | 275 | </tr> |
270 | 276 | <?php endforeach; ?> |
271 | - <?php else: ?> |
|
277 | + <?php else { |
|
278 | + : ?> |
|
272 | 279 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
280 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
281 | +} |
|
282 | +?></td> |
|
274 | 283 | </tr> |
275 | 284 | <?php endif; ?> |
276 | 285 | </tbody> |
@@ -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,92 +72,92 @@ 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 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <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> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <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> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <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> |
|
226 | + <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> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <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> |
|
263 | + <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> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <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> |
|
281 | + <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> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <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> |
|
314 | + <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> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - 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' ) ) ) { |
|
351 | + 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'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |
@@ -176,69 +176,69 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | - global $wpinv_options, $pagenow, $post; |
|
179 | + global $wpinv_options, $pagenow, $post; |
|
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | - } |
|
181 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | + } |
|
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | - } |
|
185 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | + } |
|
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | - } |
|
189 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | + } |
|
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | - } |
|
193 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | + } |
|
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | - } |
|
197 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | + } |
|
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | - } |
|
201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | + } |
|
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | - } |
|
205 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | + } |
|
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
214 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
218 | 218 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | - } |
|
221 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | - } |
|
225 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | + } |
|
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | - } |
|
229 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | + } |
|
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | - } |
|
239 | - } |
|
236 | + if ( !empty( $message ) ) { |
|
237 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors( 'wpinv-notices' ); |
|
242 | 242 | } |
243 | 243 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
244 | 244 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
304 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
305 | 305 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
306 | 306 | if ( $wpinv_euvat->allow_vat_rules() ) { |
307 | 307 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,264 +7,264 @@ 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' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
83 | - $time_format = get_option( 'time_format' ); |
|
84 | - $date_time_format = $date_format . ' '. $time_format; |
|
82 | + $date_format = get_option('date_format'); |
|
83 | + $time_format = get_option('time_format'); |
|
84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
85 | 85 | |
86 | - $t_time = get_the_time( $date_time_format ); |
|
86 | + $t_time = get_the_time($date_time_format); |
|
87 | 87 | $m_time = $post->post_date; |
88 | - $h_time = mysql2date( $date_format, $m_time ); |
|
88 | + $h_time = mysql2date($date_format, $m_time); |
|
89 | 89 | |
90 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
90 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
91 | 91 | break; |
92 | 92 | case 'payment_date' : |
93 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
94 | - $date_format = get_option( 'date_format' ); |
|
95 | - $time_format = get_option( 'time_format' ); |
|
96 | - $date_time_format = $date_format . ' '. $time_format; |
|
93 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
94 | + $date_format = get_option('date_format'); |
|
95 | + $time_format = get_option('time_format'); |
|
96 | + $date_time_format = $date_format . ' ' . $time_format; |
|
97 | 97 | |
98 | - $t_time = get_the_time( $date_time_format ); |
|
98 | + $t_time = get_the_time($date_time_format); |
|
99 | 99 | $m_time = $date_completed; |
100 | - $h_time = mysql2date( $date_format, $m_time ); |
|
100 | + $h_time = mysql2date($date_format, $m_time); |
|
101 | 101 | |
102 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
102 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
103 | 103 | } else { |
104 | 104 | $value = '-'; |
105 | 105 | } |
106 | 106 | break; |
107 | 107 | case 'status' : |
108 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
109 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
110 | - if ( 1 == $is_viewed ) { |
|
111 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
108 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
109 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
110 | + if (1 == $is_viewed) { |
|
111 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
112 | 112 | } |
113 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
114 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
113 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
114 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
115 | 115 | } |
116 | 116 | break; |
117 | 117 | case 'number' : |
118 | - $edit_link = get_edit_post_link( $post->ID ); |
|
119 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | + $edit_link = get_edit_post_link($post->ID); |
|
119 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
120 | 120 | break; |
121 | 121 | case 'wpi_actions' : |
122 | 122 | $value = ''; |
123 | - if ( !empty( $post->post_name ) ) { |
|
124 | - $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>'; |
|
123 | + if (!empty($post->post_name)) { |
|
124 | + $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>'; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( $email = $wpi_invoice->get_email() ) { |
|
128 | - $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>'; |
|
127 | + if ($email = $wpi_invoice->get_email()) { |
|
128 | + $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>'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | break; |
132 | 132 | default: |
133 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
133 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
134 | 134 | break; |
135 | 135 | |
136 | 136 | } |
137 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
137 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
138 | 138 | |
139 | - if ( $value !== NULL ) { |
|
139 | + if ($value !== NULL) { |
|
140 | 140 | echo $value; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | -function wpinv_admin_post_id( $id = 0 ) { |
|
144 | +function wpinv_admin_post_id($id = 0) { |
|
145 | 145 | global $post; |
146 | 146 | |
147 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
147 | + if (isset($id) && !empty($id)) { |
|
148 | 148 | return (int)$id; |
149 | - } else if ( get_the_ID() ) { |
|
150 | - return (int) get_the_ID(); |
|
151 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
152 | - return (int) $post->ID; |
|
153 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
154 | - return (int) $_GET['post']; |
|
155 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
156 | - return (int) $_GET['id']; |
|
157 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
158 | - return (int) $_POST['id']; |
|
149 | + } else if (get_the_ID()) { |
|
150 | + return (int)get_the_ID(); |
|
151 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
152 | + return (int)$post->ID; |
|
153 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
154 | + return (int)$_GET['post']; |
|
155 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
156 | + return (int)$_GET['id']; |
|
157 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
158 | + return (int)$_POST['id']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_admin_post_type( $id = 0 ) { |
|
165 | - if ( !$id ) { |
|
164 | +function wpinv_admin_post_type($id = 0) { |
|
165 | + if (!$id) { |
|
166 | 166 | $id = wpinv_admin_post_id(); |
167 | 167 | } |
168 | 168 | |
169 | - $type = get_post_type( $id ); |
|
169 | + $type = get_post_type($id); |
|
170 | 170 | |
171 | - if ( !$type ) { |
|
172 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
171 | + if (!$type) { |
|
172 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
173 | 173 | } |
174 | 174 | |
175 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
175 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | 179 | global $wpinv_options, $pagenow, $post; |
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
181 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
182 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
185 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
186 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
189 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
190 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
193 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
194 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
197 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
198 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
201 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
202 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
205 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
206 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
210 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
213 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
214 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
215 | 215 | } |
216 | 216 | |
217 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
218 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
217 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
218 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
221 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
222 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
225 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
226 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
229 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
230 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
234 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
236 | + if (!empty($message)) { |
|
237 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors('wpinv-notices'); |
|
242 | 242 | } |
243 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
243 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
244 | 244 | |
245 | -function wpinv_items_columns( $existing_columns ) { |
|
245 | +function wpinv_items_columns($existing_columns) { |
|
246 | 246 | global $wpinv_euvat; |
247 | 247 | |
248 | 248 | $columns = array(); |
249 | 249 | $columns['cb'] = $existing_columns['cb']; |
250 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
251 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
252 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
253 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
250 | + $columns['title'] = __('Title', 'invoicing'); |
|
251 | + $columns['price'] = __('Price', 'invoicing'); |
|
252 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
253 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
254 | 254 | } |
255 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
256 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
255 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
256 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
257 | 257 | } |
258 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
259 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
260 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
261 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
258 | + $columns['type'] = __('Type', 'invoicing'); |
|
259 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
260 | + $columns['date'] = __('Date', 'invoicing'); |
|
261 | + $columns['id'] = __('ID', 'invoicing'); |
|
262 | 262 | |
263 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
263 | + return apply_filters('wpinv_items_columns', $columns); |
|
264 | 264 | } |
265 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
265 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
266 | 266 | |
267 | -function wpinv_items_sortable_columns( $columns ) { |
|
267 | +function wpinv_items_sortable_columns($columns) { |
|
268 | 268 | $columns['price'] = 'price'; |
269 | 269 | $columns['vat_rule'] = 'vat_rule'; |
270 | 270 | $columns['vat_class'] = 'vat_class'; |
@@ -274,151 +274,151 @@ discard block |
||
274 | 274 | |
275 | 275 | return $columns; |
276 | 276 | } |
277 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
277 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
278 | 278 | |
279 | -function wpinv_items_table_custom_column( $column ) { |
|
279 | +function wpinv_items_table_custom_column($column) { |
|
280 | 280 | global $wpinv_euvat, $post, $wpi_item; |
281 | 281 | |
282 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
283 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
282 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
283 | + $wpi_item = new WPInv_Item($post->ID); |
|
284 | 284 | } |
285 | 285 | |
286 | - switch ( $column ) { |
|
286 | + switch ($column) { |
|
287 | 287 | case 'price' : |
288 | - echo wpinv_item_price( $post->ID ); |
|
288 | + echo wpinv_item_price($post->ID); |
|
289 | 289 | break; |
290 | 290 | case 'vat_rule' : |
291 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
291 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
292 | 292 | break; |
293 | 293 | case 'vat_class' : |
294 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
294 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
295 | 295 | break; |
296 | 296 | case 'type' : |
297 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
297 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
298 | 298 | break; |
299 | 299 | case 'recurring' : |
300 | - 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>' ); |
|
300 | + 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>'); |
|
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | 304 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
305 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
306 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
307 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
305 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
306 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
307 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
308 | 308 | } |
309 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
310 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
309 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
310 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
311 | 311 | } |
312 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
312 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
313 | 313 | </div>'; |
314 | 314 | break; |
315 | 315 | } |
316 | 316 | |
317 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
317 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
318 | 318 | } |
319 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
319 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
320 | 320 | |
321 | 321 | function wpinv_add_items_filters() { |
322 | 322 | global $wpinv_euvat, $typenow; |
323 | 323 | |
324 | 324 | // Checks if the current post type is 'item' |
325 | - if ( $typenow == 'wpi_item') { |
|
326 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
327 | - echo wpinv_html_select( array( |
|
328 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
325 | + if ($typenow == 'wpi_item') { |
|
326 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
327 | + echo wpinv_html_select(array( |
|
328 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
329 | 329 | 'name' => 'vat_rule', |
330 | 330 | 'id' => 'vat_rule', |
331 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
331 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
332 | 332 | 'show_option_all' => false, |
333 | 333 | 'show_option_none' => false, |
334 | 334 | 'class' => 'gdmbx2-text-medium', |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | } |
337 | 337 | |
338 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
339 | - echo wpinv_html_select( array( |
|
340 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
338 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
339 | + echo wpinv_html_select(array( |
|
340 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
341 | 341 | 'name' => 'vat_class', |
342 | 342 | 'id' => 'vat_class', |
343 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
343 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | 346 | 'class' => 'gdmbx2-text-medium', |
347 | - ) ); |
|
347 | + )); |
|
348 | 348 | } |
349 | 349 | |
350 | - echo wpinv_html_select( array( |
|
351 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
350 | + echo wpinv_html_select(array( |
|
351 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
352 | 352 | 'name' => 'type', |
353 | 353 | 'id' => 'type', |
354 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
354 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
355 | 355 | 'show_option_all' => false, |
356 | 356 | 'show_option_none' => false, |
357 | 357 | 'class' => 'gdmbx2-text-medium', |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
360 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
361 | 361 | echo '<input type="hidden" name="all_posts" value="1" />'; |
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
365 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
365 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
366 | 366 | |
367 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
368 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
367 | +function wpinv_send_invoice_after_save($invoice) { |
|
368 | + if (empty($_POST['wpi_save_send'])) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
373 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
372 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
373 | + wpinv_user_invoice_notification($invoice->ID); |
|
374 | 374 | } |
375 | 375 | } |
376 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
376 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
377 | 377 | |
378 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
379 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
380 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
381 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
378 | +function wpinv_send_register_new_user($data, $postarr) { |
|
379 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
380 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
381 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
382 | 382 | |
383 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
384 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
385 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
386 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
387 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
388 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
383 | + if ($is_new_user && $email && !email_exists($email)) { |
|
384 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
385 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
386 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
387 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
388 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
389 | 389 | |
390 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
391 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
390 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
391 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
392 | 392 | $new_user_login = strstr($email, '@', true); |
393 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
394 | - $user_login = sanitize_user($new_user_login, true ); |
|
393 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
394 | + $user_login = sanitize_user($new_user_login, true); |
|
395 | 395 | } |
396 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
397 | - $user_append_text = rand(10,1000); |
|
398 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
396 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
397 | + $user_append_text = rand(10, 1000); |
|
398 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
401 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
402 | 402 | $user_login = $email; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | 406 | $userdata = array( |
407 | 407 | 'user_login' => $user_login, |
408 | - 'user_pass' => wp_generate_password( 12, false ), |
|
409 | - 'user_email' => sanitize_text_field( $email ), |
|
408 | + 'user_pass' => wp_generate_password(12, false), |
|
409 | + 'user_email' => sanitize_text_field($email), |
|
410 | 410 | 'first_name' => $first_name, |
411 | 411 | 'last_name' => $last_name, |
412 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
412 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
413 | 413 | 'nickname' => $display_name, |
414 | 414 | 'display_name' => $display_name, |
415 | 415 | ); |
416 | 416 | |
417 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
417 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
418 | 418 | |
419 | - $new_user_id = wp_insert_user( $userdata ); |
|
419 | + $new_user_id = wp_insert_user($userdata); |
|
420 | 420 | |
421 | - if ( !is_wp_error( $new_user_id ) ) { |
|
421 | + if (!is_wp_error($new_user_id)) { |
|
422 | 422 | $data['post_author'] = $new_user_id; |
423 | 423 | $_POST['post_author'] = $new_user_id; |
424 | 424 | $_POST['post_author_override'] = $new_user_id; |
@@ -439,69 +439,69 @@ discard block |
||
439 | 439 | |
440 | 440 | $meta = array(); |
441 | 441 | ///$meta['_wpinv_user_id'] = $new_user_id; |
442 | - foreach ( $meta_fields as $field ) { |
|
443 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
442 | + foreach ($meta_fields as $field) { |
|
443 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
444 | 444 | } |
445 | 445 | |
446 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
446 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
447 | 447 | |
448 | 448 | // Update user meta. |
449 | - foreach ( $meta as $key => $value ) { |
|
450 | - update_user_meta( $new_user_id, $key, $value ); |
|
449 | + foreach ($meta as $key => $value) { |
|
450 | + update_user_meta($new_user_id, $key, $value); |
|
451 | 451 | } |
452 | 452 | |
453 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
453 | + if (function_exists('wp_send_new_user_notifications')) { |
|
454 | 454 | // Send email notifications related to the creation of new user. |
455 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
455 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
456 | 456 | } |
457 | 457 | } else { |
458 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
458 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | 463 | return $data; |
464 | 464 | } |
465 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
465 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
466 | 466 | |
467 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
467 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
468 | 468 | $all_gateways = wpinv_get_payment_gateways(); |
469 | 469 | |
470 | - if ( !empty( $all_gateways ) ) { |
|
470 | + if (!empty($all_gateways)) { |
|
471 | 471 | $gateways = array(); |
472 | 472 | |
473 | - foreach ( $all_gateways as $key => $gateway ) { |
|
474 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
473 | + foreach ($all_gateways as $key => $gateway) { |
|
474 | + if (wpinv_gateway_support_subscription($key)) { |
|
475 | 475 | $gateways[] = $gateway['admin_label']; |
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | - if ( !empty( $gateways ) ) { |
|
479 | + if (!empty($gateways)) { |
|
480 | 480 | ?> |
481 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
481 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
482 | 482 | <?php |
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
486 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
487 | 487 | |
488 | -function wpinv_post_updated_messages( $messages ) { |
|
488 | +function wpinv_post_updated_messages($messages) { |
|
489 | 489 | global $post, $post_ID; |
490 | 490 | |
491 | 491 | $messages['wpi_discount'] = array( |
492 | 492 | 0 => '', |
493 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
494 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
495 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
496 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
497 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
498 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
499 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
500 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
501 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
502 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
493 | + 1 => __('Discount updated.', 'invoicing'), |
|
494 | + 2 => __('Custom field updated.', 'invoicing'), |
|
495 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
496 | + 4 => __('Discount updated.', 'invoicing'), |
|
497 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
498 | + 6 => __('Discount updated.', 'invoicing'), |
|
499 | + 7 => __('Discount saved.', 'invoicing'), |
|
500 | + 8 => __('Discount submitted.', 'invoicing'), |
|
501 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
502 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
503 | 503 | ); |
504 | 504 | |
505 | 505 | return $messages; |
506 | 506 | } |
507 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
508 | 507 | \ No newline at end of file |
508 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
509 | 509 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,61 +133,61 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
159 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
158 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
159 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
162 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
161 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
162 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
165 | - <?php echo $invoice->get_total( true ); ?> |
|
164 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
165 | + <?php echo $invoice->get_total(true); ?> |
|
166 | 166 | |
167 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
167 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
168 | 168 | <?php |
169 | 169 | $actions = array( |
170 | 170 | 'pay' => array( |
171 | 171 | 'url' => $invoice->get_checkout_payment_url(), |
172 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
172 | + 'name' => __('Pay Now', 'invoicing'), |
|
173 | 173 | 'class' => 'btn-success' |
174 | 174 | ), |
175 | 175 | 'print' => array( |
176 | 176 | 'url' => $invoice->get_view_url(), |
177 | - 'name' => __( 'Print', 'invoicing' ), |
|
177 | + 'name' => __('Print', 'invoicing'), |
|
178 | 178 | 'class' => 'btn-primary', |
179 | 179 | 'attrs' => 'target="_blank"' |
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->needs_payment() ) { |
|
184 | - unset( $actions['pay'] ); |
|
183 | + if (!$invoice->needs_payment()) { |
|
184 | + unset($actions['pay']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
188 | - foreach ( $actions as $key => $action ) { |
|
187 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
188 | + foreach ($actions as $key => $action) { |
|
189 | 189 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
190 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
190 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | ?> |
@@ -215,64 +215,64 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | <?php |
217 | 217 | |
218 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
218 | + do_action('wpinv_bp_invoices_after_content'); |
|
219 | 219 | } else { |
220 | 220 | ?> |
221 | 221 | <div id="message" class="info"> |
222 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
222 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
223 | 223 | </div> |
224 | 224 | <?php |
225 | 225 | } |
226 | 226 | |
227 | - if ( defined( 'DOING_AJAX' ) ) { |
|
227 | + if (defined('DOING_AJAX')) { |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - public function has_invoices( $args = '' ) { |
|
232 | + public function has_invoices($args = '') { |
|
233 | 233 | global $invoices_template; |
234 | 234 | |
235 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
235 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
236 | 236 | // Parse arguments. |
237 | - $r = bp_parse_args( $args, array( |
|
237 | + $r = bp_parse_args($args, array( |
|
238 | 238 | 'status' => 'all', |
239 | 239 | 'page_arg' => 'bpage', |
240 | 240 | 'page' => 1, |
241 | 241 | 'per_page' => $per_page > 0 ? $per_page : 20, |
242 | 242 | 'max' => false, |
243 | 243 | 'user_id' => bp_loggedin_user_id(), |
244 | - ), 'has_invoices' ); |
|
244 | + ), 'has_invoices'); |
|
245 | 245 | |
246 | 246 | |
247 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
247 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
248 | 248 | $r['per_page'] = (int)$r['max']; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Get the invoices. |
252 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
252 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
253 | 253 | |
254 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
254 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | public function setup_invoice_count() { |
258 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
259 | - $invoices = wpinv_get_invoices( $query ); |
|
258 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
259 | + $invoices = wpinv_get_invoices($query); |
|
260 | 260 | |
261 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
261 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public function pagination_count() { |
265 | 265 | global $invoices_template; |
266 | 266 | |
267 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
268 | - $from_num = bp_core_number_format( $start_num ); |
|
269 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
270 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
267 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
268 | + $from_num = bp_core_number_format($start_num); |
|
269 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
270 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
271 | 271 | |
272 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
273 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
272 | + if (1 == $invoices_template->total_invoice_count) { |
|
273 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
274 | 274 | } else { |
275 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
275 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $message; |
@@ -281,32 +281,32 @@ discard block |
||
281 | 281 | function pagination_links() { |
282 | 282 | global $invoices_template; |
283 | 283 | |
284 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
284 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
285 | 285 | } |
286 | 286 | |
287 | - public function bp_section( $settings = array() ) { |
|
288 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
287 | + public function bp_section($settings = array()) { |
|
288 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
289 | 289 | return $settings; |
290 | 290 | } |
291 | 291 | |
292 | - public function bp_settings( $settings = array() ) { |
|
292 | + public function bp_settings($settings = array()) { |
|
293 | 293 | $settings['wpinv_bp'] = array( |
294 | 294 | 'wpinv_bp_labels' => array( |
295 | 295 | 'id' => 'wpinv_bp_settings', |
296 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
296 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
297 | 297 | 'desc' => '', |
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | 'wpinv_bp_hide_menu' => array( |
301 | 301 | 'id' => 'wpinv_bp_hide_menu', |
302 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
303 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
302 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
303 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
304 | 304 | 'type' => 'checkbox', |
305 | 305 | ), |
306 | 306 | 'wpinv_menu_position' => array( |
307 | 307 | 'id' => 'wpinv_menu_position', |
308 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
309 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
308 | + 'name' => __('Menu position', 'invoicing'), |
|
309 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
310 | 310 | 'type' => 'number', |
311 | 311 | 'size' => 'small', |
312 | 312 | 'min' => '1', |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | ), |
317 | 317 | 'wpinv_bp_per_page' => array( |
318 | 318 | 'id' => 'wpinv_bp_per_page', |
319 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
320 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
319 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
320 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
321 | 321 | 'type' => 'number', |
322 | 322 | 'size' => 'small', |
323 | 323 | 'min' => '1', |
@@ -342,25 +342,25 @@ discard block |
||
342 | 342 | public $pag_links = ''; |
343 | 343 | public $total_invoice_count = 0; |
344 | 344 | |
345 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
346 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
345 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
346 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
347 | 347 | |
348 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
349 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
350 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
348 | + $this->pag_arg = sanitize_key($page_arg); |
|
349 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
350 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
351 | 351 | |
352 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
353 | - if ( !empty( $status ) && $status != 'all' ) { |
|
352 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
353 | + if (!empty($status) && $status != 'all') { |
|
354 | 354 | $query_args['status'] = $status; |
355 | 355 | } |
356 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
356 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
357 | 357 | |
358 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
359 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
358 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
359 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
360 | 360 | $this->invoices['total'] = $invoices->found_posts; |
361 | 361 | } |
362 | 362 | |
363 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
363 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
364 | 364 | $this->total_invoice_count = (int)$this->invoices['total']; |
365 | 365 | } else { |
366 | 366 | $this->total_invoice_count = (int)$max; |
@@ -368,52 +368,52 @@ discard block |
||
368 | 368 | |
369 | 369 | $this->invoices = $this->invoices['invoices']; |
370 | 370 | |
371 | - $invoice_count = count( $this->invoices ); |
|
371 | + $invoice_count = count($this->invoices); |
|
372 | 372 | |
373 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
373 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
374 | 374 | $this->invoice_count = (int)$invoice_count; |
375 | 375 | } else { |
376 | 376 | $this->invoice_count = (int)$max; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
380 | - $this->pag_links = paginate_links( array( |
|
381 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
379 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
380 | + $this->pag_links = paginate_links(array( |
|
381 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
382 | 382 | 'format' => '', |
383 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
383 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
384 | 384 | 'current' => (int)$this->pag_page, |
385 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
386 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
385 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
386 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
387 | 387 | 'mid_size' => 1, |
388 | 388 | 'add_args' => array(), |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | public function has_invoices() { |
394 | - return (bool) ! empty( $this->invoice_count ); |
|
394 | + return (bool)!empty($this->invoice_count); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | public function next_invoice() { |
398 | 398 | $this->current_invoice++; |
399 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
399 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
400 | 400 | |
401 | 401 | return $this->invoice; |
402 | 402 | } |
403 | 403 | |
404 | 404 | public function rewind_invoices() { |
405 | 405 | $this->current_invoice = -1; |
406 | - if ( $this->invoice_count > 0 ) { |
|
406 | + if ($this->invoice_count > 0) { |
|
407 | 407 | $this->invoice = $this->invoices[0]; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | public function invoices() { |
412 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
412 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
413 | 413 | return true; |
414 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
414 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
415 | 415 | |
416 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
416 | + do_action('wpinv_bp_invoice_loop_end'); |
|
417 | 417 | |
418 | 418 | $this->rewind_invoices(); |
419 | 419 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | $this->in_the_loop = true; |
428 | 428 | $this->invoice = $this->next_invoice(); |
429 | 429 | |
430 | - if ( 0 === $this->current_invoice ) { |
|
431 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
430 | + if (0 === $this->current_invoice) { |
|
431 | + do_action('wpinv_bp_invoice_loop_start'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -438,9 +438,9 @@ discard block |
||
438 | 438 | |
439 | 439 | $bp->invoicing = new WPInv_BP_Component(); |
440 | 440 | |
441 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
442 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
443 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
444 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
441 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
442 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
443 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
444 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
445 | 445 | } |
446 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
447 | 446 | \ No newline at end of file |
447 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
448 | 448 | \ No newline at end of file |