@@ -664,6 +664,9 @@ discard block |
||
664 | 664 | return $sent; |
665 | 665 | } |
666 | 666 | |
667 | +/** |
|
668 | + * @return string |
|
669 | + */ |
|
667 | 670 | function wpinv_mail_get_from_address() { |
668 | 671 | $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
669 | 672 | return sanitize_email( $from_address ); |
@@ -1123,6 +1126,9 @@ discard block |
||
1123 | 1126 | } |
1124 | 1127 | add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
1125 | 1128 | |
1129 | +/** |
|
1130 | + * @param string $email_type |
|
1131 | + */ |
|
1126 | 1132 | function wpinv_email_is_enabled( $email_type ) { |
1127 | 1133 | $emails = wpinv_get_emails(); |
1128 | 1134 | $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_init_transactional_emails() { |
15 | - $email_actions = apply_filters( 'wpinv_email_actions', array( |
|
15 | + $email_actions = apply_filters('wpinv_email_actions', array( |
|
16 | 16 | 'wpinv_status_wpi-pending_to_wpi-processing', |
17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -30,377 +30,377 @@ 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 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
108 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
109 | 109 | |
110 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
111 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
112 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
113 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
114 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
110 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
111 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
112 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
113 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
114 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
115 | 115 | |
116 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
116 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
117 | 117 | 'invoice' => $invoice, |
118 | 118 | 'email_type' => $email_type, |
119 | 119 | 'email_heading' => $email_heading, |
120 | 120 | 'sent_to_admin' => true, |
121 | 121 | 'plain_text' => false, |
122 | 122 | 'message_body' => $message_body, |
123 | - ) ); |
|
123 | + )); |
|
124 | 124 | |
125 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
125 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
126 | 126 | |
127 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
127 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
128 | 128 | |
129 | 129 | return $sent; |
130 | 130 | } |
131 | 131 | |
132 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
132 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
133 | 133 | $email_type = 'cancelled_invoice'; |
134 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
134 | + if (!wpinv_email_is_enabled($email_type)) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
139 | - if ( empty( $invoice ) ) { |
|
138 | + $invoice = wpinv_get_invoice($invoice_id); |
|
139 | + if (empty($invoice)) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
143 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
148 | - if ( !is_email( $recipient ) ) { |
|
147 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
148 | + if (!is_email($recipient)) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | |
152 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
152 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
153 | 153 | |
154 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
155 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
156 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
157 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
158 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
154 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
155 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
156 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
157 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
158 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
159 | 159 | |
160 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
160 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
161 | 161 | 'invoice' => $invoice, |
162 | 162 | 'email_type' => $email_type, |
163 | 163 | 'email_heading' => $email_heading, |
164 | 164 | 'sent_to_admin' => true, |
165 | 165 | 'plain_text' => false, |
166 | 166 | 'message_body' => $message_body, |
167 | - ) ); |
|
167 | + )); |
|
168 | 168 | |
169 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
169 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
170 | 170 | |
171 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
171 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
172 | 172 | |
173 | 173 | return $sent; |
174 | 174 | } |
175 | 175 | |
176 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
176 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
177 | 177 | $email_type = 'failed_invoice'; |
178 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
178 | + if (!wpinv_email_is_enabled($email_type)) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
183 | - if ( empty( $invoice ) ) { |
|
182 | + $invoice = wpinv_get_invoice($invoice_id); |
|
183 | + if (empty($invoice)) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
187 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
187 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
192 | - if ( !is_email( $recipient ) ) { |
|
191 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
192 | + if (!is_email($recipient)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
196 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
197 | 197 | |
198 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
199 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
200 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
201 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
202 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
198 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
199 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
200 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
201 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
202 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
203 | 203 | |
204 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
204 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
205 | 205 | 'invoice' => $invoice, |
206 | 206 | 'email_type' => $email_type, |
207 | 207 | 'email_heading' => $email_heading, |
208 | 208 | 'sent_to_admin' => true, |
209 | 209 | 'plain_text' => false, |
210 | 210 | 'message_body' => $message_body, |
211 | - ) ); |
|
211 | + )); |
|
212 | 212 | |
213 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
213 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
214 | 214 | |
215 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
215 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
216 | 216 | |
217 | 217 | return $sent; |
218 | 218 | } |
219 | 219 | |
220 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
220 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
221 | 221 | $email_type = 'onhold_invoice'; |
222 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
222 | + if (!wpinv_email_is_enabled($email_type)) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
227 | - if ( empty( $invoice ) ) { |
|
226 | + $invoice = wpinv_get_invoice($invoice_id); |
|
227 | + if (empty($invoice)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
231 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
231 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
235 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
236 | - if ( !is_email( $recipient ) ) { |
|
235 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
236 | + if (!is_email($recipient)) { |
|
237 | 237 | return false; |
238 | 238 | } |
239 | 239 | |
240 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
240 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
241 | 241 | |
242 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
243 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
244 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
245 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
246 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
242 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
243 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
244 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
245 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
246 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
247 | 247 | |
248 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
248 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
249 | 249 | 'invoice' => $invoice, |
250 | 250 | 'email_type' => $email_type, |
251 | 251 | 'email_heading' => $email_heading, |
252 | 252 | 'sent_to_admin' => false, |
253 | 253 | 'plain_text' => false, |
254 | 254 | 'message_body' => $message_body, |
255 | - ) ); |
|
255 | + )); |
|
256 | 256 | |
257 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
257 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
258 | 258 | |
259 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
260 | - $recipient = wpinv_get_admin_email(); |
|
261 | - $subject .= ' - ADMIN BCC COPY'; |
|
262 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
259 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
260 | + $recipient = wpinv_get_admin_email(); |
|
261 | + $subject .= ' - ADMIN BCC COPY'; |
|
262 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
263 | 263 | } |
264 | 264 | |
265 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
265 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
266 | 266 | |
267 | 267 | return $sent; |
268 | 268 | } |
269 | 269 | |
270 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
270 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
271 | 271 | $email_type = 'processing_invoice'; |
272 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
272 | + if (!wpinv_email_is_enabled($email_type)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
276 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
277 | - if ( empty( $invoice ) ) { |
|
276 | + $invoice = wpinv_get_invoice($invoice_id); |
|
277 | + if (empty($invoice)) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
281 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
286 | - if ( !is_email( $recipient ) ) { |
|
285 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
286 | + if (!is_email($recipient)) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
290 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
291 | 291 | |
292 | 292 | $search = array(); |
293 | 293 | $search['invoice_number'] = '{invoice_number}'; |
294 | 294 | $search['invoice_date'] = '{invoice_date}'; |
295 | 295 | $search['name'] = '{name}'; |
296 | 296 | |
297 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
298 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
299 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
300 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
301 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
297 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
298 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
299 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
300 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
301 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
302 | 302 | |
303 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
303 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
304 | 304 | 'invoice' => $invoice, |
305 | 305 | 'email_type' => $email_type, |
306 | 306 | 'email_heading' => $email_heading, |
307 | 307 | 'sent_to_admin' => false, |
308 | 308 | 'plain_text' => false, |
309 | 309 | 'message_body' => $message_body, |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | |
312 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
312 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
313 | 313 | |
314 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
315 | - $recipient = wpinv_get_admin_email(); |
|
316 | - $subject .= ' - ADMIN BCC COPY'; |
|
317 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
314 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
315 | + $recipient = wpinv_get_admin_email(); |
|
316 | + $subject .= ' - ADMIN BCC COPY'; |
|
317 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
318 | 318 | } |
319 | 319 | |
320 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
320 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
321 | 321 | |
322 | 322 | return $sent; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
325 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
326 | 326 | $email_type = 'completed_invoice'; |
327 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
327 | + if (!wpinv_email_is_enabled($email_type)) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
332 | - if ( empty( $invoice ) ) { |
|
331 | + $invoice = wpinv_get_invoice($invoice_id); |
|
332 | + if (empty($invoice)) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
336 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
341 | - if ( !is_email( $recipient ) ) { |
|
340 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
341 | + if (!is_email($recipient)) { |
|
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
345 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
345 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
346 | 346 | |
347 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
348 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
349 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
350 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
351 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
347 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
348 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
349 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
350 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
351 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
352 | 352 | |
353 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
353 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
354 | 354 | 'invoice' => $invoice, |
355 | 355 | 'email_type' => $email_type, |
356 | 356 | 'email_heading' => $email_heading, |
357 | 357 | 'sent_to_admin' => false, |
358 | 358 | 'plain_text' => false, |
359 | 359 | 'message_body' => $message_body, |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | |
362 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
362 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
363 | 363 | |
364 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
365 | - $recipient = wpinv_get_admin_email(); |
|
366 | - $subject .= ' - ADMIN BCC COPY'; |
|
367 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
364 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
365 | + $recipient = wpinv_get_admin_email(); |
|
366 | + $subject .= ' - ADMIN BCC COPY'; |
|
367 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
368 | 368 | } |
369 | 369 | |
370 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
370 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
371 | 371 | |
372 | 372 | return $sent; |
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
375 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
376 | 376 | $email_type = 'refunded_invoice'; |
377 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
377 | + if (!wpinv_email_is_enabled($email_type)) { |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
382 | - if ( empty( $invoice ) ) { |
|
381 | + $invoice = wpinv_get_invoice($invoice_id); |
|
382 | + if (empty($invoice)) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
386 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
390 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
391 | - if ( !is_email( $recipient ) ) { |
|
390 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
391 | + if (!is_email($recipient)) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
395 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
396 | 396 | |
397 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
398 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
399 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
400 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
401 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
397 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
398 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
399 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
400 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
401 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
402 | 402 | |
403 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
403 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
404 | 404 | 'invoice' => $invoice, |
405 | 405 | 'email_type' => $email_type, |
406 | 406 | 'email_heading' => $email_heading, |
@@ -408,50 +408,50 @@ discard block |
||
408 | 408 | 'plain_text' => false, |
409 | 409 | 'partial_refund' => false, |
410 | 410 | 'message_body' => $message_body, |
411 | - ) ); |
|
411 | + )); |
|
412 | 412 | |
413 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
413 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
414 | 414 | |
415 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
416 | - $recipient = wpinv_get_admin_email(); |
|
417 | - $subject .= ' - ADMIN BCC COPY'; |
|
418 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
415 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
416 | + $recipient = wpinv_get_admin_email(); |
|
417 | + $subject .= ' - ADMIN BCC COPY'; |
|
418 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
419 | 419 | } |
420 | 420 | |
421 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
421 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
422 | 422 | |
423 | 423 | return $sent; |
424 | 424 | } |
425 | 425 | |
426 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
426 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
427 | 427 | $email_type = 'refunded_invoice'; |
428 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
428 | + if (!wpinv_email_is_enabled($email_type)) { |
|
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
433 | - if ( empty( $invoice ) ) { |
|
432 | + $invoice = wpinv_get_invoice($invoice_id); |
|
433 | + if (empty($invoice)) { |
|
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
437 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
437 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
438 | 438 | return false; |
439 | 439 | } |
440 | 440 | |
441 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
442 | - if ( !is_email( $recipient ) ) { |
|
441 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
442 | + if (!is_email($recipient)) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
446 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
447 | 447 | |
448 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
449 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
450 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
451 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
452 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
448 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
449 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
450 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
451 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
452 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
453 | 453 | |
454 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
454 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
455 | 455 | 'invoice' => $invoice, |
456 | 456 | 'email_type' => $email_type, |
457 | 457 | 'email_heading' => $email_heading, |
@@ -459,95 +459,95 @@ discard block |
||
459 | 459 | 'plain_text' => false, |
460 | 460 | 'partial_refund' => true, |
461 | 461 | 'message_body' => $message_body, |
462 | - ) ); |
|
462 | + )); |
|
463 | 463 | |
464 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
464 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
465 | 465 | |
466 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
467 | - $recipient = wpinv_get_admin_email(); |
|
468 | - $subject .= ' - ADMIN BCC COPY'; |
|
469 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
466 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
467 | + $recipient = wpinv_get_admin_email(); |
|
468 | + $subject .= ' - ADMIN BCC COPY'; |
|
469 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
470 | 470 | } |
471 | 471 | |
472 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
472 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
473 | 473 | |
474 | 474 | return $sent; |
475 | 475 | } |
476 | 476 | |
477 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
477 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
478 | 478 | } |
479 | 479 | |
480 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
480 | +function wpinv_user_invoice_notification($invoice_id) { |
|
481 | 481 | $email_type = 'user_invoice'; |
482 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
482 | + if (!wpinv_email_is_enabled($email_type)) { |
|
483 | 483 | return -1; |
484 | 484 | } |
485 | 485 | |
486 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
487 | - if ( empty( $invoice ) ) { |
|
486 | + $invoice = wpinv_get_invoice($invoice_id); |
|
487 | + if (empty($invoice)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
491 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
492 | 492 | return false; |
493 | 493 | } |
494 | 494 | |
495 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
496 | - if ( !is_email( $recipient ) ) { |
|
495 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
496 | + if (!is_email($recipient)) { |
|
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
500 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
501 | 501 | |
502 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
503 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
504 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
505 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
506 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
502 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
503 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
504 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
505 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
506 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
507 | 507 | |
508 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
508 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
509 | 509 | 'invoice' => $invoice, |
510 | 510 | 'email_type' => $email_type, |
511 | 511 | 'email_heading' => $email_heading, |
512 | 512 | 'sent_to_admin' => false, |
513 | 513 | 'plain_text' => false, |
514 | 514 | 'message_body' => $message_body, |
515 | - ) ); |
|
515 | + )); |
|
516 | 516 | |
517 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
517 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
518 | 518 | |
519 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
520 | - $recipient = wpinv_get_admin_email(); |
|
521 | - $subject .= ' - ADMIN BCC COPY'; |
|
522 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
519 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
520 | + $recipient = wpinv_get_admin_email(); |
|
521 | + $subject .= ' - ADMIN BCC COPY'; |
|
522 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
523 | 523 | } |
524 | 524 | |
525 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
525 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
526 | 526 | |
527 | - if ( $sent ) { |
|
528 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
527 | + if ($sent) { |
|
528 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
529 | 529 | } else { |
530 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
530 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
531 | 531 | } |
532 | 532 | |
533 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
533 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
534 | 534 | |
535 | 535 | return $sent; |
536 | 536 | } |
537 | 537 | |
538 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
538 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
539 | 539 | $email_type = 'user_note'; |
540 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
540 | + if (!wpinv_email_is_enabled($email_type)) { |
|
541 | 541 | return false; |
542 | 542 | } |
543 | 543 | |
544 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
545 | - if ( empty( $invoice ) ) { |
|
544 | + $invoice = wpinv_get_invoice($invoice_id); |
|
545 | + if (empty($invoice)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
550 | - if ( !is_email( $recipient ) ) { |
|
549 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
550 | + if (!is_email($recipient)) { |
|
551 | 551 | return false; |
552 | 552 | } |
553 | 553 | |
@@ -555,19 +555,19 @@ discard block |
||
555 | 555 | 'user_note' => '' |
556 | 556 | ); |
557 | 557 | |
558 | - $args = wp_parse_args( $args, $defaults ); |
|
558 | + $args = wp_parse_args($args, $defaults); |
|
559 | 559 | |
560 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
560 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
561 | 561 | |
562 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
563 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
564 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
565 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
566 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
562 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
563 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
564 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
565 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
566 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
567 | 567 | |
568 | - $message_body = str_replace( '{customer_note}', $args['user_note'], $message_body ); |
|
568 | + $message_body = str_replace('{customer_note}', $args['user_note'], $message_body); |
|
569 | 569 | |
570 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
570 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
571 | 571 | 'invoice' => $invoice, |
572 | 572 | 'email_type' => $email_type, |
573 | 573 | 'email_heading' => $email_heading, |
@@ -575,36 +575,36 @@ discard block |
||
575 | 575 | 'plain_text' => false, |
576 | 576 | 'message_body' => $message_body, |
577 | 577 | 'customer_note' => $args['user_note'] |
578 | - ) ); |
|
578 | + )); |
|
579 | 579 | |
580 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
580 | + $content = wpinv_email_format_text($content, $invoice); |
|
581 | 581 | |
582 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
582 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
583 | 583 | |
584 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
584 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
585 | 585 | |
586 | 586 | return $sent; |
587 | 587 | } |
588 | 588 | |
589 | 589 | function wpinv_mail_get_from_address() { |
590 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
591 | - return sanitize_email( $from_address ); |
|
590 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
591 | + return sanitize_email($from_address); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | function wpinv_mail_get_from_name() { |
595 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
596 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
595 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
596 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
597 | 597 | } |
598 | 598 | |
599 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
600 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
601 | - return ( $active ? true : false ); |
|
599 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
600 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
601 | + return ($active ? true : false); |
|
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
605 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
604 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
605 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
606 | 606 | |
607 | - switch ( $email_type ) { |
|
607 | + switch ($email_type) { |
|
608 | 608 | case 'html' : |
609 | 609 | $content_type = 'text/html'; |
610 | 610 | break; |
@@ -619,35 +619,35 @@ discard block |
||
619 | 619 | return $content_type; |
620 | 620 | } |
621 | 621 | |
622 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
623 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
624 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
625 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
622 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
623 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
624 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
625 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
626 | 626 | |
627 | - $message = wpinv_email_style_body( $message ); |
|
628 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
627 | + $message = wpinv_email_style_body($message); |
|
628 | + $message = apply_filters('wpinv_mail_content', $message); |
|
629 | 629 | |
630 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
630 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
631 | 631 | |
632 | - if ( !$sent ) { |
|
633 | - $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 ); |
|
634 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
632 | + if (!$sent) { |
|
633 | + $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); |
|
634 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
635 | 635 | } |
636 | 636 | |
637 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
638 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
639 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
637 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
638 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
639 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
640 | 640 | |
641 | 641 | return $sent; |
642 | 642 | } |
643 | 643 | |
644 | 644 | function wpinv_get_emails() { |
645 | 645 | $overdue_days_options = array(); |
646 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
647 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
646 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
647 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
648 | 648 | |
649 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
650 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
649 | + for ($i = 2; $i <= 10; $i++) { |
|
650 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | // Default, built-in gateways |
@@ -655,39 +655,39 @@ discard block |
||
655 | 655 | 'new_invoice' => array( |
656 | 656 | 'email_new_invoice_header' => array( |
657 | 657 | 'id' => 'email_new_invoice_header', |
658 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
659 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
658 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
659 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
660 | 660 | 'type' => 'header', |
661 | 661 | ), |
662 | 662 | 'email_new_invoice_active' => array( |
663 | 663 | 'id' => 'email_new_invoice_active', |
664 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
665 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
664 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
665 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
666 | 666 | 'type' => 'checkbox', |
667 | 667 | 'std' => 1 |
668 | 668 | ), |
669 | 669 | 'email_new_invoice_subject' => array( |
670 | 670 | 'id' => 'email_new_invoice_subject', |
671 | - 'name' => __( 'Subject', 'invoicing' ), |
|
672 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
671 | + 'name' => __('Subject', 'invoicing'), |
|
672 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
673 | 673 | 'type' => 'text', |
674 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
674 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
675 | 675 | 'size' => 'large' |
676 | 676 | ), |
677 | 677 | 'email_new_invoice_heading' => array( |
678 | 678 | 'id' => 'email_new_invoice_heading', |
679 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
680 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
679 | + 'name' => __('Email Heading', 'invoicing'), |
|
680 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
681 | 681 | 'type' => 'text', |
682 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
682 | + 'std' => __('New payment invoice', 'invoicing'), |
|
683 | 683 | 'size' => 'large' |
684 | 684 | ), |
685 | 685 | 'email_new_invoice_body' => array( |
686 | 686 | 'id' => 'email_new_invoice_body', |
687 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
688 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
687 | + 'name' => __('Email Content', 'invoicing'), |
|
688 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
689 | 689 | 'type' => 'rich_editor', |
690 | - 'std' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ), |
|
690 | + 'std' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'), |
|
691 | 691 | 'class' => 'large', |
692 | 692 | 'size' => '10' |
693 | 693 | ), |
@@ -695,39 +695,39 @@ discard block |
||
695 | 695 | 'cancelled_invoice' => array( |
696 | 696 | 'email_cancelled_invoice_header' => array( |
697 | 697 | 'id' => 'email_cancelled_invoice_header', |
698 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
699 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
698 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
699 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
700 | 700 | 'type' => 'header', |
701 | 701 | ), |
702 | 702 | 'email_cancelled_invoice_active' => array( |
703 | 703 | 'id' => 'email_cancelled_invoice_active', |
704 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
705 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
704 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
705 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
706 | 706 | 'type' => 'checkbox', |
707 | 707 | 'std' => 1 |
708 | 708 | ), |
709 | 709 | 'email_cancelled_invoice_subject' => array( |
710 | 710 | 'id' => 'email_cancelled_invoice_subject', |
711 | - 'name' => __( 'Subject', 'invoicing' ), |
|
712 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
711 | + 'name' => __('Subject', 'invoicing'), |
|
712 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
713 | 713 | 'type' => 'text', |
714 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
714 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
715 | 715 | 'size' => 'large' |
716 | 716 | ), |
717 | 717 | 'email_cancelled_invoice_heading' => array( |
718 | 718 | 'id' => 'email_cancelled_invoice_heading', |
719 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
720 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
719 | + 'name' => __('Email Heading', 'invoicing'), |
|
720 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
721 | 721 | 'type' => 'text', |
722 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
722 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
723 | 723 | 'size' => 'large' |
724 | 724 | ), |
725 | 725 | 'email_cancelled_invoice_body' => array( |
726 | 726 | 'id' => 'email_cancelled_invoice_body', |
727 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
728 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
727 | + 'name' => __('Email Content', 'invoicing'), |
|
728 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
729 | 729 | 'type' => 'rich_editor', |
730 | - 'std' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ), |
|
730 | + 'std' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'), |
|
731 | 731 | 'class' => 'large', |
732 | 732 | 'size' => '10' |
733 | 733 | ), |
@@ -735,39 +735,39 @@ discard block |
||
735 | 735 | 'failed_invoice' => array( |
736 | 736 | 'email_failed_invoice_header' => array( |
737 | 737 | 'id' => 'email_failed_invoice_header', |
738 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
739 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
738 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
739 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
740 | 740 | 'type' => 'header', |
741 | 741 | ), |
742 | 742 | 'email_failed_invoice_active' => array( |
743 | 743 | 'id' => 'email_failed_invoice_active', |
744 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
745 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
744 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
745 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
746 | 746 | 'type' => 'checkbox', |
747 | 747 | 'std' => 1 |
748 | 748 | ), |
749 | 749 | 'email_failed_invoice_subject' => array( |
750 | 750 | 'id' => 'email_failed_invoice_subject', |
751 | - 'name' => __( 'Subject', 'invoicing' ), |
|
752 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
751 | + 'name' => __('Subject', 'invoicing'), |
|
752 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
753 | 753 | 'type' => 'text', |
754 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
754 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
755 | 755 | 'size' => 'large' |
756 | 756 | ), |
757 | 757 | 'email_failed_invoice_heading' => array( |
758 | 758 | 'id' => 'email_failed_invoice_heading', |
759 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
760 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
759 | + 'name' => __('Email Heading', 'invoicing'), |
|
760 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
761 | 761 | 'type' => 'text', |
762 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
762 | + 'std' => __('Failed invoice', 'invoicing'), |
|
763 | 763 | 'size' => 'large' |
764 | 764 | ), |
765 | 765 | 'email_failed_invoice_body' => array( |
766 | 766 | 'id' => 'email_failed_invoice_body', |
767 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
768 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
767 | + 'name' => __('Email Content', 'invoicing'), |
|
768 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
769 | 769 | 'type' => 'rich_editor', |
770 | - 'std' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ), |
|
770 | + 'std' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'), |
|
771 | 771 | 'class' => 'large', |
772 | 772 | 'size' => '10' |
773 | 773 | ), |
@@ -775,46 +775,46 @@ discard block |
||
775 | 775 | 'onhold_invoice' => array( |
776 | 776 | 'email_onhold_invoice_header' => array( |
777 | 777 | 'id' => 'email_onhold_invoice_header', |
778 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
779 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
778 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
779 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
780 | 780 | 'type' => 'header', |
781 | 781 | ), |
782 | 782 | 'email_onhold_invoice_active' => array( |
783 | 783 | 'id' => 'email_onhold_invoice_active', |
784 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
785 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
784 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
785 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
786 | 786 | 'type' => 'checkbox', |
787 | 787 | 'std' => 1 |
788 | 788 | ), |
789 | 789 | 'email_onhold_invoice_subject' => array( |
790 | 790 | 'id' => 'email_onhold_invoice_subject', |
791 | - 'name' => __( 'Subject', 'invoicing' ), |
|
792 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
791 | + 'name' => __('Subject', 'invoicing'), |
|
792 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
793 | 793 | 'type' => 'text', |
794 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
794 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
795 | 795 | 'size' => 'large' |
796 | 796 | ), |
797 | 797 | 'email_onhold_invoice_heading' => array( |
798 | 798 | 'id' => 'email_onhold_invoice_heading', |
799 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
800 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
799 | + 'name' => __('Email Heading', 'invoicing'), |
|
800 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
801 | 801 | 'type' => 'text', |
802 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
802 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
803 | 803 | 'size' => 'large' |
804 | 804 | ), |
805 | 805 | 'email_onhold_invoice_admin_bcc' => array( |
806 | 806 | 'id' => 'email_onhold_invoice_admin_bcc', |
807 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
808 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
807 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
808 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
809 | 809 | 'type' => 'checkbox', |
810 | 810 | 'std' => 1 |
811 | 811 | ), |
812 | 812 | 'email_onhold_invoice_body' => array( |
813 | 813 | 'id' => 'email_onhold_invoice_body', |
814 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
815 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
814 | + 'name' => __('Email Content', 'invoicing'), |
|
815 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
816 | 816 | 'type' => 'rich_editor', |
817 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ), |
|
817 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'), |
|
818 | 818 | 'class' => 'large', |
819 | 819 | 'size' => '10' |
820 | 820 | ), |
@@ -822,46 +822,46 @@ discard block |
||
822 | 822 | 'processing_invoice' => array( |
823 | 823 | 'email_processing_invoice_header' => array( |
824 | 824 | 'id' => 'email_processing_invoice_header', |
825 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
826 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
825 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
826 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
827 | 827 | 'type' => 'header', |
828 | 828 | ), |
829 | 829 | 'email_processing_invoice_active' => array( |
830 | 830 | 'id' => 'email_processing_invoice_active', |
831 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
832 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
831 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
832 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
833 | 833 | 'type' => 'checkbox', |
834 | 834 | 'std' => 1 |
835 | 835 | ), |
836 | 836 | 'email_processing_invoice_subject' => array( |
837 | 837 | 'id' => 'email_processing_invoice_subject', |
838 | - 'name' => __( 'Subject', 'invoicing' ), |
|
839 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
838 | + 'name' => __('Subject', 'invoicing'), |
|
839 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
840 | 840 | 'type' => 'text', |
841 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
841 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
842 | 842 | 'size' => 'large' |
843 | 843 | ), |
844 | 844 | 'email_processing_invoice_heading' => array( |
845 | 845 | 'id' => 'email_processing_invoice_heading', |
846 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
847 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
846 | + 'name' => __('Email Heading', 'invoicing'), |
|
847 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
848 | 848 | 'type' => 'text', |
849 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
849 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
850 | 850 | 'size' => 'large' |
851 | 851 | ), |
852 | 852 | 'email_processing_invoice_admin_bcc' => array( |
853 | 853 | 'id' => 'email_processing_invoice_admin_bcc', |
854 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
855 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
854 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
855 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
856 | 856 | 'type' => 'checkbox', |
857 | 857 | 'std' => 1 |
858 | 858 | ), |
859 | 859 | 'email_processing_invoice_body' => array( |
860 | 860 | 'id' => 'email_processing_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 invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ), |
|
864 | + 'std' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'), |
|
865 | 865 | 'class' => 'large', |
866 | 866 | 'size' => '10' |
867 | 867 | ), |
@@ -869,45 +869,45 @@ discard block |
||
869 | 869 | 'completed_invoice' => array( |
870 | 870 | 'email_completed_invoice_header' => array( |
871 | 871 | 'id' => 'email_completed_invoice_header', |
872 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
873 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
872 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
873 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
874 | 874 | 'type' => 'header', |
875 | 875 | ), |
876 | 876 | 'email_completed_invoice_active' => array( |
877 | 877 | 'id' => 'email_completed_invoice_active', |
878 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
879 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
878 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
879 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
880 | 880 | 'type' => 'checkbox', |
881 | 881 | 'std' => 1 |
882 | 882 | ), |
883 | 883 | 'email_completed_invoice_subject' => array( |
884 | 884 | 'id' => 'email_completed_invoice_subject', |
885 | - 'name' => __( 'Subject', 'invoicing' ), |
|
886 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
885 | + 'name' => __('Subject', 'invoicing'), |
|
886 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
887 | 887 | 'type' => 'text', |
888 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
888 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
889 | 889 | 'size' => 'large' |
890 | 890 | ), |
891 | 891 | 'email_completed_invoice_heading' => array( |
892 | 892 | 'id' => 'email_completed_invoice_heading', |
893 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
894 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
893 | + 'name' => __('Email Heading', 'invoicing'), |
|
894 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
895 | 895 | 'type' => 'text', |
896 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
896 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
897 | 897 | 'size' => 'large' |
898 | 898 | ), |
899 | 899 | 'email_completed_invoice_admin_bcc' => array( |
900 | 900 | 'id' => 'email_completed_invoice_admin_bcc', |
901 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
902 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
901 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
902 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
903 | 903 | 'type' => 'checkbox', |
904 | 904 | ), |
905 | 905 | 'email_completed_invoice_body' => array( |
906 | 906 | 'id' => 'email_completed_invoice_body', |
907 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
908 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
907 | + 'name' => __('Email Content', 'invoicing'), |
|
908 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
909 | 909 | 'type' => 'rich_editor', |
910 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ), |
|
910 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'), |
|
911 | 911 | 'class' => 'large', |
912 | 912 | 'size' => '10' |
913 | 913 | ), |
@@ -916,46 +916,46 @@ discard block |
||
916 | 916 | 'refunded_invoice' => array( |
917 | 917 | 'email_refunded_invoice_header' => array( |
918 | 918 | 'id' => 'email_refunded_invoice_header', |
919 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
920 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
919 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
920 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
921 | 921 | 'type' => 'header', |
922 | 922 | ), |
923 | 923 | 'email_refunded_invoice_active' => array( |
924 | 924 | 'id' => 'email_refunded_invoice_active', |
925 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
926 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
925 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
926 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
927 | 927 | 'type' => 'checkbox', |
928 | 928 | 'std' => 1 |
929 | 929 | ), |
930 | 930 | 'email_refunded_invoice_subject' => array( |
931 | 931 | 'id' => 'email_refunded_invoice_subject', |
932 | - 'name' => __( 'Subject', 'invoicing' ), |
|
933 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
932 | + 'name' => __('Subject', 'invoicing'), |
|
933 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
934 | 934 | 'type' => 'text', |
935 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
935 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
936 | 936 | 'size' => 'large' |
937 | 937 | ), |
938 | 938 | 'email_refunded_invoice_heading' => array( |
939 | 939 | 'id' => 'email_refunded_invoice_heading', |
940 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
941 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
940 | + 'name' => __('Email Heading', 'invoicing'), |
|
941 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
942 | 942 | 'type' => 'text', |
943 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
943 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
944 | 944 | 'size' => 'large' |
945 | 945 | ), |
946 | 946 | 'email_refunded_invoice_admin_bcc' => array( |
947 | 947 | 'id' => 'email_refunded_invoice_admin_bcc', |
948 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
949 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
948 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
949 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
950 | 950 | 'type' => 'checkbox', |
951 | 951 | 'std' => 1 |
952 | 952 | ), |
953 | 953 | 'email_refunded_invoice_body' => array( |
954 | 954 | 'id' => 'email_refunded_invoice_body', |
955 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
956 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
955 | + 'name' => __('Email Content', 'invoicing'), |
|
956 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
957 | 957 | 'type' => 'rich_editor', |
958 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
958 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
959 | 959 | 'class' => 'large', |
960 | 960 | 'size' => '10' |
961 | 961 | ), |
@@ -963,46 +963,46 @@ discard block |
||
963 | 963 | 'user_invoice' => array( |
964 | 964 | 'email_user_invoice_header' => array( |
965 | 965 | 'id' => 'email_user_invoice_header', |
966 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
967 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
966 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
967 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
968 | 968 | 'type' => 'header', |
969 | 969 | ), |
970 | 970 | 'email_user_invoice_active' => array( |
971 | 971 | 'id' => 'email_user_invoice_active', |
972 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
973 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
972 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
973 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
974 | 974 | 'type' => 'checkbox', |
975 | 975 | 'std' => 1 |
976 | 976 | ), |
977 | 977 | 'email_user_invoice_subject' => array( |
978 | 978 | 'id' => 'email_user_invoice_subject', |
979 | - 'name' => __( 'Subject', 'invoicing' ), |
|
980 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
979 | + 'name' => __('Subject', 'invoicing'), |
|
980 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
981 | 981 | 'type' => 'text', |
982 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
982 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
983 | 983 | 'size' => 'large' |
984 | 984 | ), |
985 | 985 | 'email_user_invoice_heading' => array( |
986 | 986 | 'id' => 'email_user_invoice_heading', |
987 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
988 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
987 | + 'name' => __('Email Heading', 'invoicing'), |
|
988 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
989 | 989 | 'type' => 'text', |
990 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
990 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
991 | 991 | 'size' => 'large' |
992 | 992 | ), |
993 | 993 | 'email_user_invoice_admin_bcc' => array( |
994 | 994 | 'id' => 'email_user_invoice_admin_bcc', |
995 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
996 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
995 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
996 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
997 | 997 | 'type' => 'checkbox', |
998 | 998 | 'std' => 1 |
999 | 999 | ), |
1000 | 1000 | 'email_user_invoice_body' => array( |
1001 | 1001 | 'id' => 'email_user_invoice_body', |
1002 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1003 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
1002 | + 'name' => __('Email Content', 'invoicing'), |
|
1003 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
1004 | 1004 | 'type' => 'rich_editor', |
1005 | - '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' ), |
|
1005 | + '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'), |
|
1006 | 1006 | 'class' => 'large', |
1007 | 1007 | 'size' => '10' |
1008 | 1008 | ), |
@@ -1010,39 +1010,39 @@ discard block |
||
1010 | 1010 | 'user_note' => array( |
1011 | 1011 | 'email_user_note_header' => array( |
1012 | 1012 | 'id' => 'email_user_note_header', |
1013 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
1014 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
1013 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
1014 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
1015 | 1015 | 'type' => 'header', |
1016 | 1016 | ), |
1017 | 1017 | 'email_user_note_active' => array( |
1018 | 1018 | 'id' => 'email_user_note_active', |
1019 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1020 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1019 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1020 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1021 | 1021 | 'type' => 'checkbox', |
1022 | 1022 | 'std' => 1 |
1023 | 1023 | ), |
1024 | 1024 | 'email_user_note_subject' => array( |
1025 | 1025 | 'id' => 'email_user_note_subject', |
1026 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1027 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1026 | + 'name' => __('Subject', 'invoicing'), |
|
1027 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1028 | 1028 | 'type' => 'text', |
1029 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
1029 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
1030 | 1030 | 'size' => 'large' |
1031 | 1031 | ), |
1032 | 1032 | 'email_user_note_heading' => array( |
1033 | 1033 | 'id' => 'email_user_note_heading', |
1034 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1035 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1034 | + 'name' => __('Email Heading', 'invoicing'), |
|
1035 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1036 | 1036 | 'type' => 'text', |
1037 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
1037 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
1038 | 1038 | 'size' => 'large' |
1039 | 1039 | ), |
1040 | 1040 | 'email_user_note_body' => array( |
1041 | 1041 | 'id' => 'email_user_note_body', |
1042 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1043 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
1042 | + 'name' => __('Email Content', 'invoicing'), |
|
1043 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
1044 | 1044 | 'type' => 'rich_editor', |
1045 | - 'std' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
1045 | + 'std' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
1046 | 1046 | 'class' => 'large', |
1047 | 1047 | 'size' => '10' |
1048 | 1048 | ), |
@@ -1050,158 +1050,158 @@ discard block |
||
1050 | 1050 | 'overdue' => array( |
1051 | 1051 | 'email_overdue_header' => array( |
1052 | 1052 | 'id' => 'email_overdue_header', |
1053 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
1054 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
1053 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
1054 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
1055 | 1055 | 'type' => 'header', |
1056 | 1056 | ), |
1057 | 1057 | 'email_overdue_active' => array( |
1058 | 1058 | 'id' => 'email_overdue_active', |
1059 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1060 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1059 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1060 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1061 | 1061 | 'type' => 'checkbox', |
1062 | 1062 | 'std' => 1 |
1063 | 1063 | ), |
1064 | 1064 | 'email_due_reminder_days' => array( |
1065 | 1065 | 'id' => 'email_due_reminder_days', |
1066 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
1067 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
1066 | + 'name' => __('When to Send', 'invoicing'), |
|
1067 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
1068 | 1068 | 'default' => '', |
1069 | 1069 | 'type' => 'multicheck', |
1070 | 1070 | 'options' => $overdue_days_options, |
1071 | 1071 | ), |
1072 | 1072 | 'email_overdue_subject' => array( |
1073 | 1073 | 'id' => 'email_overdue_subject', |
1074 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1075 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1074 | + 'name' => __('Subject', 'invoicing'), |
|
1075 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1076 | 1076 | 'type' => 'text', |
1077 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
1077 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
1078 | 1078 | 'size' => 'large' |
1079 | 1079 | ), |
1080 | 1080 | 'email_overdue_heading' => array( |
1081 | 1081 | 'id' => 'email_overdue_heading', |
1082 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1083 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1082 | + 'name' => __('Email Heading', 'invoicing'), |
|
1083 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1084 | 1084 | 'type' => 'text', |
1085 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
1085 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
1086 | 1086 | 'size' => 'large' |
1087 | 1087 | ), |
1088 | 1088 | 'email_overdue_body' => array( |
1089 | 1089 | 'id' => 'email_overdue_body', |
1090 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1091 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
1090 | + 'name' => __('Email Content', 'invoicing'), |
|
1091 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
1092 | 1092 | 'type' => 'rich_editor', |
1093 | - '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' ), |
|
1093 | + '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'), |
|
1094 | 1094 | 'class' => 'large', |
1095 | 1095 | 'size' => 10, |
1096 | 1096 | ), |
1097 | 1097 | ), |
1098 | 1098 | ); |
1099 | 1099 | |
1100 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
1100 | + return apply_filters('wpinv_get_emails', $emails); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | -function wpinv_settings_emails( $settings = array() ) { |
|
1103 | +function wpinv_settings_emails($settings = array()) { |
|
1104 | 1104 | $emails = wpinv_get_emails(); |
1105 | 1105 | |
1106 | - if ( !empty( $emails ) ) { |
|
1107 | - foreach ( $emails as $key => $email ) { |
|
1106 | + if (!empty($emails)) { |
|
1107 | + foreach ($emails as $key => $email) { |
|
1108 | 1108 | $settings[$key] = $email; |
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
1112 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
1113 | 1113 | } |
1114 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
1114 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
1115 | 1115 | |
1116 | -function wpinv_settings_sections_emails( $settings ) { |
|
1116 | +function wpinv_settings_sections_emails($settings) { |
|
1117 | 1117 | $emails = wpinv_get_emails(); |
1118 | 1118 | |
1119 | 1119 | if (!empty($emails)) { |
1120 | - foreach ($emails as $key => $email) { |
|
1121 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
1120 | + foreach ($emails as $key => $email) { |
|
1121 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | return $settings; |
1126 | 1126 | } |
1127 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
1127 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
1128 | 1128 | |
1129 | -function wpinv_email_is_enabled( $email_type ) { |
|
1129 | +function wpinv_email_is_enabled($email_type) { |
|
1130 | 1130 | $emails = wpinv_get_emails(); |
1131 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
1131 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
1132 | 1132 | |
1133 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
1133 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1137 | - switch ( $email_type ) { |
|
1136 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1137 | + switch ($email_type) { |
|
1138 | 1138 | case 'new_invoice': |
1139 | 1139 | case 'cancelled_invoice': |
1140 | 1140 | case 'failed_invoice': |
1141 | 1141 | $recipient = wpinv_get_admin_email(); |
1142 | 1142 | break; |
1143 | 1143 | default: |
1144 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1145 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
1144 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1145 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
1146 | 1146 | break; |
1147 | 1147 | } |
1148 | 1148 | |
1149 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
1149 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1153 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
1154 | - $subject = __( $subject, 'invoicing' ); |
|
1152 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1153 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
1154 | + $subject = __($subject, 'invoicing'); |
|
1155 | 1155 | |
1156 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
1156 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
1157 | 1157 | |
1158 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
1158 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1162 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
1163 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
1161 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1162 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
1163 | + $email_heading = __($email_heading, 'invoicing'); |
|
1164 | 1164 | |
1165 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
1165 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
1166 | 1166 | |
1167 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
1167 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1171 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
1172 | - $content = __( $content, 'invoicing' ); |
|
1170 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1171 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
1172 | + $content = __($content, 'invoicing'); |
|
1173 | 1173 | |
1174 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1174 | + $content = wpinv_email_format_text($content, $invoice); |
|
1175 | 1175 | |
1176 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
1176 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1179 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1180 | 1180 | $from_name = wpinv_mail_get_from_address(); |
1181 | 1181 | $from_email = wpinv_mail_get_from_address(); |
1182 | 1182 | |
1183 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1183 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1184 | 1184 | |
1185 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
1186 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
1185 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
1186 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
1187 | 1187 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
1188 | 1188 | |
1189 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
1189 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1192 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1193 | 1193 | $attachments = array(); |
1194 | 1194 | |
1195 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
1195 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | -function wpinv_email_format_text( $content, $invoice ) { |
|
1198 | +function wpinv_email_format_text($content, $invoice) { |
|
1199 | 1199 | $replace_array = array( |
1200 | 1200 | '{site_title}' => wpinv_get_blogname(), |
1201 | - '{date}' => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ), |
|
1201 | + '{date}' => date_i18n(get_option('date_format'), (int)current_time('timestamp')), |
|
1202 | 1202 | ); |
1203 | 1203 | |
1204 | - if ( !empty( $invoice->ID ) ) { |
|
1204 | + if (!empty($invoice->ID)) { |
|
1205 | 1205 | $replace_array = array_merge( |
1206 | 1206 | $replace_array, |
1207 | 1207 | array( |
@@ -1211,65 +1211,65 @@ discard block |
||
1211 | 1211 | '{last_name}' => $invoice->get_last_name(), |
1212 | 1212 | '{email}' => $invoice->get_email(), |
1213 | 1213 | '{invoice_number}' => $invoice->get_number(), |
1214 | - '{invoice_total}' => $invoice->get_total( true ), |
|
1215 | - '{invoice_link}' => $invoice->get_view_url( true ), |
|
1216 | - '{invoice_pay_link}'=> $invoice->get_view_url( true ), |
|
1217 | - '{invoice_date}' => $invoice->get_invoice_date( true ), |
|
1218 | - '{invoice_due_date}'=> $invoice->get_due_date( true ), |
|
1219 | - '{invoice_quote}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1220 | - '{invoice_label}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1221 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
1214 | + '{invoice_total}' => $invoice->get_total(true), |
|
1215 | + '{invoice_link}' => $invoice->get_view_url(true), |
|
1216 | + '{invoice_pay_link}'=> $invoice->get_view_url(true), |
|
1217 | + '{invoice_date}' => $invoice->get_invoice_date(true), |
|
1218 | + '{invoice_due_date}'=> $invoice->get_due_date(true), |
|
1219 | + '{invoice_quote}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1220 | + '{invoice_label}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1221 | + '{is_was}' => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
1222 | 1222 | ) |
1223 | 1223 | ); |
1224 | 1224 | } |
1225 | 1225 | |
1226 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
1226 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
1227 | 1227 | |
1228 | - foreach ( $replace_array as $key => $value ) { |
|
1229 | - $content = str_replace( $key, $value, $content ); |
|
1228 | + foreach ($replace_array as $key => $value) { |
|
1229 | + $content = str_replace($key, $value, $content); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
1232 | + return apply_filters('wpinv_email_content_replace', $content); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | -function wpinv_email_style_body( $content ) { |
|
1235 | +function wpinv_email_style_body($content) { |
|
1236 | 1236 | // make sure we only inline CSS for html emails |
1237 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
1237 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
1238 | 1238 | ob_start(); |
1239 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
1240 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
1239 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
1240 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
1241 | 1241 | |
1242 | 1242 | // apply CSS styles inline for picky email clients |
1243 | 1243 | try { |
1244 | - $emogrifier = new Emogrifier( $content, $css ); |
|
1244 | + $emogrifier = new Emogrifier($content, $css); |
|
1245 | 1245 | $content = $emogrifier->emogrify(); |
1246 | - } catch ( Exception $e ) { |
|
1247 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
1246 | + } catch (Exception $e) { |
|
1247 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | return $content; |
1251 | 1251 | } |
1252 | 1252 | |
1253 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1254 | - wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1253 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1254 | + wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | /** |
1258 | 1258 | * Get the email footer. |
1259 | 1259 | */ |
1260 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1261 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1260 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1261 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | -function wpinv_email_wrap_message( $message ) { |
|
1264 | +function wpinv_email_wrap_message($message) { |
|
1265 | 1265 | // Buffer |
1266 | 1266 | ob_start(); |
1267 | 1267 | |
1268 | - do_action( 'wpinv_email_header' ); |
|
1268 | + do_action('wpinv_email_header'); |
|
1269 | 1269 | |
1270 | - echo wpautop( wptexturize( $message ) ); |
|
1270 | + echo wpautop(wptexturize($message)); |
|
1271 | 1271 | |
1272 | - do_action( 'wpinv_email_footer' ); |
|
1272 | + do_action('wpinv_email_footer'); |
|
1273 | 1273 | |
1274 | 1274 | // Get contents |
1275 | 1275 | $message = ob_get_clean(); |
@@ -1277,92 +1277,92 @@ discard block |
||
1277 | 1277 | return $message; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1281 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1280 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1281 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1285 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1284 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
1285 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1289 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1288 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1289 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
1293 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1292 | +function wpinv_send_customer_invoice($data = array()) { |
|
1293 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1294 | 1294 | |
1295 | - if ( empty( $invoice_id ) ) { |
|
1295 | + if (empty($invoice_id)) { |
|
1296 | 1296 | return; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1300 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1299 | + if (!current_user_can('manage_options')) { |
|
1300 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
1303 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
1304 | 1304 | |
1305 | 1305 | if ( -1 === $sent ) { |
1306 | 1306 | $status = 'email_disabled'; |
1307 | - } elseif ( $sent ) { |
|
1307 | + } elseif ($sent) { |
|
1308 | 1308 | $status = 'email_sent'; |
1309 | 1309 | } else { |
1310 | 1310 | $status = 'email_fail'; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1314 | - wp_redirect( $redirect ); |
|
1313 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1314 | + wp_redirect($redirect); |
|
1315 | 1315 | exit; |
1316 | 1316 | } |
1317 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
1317 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
1318 | 1318 | |
1319 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
1320 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1319 | +function wpinv_send_overdue_reminder($data = array()) { |
|
1320 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1321 | 1321 | |
1322 | - if ( empty( $invoice_id ) ) { |
|
1322 | + if (empty($invoice_id)) { |
|
1323 | 1323 | return; |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1327 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1326 | + if (!current_user_can('manage_options')) { |
|
1327 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
1330 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
1331 | 1331 | |
1332 | 1332 | $status = $sent ? 'email_sent' : 'email_fail'; |
1333 | 1333 | |
1334 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1335 | - wp_redirect( $redirect ); |
|
1334 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1335 | + wp_redirect($redirect); |
|
1336 | 1336 | exit; |
1337 | 1337 | } |
1338 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
1338 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
1339 | 1339 | |
1340 | -function wpinv_send_customer_note_email( $data ) { |
|
1341 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1340 | +function wpinv_send_customer_note_email($data) { |
|
1341 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1342 | 1342 | |
1343 | - if ( empty( $invoice_id ) ) { |
|
1343 | + if (empty($invoice_id)) { |
|
1344 | 1344 | return; |
1345 | 1345 | } |
1346 | 1346 | |
1347 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
1347 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
1348 | 1348 | } |
1349 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
1349 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
1350 | 1350 | |
1351 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
1352 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
1353 | - $date_format = get_option( 'date_format' ); |
|
1354 | - $time_format = get_option( 'time_format' ); |
|
1351 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
1352 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
1353 | + $date_format = get_option('date_format'); |
|
1354 | + $time_format = get_option('time_format'); |
|
1355 | 1355 | ?> |
1356 | 1356 | <div id="wpinv-email-notes"> |
1357 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
1357 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
1358 | 1358 | <ol class="wpinv-notes-lists"> |
1359 | 1359 | <?php |
1360 | - foreach ( $invoice_notes as $note ) { |
|
1361 | - $note_time = strtotime( $note->comment_date ); |
|
1360 | + foreach ($invoice_notes as $note) { |
|
1361 | + $note_time = strtotime($note->comment_date); |
|
1362 | 1362 | ?> |
1363 | 1363 | <li class="comment wpinv-note"> |
1364 | - <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> |
|
1365 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
1364 | + <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> |
|
1365 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
1366 | 1366 | </li> |
1367 | 1367 | <?php |
1368 | 1368 | } |
@@ -1371,21 +1371,21 @@ discard block |
||
1371 | 1371 | <?php |
1372 | 1372 | } |
1373 | 1373 | } |
1374 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
1374 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
1375 | 1375 | |
1376 | 1376 | function wpinv_email_payment_reminders() { |
1377 | 1377 | global $wpi_auto_reminder; |
1378 | - if ( !wpinv_get_option( 'email_overdue_active' ) ) { |
|
1378 | + if (!wpinv_get_option('email_overdue_active')) { |
|
1379 | 1379 | return; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
1383 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : ''; |
|
1382 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
1383 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : ''; |
|
1384 | 1384 | |
1385 | - if ( empty( $reminder_days ) ) { |
|
1385 | + if (empty($reminder_days)) { |
|
1386 | 1386 | return; |
1387 | 1387 | } |
1388 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
1388 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
1389 | 1389 | |
1390 | 1390 | $args = array( |
1391 | 1391 | 'post_type' => 'wpi_invoice', |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | 'meta_query' => array( |
1396 | 1396 | array( |
1397 | 1397 | 'key' => '_wpinv_due_date', |
1398 | - 'value' => array( '', 'none' ), |
|
1398 | + 'value' => array('', 'none'), |
|
1399 | 1399 | 'compare' => 'NOT IN', |
1400 | 1400 | ) |
1401 | 1401 | ), |
@@ -1404,143 +1404,143 @@ discard block |
||
1404 | 1404 | 'order' => 'ASC', |
1405 | 1405 | ); |
1406 | 1406 | |
1407 | - $invoices = get_posts( $args ); |
|
1407 | + $invoices = get_posts($args); |
|
1408 | 1408 | |
1409 | - if ( empty( $invoices ) ) { |
|
1409 | + if (empty($invoices)) { |
|
1410 | 1410 | return; |
1411 | 1411 | } |
1412 | 1412 | |
1413 | - $date_to_send = array(); |
|
1413 | + $date_to_send = array(); |
|
1414 | 1414 | |
1415 | - foreach ( $invoices as $id ) { |
|
1416 | - $due_date = get_post_meta( $id, '_wpinv_due_date', true ); |
|
1415 | + foreach ($invoices as $id) { |
|
1416 | + $due_date = get_post_meta($id, '_wpinv_due_date', true); |
|
1417 | 1417 | |
1418 | - foreach ( $reminder_days as $key => $days ) { |
|
1419 | - if ( $days !== '' ) { |
|
1420 | - $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) ); |
|
1418 | + foreach ($reminder_days as $key => $days) { |
|
1419 | + if ($days !== '') { |
|
1420 | + $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS)); |
|
1421 | 1421 | } |
1422 | 1422 | } |
1423 | 1423 | } |
1424 | 1424 | |
1425 | - $today = date_i18n( 'Y-m-d' ); |
|
1425 | + $today = date_i18n('Y-m-d'); |
|
1426 | 1426 | $wpi_auto_reminder = true; |
1427 | 1427 | |
1428 | - foreach ( $date_to_send as $id => $values ) { |
|
1429 | - if ( in_array( $today, $values ) ) { |
|
1430 | - $sent = get_post_meta( $id, '_wpinv_reminder_sent', true ); |
|
1428 | + foreach ($date_to_send as $id => $values) { |
|
1429 | + if (in_array($today, $values)) { |
|
1430 | + $sent = get_post_meta($id, '_wpinv_reminder_sent', true); |
|
1431 | 1431 | |
1432 | - if ( isset( $sent ) && !empty( $sent ) ) { |
|
1433 | - if ( !in_array( $today, $sent ) ) { |
|
1434 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1432 | + if (isset($sent) && !empty($sent)) { |
|
1433 | + if (!in_array($today, $sent)) { |
|
1434 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1435 | 1435 | } |
1436 | 1436 | } else { |
1437 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1437 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1438 | 1438 | } |
1439 | 1439 | } |
1440 | 1440 | } |
1441 | 1441 | |
1442 | - $wpi_auto_reminder = false; |
|
1442 | + $wpi_auto_reminder = false; |
|
1443 | 1443 | } |
1444 | 1444 | } |
1445 | 1445 | |
1446 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
1446 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
1447 | 1447 | $email_type = 'overdue'; |
1448 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
1448 | + if (!wpinv_email_is_enabled($email_type)) { |
|
1449 | 1449 | return false; |
1450 | 1450 | } |
1451 | 1451 | |
1452 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1453 | - if ( empty( $invoice ) ) { |
|
1452 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1453 | + if (empty($invoice)) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - if ( !$invoice->needs_payment() ) { |
|
1457 | + if (!$invoice->needs_payment()) { |
|
1458 | 1458 | return false; |
1459 | 1459 | } |
1460 | 1460 | |
1461 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
1462 | - if ( !is_email( $recipient ) ) { |
|
1461 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
1462 | + if (!is_email($recipient)) { |
|
1463 | 1463 | return false; |
1464 | 1464 | } |
1465 | 1465 | |
1466 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
1466 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
1467 | 1467 | |
1468 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
1469 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
1470 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
1471 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
1472 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
1468 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
1469 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
1470 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
1471 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
1472 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
1473 | 1473 | |
1474 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
1474 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
1475 | 1475 | 'invoice' => $invoice, |
1476 | 1476 | 'email_type' => $email_type, |
1477 | 1477 | 'email_heading' => $email_heading, |
1478 | 1478 | 'sent_to_admin' => false, |
1479 | 1479 | 'plain_text' => false, |
1480 | 1480 | 'message_body' => $message_body |
1481 | - ) ); |
|
1481 | + )); |
|
1482 | 1482 | |
1483 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1483 | + $content = wpinv_email_format_text($content, $invoice); |
|
1484 | 1484 | |
1485 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
1486 | - if ( $sent ) { |
|
1487 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
1485 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
1486 | + if ($sent) { |
|
1487 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
1490 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
1491 | 1491 | |
1492 | 1492 | return $sent; |
1493 | 1493 | } |
1494 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
1494 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
1495 | 1495 | |
1496 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
1496 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
1497 | 1497 | global $wpi_auto_reminder; |
1498 | 1498 | |
1499 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
1499 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
1500 | 1500 | |
1501 | - if ( empty( $sent ) ) { |
|
1501 | + if (empty($sent)) { |
|
1502 | 1502 | $sent = array(); |
1503 | 1503 | } |
1504 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
1504 | + $sent[] = date_i18n('Y-m-d'); |
|
1505 | 1505 | |
1506 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
1506 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
1507 | 1507 | |
1508 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
1509 | - $note = __( 'Automated reminder sent to the user.', 'invoicing' ); |
|
1510 | - $invoice->add_note( $note, false, false, true ); |
|
1508 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
1509 | + $note = __('Automated reminder sent to the user.', 'invoicing'); |
|
1510 | + $invoice->add_note($note, false, false, true); |
|
1511 | 1511 | } else { // Menual reminder note. |
1512 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1513 | - $invoice->add_note( $note ); |
|
1512 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1513 | + $invoice->add_note($note); |
|
1514 | 1514 | } |
1515 | 1515 | } |
1516 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
1516 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
|
1517 | 1517 | |
1518 | -function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) { |
|
1519 | - if ( empty( $invoice ) ) { |
|
1518 | +function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) { |
|
1519 | + if (empty($invoice)) { |
|
1520 | 1520 | return; |
1521 | 1521 | } |
1522 | 1522 | |
1523 | - if ( is_int( $invoice ) ) { |
|
1524 | - $invoice = new wpinv_get_invoice( $invoice ); |
|
1523 | + if (is_int($invoice)) { |
|
1524 | + $invoice = new wpinv_get_invoice($invoice); |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | - if ( ! empty( $invoice ) && is_object( $invoice ) ) { |
|
1528 | - if ( ! $site && function_exists( 'get_user_locale' ) ) { |
|
1529 | - $locale = get_user_locale( $invoice->get_user_id() ); |
|
1527 | + if (!empty($invoice) && is_object($invoice)) { |
|
1528 | + if (!$site && function_exists('get_user_locale')) { |
|
1529 | + $locale = get_user_locale($invoice->get_user_id()); |
|
1530 | 1530 | } else { |
1531 | 1531 | $locale = get_locale(); |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - wpinv_switch_to_locale( $locale ); |
|
1534 | + wpinv_switch_to_locale($locale); |
|
1535 | 1535 | } |
1536 | 1536 | } |
1537 | -add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 ); |
|
1537 | +add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3); |
|
1538 | 1538 | |
1539 | -function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) { |
|
1540 | - if ( empty( $invoice ) ) { |
|
1539 | +function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) { |
|
1540 | + if (empty($invoice)) { |
|
1541 | 1541 | return; |
1542 | 1542 | } |
1543 | 1543 | |
1544 | 1544 | wpinv_restore_locale(); |
1545 | 1545 | } |
1546 | -add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 ); |
|
1546 | +add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3); |
@@ -140,6 +140,9 @@ discard block |
||
140 | 140 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
141 | 141 | } |
142 | 142 | |
143 | +/** |
|
144 | + * @param string $template_name |
|
145 | + */ |
|
143 | 146 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | 147 | ob_start(); |
145 | 148 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -172,6 +175,9 @@ discard block |
||
172 | 175 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
173 | 176 | } |
174 | 177 | |
178 | +/** |
|
179 | + * @param string $slug |
|
180 | + */ |
|
175 | 181 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | 182 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
177 | 183 | |
@@ -871,6 +877,9 @@ discard block |
||
871 | 877 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
872 | 878 | } |
873 | 879 | |
880 | +/** |
|
881 | + * @param integer $id |
|
882 | + */ |
|
874 | 883 | function wpinv_get_watermark( $id ) { |
875 | 884 | if ( !$id > 0 ) { |
876 | 885 | return NULL; |
@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | |
104 | 104 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
105 | 105 | if ( ! empty( $args ) && is_array( $args ) ) { |
106 | - extract( $args ); |
|
107 | - } |
|
106 | + extract( $args ); |
|
107 | + } |
|
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | - // Allow 3rd party plugin filter template file from their plugin. |
|
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | + // Allow 3rd party plugin filter template file from their plugin. |
|
111 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
113 | + if ( ! file_exists( $located ) ) { |
|
114 | 114 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
115 | - return; |
|
116 | - } |
|
115 | + return; |
|
116 | + } |
|
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include( $located ); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
126 | - ob_start(); |
|
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | - return ob_get_clean(); |
|
126 | + ob_start(); |
|
127 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | + return ob_get_clean(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -155,126 +155,126 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
158 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
159 | 159 | |
160 | - // Setup possible parts |
|
161 | - $templates = array(); |
|
162 | - if ( isset( $name ) ) |
|
163 | - $templates[] = $slug . '-' . $name . '.php'; |
|
164 | - $templates[] = $slug . '.php'; |
|
160 | + // Setup possible parts |
|
161 | + $templates = array(); |
|
162 | + if ( isset( $name ) ) |
|
163 | + $templates[] = $slug . '-' . $name . '.php'; |
|
164 | + $templates[] = $slug . '.php'; |
|
165 | 165 | |
166 | - // Allow template parts to be filtered |
|
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
166 | + // Allow template parts to be filtered |
|
167 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
168 | 168 | |
169 | - // Return the part that is found |
|
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
169 | + // Return the part that is found |
|
170 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
174 | - // No file found yet |
|
175 | - $located = false; |
|
174 | + // No file found yet |
|
175 | + $located = false; |
|
176 | 176 | |
177 | - // Try to find a template file |
|
178 | - foreach ( (array)$template_names as $template_name ) { |
|
177 | + // Try to find a template file |
|
178 | + foreach ( (array)$template_names as $template_name ) { |
|
179 | 179 | |
180 | - // Continue if template is empty |
|
181 | - if ( empty( $template_name ) ) |
|
182 | - continue; |
|
180 | + // Continue if template is empty |
|
181 | + if ( empty( $template_name ) ) |
|
182 | + continue; |
|
183 | 183 | |
184 | - // Trim off any slashes from the template name |
|
185 | - $template_name = ltrim( $template_name, '/' ); |
|
184 | + // Trim off any slashes from the template name |
|
185 | + $template_name = ltrim( $template_name, '/' ); |
|
186 | 186 | |
187 | - // try locating this template file by looping through the template paths |
|
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
187 | + // try locating this template file by looping through the template paths |
|
188 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
191 | - $located = $template_path . $template_name; |
|
192 | - break; |
|
193 | - } |
|
194 | - } |
|
190 | + if( file_exists( $template_path . $template_name ) ) { |
|
191 | + $located = $template_path . $template_name; |
|
192 | + break; |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
197 | - break; |
|
198 | - } |
|
199 | - } |
|
196 | + if( !empty( $located ) ) { |
|
197 | + break; |
|
198 | + } |
|
199 | + } |
|
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | + load_template( $located, $require_once ); |
|
203 | 203 | |
204 | - return $located; |
|
204 | + return $located; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function wpinv_get_theme_template_paths() { |
208 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
208 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
209 | 209 | |
210 | - $file_paths = array( |
|
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | - 100 => wpinv_get_templates_dir() |
|
214 | - ); |
|
210 | + $file_paths = array( |
|
211 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | + 100 => wpinv_get_templates_dir() |
|
214 | + ); |
|
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
217 | 217 | |
218 | - // sort the file paths based on priority |
|
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
218 | + // sort the file paths based on priority |
|
219 | + ksort( $file_paths, SORT_NUMERIC ); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map( 'trailingslashit', $file_paths ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | - $pages = array(); |
|
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
230 | + $pages = array(); |
|
231 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
237 | - return; |
|
238 | - } |
|
236 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
237 | + return; |
|
238 | + } |
|
239 | 239 | |
240 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
240 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
241 | 241 | } |
242 | 242 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
243 | 243 | |
244 | 244 | function wpinv_add_body_classes( $class ) { |
245 | - $classes = (array)$class; |
|
245 | + $classes = (array)$class; |
|
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
248 | - $classes[] = 'wpinv-checkout'; |
|
249 | - $classes[] = 'wpinv-page'; |
|
250 | - } |
|
247 | + if( wpinv_is_checkout() ) { |
|
248 | + $classes[] = 'wpinv-checkout'; |
|
249 | + $classes[] = 'wpinv-page'; |
|
250 | + } |
|
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
253 | - $classes[] = 'wpinv-success'; |
|
254 | - $classes[] = 'wpinv-page'; |
|
255 | - } |
|
252 | + if( wpinv_is_success_page() ) { |
|
253 | + $classes[] = 'wpinv-success'; |
|
254 | + $classes[] = 'wpinv-page'; |
|
255 | + } |
|
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
258 | - $classes[] = 'wpinv-failed-transaction'; |
|
259 | - $classes[] = 'wpinv-page'; |
|
260 | - } |
|
257 | + if( wpinv_is_failed_transaction_page() ) { |
|
258 | + $classes[] = 'wpinv-failed-transaction'; |
|
259 | + $classes[] = 'wpinv-page'; |
|
260 | + } |
|
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
263 | - $classes[] = 'wpinv-history'; |
|
264 | - $classes[] = 'wpinv-page'; |
|
265 | - } |
|
262 | + if( wpinv_is_invoice_history_page() ) { |
|
263 | + $classes[] = 'wpinv-history'; |
|
264 | + $classes[] = 'wpinv-page'; |
|
265 | + } |
|
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
268 | - $classes[] = 'wpinv-subscription'; |
|
269 | - $classes[] = 'wpinv-page'; |
|
270 | - } |
|
267 | + if( wpinv_is_subscriptions_history_page() ) { |
|
268 | + $classes[] = 'wpinv-subscription'; |
|
269 | + $classes[] = 'wpinv-page'; |
|
270 | + } |
|
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
273 | - $classes[] = 'wpinv-test-mode'; |
|
274 | - $classes[] = 'wpinv-page'; |
|
275 | - } |
|
272 | + if( wpinv_is_test_mode() ) { |
|
273 | + $classes[] = 'wpinv-test-mode'; |
|
274 | + $classes[] = 'wpinv-page'; |
|
275 | + } |
|
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique( $classes ); |
|
278 | 278 | } |
279 | 279 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
280 | 280 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1409 | 1409 | |
1410 | 1410 | function wpinv_empty_cart_message() { |
1411 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1411 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | * @return void |
1419 | 1419 | */ |
1420 | 1420 | function wpinv_empty_checkout_cart() { |
1421 | - echo wpinv_empty_cart_message(); |
|
1421 | + echo wpinv_empty_cart_message(); |
|
1422 | 1422 | } |
1423 | 1423 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1424 | 1424 |
@@ -159,8 +159,9 @@ discard block |
||
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
163 | - $templates[] = $slug . '-' . $name . '.php'; |
|
162 | + if ( isset( $name ) ) { |
|
163 | + $templates[] = $slug . '-' . $name . '.php'; |
|
164 | + } |
|
164 | 165 | $templates[] = $slug . '.php'; |
165 | 166 | |
166 | 167 | // Allow template parts to be filtered |
@@ -178,8 +179,9 @@ discard block |
||
178 | 179 | foreach ( (array)$template_names as $template_name ) { |
179 | 180 | |
180 | 181 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
182 | - continue; |
|
182 | + if ( empty( $template_name ) ) { |
|
183 | + continue; |
|
184 | + } |
|
183 | 185 | |
184 | 186 | // Trim off any slashes from the template name |
185 | 187 | $template_name = ltrim( $template_name, '/' ); |
@@ -198,8 +200,9 @@ discard block |
||
198 | 200 | } |
199 | 201 | } |
200 | 202 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
203 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
204 | + load_template( $located, $require_once ); |
|
205 | + } |
|
203 | 206 | |
204 | 207 | return $located; |
205 | 208 | } |
@@ -281,8 +284,9 @@ discard block |
||
281 | 284 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
282 | 285 | $args = array( 'nopaging' => true ); |
283 | 286 | |
284 | - if ( ! empty( $status ) ) |
|
285 | - $args['post_status'] = $status; |
|
287 | + if ( ! empty( $status ) ) { |
|
288 | + $args['post_status'] = $status; |
|
289 | + } |
|
286 | 290 | |
287 | 291 | $discounts = wpinv_get_discounts( $args ); |
288 | 292 | $options = array(); |
@@ -1423,17 +1427,19 @@ discard block |
||
1423 | 1427 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1424 | 1428 | |
1425 | 1429 | function wpinv_save_cart_button() { |
1426 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1427 | - return; |
|
1428 | -?> |
|
1430 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
1431 | + return; |
|
1432 | + } |
|
1433 | + ?> |
|
1429 | 1434 | <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
1430 | 1435 | <?php |
1431 | 1436 | } |
1432 | 1437 | |
1433 | 1438 | function wpinv_update_cart_button() { |
1434 | - if ( !wpinv_item_quantities_enabled() ) |
|
1435 | - return; |
|
1436 | -?> |
|
1439 | + if ( !wpinv_item_quantities_enabled() ) { |
|
1440 | + return; |
|
1441 | + } |
|
1442 | + ?> |
|
1437 | 1443 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
1438 | 1444 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1439 | 1445 | <?php |
@@ -7,91 +7,91 @@ 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 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
26 | - if ( empty( $invoice ) ) { |
|
25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
26 | + if (empty($invoice)) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | ?> |
30 | 30 | <div class="row wpinv-top-bar no-print"> |
31 | 31 | <div class="container"> |
32 | 32 | <div class="col-xs-6"> |
33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
34 | 34 | </div> |
35 | 35 | <div class="col-xs-6 text-right"> |
36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | <?php |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
44 | - if ( empty( $invoice ) ) { |
|
43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
44 | + if (empty($invoice)) { |
|
45 | 45 | return; // Exit if invoice is not set. |
46 | 46 | } |
47 | 47 | |
48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
49 | - if ( $invoice->needs_payment() ) { |
|
50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
49 | + if ($invoice->needs_payment()) { |
|
50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
54 | 54 | } |
55 | 55 | |
56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
57 | - if ( empty( $invoice ) ) { |
|
56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
57 | + if (empty($invoice)) { |
|
58 | 58 | return; // Exit if invoice is not set. |
59 | 59 | } |
60 | 60 | |
61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
62 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
63 | - <?php if ( is_user_logged_in() ) { ?> |
|
64 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
62 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
63 | + <?php if (is_user_logged_in()) { ?> |
|
64 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
65 | 65 | <?php } |
66 | 66 | } |
67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_before_invoice_content( $content ) { |
|
70 | +function wpinv_before_invoice_content($content) { |
|
71 | 71 | global $post; |
72 | 72 | |
73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
74 | 74 | ob_start(); |
75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
76 | 76 | $content = ob_get_clean() . $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | return $content; |
80 | 80 | } |
81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
82 | 82 | |
83 | -function wpinv_after_invoice_content( $content ) { |
|
83 | +function wpinv_after_invoice_content($content) { |
|
84 | 84 | global $post; |
85 | 85 | |
86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
87 | 87 | ob_start(); |
88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
89 | 89 | $content .= ob_get_clean(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $content; |
93 | 93 | } |
94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
95 | 95 | |
96 | 96 | function wpinv_get_templates_dir() { |
97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
102 | 102 | } |
103 | 103 | |
104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
106 | - extract( $args ); |
|
104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
105 | + if (!empty($args) && is_array($args)) { |
|
106 | + extract($args); |
|
107 | 107 | } |
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
113 | + if (!file_exists($located)) { |
|
114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include($located); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
123 | 123 | } |
124 | 124 | |
125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
126 | 126 | ob_start(); |
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
128 | 128 | return ob_get_clean(); |
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
132 | - if ( ! $template_path ) { |
|
131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
132 | + if (!$template_path) { |
|
133 | 133 | $template_path = wpinv_template_path(); |
134 | 134 | } |
135 | 135 | |
136 | - if ( ! $default_path ) { |
|
136 | + if (!$default_path) { |
|
137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Look within passed path within the theme - this is priority. |
141 | 141 | $template = locate_template( |
142 | 142 | array( |
143 | - trailingslashit( $template_path ) . $template_name, |
|
143 | + trailingslashit($template_path) . $template_name, |
|
144 | 144 | $template_name |
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Get default templates/ |
149 | - if ( !$template && $default_path ) { |
|
150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
149 | + if (!$template && $default_path) { |
|
150 | + $template = trailingslashit($default_path) . $template_name; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Return what we found. |
154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
162 | + if (isset($name)) |
|
163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
164 | 164 | $templates[] = $slug . '.php'; |
165 | 165 | |
166 | 166 | // Allow template parts to be filtered |
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
168 | 168 | |
169 | 169 | // Return the part that is found |
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
171 | 171 | } |
172 | 172 | |
173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
174 | 174 | // No file found yet |
175 | 175 | $located = false; |
176 | 176 | |
177 | 177 | // Try to find a template file |
178 | - foreach ( (array)$template_names as $template_name ) { |
|
178 | + foreach ((array)$template_names as $template_name) { |
|
179 | 179 | |
180 | 180 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
181 | + if (empty($template_name)) |
|
182 | 182 | continue; |
183 | 183 | |
184 | 184 | // Trim off any slashes from the template name |
185 | - $template_name = ltrim( $template_name, '/' ); |
|
185 | + $template_name = ltrim($template_name, '/'); |
|
186 | 186 | |
187 | 187 | // try locating this template file by looping through the template paths |
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
190 | + if (file_exists($template_path . $template_name)) { |
|
191 | 191 | $located = $template_path . $template_name; |
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
196 | + if (!empty($located)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ((true == $load) && !empty($located)) |
|
202 | + load_template($located, $require_once); |
|
203 | 203 | |
204 | 204 | return $located; |
205 | 205 | } |
@@ -208,149 +208,149 @@ discard block |
||
208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
209 | 209 | |
210 | 210 | $file_paths = array( |
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
213 | 213 | 100 => wpinv_get_templates_dir() |
214 | 214 | ); |
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
217 | 217 | |
218 | 218 | // sort the file paths based on priority |
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
219 | + ksort($file_paths, SORT_NUMERIC); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map('trailingslashit', $file_paths); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | 230 | $pages = array(); |
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
231 | + $pages[] = wpinv_get_option('success_page'); |
|
232 | + $pages[] = wpinv_get_option('failure_page'); |
|
233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
241 | 241 | } |
242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
243 | 243 | |
244 | -function wpinv_add_body_classes( $class ) { |
|
244 | +function wpinv_add_body_classes($class) { |
|
245 | 245 | $classes = (array)$class; |
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
247 | + if (wpinv_is_checkout()) { |
|
248 | 248 | $classes[] = 'wpinv-checkout'; |
249 | 249 | $classes[] = 'wpinv-page'; |
250 | 250 | } |
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
252 | + if (wpinv_is_success_page()) { |
|
253 | 253 | $classes[] = 'wpinv-success'; |
254 | 254 | $classes[] = 'wpinv-page'; |
255 | 255 | } |
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
257 | + if (wpinv_is_failed_transaction_page()) { |
|
258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
259 | 259 | $classes[] = 'wpinv-page'; |
260 | 260 | } |
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
262 | + if (wpinv_is_invoice_history_page()) { |
|
263 | 263 | $classes[] = 'wpinv-history'; |
264 | 264 | $classes[] = 'wpinv-page'; |
265 | 265 | } |
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
267 | + if (wpinv_is_subscriptions_history_page()) { |
|
268 | 268 | $classes[] = 'wpinv-subscription'; |
269 | 269 | $classes[] = 'wpinv-page'; |
270 | 270 | } |
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
272 | + if (wpinv_is_test_mode()) { |
|
273 | 273 | $classes[] = 'wpinv-test-mode'; |
274 | 274 | $classes[] = 'wpinv-page'; |
275 | 275 | } |
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique($classes); |
|
278 | 278 | } |
279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
280 | 280 | |
281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
282 | - $args = array( 'nopaging' => true ); |
|
281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
282 | + $args = array('nopaging' => true); |
|
283 | 283 | |
284 | - if ( ! empty( $status ) ) |
|
284 | + if (!empty($status)) |
|
285 | 285 | $args['post_status'] = $status; |
286 | 286 | |
287 | - $discounts = wpinv_get_discounts( $args ); |
|
287 | + $discounts = wpinv_get_discounts($args); |
|
288 | 288 | $options = array(); |
289 | 289 | |
290 | - if ( $discounts ) { |
|
291 | - foreach ( $discounts as $discount ) { |
|
292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
290 | + if ($discounts) { |
|
291 | + foreach ($discounts as $discount) { |
|
292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
293 | 293 | } |
294 | 294 | } else { |
295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
296 | 296 | } |
297 | 297 | |
298 | - $output = wpinv_html_select( array( |
|
298 | + $output = wpinv_html_select(array( |
|
299 | 299 | 'name' => $name, |
300 | 300 | 'selected' => $selected, |
301 | 301 | 'options' => $options, |
302 | 302 | 'show_option_all' => false, |
303 | 303 | 'show_option_none' => false, |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | |
306 | 306 | return $output; |
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
310 | - $current = date( 'Y' ); |
|
311 | - $start_year = $current - absint( $years_before ); |
|
312 | - $end_year = $current + absint( $years_after ); |
|
313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
310 | + $current = date('Y'); |
|
311 | + $start_year = $current - absint($years_before); |
|
312 | + $end_year = $current + absint($years_after); |
|
313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
314 | 314 | $options = array(); |
315 | 315 | |
316 | - while ( $start_year <= $end_year ) { |
|
317 | - $options[ absint( $start_year ) ] = $start_year; |
|
316 | + while ($start_year <= $end_year) { |
|
317 | + $options[absint($start_year)] = $start_year; |
|
318 | 318 | $start_year++; |
319 | 319 | } |
320 | 320 | |
321 | - $output = wpinv_html_select( array( |
|
321 | + $output = wpinv_html_select(array( |
|
322 | 322 | 'name' => $name, |
323 | 323 | 'selected' => $selected, |
324 | 324 | 'options' => $options, |
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | 329 | return $output; |
330 | 330 | } |
331 | 331 | |
332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
333 | 333 | $month = 1; |
334 | 334 | $options = array(); |
335 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
335 | + $selected = empty($selected) ? date('n') : $selected; |
|
336 | 336 | |
337 | - while ( $month <= 12 ) { |
|
338 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
337 | + while ($month <= 12) { |
|
338 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
339 | 339 | $month++; |
340 | 340 | } |
341 | 341 | |
342 | - $output = wpinv_html_select( array( |
|
342 | + $output = wpinv_html_select(array( |
|
343 | 343 | 'name' => $name, |
344 | 344 | 'selected' => $selected, |
345 | 345 | 'options' => $options, |
346 | 346 | 'show_option_all' => false, |
347 | 347 | 'show_option_none' => false |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | |
350 | 350 | return $output; |
351 | 351 | } |
352 | 352 | |
353 | -function wpinv_html_select( $args = array() ) { |
|
353 | +function wpinv_html_select($args = array()) { |
|
354 | 354 | $defaults = array( |
355 | 355 | 'options' => array(), |
356 | 356 | 'name' => null, |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | 'selected' => 0, |
360 | 360 | 'placeholder' => null, |
361 | 361 | 'multiple' => false, |
362 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
363 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
362 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
363 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
364 | 364 | 'data' => array(), |
365 | 365 | 'onchange' => null, |
366 | 366 | 'required' => false, |
@@ -368,74 +368,74 @@ discard block |
||
368 | 368 | 'readonly' => false, |
369 | 369 | ); |
370 | 370 | |
371 | - $args = wp_parse_args( $args, $defaults ); |
|
371 | + $args = wp_parse_args($args, $defaults); |
|
372 | 372 | |
373 | 373 | $data_elements = ''; |
374 | - foreach ( $args['data'] as $key => $value ) { |
|
375 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
374 | + foreach ($args['data'] as $key => $value) { |
|
375 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
376 | 376 | } |
377 | 377 | |
378 | - if( $args['multiple'] ) { |
|
378 | + if ($args['multiple']) { |
|
379 | 379 | $multiple = ' MULTIPLE'; |
380 | 380 | } else { |
381 | 381 | $multiple = ''; |
382 | 382 | } |
383 | 383 | |
384 | - if( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | $options = ''; |
391 | - if( !empty( $args['onchange'] ) ) { |
|
392 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
391 | + if (!empty($args['onchange'])) { |
|
392 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
393 | 393 | } |
394 | 394 | |
395 | - if( !empty( $args['required'] ) ) { |
|
395 | + if (!empty($args['required'])) { |
|
396 | 396 | $options .= ' required="required"'; |
397 | 397 | } |
398 | 398 | |
399 | - if( !empty( $args['disabled'] ) ) { |
|
399 | + if (!empty($args['disabled'])) { |
|
400 | 400 | $options .= ' disabled'; |
401 | 401 | } |
402 | 402 | |
403 | - if( !empty( $args['readonly'] ) ) { |
|
403 | + if (!empty($args['readonly'])) { |
|
404 | 404 | $options .= ' readonly'; |
405 | 405 | } |
406 | 406 | |
407 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
408 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
407 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
408 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
409 | 409 | |
410 | - if ( $args['show_option_all'] ) { |
|
411 | - if( $args['multiple'] ) { |
|
412 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
410 | + if ($args['show_option_all']) { |
|
411 | + if ($args['multiple']) { |
|
412 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
413 | 413 | } else { |
414 | - $selected = selected( $args['selected'], 0, false ); |
|
414 | + $selected = selected($args['selected'], 0, false); |
|
415 | 415 | } |
416 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
416 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( !empty( $args['options'] ) ) { |
|
419 | + if (!empty($args['options'])) { |
|
420 | 420 | |
421 | - if ( $args['show_option_none'] ) { |
|
422 | - if( $args['multiple'] ) { |
|
423 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
421 | + if ($args['show_option_none']) { |
|
422 | + if ($args['multiple']) { |
|
423 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
424 | 424 | } else { |
425 | - $selected = selected( $args['selected'] === "", true, false ); |
|
425 | + $selected = selected($args['selected'] === "", true, false); |
|
426 | 426 | } |
427 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
427 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
428 | 428 | } |
429 | 429 | |
430 | - foreach( $args['options'] as $key => $option ) { |
|
430 | + foreach ($args['options'] as $key => $option) { |
|
431 | 431 | |
432 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
433 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
432 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
433 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
434 | 434 | } else { |
435 | - $selected = selected( $args['selected'], $key, false ); |
|
435 | + $selected = selected($args['selected'], $key, false); |
|
436 | 436 | } |
437 | 437 | |
438 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
438 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | return $output; |
445 | 445 | } |
446 | 446 | |
447 | -function wpinv_item_dropdown( $args = array() ) { |
|
447 | +function wpinv_item_dropdown($args = array()) { |
|
448 | 448 | $defaults = array( |
449 | 449 | 'name' => 'wpi_item', |
450 | 450 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | 'multiple' => false, |
453 | 453 | 'selected' => 0, |
454 | 454 | 'number' => 100, |
455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
456 | - 'data' => array( 'search-type' => 'item' ), |
|
455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
456 | + 'data' => array('search-type' => 'item'), |
|
457 | 457 | 'show_option_all' => false, |
458 | 458 | 'show_option_none' => false, |
459 | 459 | 'show_recurring' => false, |
460 | 460 | ); |
461 | 461 | |
462 | - $args = wp_parse_args( $args, $defaults ); |
|
462 | + $args = wp_parse_args($args, $defaults); |
|
463 | 463 | |
464 | 464 | $item_args = array( |
465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
468 | 468 | 'posts_per_page' => $args['number'] |
469 | 469 | ); |
470 | 470 | |
471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
472 | 472 | |
473 | - $items = get_posts( $item_args ); |
|
473 | + $items = get_posts($item_args); |
|
474 | 474 | $options = array(); |
475 | - if ( $items ) { |
|
476 | - foreach ( $items as $item ) { |
|
477 | - $title = esc_html( $item->post_title ); |
|
475 | + if ($items) { |
|
476 | + foreach ($items as $item) { |
|
477 | + $title = esc_html($item->post_title); |
|
478 | 478 | |
479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
479 | + if (!empty($args['show_recurring'])) { |
|
480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
481 | 481 | } |
482 | 482 | |
483 | - $options[ absint( $item->ID ) ] = $title; |
|
483 | + $options[absint($item->ID)] = $title; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | // This ensures that any selected items are included in the drop down |
488 | - if( is_array( $args['selected'] ) ) { |
|
489 | - foreach( $args['selected'] as $item ) { |
|
490 | - if( ! in_array( $item, $options ) ) { |
|
491 | - $title = get_the_title( $item ); |
|
492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
488 | + if (is_array($args['selected'])) { |
|
489 | + foreach ($args['selected'] as $item) { |
|
490 | + if (!in_array($item, $options)) { |
|
491 | + $title = get_the_title($item); |
|
492 | + if (!empty($args['show_recurring'])) { |
|
493 | + $title .= wpinv_get_item_suffix($item, false); |
|
494 | 494 | } |
495 | 495 | $options[$item] = $title; |
496 | 496 | } |
497 | 497 | } |
498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
500 | - $title = get_the_title( $args['selected'] ); |
|
501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
499 | + if (!in_array($args['selected'], $options)) { |
|
500 | + $title = get_the_title($args['selected']); |
|
501 | + if (!empty($args['show_recurring'])) { |
|
502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
503 | 503 | } |
504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $output = wpinv_html_select( array( |
|
508 | + $output = wpinv_html_select(array( |
|
509 | 509 | 'name' => $args['name'], |
510 | 510 | 'selected' => $args['selected'], |
511 | 511 | 'id' => $args['id'], |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | 'show_option_all' => $args['show_option_all'], |
517 | 517 | 'show_option_none' => $args['show_option_none'], |
518 | 518 | 'data' => $args['data'], |
519 | - ) ); |
|
519 | + )); |
|
520 | 520 | |
521 | 521 | return $output; |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_html_checkbox( $args = array() ) { |
|
524 | +function wpinv_html_checkbox($args = array()) { |
|
525 | 525 | $defaults = array( |
526 | 526 | 'name' => null, |
527 | 527 | 'current' => null, |
@@ -532,38 +532,38 @@ discard block |
||
532 | 532 | ) |
533 | 533 | ); |
534 | 534 | |
535 | - $args = wp_parse_args( $args, $defaults ); |
|
535 | + $args = wp_parse_args($args, $defaults); |
|
536 | 536 | |
537 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
537 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
538 | 538 | $options = ''; |
539 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
539 | + if (!empty($args['options']['disabled'])) { |
|
540 | 540 | $options .= ' disabled="disabled"'; |
541 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
541 | + } elseif (!empty($args['options']['readonly'])) { |
|
542 | 542 | $options .= ' readonly'; |
543 | 543 | } |
544 | 544 | |
545 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
545 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
549 | 549 | |
550 | -function wpinv_html_text( $args = array() ) { |
|
550 | +function wpinv_html_text($args = array()) { |
|
551 | 551 | // Backwards compatibility |
552 | - if ( func_num_args() > 1 ) { |
|
552 | + if (func_num_args() > 1) { |
|
553 | 553 | $args = func_get_args(); |
554 | 554 | |
555 | 555 | $name = $args[0]; |
556 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
557 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
558 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
556 | + $value = isset($args[1]) ? $args[1] : ''; |
|
557 | + $label = isset($args[2]) ? $args[2] : ''; |
|
558 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | $defaults = array( |
562 | 562 | 'id' => '', |
563 | - 'name' => isset( $name ) ? $name : 'text', |
|
564 | - 'value' => isset( $value ) ? $value : null, |
|
565 | - 'label' => isset( $label ) ? $label : null, |
|
566 | - 'desc' => isset( $desc ) ? $desc : null, |
|
563 | + 'name' => isset($name) ? $name : 'text', |
|
564 | + 'value' => isset($value) ? $value : null, |
|
565 | + 'label' => isset($label) ? $label : null, |
|
566 | + 'desc' => isset($desc) ? $desc : null, |
|
567 | 567 | 'placeholder' => '', |
568 | 568 | 'class' => 'regular-text', |
569 | 569 | 'disabled' => false, |
@@ -573,51 +573,51 @@ discard block |
||
573 | 573 | 'data' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
578 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
579 | 579 | $options = ''; |
580 | - if( $args['required'] ) { |
|
580 | + if ($args['required']) { |
|
581 | 581 | $options .= ' required="required"'; |
582 | 582 | } |
583 | - if( $args['readonly'] ) { |
|
583 | + if ($args['readonly']) { |
|
584 | 584 | $options .= ' readonly'; |
585 | 585 | } |
586 | - if( $args['readonly'] ) { |
|
586 | + if ($args['readonly']) { |
|
587 | 587 | $options .= ' readonly'; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $data = ''; |
591 | - if ( !empty( $args['data'] ) ) { |
|
592 | - foreach ( $args['data'] as $key => $value ) { |
|
593 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
591 | + if (!empty($args['data'])) { |
|
592 | + foreach ($args['data'] as $key => $value) { |
|
593 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
598 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
599 | - if ( ! empty( $args['desc'] ) ) { |
|
600 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
597 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
598 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
599 | + if (!empty($args['desc'])) { |
|
600 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
601 | 601 | } |
602 | 602 | |
603 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
603 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
604 | 604 | |
605 | 605 | $output .= '</span>'; |
606 | 606 | |
607 | 607 | return $output; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_date_field( $args = array() ) { |
|
611 | - if( empty( $args['class'] ) ) { |
|
610 | +function wpinv_html_date_field($args = array()) { |
|
611 | + if (empty($args['class'])) { |
|
612 | 612 | $args['class'] = 'wpiDatepicker'; |
613 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
613 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
614 | 614 | $args['class'] .= ' wpiDatepicker'; |
615 | 615 | } |
616 | 616 | |
617 | - return wpinv_html_text( $args ); |
|
617 | + return wpinv_html_text($args); |
|
618 | 618 | } |
619 | 619 | |
620 | -function wpinv_html_textarea( $args = array() ) { |
|
620 | +function wpinv_html_textarea($args = array()) { |
|
621 | 621 | $defaults = array( |
622 | 622 | 'name' => 'textarea', |
623 | 623 | 'value' => null, |
@@ -627,31 +627,31 @@ discard block |
||
627 | 627 | 'disabled' => false |
628 | 628 | ); |
629 | 629 | |
630 | - $args = wp_parse_args( $args, $defaults ); |
|
630 | + $args = wp_parse_args($args, $defaults); |
|
631 | 631 | |
632 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
632 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
633 | 633 | $disabled = ''; |
634 | - if( $args['disabled'] ) { |
|
634 | + if ($args['disabled']) { |
|
635 | 635 | $disabled = ' disabled="disabled"'; |
636 | 636 | } |
637 | 637 | |
638 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
639 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
640 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
638 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
639 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
640 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
641 | 641 | |
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | $output .= '</span>'; |
646 | 646 | |
647 | 647 | return $output; |
648 | 648 | } |
649 | 649 | |
650 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
650 | +function wpinv_html_ajax_user_search($args = array()) { |
|
651 | 651 | $defaults = array( |
652 | 652 | 'name' => 'user_id', |
653 | 653 | 'value' => null, |
654 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
654 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
655 | 655 | 'label' => null, |
656 | 656 | 'desc' => null, |
657 | 657 | 'class' => '', |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | 'data' => false |
661 | 661 | ); |
662 | 662 | |
663 | - $args = wp_parse_args( $args, $defaults ); |
|
663 | + $args = wp_parse_args($args, $defaults); |
|
664 | 664 | |
665 | 665 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
666 | 666 | |
667 | 667 | $output = '<span class="wpinv_user_search_wrap">'; |
668 | - $output .= wpinv_html_text( $args ); |
|
669 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
668 | + $output .= wpinv_html_text($args); |
|
669 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
670 | 670 | $output .= '</span>'; |
671 | 671 | |
672 | 672 | return $output; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function wpinv_ip_geolocation() { |
676 | 676 | global $wpinv_euvat; |
677 | 677 | |
678 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
678 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
679 | 679 | $content = ''; |
680 | 680 | $iso = ''; |
681 | 681 | $country = ''; |
@@ -686,69 +686,69 @@ discard block |
||
686 | 686 | $credit = ''; |
687 | 687 | $address = ''; |
688 | 688 | |
689 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
689 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
690 | 690 | try { |
691 | 691 | $iso = $geoip2_city->country->isoCode; |
692 | 692 | $country = $geoip2_city->country->name; |
693 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
693 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
694 | 694 | $city = $geoip2_city->city->name; |
695 | 695 | $longitude = $geoip2_city->location->longitude; |
696 | 696 | $latitude = $geoip2_city->location->latitude; |
697 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
698 | - } catch( Exception $e ) { } |
|
697 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
698 | + } catch (Exception $e) { } |
|
699 | 699 | } |
700 | 700 | |
701 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
701 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
702 | 702 | try { |
703 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
703 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
704 | 704 | |
705 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
705 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
706 | 706 | $iso = $load_xml->geoplugin_countryCode; |
707 | 707 | $country = $load_xml->geoplugin_countryName; |
708 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
709 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
708 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
709 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
710 | 710 | $longitude = $load_xml->geoplugin_longitude; |
711 | 711 | $latitude = $load_xml->geoplugin_latitude; |
712 | 712 | $credit = $load_xml->geoplugin_credit; |
713 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
713 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
714 | 714 | } |
715 | - } catch( Exception $e ) { } |
|
715 | + } catch (Exception $e) { } |
|
716 | 716 | } |
717 | 717 | |
718 | - if ( $iso && $longitude && $latitude ) { |
|
719 | - if ( $city ) { |
|
718 | + if ($iso && $longitude && $latitude) { |
|
719 | + if ($city) { |
|
720 | 720 | $address .= $city . ', '; |
721 | 721 | } |
722 | 722 | |
723 | - if ( $region ) { |
|
723 | + if ($region) { |
|
724 | 724 | $address .= $region . ', '; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $address .= $country . ' (' . $iso . ')'; |
728 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
729 | - $content .= '<p>'. $credit . '</p>'; |
|
728 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
729 | + $content .= '<p>' . $credit . '</p>'; |
|
730 | 730 | } else { |
731 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
731 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
732 | 732 | } |
733 | 733 | ?> |
734 | 734 | <!DOCTYPE html> |
735 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
735 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
736 | 736 | <body> |
737 | - <?php if ( $latitude && $latitude ) { ?> |
|
737 | + <?php if ($latitude && $latitude) { ?> |
|
738 | 738 | <div id="map"></div> |
739 | 739 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
740 | 740 | <script type="text/javascript"> |
741 | 741 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
742 | 742 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
743 | 743 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
744 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
744 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
745 | 745 | |
746 | 746 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
747 | 747 | |
748 | 748 | var marker = new L.Marker(latlng); |
749 | 749 | map.addLayer(marker); |
750 | 750 | |
751 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
751 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
752 | 752 | </script> |
753 | 753 | <?php } ?> |
754 | 754 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | <?php |
757 | 757 | exit; |
758 | 758 | } |
759 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
760 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
759 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
760 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
761 | 761 | |
762 | 762 | // Set up the template for the invoice. |
763 | -function wpinv_template( $template ) { |
|
763 | +function wpinv_template($template) { |
|
764 | 764 | global $post, $wp_query; |
765 | 765 | |
766 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
767 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
768 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
766 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
767 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
768 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
769 | 769 | } else { |
770 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
770 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | function wpinv_get_business_address() { |
778 | 778 | $business_address = wpinv_store_address(); |
779 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
779 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
780 | 780 | |
781 | 781 | /* |
782 | 782 | $default_country = wpinv_get_default_country(); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | |
801 | 801 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
802 | 802 | |
803 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
803 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | function wpinv_display_from_address() { |
@@ -810,192 +810,192 @@ discard block |
||
810 | 810 | if (empty($from_name)) { |
811 | 811 | $from_name = wpinv_get_business_name(); |
812 | 812 | } |
813 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
813 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
814 | 814 | <div class="wrapper col-xs-10"> |
815 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
816 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
817 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
815 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
816 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
817 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
818 | 818 | <?php } ?> |
819 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
820 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
819 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
820 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
821 | 821 | <?php } ?> |
822 | 822 | </div> |
823 | 823 | <?php |
824 | 824 | } |
825 | 825 | |
826 | -function wpinv_watermark( $id = 0 ) { |
|
827 | - $output = wpinv_get_watermark( $id ); |
|
826 | +function wpinv_watermark($id = 0) { |
|
827 | + $output = wpinv_get_watermark($id); |
|
828 | 828 | |
829 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
829 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_get_watermark( $id ) { |
|
833 | - if ( !$id > 0 ) { |
|
832 | +function wpinv_get_watermark($id) { |
|
833 | + if (!$id > 0) { |
|
834 | 834 | return NULL; |
835 | 835 | } |
836 | - $invoice = wpinv_get_invoice( $id ); |
|
836 | + $invoice = wpinv_get_invoice($id); |
|
837 | 837 | |
838 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
839 | - if ( $invoice->is_paid() ) { |
|
840 | - return __( 'Paid', 'invoicing' ); |
|
838 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
839 | + if ($invoice->is_paid()) { |
|
840 | + return __('Paid', 'invoicing'); |
|
841 | 841 | } |
842 | - if ( $invoice->is_refunded() ) { |
|
843 | - return __( 'Refunded', 'invoicing' ); |
|
842 | + if ($invoice->is_refunded()) { |
|
843 | + return __('Refunded', 'invoicing'); |
|
844 | 844 | } |
845 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
846 | - return __( 'Cancelled', 'invoicing' ); |
|
845 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
846 | + return __('Cancelled', 'invoicing'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | 850 | return NULL; |
851 | 851 | } |
852 | 852 | |
853 | -function wpinv_display_invoice_details( $invoice ) { |
|
853 | +function wpinv_display_invoice_details($invoice) { |
|
854 | 854 | global $wpinv_euvat; |
855 | 855 | |
856 | 856 | $invoice_id = $invoice->ID; |
857 | 857 | $vat_name = $wpinv_euvat->get_vat_name(); |
858 | 858 | $use_taxes = wpinv_use_taxes(); |
859 | 859 | |
860 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
860 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
861 | 861 | ?> |
862 | 862 | <table class="table table-bordered table-sm"> |
863 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
863 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
864 | 864 | <tr class="wpi-row-number"> |
865 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
866 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
865 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
866 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
867 | 867 | </tr> |
868 | 868 | <?php } ?> |
869 | 869 | <tr class="wpi-row-status"> |
870 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
871 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
870 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
871 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
872 | 872 | </tr> |
873 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
873 | + <?php if ($invoice->is_renewal()) { ?> |
|
874 | 874 | <tr class="wpi-row-parent"> |
875 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
876 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
875 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
876 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
877 | 877 | </tr> |
878 | 878 | <?php } ?> |
879 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
879 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
880 | 880 | <tr class="wpi-row-gateway"> |
881 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
881 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
882 | 882 | <td><?php echo $gateway_name; ?></td> |
883 | 883 | </tr> |
884 | 884 | <?php } ?> |
885 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
885 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
886 | 886 | <tr class="wpi-row-date"> |
887 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
887 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
888 | 888 | <td><?php echo $invoice_date; ?></td> |
889 | 889 | </tr> |
890 | 890 | <?php } ?> |
891 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
891 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
892 | 892 | <tr class="wpi-row-date"> |
893 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
893 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
894 | 894 | <td><?php echo $due_date; ?></td> |
895 | 895 | </tr> |
896 | 896 | <?php } ?> |
897 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
898 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
897 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
898 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
899 | 899 | <tr class="wpi-row-ovatno"> |
900 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
900 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
901 | 901 | <td><?php echo $owner_vat_number; ?></td> |
902 | 902 | </tr> |
903 | 903 | <?php } ?> |
904 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
904 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
906 | 906 | <tr class="wpi-row-uvatno"> |
907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
908 | 908 | <td><?php echo $user_vat_number; ?></td> |
909 | 909 | </tr> |
910 | 910 | <?php } ?> |
911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
914 | 914 | </tr> |
915 | 915 | </table> |
916 | 916 | <?php |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
921 | 921 | |
922 | - if ( empty( $invoice ) ) { |
|
922 | + if (empty($invoice)) { |
|
923 | 923 | return NULL; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $billing_details = $invoice->get_user_info(); |
927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
929 | 929 | |
930 | 930 | ob_start(); |
931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
932 | 932 | $output .= ob_get_clean(); |
933 | 933 | |
934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
935 | - if ( $company = $billing_details['company'] ) { |
|
936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
935 | + if ($company = $billing_details['company']) { |
|
936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
937 | 937 | } |
938 | 938 | $address_row = ''; |
939 | - if ( $address = $billing_details['address'] ) { |
|
940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
939 | + if ($address = $billing_details['address']) { |
|
940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | $address_fields = array(); |
944 | - if ( !empty( $billing_details['city'] ) ) { |
|
944 | + if (!empty($billing_details['city'])) { |
|
945 | 945 | $address_fields[] = $billing_details['city']; |
946 | 946 | } |
947 | 947 | |
948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
949 | - if ( !empty( $billing_details['state'] ) ) { |
|
950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
949 | + if (!empty($billing_details['state'])) { |
|
950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
951 | 951 | } |
952 | 952 | |
953 | - if ( !empty( $billing_country ) ) { |
|
954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
953 | + if (!empty($billing_country)) { |
|
954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( !empty( $address_fields ) ) { |
|
958 | - $address_fields = implode( ", ", $address_fields ); |
|
957 | + if (!empty($address_fields)) { |
|
958 | + $address_fields = implode(", ", $address_fields); |
|
959 | 959 | |
960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
960 | + if (!empty($billing_details['zip'])) { |
|
961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
962 | 962 | } |
963 | 963 | |
964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
965 | 965 | } |
966 | 966 | |
967 | - if ( $address_row ) { |
|
967 | + if ($address_row) { |
|
968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
969 | 969 | } |
970 | 970 | |
971 | - if ( $phone = $invoice->get_phone() ) { |
|
972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
971 | + if ($phone = $invoice->get_phone()) { |
|
972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
973 | 973 | } |
974 | - if ( $email = $invoice->get_email() ) { |
|
975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
974 | + if ($email = $invoice->get_email()) { |
|
975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | ob_start(); |
979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
980 | 980 | $output .= ob_get_clean(); |
981 | 981 | |
982 | 982 | $output .= '</div>'; |
983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
984 | 984 | |
985 | 985 | echo $output; |
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
992 | 992 | $use_taxes = wpinv_use_taxes(); |
993 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
993 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
994 | 994 | $use_taxes = true; |
995 | 995 | } |
996 | 996 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
997 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
998 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
997 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
998 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
999 | 999 | |
1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
1001 | 1001 | $ajax_cart_details = $cart_details; |
@@ -1004,64 +1004,64 @@ discard block |
||
1004 | 1004 | <table class="table table-sm table-bordered table-responsive"> |
1005 | 1005 | <thead> |
1006 | 1006 | <tr> |
1007 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1008 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1007 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1008 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1009 | 1009 | <?php if ($quantities_enabled) { ?> |
1010 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1010 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1011 | 1011 | <?php } ?> |
1012 | 1012 | <?php if ($use_taxes && !$zero_tax) { ?> |
1013 | 1013 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1014 | 1014 | <?php } ?> |
1015 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1015 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1016 | 1016 | </tr> |
1017 | 1017 | </thead> |
1018 | 1018 | <tbody> |
1019 | 1019 | <?php |
1020 | - if ( !empty( $cart_details ) ) { |
|
1021 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1020 | + if (!empty($cart_details)) { |
|
1021 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1022 | 1022 | |
1023 | 1023 | $count = 0; |
1024 | 1024 | $cols = 3; |
1025 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1026 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1027 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1028 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1029 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1025 | + foreach ($cart_details as $key => $cart_item) { |
|
1026 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1027 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1028 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1029 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1030 | 1030 | |
1031 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1031 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1032 | 1032 | $summary = ''; |
1033 | 1033 | $cols = 3; |
1034 | - if ( !empty($item) ) { |
|
1034 | + if (!empty($item)) { |
|
1035 | 1035 | $item_name = $item->get_name(); |
1036 | 1036 | $summary = $item->get_summary(); |
1037 | 1037 | } |
1038 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1038 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1039 | 1039 | |
1040 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1040 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1041 | 1041 | |
1042 | 1042 | $item_tax = ''; |
1043 | 1043 | $tax_rate = ''; |
1044 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1045 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1046 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1047 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1044 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1045 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1046 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1047 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1048 | 1048 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | $line_item_tax = $item_tax . $tax_rate; |
1052 | 1052 | |
1053 | - if ( $line_item_tax === '' ) { |
|
1053 | + if ($line_item_tax === '') { |
|
1054 | 1054 | $line_item_tax = 0; // Zero tax |
1055 | 1055 | } |
1056 | 1056 | |
1057 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1058 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1059 | - if ( $summary !== '' ) { |
|
1060 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1057 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1058 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1059 | + if ($summary !== '') { |
|
1060 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1061 | 1061 | } |
1062 | 1062 | $line_item .= '</td>'; |
1063 | 1063 | |
1064 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1064 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1065 | 1065 | if ($quantities_enabled) { |
1066 | 1066 | $cols++; |
1067 | 1067 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1070,55 +1070,55 @@ discard block |
||
1070 | 1070 | $cols++; |
1071 | 1071 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1072 | 1072 | } |
1073 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1073 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1074 | 1074 | $line_item .= '</tr>'; |
1075 | 1075 | |
1076 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1076 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1077 | 1077 | |
1078 | 1078 | $count++; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1081 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1082 | 1082 | ?> |
1083 | 1083 | <tr class="row-sub-total row_odd"> |
1084 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1085 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1084 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1085 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1086 | 1086 | </tr> |
1087 | 1087 | <?php |
1088 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1088 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1089 | 1089 | |
1090 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1091 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1090 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1091 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1092 | 1092 | ?> |
1093 | 1093 | <tr class="row-discount"> |
1094 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1095 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1094 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1095 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1096 | 1096 | </tr> |
1097 | 1097 | <?php |
1098 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1098 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | - if ( $use_taxes ) { |
|
1102 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1101 | + if ($use_taxes) { |
|
1102 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1103 | 1103 | ?> |
1104 | 1104 | <tr class="row-tax"> |
1105 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1106 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1105 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1106 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1107 | 1107 | </tr> |
1108 | 1108 | <?php |
1109 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1109 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1112 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1113 | 1113 | ?> |
1114 | 1114 | <tr class="table-active row-total"> |
1115 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1116 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1115 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1116 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1117 | 1117 | </tr> |
1118 | 1118 | <?php |
1119 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1119 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1120 | 1120 | |
1121 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1121 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1122 | 1122 | } |
1123 | 1123 | ?> |
1124 | 1124 | </tbody> |
@@ -1127,35 +1127,35 @@ discard block |
||
1127 | 1127 | echo ob_get_clean(); |
1128 | 1128 | } |
1129 | 1129 | |
1130 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1130 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1131 | 1131 | $use_taxes = wpinv_use_taxes(); |
1132 | 1132 | |
1133 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1133 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1134 | 1134 | ?> |
1135 | 1135 | <table class="table table-sm table-bordered table-responsive"> |
1136 | 1136 | <tbody> |
1137 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1137 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1138 | 1138 | <tr class="row-sub-total"> |
1139 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1140 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1139 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1140 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1141 | 1141 | </tr> |
1142 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1143 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1142 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1143 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1144 | 1144 | <tr class="row-discount"> |
1145 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1146 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1145 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1146 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1147 | 1147 | </tr> |
1148 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1148 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1149 | 1149 | <?php } ?> |
1150 | - <?php if ( $use_taxes ) { ?> |
|
1150 | + <?php if ($use_taxes) { ?> |
|
1151 | 1151 | <tr class="row-tax"> |
1152 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1153 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1152 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1153 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1154 | 1154 | </tr> |
1155 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1155 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1156 | 1156 | <?php } ?> |
1157 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1158 | - <?php foreach ( $fees as $fee ) { ?> |
|
1157 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1158 | + <?php foreach ($fees as $fee) { ?> |
|
1159 | 1159 | <tr class="row-fee"> |
1160 | 1160 | <td class="rate"><?php echo $fee['label']; ?></td> |
1161 | 1161 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1163,73 +1163,73 @@ discard block |
||
1163 | 1163 | <?php } ?> |
1164 | 1164 | <?php } ?> |
1165 | 1165 | <tr class="table-active row-total"> |
1166 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1167 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1166 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1167 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1168 | 1168 | </tr> |
1169 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1169 | + <?php do_action('wpinv_after_totals'); ?> |
|
1170 | 1170 | </tbody> |
1171 | 1171 | |
1172 | 1172 | </table> |
1173 | 1173 | |
1174 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1174 | + <?php do_action('wpinv_after_totals_table'); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1178 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1177 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1178 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1179 | 1179 | |
1180 | 1180 | ob_start(); |
1181 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1182 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1181 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1182 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1183 | 1183 | ?> |
1184 | 1184 | <div class="wpi-payment-info"> |
1185 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1186 | - <?php if ( $gateway_title ) { ?> |
|
1187 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1185 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1186 | + <?php if ($gateway_title) { ?> |
|
1187 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1188 | 1188 | <?php } ?> |
1189 | 1189 | </div> |
1190 | 1190 | <?php |
1191 | 1191 | } |
1192 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1192 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1193 | 1193 | $outout = ob_get_clean(); |
1194 | 1194 | |
1195 | - if ( $echo ) { |
|
1195 | + if ($echo) { |
|
1196 | 1196 | echo $outout; |
1197 | 1197 | } else { |
1198 | 1198 | return $outout; |
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
1202 | -function wpinv_display_style( $invoice ) { |
|
1203 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1202 | +function wpinv_display_style($invoice) { |
|
1203 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1204 | 1204 | |
1205 | - wp_print_styles( 'open-sans' ); |
|
1206 | - wp_print_styles( 'wpinv-single-style' ); |
|
1205 | + wp_print_styles('open-sans'); |
|
1206 | + wp_print_styles('wpinv-single-style'); |
|
1207 | 1207 | } |
1208 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1209 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1208 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1209 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1210 | 1210 | |
1211 | 1211 | function wpinv_checkout_billing_details() { |
1212 | 1212 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1213 | 1213 | if (empty($invoice_id)) { |
1214 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1214 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1215 | 1215 | return null; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1218 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1219 | 1219 | if (empty($invoice)) { |
1220 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1220 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1221 | 1221 | return null; |
1222 | 1222 | } |
1223 | 1223 | $user_id = $invoice->get_user_id(); |
1224 | 1224 | $user_info = $invoice->get_user_info(); |
1225 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1225 | + $address_info = wpinv_get_user_address($user_id); |
|
1226 | 1226 | |
1227 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1227 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1228 | 1228 | $user_info['first_name'] = $user_info['first_name']; |
1229 | 1229 | $user_info['last_name'] = $user_info['last_name']; |
1230 | 1230 | } |
1231 | 1231 | |
1232 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1232 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1233 | 1233 | $user_info['country'] = $address_info['country']; |
1234 | 1234 | $user_info['state'] = $address_info['state']; |
1235 | 1235 | $user_info['city'] = $address_info['city']; |
@@ -1245,98 +1245,98 @@ discard block |
||
1245 | 1245 | 'address' |
1246 | 1246 | ); |
1247 | 1247 | |
1248 | - foreach ( $address_fields as $field ) { |
|
1249 | - if ( empty( $user_info[$field] ) ) { |
|
1248 | + foreach ($address_fields as $field) { |
|
1249 | + if (empty($user_info[$field])) { |
|
1250 | 1250 | $user_info[$field] = $address_info[$field]; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1254 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | function wpinv_admin_get_line_items($invoice = array()) { |
1258 | 1258 | $item_quantities = wpinv_item_quantities_enabled(); |
1259 | 1259 | $use_taxes = wpinv_use_taxes(); |
1260 | 1260 | |
1261 | - if ( empty( $invoice ) ) { |
|
1261 | + if (empty($invoice)) { |
|
1262 | 1262 | return NULL; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | $cart_items = $invoice->get_cart_details(); |
1266 | - if ( empty( $cart_items ) ) { |
|
1266 | + if (empty($cart_items)) { |
|
1267 | 1267 | return NULL; |
1268 | 1268 | } |
1269 | 1269 | ob_start(); |
1270 | 1270 | |
1271 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1271 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1272 | 1272 | |
1273 | 1273 | $count = 0; |
1274 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1274 | + foreach ($cart_items as $key => $cart_item) { |
|
1275 | 1275 | $item_id = $cart_item['id']; |
1276 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1276 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1277 | 1277 | |
1278 | 1278 | if (empty($wpi_item)) { |
1279 | 1279 | continue; |
1280 | 1280 | } |
1281 | 1281 | |
1282 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1283 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1284 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1282 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1283 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1284 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1285 | 1285 | $can_remove = true; |
1286 | 1286 | |
1287 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1287 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1288 | 1288 | |
1289 | 1289 | $item_tax = ''; |
1290 | 1290 | $tax_rate = ''; |
1291 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1292 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1293 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1294 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1291 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1292 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1293 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1294 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1295 | 1295 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1296 | 1296 | } |
1297 | 1297 | $line_item_tax = $item_tax . $tax_rate; |
1298 | 1298 | |
1299 | - if ( $line_item_tax === '' ) { |
|
1299 | + if ($line_item_tax === '') { |
|
1300 | 1300 | $line_item_tax = 0; // Zero tax |
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1303 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1304 | 1304 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1305 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1306 | - if ( $summary !== '' ) { |
|
1307 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1305 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1306 | + if ($summary !== '') { |
|
1307 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1308 | 1308 | } |
1309 | 1309 | $line_item .= '</td>'; |
1310 | 1310 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1311 | 1311 | |
1312 | - if ( $item_quantities ) { |
|
1313 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1312 | + if ($item_quantities) { |
|
1313 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1314 | 1314 | $can_remove = false; |
1315 | 1315 | } |
1316 | 1316 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1317 | 1317 | } else { |
1318 | - if ( count( $cart_items ) == 1 ) { |
|
1318 | + if (count($cart_items) == 1) { |
|
1319 | 1319 | $can_remove = false; |
1320 | 1320 | } |
1321 | 1321 | } |
1322 | 1322 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1323 | 1323 | |
1324 | - if ( $use_taxes ) { |
|
1324 | + if ($use_taxes) { |
|
1325 | 1325 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1326 | 1326 | } |
1327 | 1327 | $line_item .= '<td class="action">'; |
1328 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1328 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1329 | 1329 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1330 | 1330 | } |
1331 | 1331 | $line_item .= '</td>'; |
1332 | 1332 | $line_item .= '</tr>'; |
1333 | 1333 | |
1334 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1334 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1335 | 1335 | |
1336 | 1336 | $count++; |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1339 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1340 | 1340 | |
1341 | 1341 | return ob_get_clean(); |
1342 | 1342 | } |
@@ -1347,35 +1347,35 @@ discard block |
||
1347 | 1347 | // Set current invoice id. |
1348 | 1348 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1349 | 1349 | |
1350 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1350 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1351 | 1351 | |
1352 | 1352 | ob_start(); |
1353 | 1353 | echo '<div id="wpinv_checkout_wrap">'; |
1354 | 1354 | |
1355 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1355 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1356 | 1356 | ?> |
1357 | 1357 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1358 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1358 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1359 | 1359 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1360 | 1360 | <?php |
1361 | - do_action( 'wpinv_checkout_form_top' ); |
|
1362 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1363 | - do_action( 'wpinv_checkout_cart' ); |
|
1364 | - do_action( 'wpinv_payment_mode_select' ); |
|
1365 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1361 | + do_action('wpinv_checkout_form_top'); |
|
1362 | + do_action('wpinv_checkout_billing_info'); |
|
1363 | + do_action('wpinv_checkout_cart'); |
|
1364 | + do_action('wpinv_payment_mode_select'); |
|
1365 | + do_action('wpinv_checkout_form_bottom') |
|
1366 | 1366 | ?> |
1367 | 1367 | </form> |
1368 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1368 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1369 | 1369 | </div><!--end #wpinv_checkout_form_wrap--> |
1370 | 1370 | <?php |
1371 | 1371 | } else { |
1372 | - do_action( 'wpinv_cart_empty' ); |
|
1372 | + do_action('wpinv_cart_empty'); |
|
1373 | 1373 | } |
1374 | 1374 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1375 | 1375 | return ob_get_clean(); |
1376 | 1376 | } |
1377 | 1377 | |
1378 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1378 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1379 | 1379 | global $ajax_cart_details; |
1380 | 1380 | $ajax_cart_details = $cart_details; |
1381 | 1381 | /* |
@@ -1390,25 +1390,25 @@ discard block |
||
1390 | 1390 | } |
1391 | 1391 | */ |
1392 | 1392 | ob_start(); |
1393 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1393 | + do_action('wpinv_before_checkout_cart'); |
|
1394 | 1394 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1395 | 1395 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1396 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1396 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1397 | 1397 | echo '</div>'; |
1398 | 1398 | echo '</div>'; |
1399 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1399 | + do_action('wpinv_after_checkout_cart'); |
|
1400 | 1400 | $content = ob_get_clean(); |
1401 | 1401 | |
1402 | - if ( $echo ) { |
|
1402 | + if ($echo) { |
|
1403 | 1403 | echo $content; |
1404 | 1404 | } else { |
1405 | 1405 | return $content; |
1406 | 1406 | } |
1407 | 1407 | } |
1408 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1408 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1409 | 1409 | |
1410 | 1410 | function wpinv_empty_cart_message() { |
1411 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1411 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1420,91 +1420,91 @@ discard block |
||
1420 | 1420 | function wpinv_empty_checkout_cart() { |
1421 | 1421 | echo wpinv_empty_cart_message(); |
1422 | 1422 | } |
1423 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1423 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1424 | 1424 | |
1425 | 1425 | function wpinv_save_cart_button() { |
1426 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1426 | + if (wpinv_is_cart_saving_disabled()) |
|
1427 | 1427 | return; |
1428 | 1428 | ?> |
1429 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
1429 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
1430 | 1430 | <?php |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | function wpinv_update_cart_button() { |
1434 | - if ( !wpinv_item_quantities_enabled() ) |
|
1434 | + if (!wpinv_item_quantities_enabled()) |
|
1435 | 1435 | return; |
1436 | 1436 | ?> |
1437 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1437 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1438 | 1438 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1439 | 1439 | <?php |
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | function wpinv_checkout_cart_columns() { |
1443 | 1443 | $default = 3; |
1444 | - if ( wpinv_item_quantities_enabled() ) { |
|
1444 | + if (wpinv_item_quantities_enabled()) { |
|
1445 | 1445 | $default++; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - if ( wpinv_use_taxes() ) { |
|
1448 | + if (wpinv_use_taxes()) { |
|
1449 | 1449 | $default++; |
1450 | 1450 | } |
1451 | 1451 | |
1452 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1452 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | function wpinv_display_cart_messages() { |
1456 | 1456 | global $wpi_session; |
1457 | 1457 | |
1458 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1458 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1459 | 1459 | |
1460 | - if ( $messages ) { |
|
1461 | - foreach ( $messages as $message_id => $message ) { |
|
1460 | + if ($messages) { |
|
1461 | + foreach ($messages as $message_id => $message) { |
|
1462 | 1462 | // Try and detect what type of message this is |
1463 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1463 | + if (strpos(strtolower($message), 'error')) { |
|
1464 | 1464 | $type = 'error'; |
1465 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1465 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1466 | 1466 | $type = 'success'; |
1467 | 1467 | } else { |
1468 | 1468 | $type = 'info'; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1471 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1472 | 1472 | |
1473 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1473 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1474 | 1474 | // Loop message codes and display messages |
1475 | 1475 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1476 | 1476 | echo '</div>'; |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // Remove all of the cart saving messages |
1480 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1480 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1481 | 1481 | } |
1482 | 1482 | } |
1483 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1483 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1484 | 1484 | |
1485 | 1485 | function wpinv_discount_field() { |
1486 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1486 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1487 | 1487 | return; // Only show before a payment method has been selected if ajax is disabled |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - if ( !wpinv_is_checkout() ) { |
|
1490 | + if (!wpinv_is_checkout()) { |
|
1491 | 1491 | return; |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1494 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1495 | 1495 | ?> |
1496 | 1496 | <div id="wpinv-discount-field" class="panel panel-default"> |
1497 | 1497 | <div class="panel-body"> |
1498 | 1498 | <p> |
1499 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1500 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1499 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1500 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1501 | 1501 | </p> |
1502 | 1502 | <div class="form-group row"> |
1503 | 1503 | <div class="col-sm-4"> |
1504 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1504 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1505 | 1505 | </div> |
1506 | 1506 | <div class="col-sm-3"> |
1507 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1507 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1508 | 1508 | </div> |
1509 | 1509 | <div style="clear:both"></div> |
1510 | 1510 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1517,10 +1517,10 @@ discard block |
||
1517 | 1517 | <?php |
1518 | 1518 | } |
1519 | 1519 | } |
1520 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1520 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1521 | 1521 | |
1522 | 1522 | function wpinv_agree_to_terms_js() { |
1523 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1523 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1524 | 1524 | ?> |
1525 | 1525 | <script type="text/javascript"> |
1526 | 1526 | jQuery(document).ready(function($){ |
@@ -1535,126 +1535,126 @@ discard block |
||
1535 | 1535 | <?php |
1536 | 1536 | } |
1537 | 1537 | } |
1538 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1538 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1539 | 1539 | |
1540 | 1540 | function wpinv_payment_mode_select() { |
1541 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1542 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1541 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1542 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1543 | 1543 | $page_URL = wpinv_get_current_page_url(); |
1544 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1544 | + $invoice = wpinv_get_invoice(0, true); |
|
1545 | 1545 | |
1546 | 1546 | do_action('wpinv_payment_mode_top'); |
1547 | 1547 | $invoice_id = (int)$invoice->ID; |
1548 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1548 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1549 | 1549 | ?> |
1550 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1551 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1550 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1551 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1552 | 1552 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1553 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1553 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1554 | 1554 | <div class="panel-body list-group wpi-payment_methods"> |
1555 | 1555 | <?php |
1556 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1556 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1557 | 1557 | |
1558 | - if ( !empty( $gateways ) ) { |
|
1559 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1560 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1561 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1562 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1558 | + if (!empty($gateways)) { |
|
1559 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1560 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1561 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1562 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1563 | 1563 | ?> |
1564 | 1564 | <div class="list-group-item"> |
1565 | 1565 | <div class="radio"> |
1566 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1566 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1567 | 1567 | </div> |
1568 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1569 | - <?php if ( !empty( $description ) ) { ?> |
|
1570 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1568 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1569 | + <?php if (!empty($description)) { ?> |
|
1570 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1571 | 1571 | <?php } ?> |
1572 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1572 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1573 | 1573 | </div> |
1574 | 1574 | </div> |
1575 | 1575 | <?php |
1576 | 1576 | } |
1577 | 1577 | } else { |
1578 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1578 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1581 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1582 | 1582 | ?> |
1583 | 1583 | </div> |
1584 | 1584 | </div> |
1585 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1585 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1586 | 1586 | </div> |
1587 | 1587 | <?php |
1588 | 1588 | do_action('wpinv_payment_mode_bottom'); |
1589 | 1589 | } |
1590 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1590 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1591 | 1591 | |
1592 | 1592 | function wpinv_checkout_billing_info() { |
1593 | - if ( wpinv_is_checkout() ) { |
|
1593 | + if (wpinv_is_checkout()) { |
|
1594 | 1594 | $logged_in = is_user_logged_in(); |
1595 | 1595 | $billing_details = wpinv_checkout_billing_details(); |
1596 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1596 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1597 | 1597 | ?> |
1598 | 1598 | <div id="wpinv-fields" class="clearfix"> |
1599 | 1599 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1600 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1600 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1601 | 1601 | <div id="wpinv-fields-box" class="panel-body"> |
1602 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1602 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1603 | 1603 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1604 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1604 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1605 | 1605 | <?php |
1606 | - echo wpinv_html_text( array( |
|
1606 | + echo wpinv_html_text(array( |
|
1607 | 1607 | 'id' => 'wpinv_first_name', |
1608 | 1608 | 'name' => 'wpinv_first_name', |
1609 | 1609 | 'value' => $billing_details['first_name'], |
1610 | 1610 | 'class' => 'wpi-input form-control', |
1611 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1612 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1613 | - ) ); |
|
1611 | + 'placeholder' => __('First name', 'invoicing'), |
|
1612 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1613 | + )); |
|
1614 | 1614 | ?> |
1615 | 1615 | </p> |
1616 | 1616 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1617 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1617 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1618 | 1618 | <?php |
1619 | - echo wpinv_html_text( array( |
|
1619 | + echo wpinv_html_text(array( |
|
1620 | 1620 | 'id' => 'wpinv_last_name', |
1621 | 1621 | 'name' => 'wpinv_last_name', |
1622 | 1622 | 'value' => $billing_details['last_name'], |
1623 | 1623 | 'class' => 'wpi-input form-control', |
1624 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1625 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1626 | - ) ); |
|
1624 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1625 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1626 | + )); |
|
1627 | 1627 | ?> |
1628 | 1628 | </p> |
1629 | 1629 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1630 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1630 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1631 | 1631 | <?php |
1632 | - echo wpinv_html_text( array( |
|
1632 | + echo wpinv_html_text(array( |
|
1633 | 1633 | 'id' => 'wpinv_address', |
1634 | 1634 | 'name' => 'wpinv_address', |
1635 | 1635 | 'value' => $billing_details['address'], |
1636 | 1636 | 'class' => 'wpi-input form-control', |
1637 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1638 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1639 | - ) ); |
|
1637 | + 'placeholder' => __('Address', 'invoicing'), |
|
1638 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1639 | + )); |
|
1640 | 1640 | ?> |
1641 | 1641 | </p> |
1642 | 1642 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1643 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1643 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1644 | 1644 | <?php |
1645 | - echo wpinv_html_text( array( |
|
1645 | + echo wpinv_html_text(array( |
|
1646 | 1646 | 'id' => 'wpinv_city', |
1647 | 1647 | 'name' => 'wpinv_city', |
1648 | 1648 | 'value' => $billing_details['city'], |
1649 | 1649 | 'class' => 'wpi-input form-control', |
1650 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1651 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1652 | - ) ); |
|
1650 | + 'placeholder' => __('City', 'invoicing'), |
|
1651 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1652 | + )); |
|
1653 | 1653 | ?> |
1654 | 1654 | </p> |
1655 | 1655 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1656 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1657 | - <?php echo wpinv_html_select( array( |
|
1656 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1657 | + <?php echo wpinv_html_select(array( |
|
1658 | 1658 | 'options' => wpinv_get_country_list(), |
1659 | 1659 | 'name' => 'wpinv_country', |
1660 | 1660 | 'id' => 'wpinv_country', |
@@ -1662,16 +1662,16 @@ discard block |
||
1662 | 1662 | 'show_option_all' => false, |
1663 | 1663 | 'show_option_none' => false, |
1664 | 1664 | 'class' => 'wpi-input form-control', |
1665 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1666 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1667 | - ) ); ?> |
|
1665 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1666 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1667 | + )); ?> |
|
1668 | 1668 | </p> |
1669 | 1669 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1670 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1670 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1671 | 1671 | <?php |
1672 | - $states = wpinv_get_country_states( $selected_country ); |
|
1673 | - if( !empty( $states ) ) { |
|
1674 | - echo wpinv_html_select( array( |
|
1672 | + $states = wpinv_get_country_states($selected_country); |
|
1673 | + if (!empty($states)) { |
|
1674 | + echo wpinv_html_select(array( |
|
1675 | 1675 | 'options' => $states, |
1676 | 1676 | 'name' => 'wpinv_state', |
1677 | 1677 | 'id' => 'wpinv_state', |
@@ -1679,61 +1679,61 @@ discard block |
||
1679 | 1679 | 'show_option_all' => false, |
1680 | 1680 | 'show_option_none' => false, |
1681 | 1681 | 'class' => 'wpi-input form-control', |
1682 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1683 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1684 | - ) ); |
|
1682 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1683 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1684 | + )); |
|
1685 | 1685 | } else { |
1686 | - echo wpinv_html_text( array( |
|
1686 | + echo wpinv_html_text(array( |
|
1687 | 1687 | 'name' => 'wpinv_state', |
1688 | 1688 | 'value' => $billing_details['state'], |
1689 | 1689 | 'id' => 'wpinv_state', |
1690 | 1690 | 'class' => 'wpi-input form-control', |
1691 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1692 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1693 | - ) ); |
|
1691 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1692 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1693 | + )); |
|
1694 | 1694 | } |
1695 | 1695 | ?> |
1696 | 1696 | </p> |
1697 | 1697 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1698 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1698 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1699 | 1699 | <?php |
1700 | - echo wpinv_html_text( array( |
|
1700 | + echo wpinv_html_text(array( |
|
1701 | 1701 | 'name' => 'wpinv_zip', |
1702 | 1702 | 'value' => $billing_details['zip'], |
1703 | 1703 | 'id' => 'wpinv_zip', |
1704 | 1704 | 'class' => 'wpi-input form-control', |
1705 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1706 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1707 | - ) ); |
|
1705 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1706 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1707 | + )); |
|
1708 | 1708 | ?> |
1709 | 1709 | </p> |
1710 | 1710 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1711 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1711 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1712 | 1712 | <?php |
1713 | - echo wpinv_html_text( array( |
|
1713 | + echo wpinv_html_text(array( |
|
1714 | 1714 | 'id' => 'wpinv_phone', |
1715 | 1715 | 'name' => 'wpinv_phone', |
1716 | 1716 | 'value' => $billing_details['phone'], |
1717 | 1717 | 'class' => 'wpi-input form-control', |
1718 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1719 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1720 | - ) ); |
|
1718 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1719 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1720 | + )); |
|
1721 | 1721 | ?> |
1722 | 1722 | </p> |
1723 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1723 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1724 | 1724 | <div class="clearfix"></div> |
1725 | 1725 | </div> |
1726 | 1726 | </div> |
1727 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1727 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1728 | 1728 | </div> |
1729 | 1729 | <?php |
1730 | 1730 | } |
1731 | 1731 | } |
1732 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1732 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1733 | 1733 | |
1734 | 1734 | function wpinv_checkout_hidden_fields() { |
1735 | 1735 | ?> |
1736 | - <?php if ( is_user_logged_in() ) { ?> |
|
1736 | + <?php if (is_user_logged_in()) { ?> |
|
1737 | 1737 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1738 | 1738 | <?php } ?> |
1739 | 1739 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1743,9 +1743,9 @@ discard block |
||
1743 | 1743 | function wpinv_checkout_button_purchase() { |
1744 | 1744 | ob_start(); |
1745 | 1745 | ?> |
1746 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1746 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1747 | 1747 | <?php |
1748 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1748 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | function wpinv_checkout_total() { |
@@ -1754,113 +1754,113 @@ discard block |
||
1754 | 1754 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1755 | 1755 | <div class="panel-body"> |
1756 | 1756 | <?php |
1757 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1757 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1758 | 1758 | ?> |
1759 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1759 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1760 | 1760 | <?php |
1761 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1761 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1762 | 1762 | ?> |
1763 | 1763 | </div> |
1764 | 1764 | </div> |
1765 | 1765 | <?php |
1766 | 1766 | } |
1767 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1767 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1768 | 1768 | |
1769 | 1769 | function wpinv_checkout_accept_tandc() { |
1770 | - $page = wpinv_get_option( 'tandc_page' ); |
|
1771 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
1772 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
1770 | + $page = wpinv_get_option('tandc_page'); |
|
1771 | + if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
1772 | + $terms_link = esc_url(get_permalink($page)); |
|
1773 | 1773 | ?> |
1774 | 1774 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
1775 | 1775 | <div class="panel-body"> |
1776 | 1776 | <label class=""> |
1777 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
1777 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
1778 | 1778 | </label> |
1779 | 1779 | </div> |
1780 | 1780 | </div> |
1781 | 1781 | <?php |
1782 | 1782 | } |
1783 | 1783 | } |
1784 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
1784 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
1785 | 1785 | |
1786 | 1786 | function wpinv_checkout_submit() { |
1787 | 1787 | ?> |
1788 | 1788 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1789 | 1789 | <div class="panel-body text-center"> |
1790 | 1790 | <?php |
1791 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1791 | + do_action('wpinv_purchase_form_before_submit'); |
|
1792 | 1792 | wpinv_checkout_hidden_fields(); |
1793 | 1793 | echo wpinv_checkout_button_purchase(); |
1794 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1794 | + do_action('wpinv_purchase_form_after_submit'); |
|
1795 | 1795 | ?> |
1796 | 1796 | </div> |
1797 | 1797 | </div> |
1798 | 1798 | <?php |
1799 | 1799 | } |
1800 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1800 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1801 | 1801 | |
1802 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1803 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1802 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1803 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1804 | 1804 | |
1805 | - if ( empty( $invoice ) ) { |
|
1805 | + if (empty($invoice)) { |
|
1806 | 1806 | return NULL; |
1807 | 1807 | } |
1808 | 1808 | |
1809 | 1809 | $billing_details = $invoice->get_user_info(); |
1810 | 1810 | $address_row = ''; |
1811 | - if ( $address = $billing_details['address'] ) { |
|
1812 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1811 | + if ($address = $billing_details['address']) { |
|
1812 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | $address_fields = array(); |
1816 | - if ( !empty( $billing_details['city'] ) ) { |
|
1816 | + if (!empty($billing_details['city'])) { |
|
1817 | 1817 | $address_fields[] = $billing_details['city']; |
1818 | 1818 | } |
1819 | 1819 | |
1820 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1821 | - if ( !empty( $billing_details['state'] ) ) { |
|
1822 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1820 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1821 | + if (!empty($billing_details['state'])) { |
|
1822 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1823 | 1823 | } |
1824 | 1824 | |
1825 | - if ( !empty( $billing_country ) ) { |
|
1826 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1825 | + if (!empty($billing_country)) { |
|
1826 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | - if ( !empty( $address_fields ) ) { |
|
1830 | - $address_fields = implode( ", ", $address_fields ); |
|
1829 | + if (!empty($address_fields)) { |
|
1830 | + $address_fields = implode(", ", $address_fields); |
|
1831 | 1831 | |
1832 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1832 | + if (!empty($billing_details['zip'])) { |
|
1833 | 1833 | $address_fields .= ' ' . $billing_details['zip']; |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1836 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1837 | 1837 | } |
1838 | 1838 | ob_start(); |
1839 | 1839 | ?> |
1840 | 1840 | <table class="table table-bordered table-sm wpi-billing-details"> |
1841 | 1841 | <tbody> |
1842 | 1842 | <tr class="wpi-receipt-name"> |
1843 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1844 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1843 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1844 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1845 | 1845 | </tr> |
1846 | 1846 | <tr class="wpi-receipt-email"> |
1847 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1848 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1847 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1848 | + <td><?php echo $billing_details['email']; ?></td> |
|
1849 | 1849 | </tr> |
1850 | - <?php if ( $billing_details['company'] ) { ?> |
|
1850 | + <?php if ($billing_details['company']) { ?> |
|
1851 | 1851 | <tr class="wpi-receipt-company"> |
1852 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1853 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1852 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1853 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1854 | 1854 | </tr> |
1855 | 1855 | <?php } ?> |
1856 | 1856 | <tr class="wpi-receipt-address"> |
1857 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1858 | - <td><?php echo $address_row ;?></td> |
|
1857 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1858 | + <td><?php echo $address_row; ?></td> |
|
1859 | 1859 | </tr> |
1860 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1860 | + <?php if ($billing_details['phone']) { ?> |
|
1861 | 1861 | <tr class="wpi-receipt-phone"> |
1862 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1863 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1862 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1863 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1864 | 1864 | </tr> |
1865 | 1865 | <?php } ?> |
1866 | 1866 | </tbody> |
@@ -1868,74 +1868,74 @@ discard block |
||
1868 | 1868 | <?php |
1869 | 1869 | $output = ob_get_clean(); |
1870 | 1870 | |
1871 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1871 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1872 | 1872 | |
1873 | 1873 | echo $output; |
1874 | 1874 | } |
1875 | 1875 | |
1876 | -function wpinv_filter_success_page_content( $content ) { |
|
1877 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1878 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1879 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1876 | +function wpinv_filter_success_page_content($content) { |
|
1877 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1878 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1879 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1880 | 1880 | } |
1881 | 1881 | } |
1882 | 1882 | |
1883 | 1883 | return $content; |
1884 | 1884 | } |
1885 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1885 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1886 | 1886 | |
1887 | -function wpinv_receipt_actions( $invoice ) { |
|
1888 | - if ( !empty( $invoice ) ) { |
|
1887 | +function wpinv_receipt_actions($invoice) { |
|
1888 | + if (!empty($invoice)) { |
|
1889 | 1889 | $actions = array(); |
1890 | 1890 | |
1891 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1892 | - $actions['print'] = array( |
|
1893 | - 'url' => $invoice->get_view_url( true ), |
|
1894 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1891 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1892 | + $actions['print'] = array( |
|
1893 | + 'url' => $invoice->get_view_url(true), |
|
1894 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1895 | 1895 | 'class' => 'btn-primary', |
1896 | 1896 | ); |
1897 | 1897 | } |
1898 | 1898 | |
1899 | - if ( is_user_logged_in() ) { |
|
1899 | + if (is_user_logged_in()) { |
|
1900 | 1900 | $actions['history'] = array( |
1901 | 1901 | 'url' => wpinv_get_history_page_uri(), |
1902 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1902 | + 'name' => __('Invoice History', 'invoicing'), |
|
1903 | 1903 | 'class' => 'btn-warning', |
1904 | 1904 | ); |
1905 | 1905 | } |
1906 | 1906 | |
1907 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1907 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1908 | 1908 | |
1909 | - if ( !empty( $actions ) ) { |
|
1909 | + if (!empty($actions)) { |
|
1910 | 1910 | ?> |
1911 | 1911 | <div class="wpinv-receipt-actions text-right"> |
1912 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1913 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1912 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1913 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1914 | 1914 | <?php } ?> |
1915 | 1915 | </div> |
1916 | 1916 | <?php |
1917 | 1917 | } |
1918 | 1918 | } |
1919 | 1919 | } |
1920 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1920 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1921 | 1921 | |
1922 | -function wpinv_invoice_link( $invoice_id ) { |
|
1923 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1922 | +function wpinv_invoice_link($invoice_id) { |
|
1923 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1924 | 1924 | |
1925 | - if ( empty( $invoice ) ) { |
|
1925 | + if (empty($invoice)) { |
|
1926 | 1926 | return NULL; |
1927 | 1927 | } |
1928 | 1928 | |
1929 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1929 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1930 | 1930 | |
1931 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1931 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1935 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
1936 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
1934 | +function wpinv_invoice_subscription_details($invoice) { |
|
1935 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1936 | + $subscription = wpinv_get_subscription($invoice, true); |
|
1937 | 1937 | |
1938 | - if ( empty( $subscription ) ) { |
|
1938 | + if (empty($subscription)) { |
|
1939 | 1939 | return; |
1940 | 1940 | } |
1941 | 1941 | |
@@ -1946,15 +1946,15 @@ discard block |
||
1946 | 1946 | $payments = $subscription->get_child_payments(); |
1947 | 1947 | ?> |
1948 | 1948 | <div class="wpinv-subscriptions-details"> |
1949 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1949 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1950 | 1950 | <table class="table"> |
1951 | 1951 | <thead> |
1952 | 1952 | <tr> |
1953 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1954 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1955 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1956 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1957 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1953 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1954 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1955 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1956 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1957 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1958 | 1958 | </tr> |
1959 | 1959 | </thead> |
1960 | 1960 | <tbody> |
@@ -1968,29 +1968,29 @@ discard block |
||
1968 | 1968 | </tbody> |
1969 | 1969 | </table> |
1970 | 1970 | </div> |
1971 | - <?php if ( !empty( $payments ) ) { ?> |
|
1971 | + <?php if (!empty($payments)) { ?> |
|
1972 | 1972 | <div class="wpinv-renewal-payments"> |
1973 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1973 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1974 | 1974 | <table class="table"> |
1975 | 1975 | <thead> |
1976 | 1976 | <tr> |
1977 | 1977 | <th>#</th> |
1978 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1979 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
1980 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1978 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1979 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
1980 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
1981 | 1981 | </tr> |
1982 | 1982 | </thead> |
1983 | 1983 | <tbody> |
1984 | 1984 | <?php |
1985 | 1985 | $i = 1; |
1986 | - foreach ( $payments as $payment ) { |
|
1986 | + foreach ($payments as $payment) { |
|
1987 | 1987 | $invoice_id = $payment->ID; |
1988 | 1988 | ?> |
1989 | 1989 | <tr> |
1990 | - <th scope="row"><?php echo $i;?></th> |
|
1991 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
1992 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
1993 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
1990 | + <th scope="row"><?php echo $i; ?></th> |
|
1991 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
1992 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
1993 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
1994 | 1994 | </tr> |
1995 | 1995 | <?php $i++; } ?> |
1996 | 1996 | </tbody> |
@@ -2001,52 +2001,52 @@ discard block |
||
2001 | 2001 | } |
2002 | 2002 | } |
2003 | 2003 | |
2004 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2005 | - if ( empty( $invoice ) ) { |
|
2004 | +function wpinv_cart_total_label($label, $invoice) { |
|
2005 | + if (empty($invoice)) { |
|
2006 | 2006 | return $label; |
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | $prefix_label = ''; |
2010 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2011 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2012 | - } else if ( $invoice->is_renewal() ) { |
|
2013 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2010 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2011 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2012 | + } else if ($invoice->is_renewal()) { |
|
2013 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2014 | 2014 | } |
2015 | 2015 | |
2016 | - if ( $prefix_label != '' ) { |
|
2017 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2016 | + if ($prefix_label != '') { |
|
2017 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2018 | 2018 | } |
2019 | 2019 | |
2020 | 2020 | return $label; |
2021 | 2021 | } |
2022 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2023 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2024 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2022 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2023 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2024 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2025 | 2025 | |
2026 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2026 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2027 | 2027 | |
2028 | -function wpinv_invoice_print_description( $invoice ) { |
|
2029 | - if ( empty( $invoice ) ) { |
|
2028 | +function wpinv_invoice_print_description($invoice) { |
|
2029 | + if (empty($invoice)) { |
|
2030 | 2030 | return NULL; |
2031 | 2031 | } |
2032 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2032 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2033 | 2033 | ?> |
2034 | 2034 | <div class="row wpinv-lower"> |
2035 | 2035 | <div class="col-sm-12 wpinv-description"> |
2036 | - <?php echo wpautop( $description ); ?> |
|
2036 | + <?php echo wpautop($description); ?> |
|
2037 | 2037 | </div> |
2038 | 2038 | </div> |
2039 | 2039 | <?php |
2040 | 2040 | } |
2041 | 2041 | } |
2042 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2042 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2043 | 2043 | |
2044 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2045 | - if ( empty( $invoice ) ) { |
|
2044 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2045 | + if (empty($invoice)) { |
|
2046 | 2046 | return NULL; |
2047 | 2047 | } |
2048 | 2048 | |
2049 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2049 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2050 | 2050 | ?> |
2051 | 2051 | <div class="row wpinv-payments"> |
2052 | 2052 | <div class="col-sm-12"> |
@@ -2058,43 +2058,43 @@ discard block |
||
2058 | 2058 | } |
2059 | 2059 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2060 | 2060 | |
2061 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2062 | - if ( empty( $note ) ) { |
|
2061 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2062 | + if (empty($note)) { |
|
2063 | 2063 | return NULL; |
2064 | 2064 | } |
2065 | 2065 | |
2066 | - if ( is_int( $note ) ) { |
|
2067 | - $note = get_comment( $note ); |
|
2066 | + if (is_int($note)) { |
|
2067 | + $note = get_comment($note); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2070 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2071 | 2071 | return NULL; |
2072 | 2072 | } |
2073 | 2073 | |
2074 | - $note_classes = array( 'note' ); |
|
2075 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2074 | + $note_classes = array('note'); |
|
2075 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2076 | 2076 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2077 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2078 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2077 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2078 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2079 | 2079 | |
2080 | 2080 | ob_start(); |
2081 | 2081 | ?> |
2082 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2082 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2083 | 2083 | <div class="note_content"> |
2084 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2084 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2085 | 2085 | </div> |
2086 | 2086 | <p class="meta"> |
2087 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2088 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
2089 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2087 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2088 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
2089 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2090 | 2090 | <?php } ?> |
2091 | 2091 | </p> |
2092 | 2092 | </li> |
2093 | 2093 | <?php |
2094 | 2094 | $note_content = ob_get_clean(); |
2095 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2095 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2096 | 2096 | |
2097 | - if ( $echo ) { |
|
2097 | + if ($echo) { |
|
2098 | 2098 | echo $note_content; |
2099 | 2099 | } else { |
2100 | 2100 | return $note_content; |
@@ -2104,43 +2104,43 @@ discard block |
||
2104 | 2104 | function wpinv_invalid_invoice_content() { |
2105 | 2105 | global $post; |
2106 | 2106 | |
2107 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2107 | + $invoice = wpinv_get_invoice($post->ID); |
|
2108 | 2108 | |
2109 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2110 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2111 | - if ( is_user_logged_in() ) { |
|
2112 | - if ( wpinv_require_login_to_checkout() ) { |
|
2113 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2114 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2109 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2110 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2111 | + if (is_user_logged_in()) { |
|
2112 | + if (wpinv_require_login_to_checkout()) { |
|
2113 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2114 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2115 | 2115 | } |
2116 | 2116 | } |
2117 | 2117 | } else { |
2118 | - if ( wpinv_require_login_to_checkout() ) { |
|
2119 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2120 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2118 | + if (wpinv_require_login_to_checkout()) { |
|
2119 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2120 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2121 | 2121 | } |
2122 | 2122 | } |
2123 | 2123 | } |
2124 | 2124 | } else { |
2125 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2125 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2126 | 2126 | } |
2127 | 2127 | ?> |
2128 | 2128 | <div class="row wpinv-row-invalid"> |
2129 | 2129 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2130 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2130 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2131 | 2131 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2132 | 2132 | </div> |
2133 | 2133 | </div> |
2134 | 2134 | <?php |
2135 | 2135 | } |
2136 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2136 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2137 | 2137 | |
2138 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2139 | -function wpinv_force_company_name_field(){ |
|
2138 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2139 | +function wpinv_force_company_name_field() { |
|
2140 | 2140 | $invoice = wpinv_get_invoice_cart(); |
2141 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
2142 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
2143 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
2141 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
2142 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
2143 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
2144 | 2144 | ?> |
2145 | 2145 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
2146 | 2146 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | <tbody> |
32 | 32 | <?php foreach ( $user_invoices->invoices as $invoice ) { |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
35 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
36 | 36 | <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | |
54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
55 | 55 | <?php |
56 | - $actions = array( |
|
57 | - 'pay' => array( |
|
58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
56 | + $actions = array( |
|
57 | + 'pay' => array( |
|
58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
60 | 60 | 'class' => 'btn-success' |
61 | - ), |
|
61 | + ), |
|
62 | 62 | 'print' => array( |
63 | - 'url' => $invoice->get_view_url(), |
|
64 | - 'name' => __( 'Print', 'invoicing' ), |
|
63 | + 'url' => $invoice->get_view_url(), |
|
64 | + 'name' => __( 'Print', 'invoicing' ), |
|
65 | 65 | 'class' => 'btn-primary', |
66 | 66 | 'attrs' => 'target="_blank"' |
67 | - ) |
|
68 | - ); |
|
67 | + ) |
|
68 | + ); |
|
69 | 69 | |
70 | - if ( ! $invoice->needs_payment() ) { |
|
71 | - unset( $actions['pay'] ); |
|
72 | - } |
|
70 | + if ( ! $invoice->needs_payment() ) { |
|
71 | + unset( $actions['pay'] ); |
|
72 | + } |
|
73 | 73 | |
74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | - foreach ( $actions as $key => $action ) { |
|
76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | + foreach ( $actions as $key => $action ) { |
|
76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
77 | 77 | echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
78 | - } |
|
79 | - } |
|
80 | - ?> |
|
78 | + } |
|
79 | + } |
|
80 | + ?> |
|
81 | 81 | <?php endif; ?> |
82 | 82 | </td> |
83 | 83 | <?php endforeach; ?> |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
92 | 92 | <div class="invoicing-Pagination"> |
93 | 93 | <?php |
94 | - $big = 999999; |
|
95 | - |
|
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
102 | - |
|
103 | - echo paginate_links( array( |
|
104 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | - 'format' => '?paged=%#%', |
|
106 | - 'current' => max( 1, $current_page ), |
|
107 | - 'total' => $user_invoices->max_num_pages, |
|
108 | - ) ); |
|
109 | - ?> |
|
94 | + $big = 999999; |
|
95 | + |
|
96 | + if (get_query_var('paged')) |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + elseif (get_query_var('page')) |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + else |
|
101 | + $current_page = 1; |
|
102 | + |
|
103 | + echo paginate_links( array( |
|
104 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | + 'format' => '?paged=%#%', |
|
106 | + 'current' => max( 1, $current_page ), |
|
107 | + 'total' => $user_invoices->max_num_pages, |
|
108 | + ) ); |
|
109 | + ?> |
|
110 | 110 | </div> |
111 | 111 | <?php endif; ?> |
112 | 112 |
@@ -93,12 +93,13 @@ |
||
93 | 93 | <?php |
94 | 94 | $big = 999999; |
95 | 95 | |
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
96 | + if (get_query_var('paged')) { |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + } elseif (get_query_var('page')) { |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + } else { |
|
101 | + $current_page = 1; |
|
102 | + } |
|
102 | 103 | |
103 | 104 | echo paginate_links( array( |
104 | 105 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
@@ -1,83 +1,83 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | -if ( !( $user_id = get_current_user_id() ) ) { |
|
6 | +if (!($user_id = get_current_user_id())) { |
|
7 | 7 | ?> |
8 | - <div class="wpinv-empty alert alert-error"><?php _e( 'You are not allowed to access this section', 'invoicing' ) ;?></div> |
|
8 | + <div class="wpinv-empty alert alert-error"><?php _e('You are not allowed to access this section', 'invoicing'); ?></div> |
|
9 | 9 | <?php |
10 | 10 | return; |
11 | 11 | } |
12 | 12 | |
13 | 13 | global $current_page; |
14 | -$current_page = empty( $current_page ) ? 1 : absint( $current_page ); |
|
15 | -$query = apply_filters( 'wpinv_user_invoices_query', array( 'user' => $user_id, 'page' => $current_page, 'paginate' => true, 'orderby' => 'invoice_date' ) ); |
|
16 | -$user_invoices = wpinv_get_invoices( $query ); |
|
14 | +$current_page = empty($current_page) ? 1 : absint($current_page); |
|
15 | +$query = apply_filters('wpinv_user_invoices_query', array('user' => $user_id, 'page' => $current_page, 'paginate' => true, 'orderby' => 'invoice_date')); |
|
16 | +$user_invoices = wpinv_get_invoices($query); |
|
17 | 17 | $has_invoices = 0 < $user_invoices->total; |
18 | 18 | |
19 | -do_action( 'wpinv_before_user_invoices', $has_invoices ); ?> |
|
19 | +do_action('wpinv_before_user_invoices', $has_invoices); ?> |
|
20 | 20 | |
21 | -<?php if ( $has_invoices ) { ?> |
|
21 | +<?php if ($has_invoices) { ?> |
|
22 | 22 | <table class="table table-bordered table-hover table-responsive wpi-user-invoices"> |
23 | 23 | <thead> |
24 | 24 | <tr> |
25 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
26 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
25 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
26 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
27 | 27 | <?php endforeach; ?> |
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | |
31 | 31 | <tbody> |
32 | - <?php foreach ( $user_invoices->invoices as $invoice ) { |
|
32 | + <?php foreach ($user_invoices->invoices as $invoice) { |
|
33 | 33 | ?> |
34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
35 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
36 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
37 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
38 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
39 | - |
|
40 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
41 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
42 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
35 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
36 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
37 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
38 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
39 | + |
|
40 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
41 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
42 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
43 | 43 | </a> |
44 | 44 | |
45 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
46 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
45 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
46 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
47 | 47 | |
48 | - <?php elseif ( '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 ); ?> |
|
49 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
48 | + <?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); ?> |
|
49 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
50 | 50 | |
51 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
52 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
51 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
52 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
53 | 53 | |
54 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
55 | - <?php echo $invoice->get_total( true ); ?> |
|
54 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
55 | + <?php echo $invoice->get_total(true); ?> |
|
56 | 56 | |
57 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
57 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
58 | 58 | <?php |
59 | 59 | $actions = array( |
60 | 60 | 'pay' => array( |
61 | 61 | 'url' => $invoice->get_checkout_payment_url(), |
62 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
62 | + 'name' => __('Pay Now', 'invoicing'), |
|
63 | 63 | 'class' => 'btn-success' |
64 | 64 | ), |
65 | 65 | 'print' => array( |
66 | 66 | 'url' => $invoice->get_view_url(), |
67 | - 'name' => __( 'Print', 'invoicing' ), |
|
67 | + 'name' => __('Print', 'invoicing'), |
|
68 | 68 | 'class' => 'btn-primary', |
69 | 69 | 'attrs' => 'target="_blank"' |
70 | 70 | ) |
71 | 71 | ); |
72 | 72 | |
73 | - if ( ! $invoice->needs_payment() ) { |
|
74 | - unset( $actions['pay'] ); |
|
73 | + if (!$invoice->needs_payment()) { |
|
74 | + unset($actions['pay']); |
|
75 | 75 | } |
76 | 76 | |
77 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
78 | - foreach ( $actions as $key => $action ) { |
|
77 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
78 | + foreach ($actions as $key => $action) { |
|
79 | 79 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
80 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
80 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | ?> |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | </tbody> |
90 | 90 | </table> |
91 | 91 | |
92 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
92 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
93 | 93 | |
94 | - <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
|
94 | + <?php if (1 < $user_invoices->max_num_pages) : ?> |
|
95 | 95 | <div class="invoicing-Pagination"> |
96 | 96 | <?php |
97 | 97 | $big = 999999; |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | else |
104 | 104 | $current_page = 1; |
105 | 105 | |
106 | - echo paginate_links( array( |
|
107 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
106 | + echo paginate_links(array( |
|
107 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
108 | 108 | 'format' => '?paged=%#%', |
109 | - 'current' => max( 1, $current_page ), |
|
109 | + 'current' => max(1, $current_page), |
|
110 | 110 | 'total' => $user_invoices->max_num_pages, |
111 | - ) ); |
|
111 | + )); |
|
112 | 112 | ?> |
113 | 113 | </div> |
114 | 114 | <?php endif; ?> |
115 | 115 | |
116 | 116 | <?php } else { ?> |
117 | 117 | <div class="wpinv-empty alert-info"> |
118 | - <?php _e( 'No invoice has been made yet.', 'invoicing' ); ?> |
|
118 | + <?php _e('No invoice has been made yet.', 'invoicing'); ?> |
|
119 | 119 | </div> |
120 | 120 | <?php } ?> |
121 | 121 | |
122 | -<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?> |
|
122 | +<?php do_action('wpinv_after_user_invoices', $has_invoices); ?> |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
6 | 6 | <html <?php language_attributes(); ?>> |
7 | 7 | <head> |
8 | 8 | <meta charset="UTF-8"> |
9 | 9 | <title><?php wp_title() ?></title> |
10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
12 | 12 | <meta name="robots" content="noindex,nofollow"> |
13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
14 | 14 | </head> |
15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
17 | 17 | <div class="container wpinv-wrap"> |
18 | 18 | <!-- ///// Start Header --> |
19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
21 | 21 | <div class="row wpinv-header"> |
22 | 22 | <div class="col-xs-12 wpinv-business"> |
23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
26 | 26 | <?php } else { ?> |
27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php } ?> |
29 | 29 | </a> |
30 | 30 | </div> |
31 | 31 | </div> |
32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
33 | 33 | </htmlpageheader> |
34 | 34 | <!-- End Header ///// --> |
35 | 35 | |
36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
37 | 37 | |
38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
39 | 39 | |
40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
41 | 41 | |
42 | 42 | <!-- ///// Start Footer --> |
43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
45 | 45 | <div class="row wpinv-footer"> |
46 | 46 | <div class="col-sm-12"> |
47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
51 | 51 | </htmlpagefooter> |
52 | 52 | <!-- End Footer ///// --> |
53 | 53 | </div> |
54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
55 | 55 | </body> |
56 | 56 | </html> |
57 | 57 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | /** |
6 | 8 | * The Subscriptions DB Class |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * The Subscriptions DB Class |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | 'transaction_id' => '', |
69 | 69 | 'parent_payment_id' => 0, |
70 | 70 | 'product_id' => 0, |
71 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
72 | - 'expiration' => date( 'Y-m-d H:i:s' ), |
|
71 | + 'created' => date('Y-m-d H:i:s'), |
|
72 | + 'expiration' => date('Y-m-d H:i:s'), |
|
73 | 73 | 'trial_period' => '', |
74 | 74 | 'status' => '', |
75 | 75 | 'profile_id' => '', |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * @access public |
83 | 83 | * @since 1.0.0 |
84 | 84 | */ |
85 | - public function get_subscriptions( $args = array() ) { |
|
85 | + public function get_subscriptions($args = array()) { |
|
86 | 86 | global $wpdb; |
87 | 87 | |
88 | 88 | $defaults = array( |
89 | - 'number' => get_option( 'posts_per_page' ), |
|
89 | + 'number' => get_option('posts_per_page'), |
|
90 | 90 | 'offset' => 0, |
91 | 91 | 'search' => '', |
92 | 92 | 'customer_id' => 0, |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | 'order' => 'DESC' |
95 | 95 | ); |
96 | 96 | |
97 | - $args = wp_parse_args( $args, $defaults ); |
|
97 | + $args = wp_parse_args($args, $defaults); |
|
98 | 98 | |
99 | - if( $args['number'] < 1 ) { |
|
99 | + if ($args['number'] < 1) { |
|
100 | 100 | $args['number'] = 999999999999; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $where = ' WHERE 1=1 '; |
104 | 104 | |
105 | 105 | // specific customers |
106 | - if( ! empty( $args['id'] ) ) { |
|
106 | + if (!empty($args['id'])) { |
|
107 | 107 | |
108 | - if( is_array( $args['id'] ) ) { |
|
109 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
108 | + if (is_array($args['id'])) { |
|
109 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
110 | 110 | } else { |
111 | - $ids = intval( $args['id'] ); |
|
111 | + $ids = intval($args['id']); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | // Specific products |
119 | - if( ! empty( $args['product_id'] ) ) { |
|
119 | + if (!empty($args['product_id'])) { |
|
120 | 120 | |
121 | - if( is_array( $args['product_id'] ) ) { |
|
122 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
121 | + if (is_array($args['product_id'])) { |
|
122 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
123 | 123 | } else { |
124 | - $product_ids = intval( $args['product_id'] ); |
|
124 | + $product_ids = intval($args['product_id']); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | // Specific parent payments |
132 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
132 | + if (!empty($args['parent_payment_id'])) { |
|
133 | 133 | |
134 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
135 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
134 | + if (is_array($args['parent_payment_id'])) { |
|
135 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
136 | 136 | } else { |
137 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
137 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | // Specific transaction IDs |
145 | - if( ! empty( $args['transaction_id'] ) ) { |
|
145 | + if (!empty($args['transaction_id'])) { |
|
146 | 146 | |
147 | - if( is_array( $args['transaction_id'] ) ) { |
|
148 | - $transaction_ids = implode( "','", array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
147 | + if (is_array($args['transaction_id'])) { |
|
148 | + $transaction_ids = implode("','", array_map('sanitize_text_field', $args['transaction_id'])); |
|
149 | 149 | } else { |
150 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
150 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $where .= " AND `transaction_id` IN ( '{$transaction_ids}' ) "; |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Subscriptoins for specific customers |
158 | - if( ! empty( $args['customer_id'] ) ) { |
|
158 | + if (!empty($args['customer_id'])) { |
|
159 | 159 | |
160 | - if( is_array( $args['customer_id'] ) ) { |
|
161 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
160 | + if (is_array($args['customer_id'])) { |
|
161 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
162 | 162 | } else { |
163 | - $customer_ids = intval( $args['customer_id'] ); |
|
163 | + $customer_ids = intval($args['customer_id']); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | // Subscriptions for specific profile IDs |
171 | - if( ! empty( $args['profile_id'] ) ) { |
|
171 | + if (!empty($args['profile_id'])) { |
|
172 | 172 | |
173 | - if( is_array( $args['profile_id'] ) ) { |
|
174 | - $profile_ids = implode( "','", array_map('sanitize_text_field', $args['profile_id'] ) ); |
|
173 | + if (is_array($args['profile_id'])) { |
|
174 | + $profile_ids = implode("','", array_map('sanitize_text_field', $args['profile_id'])); |
|
175 | 175 | } else { |
176 | - $profile_ids = sanitize_text_field( $args['profile_id'] ); |
|
176 | + $profile_ids = sanitize_text_field($args['profile_id']); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $where .= " AND `profile_id` IN( '{$profile_ids}' ) "; |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | // Subscriptions for specific statuses |
184 | - if( ! empty( $args['status'] ) ) { |
|
184 | + if (!empty($args['status'])) { |
|
185 | 185 | |
186 | - if( is_array( $args['status'] ) ) { |
|
187 | - $statuses = implode( "','", array_map( 'sanitize_text_field', $args['status'] ) ); |
|
186 | + if (is_array($args['status'])) { |
|
187 | + $statuses = implode("','", array_map('sanitize_text_field', $args['status'])); |
|
188 | 188 | } else { |
189 | - $statuses = sanitize_text_field( $args['status'] ); |
|
189 | + $statuses = sanitize_text_field($args['status']); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $where .= " AND `status` IN( '{$statuses}' ) "; |
@@ -194,21 +194,21 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | // Subscriptions created for a specific date or in a date range |
197 | - if( ! empty( $args['date'] ) ) { |
|
197 | + if (!empty($args['date'])) { |
|
198 | 198 | |
199 | - if( is_array( $args['date'] ) ) { |
|
199 | + if (is_array($args['date'])) { |
|
200 | 200 | |
201 | - if( ! empty( $args['date']['start'] ) ) { |
|
201 | + if (!empty($args['date']['start'])) { |
|
202 | 202 | |
203 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
203 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
204 | 204 | |
205 | 205 | $where .= " AND `created` >= '{$start}'"; |
206 | 206 | |
207 | 207 | } |
208 | 208 | |
209 | - if( ! empty( $args['date']['end'] ) ) { |
|
209 | + if (!empty($args['date']['end'])) { |
|
210 | 210 | |
211 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
211 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
212 | 212 | |
213 | 213 | $where .= " AND `created` <= '{$end}'"; |
214 | 214 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | } else { |
218 | 218 | |
219 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
220 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
221 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
219 | + $year = date('Y', strtotime($args['date'])); |
|
220 | + $month = date('m', strtotime($args['date'])); |
|
221 | + $day = date('d', strtotime($args['date'])); |
|
222 | 222 | |
223 | 223 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
224 | 224 | } |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | // Subscriptions with a specific expiration date or in an expiration date range |
229 | - if( ! empty( $args['expiration'] ) ) { |
|
229 | + if (!empty($args['expiration'])) { |
|
230 | 230 | |
231 | - if( is_array( $args['expiration'] ) ) { |
|
231 | + if (is_array($args['expiration'])) { |
|
232 | 232 | |
233 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
233 | + if (!empty($args['expiration']['start'])) { |
|
234 | 234 | |
235 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
235 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
236 | 236 | |
237 | 237 | $where .= " AND `expiration` >= '{$start}'"; |
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
241 | + if (!empty($args['expiration']['end'])) { |
|
242 | 242 | |
243 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
243 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
244 | 244 | |
245 | 245 | $where .= " AND `expiration` <= '{$end}'"; |
246 | 246 | |
@@ -248,73 +248,73 @@ discard block |
||
248 | 248 | |
249 | 249 | } else { |
250 | 250 | |
251 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
252 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
253 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
251 | + $year = date('Y', strtotime($args['expiration'])); |
|
252 | + $month = date('m', strtotime($args['expiration'])); |
|
253 | + $day = date('d', strtotime($args['expiration'])); |
|
254 | 254 | |
255 | 255 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! empty( $args['search'] ) ) { |
|
260 | + if (!empty($args['search'])) { |
|
261 | 261 | |
262 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
262 | + if (false !== strpos('id:', $args['search'])) { |
|
263 | 263 | |
264 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
265 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
264 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
265 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
266 | 266 | |
267 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
267 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
268 | 268 | |
269 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
270 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
269 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
270 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
271 | 271 | |
272 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
272 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
273 | 273 | |
274 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
275 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
274 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
275 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
276 | 276 | |
277 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
277 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
278 | 278 | |
279 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
280 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
279 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
280 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
281 | 281 | |
282 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
282 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
283 | 283 | |
284 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
285 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
284 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
285 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
286 | 286 | |
287 | 287 | } else { |
288 | 288 | |
289 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
289 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
295 | + $args['orderby'] = !array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
296 | 296 | |
297 | - if( 'amount' == $args['orderby'] ) { |
|
297 | + if ('amount' == $args['orderby']) { |
|
298 | 298 | $args['orderby'] = 'amount+0'; |
299 | 299 | } |
300 | 300 | |
301 | - $cache_key = md5( 'wpinv_subscriptions_' . serialize( $args ) ); |
|
301 | + $cache_key = md5('wpinv_subscriptions_' . serialize($args)); |
|
302 | 302 | |
303 | - $subscriptions = wp_cache_get( $cache_key, 'subscriptions' ); |
|
303 | + $subscriptions = wp_cache_get($cache_key, 'subscriptions'); |
|
304 | 304 | |
305 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
306 | - $args['order'] = esc_sql( $args['order'] ); |
|
305 | + $args['orderby'] = esc_sql($args['orderby']); |
|
306 | + $args['order'] = esc_sql($args['order']); |
|
307 | 307 | |
308 | - if( $subscriptions === false ) { |
|
309 | - $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ), OBJECT ); |
|
308 | + if ($subscriptions === false) { |
|
309 | + $subscriptions = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])), OBJECT); |
|
310 | 310 | |
311 | - if( ! empty( $subscriptions ) ) { |
|
311 | + if (!empty($subscriptions)) { |
|
312 | 312 | |
313 | - foreach( $subscriptions as $key => $subscription ) { |
|
314 | - $subscriptions[ $key ] = new WPInv_Subscription( $subscription ); |
|
313 | + foreach ($subscriptions as $key => $subscription) { |
|
314 | + $subscriptions[$key] = new WPInv_Subscription($subscription); |
|
315 | 315 | } |
316 | 316 | |
317 | - wp_cache_set( $cache_key, $subscriptions, 'subscriptions', 3600 ); |
|
317 | + wp_cache_set($cache_key, $subscriptions, 'subscriptions', 3600); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -329,19 +329,19 @@ discard block |
||
329 | 329 | * @access public |
330 | 330 | * @since 1.0.0 |
331 | 331 | */ |
332 | - public function count( $args = array() ) { |
|
332 | + public function count($args = array()) { |
|
333 | 333 | |
334 | 334 | global $wpdb; |
335 | 335 | |
336 | 336 | $where = ' WHERE 1=1 '; |
337 | 337 | |
338 | 338 | // specific customers |
339 | - if( ! empty( $args['id'] ) ) { |
|
339 | + if (!empty($args['id'])) { |
|
340 | 340 | |
341 | - if( is_array( $args['id'] ) ) { |
|
342 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
341 | + if (is_array($args['id'])) { |
|
342 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
343 | 343 | } else { |
344 | - $ids = intval( $args['id'] ); |
|
344 | + $ids = intval($args['id']); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | } |
350 | 350 | |
351 | 351 | // Specific products |
352 | - if( ! empty( $args['product_id'] ) ) { |
|
352 | + if (!empty($args['product_id'])) { |
|
353 | 353 | |
354 | - if( is_array( $args['product_id'] ) ) { |
|
355 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
354 | + if (is_array($args['product_id'])) { |
|
355 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
356 | 356 | } else { |
357 | - $product_ids = intval( $args['product_id'] ); |
|
357 | + $product_ids = intval($args['product_id']); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | // Specific parent payments |
365 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
365 | + if (!empty($args['parent_payment_id'])) { |
|
366 | 366 | |
367 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
368 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
367 | + if (is_array($args['parent_payment_id'])) { |
|
368 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
369 | 369 | } else { |
370 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
370 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | // Subscriptoins for specific customers |
378 | - if( ! empty( $args['customer_id'] ) ) { |
|
378 | + if (!empty($args['customer_id'])) { |
|
379 | 379 | |
380 | - if( is_array( $args['customer_id'] ) ) { |
|
381 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
380 | + if (is_array($args['customer_id'])) { |
|
381 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
382 | 382 | } else { |
383 | - $customer_ids = intval( $args['customer_id'] ); |
|
383 | + $customer_ids = intval($args['customer_id']); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | // Subscriptions for specific profile IDs |
391 | - if( ! empty( $args['profile_id'] ) ) { |
|
391 | + if (!empty($args['profile_id'])) { |
|
392 | 392 | |
393 | - if( is_array( $args['profile_id'] ) ) { |
|
394 | - $profile_ids = implode( ',', array_map('intval', $args['profile_id'] ) ); |
|
393 | + if (is_array($args['profile_id'])) { |
|
394 | + $profile_ids = implode(',', array_map('intval', $args['profile_id'])); |
|
395 | 395 | } else { |
396 | - $profile_ids = intval( $args['profile_id'] ); |
|
396 | + $profile_ids = intval($args['profile_id']); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | $where .= " AND `profile_id` IN( {$profile_ids} ) "; |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | // Specific transaction IDs |
404 | - if( ! empty( $args['transaction_id'] ) ) { |
|
404 | + if (!empty($args['transaction_id'])) { |
|
405 | 405 | |
406 | - if( is_array( $args['transaction_id'] ) ) { |
|
407 | - $transaction_ids = implode( ',', array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
406 | + if (is_array($args['transaction_id'])) { |
|
407 | + $transaction_ids = implode(',', array_map('sanitize_text_field', $args['transaction_id'])); |
|
408 | 408 | } else { |
409 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
409 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | $where .= " AND `transaction_id` IN( {$transaction_ids} ) "; |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | // Subscriptions for specific statuses |
417 | - if( ! empty( $args['status'] ) ) { |
|
417 | + if (!empty($args['status'])) { |
|
418 | 418 | |
419 | - if( is_array( $args['status'] ) ) { |
|
420 | - $statuses = implode( ',', $args['status'] ); |
|
419 | + if (is_array($args['status'])) { |
|
420 | + $statuses = implode(',', $args['status']); |
|
421 | 421 | $where .= " AND `status` IN( {$statuses} ) "; |
422 | 422 | } else { |
423 | 423 | $statuses = $args['status']; |
@@ -429,21 +429,21 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | // Subscriptions created for a specific date or in a date range |
432 | - if( ! empty( $args['date'] ) ) { |
|
432 | + if (!empty($args['date'])) { |
|
433 | 433 | |
434 | - if( is_array( $args['date'] ) ) { |
|
434 | + if (is_array($args['date'])) { |
|
435 | 435 | |
436 | - if( ! empty( $args['date']['start'] ) ) { |
|
436 | + if (!empty($args['date']['start'])) { |
|
437 | 437 | |
438 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
438 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
439 | 439 | |
440 | 440 | $where .= " AND `created` >= '{$start}'"; |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | - if( ! empty( $args['date']['end'] ) ) { |
|
444 | + if (!empty($args['date']['end'])) { |
|
445 | 445 | |
446 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
446 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
447 | 447 | |
448 | 448 | $where .= " AND `created` <= '{$end}'"; |
449 | 449 | |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | |
452 | 452 | } else { |
453 | 453 | |
454 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
455 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
456 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
454 | + $year = date('Y', strtotime($args['date'])); |
|
455 | + $month = date('m', strtotime($args['date'])); |
|
456 | + $day = date('d', strtotime($args['date'])); |
|
457 | 457 | |
458 | 458 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
459 | 459 | } |
@@ -461,21 +461,21 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | // Subscriptions with a specific expiration date or in an expiration date range |
464 | - if( ! empty( $args['expiration'] ) ) { |
|
464 | + if (!empty($args['expiration'])) { |
|
465 | 465 | |
466 | - if( is_array( $args['expiration'] ) ) { |
|
466 | + if (is_array($args['expiration'])) { |
|
467 | 467 | |
468 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
468 | + if (!empty($args['expiration']['start'])) { |
|
469 | 469 | |
470 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
470 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
471 | 471 | |
472 | 472 | $where .= " AND `expiration` >= '{$start}'"; |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
476 | + if (!empty($args['expiration']['end'])) { |
|
477 | 477 | |
478 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
478 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
479 | 479 | |
480 | 480 | $where .= " AND `expiration` <= '{$end}'"; |
481 | 481 | |
@@ -483,64 +483,64 @@ discard block |
||
483 | 483 | |
484 | 484 | } else { |
485 | 485 | |
486 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
487 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
488 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
486 | + $year = date('Y', strtotime($args['expiration'])); |
|
487 | + $month = date('m', strtotime($args['expiration'])); |
|
488 | + $day = date('d', strtotime($args['expiration'])); |
|
489 | 489 | |
490 | 490 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | - if ( ! empty( $args['search'] ) ) { |
|
495 | + if (!empty($args['search'])) { |
|
496 | 496 | |
497 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
497 | + if (false !== strpos('id:', $args['search'])) { |
|
498 | 498 | |
499 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
500 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
499 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
500 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
501 | 501 | |
502 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
502 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
503 | 503 | |
504 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
505 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
504 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
505 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
506 | 506 | |
507 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
507 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
508 | 508 | |
509 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
510 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
509 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
510 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
511 | 511 | |
512 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
512 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
513 | 513 | |
514 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
515 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
514 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
515 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
516 | 516 | |
517 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
517 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
518 | 518 | |
519 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
520 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
519 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
520 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
521 | 521 | |
522 | 522 | } else { |
523 | 523 | |
524 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
524 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
525 | 525 | |
526 | 526 | } |
527 | 527 | |
528 | 528 | } |
529 | 529 | |
530 | - $cache_key = md5( 'wpinv_subscriptions_count' . serialize( $args ) ); |
|
530 | + $cache_key = md5('wpinv_subscriptions_count' . serialize($args)); |
|
531 | 531 | |
532 | - $count = wp_cache_get( $cache_key, 'subscriptions' ); |
|
532 | + $count = wp_cache_get($cache_key, 'subscriptions'); |
|
533 | 533 | |
534 | - if( $count === false ) { |
|
534 | + if ($count === false) { |
|
535 | 535 | |
536 | 536 | $sql = "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};"; |
537 | - $count = $wpdb->get_var( $sql ); |
|
537 | + $count = $wpdb->get_var($sql); |
|
538 | 538 | |
539 | - wp_cache_set( $cache_key, $count, 'subscriptions', 3600 ); |
|
539 | + wp_cache_set($cache_key, $count, 'subscriptions', 3600); |
|
540 | 540 | |
541 | 541 | } |
542 | 542 | |
543 | - return absint( $count ); |
|
543 | + return absint($count); |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | public function create_table() { |
554 | 554 | global $wpdb; |
555 | 555 | |
556 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
556 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
557 | 557 | |
558 | 558 | $sql = "CREATE TABLE " . $this->table_name . " ( |
559 | 559 | id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | KEY customer_and_status ( customer_id, status) |
579 | 579 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
580 | 580 | |
581 | - dbDelta( $sql ); |
|
581 | + dbDelta($sql); |
|
582 | 582 | |
583 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
583 | + update_option($this->table_name . '_db_version', $this->version); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | } |
587 | 587 | \ No newline at end of file |
@@ -5,237 +5,237 @@ |
||
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
8 | - /** |
|
9 | - * The name of our database table |
|
10 | - * |
|
11 | - * @access public |
|
12 | - * @since 1.0.0 |
|
13 | - */ |
|
14 | - public $table_name; |
|
15 | - |
|
16 | - /** |
|
17 | - * The version of our database table |
|
18 | - * |
|
19 | - * @access public |
|
20 | - * @since 1.0.0 |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * The name of the primary column |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @since 1.0.0 |
|
29 | - */ |
|
30 | - public $primary_key; |
|
31 | - |
|
32 | - /** |
|
33 | - * Get things started |
|
34 | - * |
|
35 | - * @access public |
|
36 | - * @since 1.0.0 |
|
37 | - */ |
|
38 | - public function __construct() {} |
|
39 | - |
|
40 | - /** |
|
41 | - * Whitelist of columns |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 1.0.0 |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function get_columns() { |
|
48 | - return array(); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Default column values |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @since 1.0.0 |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function get_column_defaults() { |
|
59 | - return array(); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Retrieve a row by the primary key |
|
64 | - * |
|
65 | - * @access public |
|
66 | - * @since 1.0.0 |
|
67 | - * @return object |
|
68 | - */ |
|
69 | - public function get( $row_id ) { |
|
70 | - global $wpdb; |
|
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Retrieve a row by a specific column / value |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @since 1.0.0 |
|
79 | - * @return object |
|
80 | - */ |
|
81 | - public function get_by( $column, $row_id ) { |
|
82 | - global $wpdb; |
|
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Retrieve a specific column's value by the primary key |
|
89 | - * |
|
90 | - * @access public |
|
91 | - * @since 1.0.0 |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function get_column( $column, $row_id ) { |
|
95 | - global $wpdb; |
|
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Retrieve a specific column's value by the the specified column / value |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @since 1.0.0 |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | - global $wpdb; |
|
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Insert a new row |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @since 1.0.0 |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function insert( $data, $type = '' ) { |
|
122 | - global $wpdb; |
|
123 | - |
|
124 | - // Set default values |
|
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | - |
|
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | - |
|
129 | - // Initialise column format array |
|
130 | - $column_formats = $this->get_columns(); |
|
131 | - |
|
132 | - // Force fields to lower case |
|
133 | - $data = array_change_key_case( $data ); |
|
134 | - |
|
135 | - // White list columns |
|
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
137 | - |
|
138 | - // Reorder $column_formats to match the order of columns given in $data |
|
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | - |
|
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | - $wpdb_insert_id = $wpdb->insert_id; |
|
144 | - |
|
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | - |
|
147 | - return $wpdb_insert_id; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Update a row |
|
152 | - * |
|
153 | - * @access public |
|
154 | - * @since 1.0.0 |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | - |
|
159 | - global $wpdb; |
|
160 | - |
|
161 | - // Row ID must be positive integer |
|
162 | - $row_id = absint( $row_id ); |
|
163 | - |
|
164 | - if( empty( $row_id ) ) { |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - if( empty( $where ) ) { |
|
169 | - $where = $this->primary_key; |
|
170 | - } |
|
171 | - |
|
172 | - // Initialise column format array |
|
173 | - $column_formats = $this->get_columns(); |
|
174 | - |
|
175 | - // Force fields to lower case |
|
176 | - $data = array_change_key_case( $data ); |
|
177 | - |
|
178 | - // White list columns |
|
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
180 | - |
|
181 | - // Reorder $column_formats to match the order of columns given in $data |
|
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | - |
|
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | - return false; |
|
187 | - } |
|
188 | - |
|
189 | - return true; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Delete a row identified by the primary key |
|
194 | - * |
|
195 | - * @access public |
|
196 | - * @since 1.0.0 |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function delete( $row_id = 0 ) { |
|
200 | - |
|
201 | - global $wpdb; |
|
202 | - |
|
203 | - // Row ID must be positive integer |
|
204 | - $row_id = absint( $row_id ); |
|
205 | - |
|
206 | - if( empty( $row_id ) ) { |
|
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | - return false; |
|
212 | - } |
|
213 | - |
|
214 | - return true; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Check if the given table exists |
|
219 | - * |
|
220 | - * @since 2.4 |
|
221 | - * @param string $table The table name |
|
222 | - * @return bool If the table name exists |
|
223 | - */ |
|
224 | - public function table_exists( $table ) { |
|
225 | - global $wpdb; |
|
226 | - $table = sanitize_text_field( $table ); |
|
227 | - |
|
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Check if the table was ever installed |
|
233 | - * |
|
234 | - * @since 2.4 |
|
235 | - * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | - */ |
|
237 | - public function installed() { |
|
238 | - return $this->table_exists( $this->table_name ); |
|
239 | - } |
|
8 | + /** |
|
9 | + * The name of our database table |
|
10 | + * |
|
11 | + * @access public |
|
12 | + * @since 1.0.0 |
|
13 | + */ |
|
14 | + public $table_name; |
|
15 | + |
|
16 | + /** |
|
17 | + * The version of our database table |
|
18 | + * |
|
19 | + * @access public |
|
20 | + * @since 1.0.0 |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * The name of the primary column |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @since 1.0.0 |
|
29 | + */ |
|
30 | + public $primary_key; |
|
31 | + |
|
32 | + /** |
|
33 | + * Get things started |
|
34 | + * |
|
35 | + * @access public |
|
36 | + * @since 1.0.0 |
|
37 | + */ |
|
38 | + public function __construct() {} |
|
39 | + |
|
40 | + /** |
|
41 | + * Whitelist of columns |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 1.0.0 |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function get_columns() { |
|
48 | + return array(); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Default column values |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @since 1.0.0 |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function get_column_defaults() { |
|
59 | + return array(); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Retrieve a row by the primary key |
|
64 | + * |
|
65 | + * @access public |
|
66 | + * @since 1.0.0 |
|
67 | + * @return object |
|
68 | + */ |
|
69 | + public function get( $row_id ) { |
|
70 | + global $wpdb; |
|
71 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Retrieve a row by a specific column / value |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @since 1.0.0 |
|
79 | + * @return object |
|
80 | + */ |
|
81 | + public function get_by( $column, $row_id ) { |
|
82 | + global $wpdb; |
|
83 | + $column = esc_sql( $column ); |
|
84 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Retrieve a specific column's value by the primary key |
|
89 | + * |
|
90 | + * @access public |
|
91 | + * @since 1.0.0 |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function get_column( $column, $row_id ) { |
|
95 | + global $wpdb; |
|
96 | + $column = esc_sql( $column ); |
|
97 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Retrieve a specific column's value by the the specified column / value |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @since 1.0.0 |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | + global $wpdb; |
|
109 | + $column_where = esc_sql( $column_where ); |
|
110 | + $column = esc_sql( $column ); |
|
111 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Insert a new row |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @since 1.0.0 |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function insert( $data, $type = '' ) { |
|
122 | + global $wpdb; |
|
123 | + |
|
124 | + // Set default values |
|
125 | + $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | + |
|
127 | + do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | + |
|
129 | + // Initialise column format array |
|
130 | + $column_formats = $this->get_columns(); |
|
131 | + |
|
132 | + // Force fields to lower case |
|
133 | + $data = array_change_key_case( $data ); |
|
134 | + |
|
135 | + // White list columns |
|
136 | + $data = array_intersect_key( $data, $column_formats ); |
|
137 | + |
|
138 | + // Reorder $column_formats to match the order of columns given in $data |
|
139 | + $data_keys = array_keys( $data ); |
|
140 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | + |
|
142 | + $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | + $wpdb_insert_id = $wpdb->insert_id; |
|
144 | + |
|
145 | + do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | + |
|
147 | + return $wpdb_insert_id; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Update a row |
|
152 | + * |
|
153 | + * @access public |
|
154 | + * @since 1.0.0 |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | + |
|
159 | + global $wpdb; |
|
160 | + |
|
161 | + // Row ID must be positive integer |
|
162 | + $row_id = absint( $row_id ); |
|
163 | + |
|
164 | + if( empty( $row_id ) ) { |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + if( empty( $where ) ) { |
|
169 | + $where = $this->primary_key; |
|
170 | + } |
|
171 | + |
|
172 | + // Initialise column format array |
|
173 | + $column_formats = $this->get_columns(); |
|
174 | + |
|
175 | + // Force fields to lower case |
|
176 | + $data = array_change_key_case( $data ); |
|
177 | + |
|
178 | + // White list columns |
|
179 | + $data = array_intersect_key( $data, $column_formats ); |
|
180 | + |
|
181 | + // Reorder $column_formats to match the order of columns given in $data |
|
182 | + $data_keys = array_keys( $data ); |
|
183 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | + |
|
185 | + if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | + return false; |
|
187 | + } |
|
188 | + |
|
189 | + return true; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Delete a row identified by the primary key |
|
194 | + * |
|
195 | + * @access public |
|
196 | + * @since 1.0.0 |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function delete( $row_id = 0 ) { |
|
200 | + |
|
201 | + global $wpdb; |
|
202 | + |
|
203 | + // Row ID must be positive integer |
|
204 | + $row_id = absint( $row_id ); |
|
205 | + |
|
206 | + if( empty( $row_id ) ) { |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | + return false; |
|
212 | + } |
|
213 | + |
|
214 | + return true; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Check if the given table exists |
|
219 | + * |
|
220 | + * @since 2.4 |
|
221 | + * @param string $table The table name |
|
222 | + * @return bool If the table name exists |
|
223 | + */ |
|
224 | + public function table_exists( $table ) { |
|
225 | + global $wpdb; |
|
226 | + $table = sanitize_text_field( $table ); |
|
227 | + |
|
228 | + return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Check if the table was ever installed |
|
233 | + * |
|
234 | + * @since 2.4 |
|
235 | + * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | + */ |
|
237 | + public function installed() { |
|
238 | + return $this->table_exists( $this->table_name ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if (!defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | * @return object |
68 | 68 | */ |
69 | - public function get( $row_id ) { |
|
69 | + public function get($row_id) { |
|
70 | 70 | global $wpdb; |
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
71 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @since 1.0.0 |
79 | 79 | * @return object |
80 | 80 | */ |
81 | - public function get_by( $column, $row_id ) { |
|
81 | + public function get_by($column, $row_id) { |
|
82 | 82 | global $wpdb; |
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
83 | + $column = esc_sql($column); |
|
84 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @since 1.0.0 |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public function get_column( $column, $row_id ) { |
|
94 | + public function get_column($column, $row_id) { |
|
95 | 95 | global $wpdb; |
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
96 | + $column = esc_sql($column); |
|
97 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @since 1.0.0 |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
107 | + public function get_column_by($column, $column_where, $column_value) { |
|
108 | 108 | global $wpdb; |
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
109 | + $column_where = esc_sql($column_where); |
|
110 | + $column = esc_sql($column); |
|
111 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | * @since 1.0.0 |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - public function insert( $data, $type = '' ) { |
|
121 | + public function insert($data, $type = '') { |
|
122 | 122 | global $wpdb; |
123 | 123 | |
124 | 124 | // Set default values |
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
125 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
126 | 126 | |
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
127 | + do_action('wpinv_pre_insert_' . $type, $data); |
|
128 | 128 | |
129 | 129 | // Initialise column format array |
130 | 130 | $column_formats = $this->get_columns(); |
131 | 131 | |
132 | 132 | // Force fields to lower case |
133 | - $data = array_change_key_case( $data ); |
|
133 | + $data = array_change_key_case($data); |
|
134 | 134 | |
135 | 135 | // White list columns |
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
136 | + $data = array_intersect_key($data, $column_formats); |
|
137 | 137 | |
138 | 138 | // Reorder $column_formats to match the order of columns given in $data |
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
139 | + $data_keys = array_keys($data); |
|
140 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
141 | 141 | |
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
142 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
143 | 143 | $wpdb_insert_id = $wpdb->insert_id; |
144 | 144 | |
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
145 | + do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data); |
|
146 | 146 | |
147 | 147 | return $wpdb_insert_id; |
148 | 148 | } |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | * @since 1.0.0 |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
157 | + public function update($row_id, $data = array(), $where = '') { |
|
158 | 158 | |
159 | 159 | global $wpdb; |
160 | 160 | |
161 | 161 | // Row ID must be positive integer |
162 | - $row_id = absint( $row_id ); |
|
162 | + $row_id = absint($row_id); |
|
163 | 163 | |
164 | - if( empty( $row_id ) ) { |
|
164 | + if (empty($row_id)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if( empty( $where ) ) { |
|
168 | + if (empty($where)) { |
|
169 | 169 | $where = $this->primary_key; |
170 | 170 | } |
171 | 171 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $column_formats = $this->get_columns(); |
174 | 174 | |
175 | 175 | // Force fields to lower case |
176 | - $data = array_change_key_case( $data ); |
|
176 | + $data = array_change_key_case($data); |
|
177 | 177 | |
178 | 178 | // White list columns |
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
179 | + $data = array_intersect_key($data, $column_formats); |
|
180 | 180 | |
181 | 181 | // Reorder $column_formats to match the order of columns given in $data |
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
182 | + $data_keys = array_keys($data); |
|
183 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
184 | 184 | |
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
185 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @since 1.0.0 |
197 | 197 | * @return bool |
198 | 198 | */ |
199 | - public function delete( $row_id = 0 ) { |
|
199 | + public function delete($row_id = 0) { |
|
200 | 200 | |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | 203 | // Row ID must be positive integer |
204 | - $row_id = absint( $row_id ); |
|
204 | + $row_id = absint($row_id); |
|
205 | 205 | |
206 | - if( empty( $row_id ) ) { |
|
206 | + if (empty($row_id)) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
210 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @param string $table The table name |
222 | 222 | * @return bool If the table name exists |
223 | 223 | */ |
224 | - public function table_exists( $table ) { |
|
224 | + public function table_exists($table) { |
|
225 | 225 | global $wpdb; |
226 | - $table = sanitize_text_field( $table ); |
|
226 | + $table = sanitize_text_field($table); |
|
227 | 227 | |
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
228 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool Returns if the customers table was installed and upgrade routine run |
236 | 236 | */ |
237 | 237 | public function installed() { |
238 | - return $this->table_exists( $this->table_name ); |
|
238 | + return $this->table_exists($this->table_name); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | abstract class Wpinv_DB { |
7 | 9 |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
12 | + exit; |
|
13 | +} |
|
12 | 14 | |
13 | 15 | |
14 | 16 | // Load WP_List_Table if not loaded |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // Load WP_List_Table if not loaded |
15 | 15 | if( ! class_exists( 'WP_List_Table' ) ) { |
16 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
16 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -23,102 +23,102 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class WPInv_Subscription_Reports_Table extends WP_List_Table { |
25 | 25 | |
26 | - /** |
|
27 | - * Number of results to show per page |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - */ |
|
31 | - |
|
32 | - public $per_page = 20; |
|
33 | - public $total_count = 0; |
|
34 | - public $active_count = 0; |
|
35 | - public $pending_count = 0; |
|
36 | - public $expired_count = 0; |
|
37 | - public $completed_count = 0; |
|
38 | - public $trialling_count = 0; |
|
39 | - public $cancelled_count = 0; |
|
40 | - public $failing_count = 0; |
|
41 | - |
|
42 | - /** |
|
43 | - * Get things started |
|
44 | - * |
|
45 | - * @access private |
|
46 | - * @since 1.0.0 |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - function __construct(){ |
|
50 | - global $status, $page; |
|
51 | - |
|
52 | - // Set parent defaults |
|
53 | - parent::__construct( array( |
|
54 | - 'singular' => 'subscription', |
|
55 | - 'plural' => 'subscriptions', |
|
56 | - 'ajax' => false |
|
57 | - ) ); |
|
58 | - |
|
59 | - $this->get_subscription_counts(); |
|
60 | - |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Retrieve the view types |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @since 1.0.0 |
|
68 | - * @return array $views All the views available |
|
69 | - */ |
|
70 | - public function get_views() { |
|
71 | - |
|
72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | - $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
75 | - $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | - $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | - |
|
82 | - $views = array( |
|
83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
91 | - ); |
|
92 | - |
|
93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Show the search field |
|
98 | - * |
|
99 | - * @since 2.5 |
|
100 | - * @access public |
|
101 | - * |
|
102 | - * @param string $text Label for the search box |
|
103 | - * @param string $input_id ID of the search box |
|
104 | - * |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function search_box( $text, $input_id ) { |
|
108 | - |
|
109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
110 | - return; |
|
111 | - } |
|
112 | - |
|
113 | - $input_id = $input_id . '-search-input'; |
|
114 | - |
|
115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
117 | - } |
|
118 | - |
|
119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
121 | - } |
|
26 | + /** |
|
27 | + * Number of results to show per page |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + */ |
|
31 | + |
|
32 | + public $per_page = 20; |
|
33 | + public $total_count = 0; |
|
34 | + public $active_count = 0; |
|
35 | + public $pending_count = 0; |
|
36 | + public $expired_count = 0; |
|
37 | + public $completed_count = 0; |
|
38 | + public $trialling_count = 0; |
|
39 | + public $cancelled_count = 0; |
|
40 | + public $failing_count = 0; |
|
41 | + |
|
42 | + /** |
|
43 | + * Get things started |
|
44 | + * |
|
45 | + * @access private |
|
46 | + * @since 1.0.0 |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + function __construct(){ |
|
50 | + global $status, $page; |
|
51 | + |
|
52 | + // Set parent defaults |
|
53 | + parent::__construct( array( |
|
54 | + 'singular' => 'subscription', |
|
55 | + 'plural' => 'subscriptions', |
|
56 | + 'ajax' => false |
|
57 | + ) ); |
|
58 | + |
|
59 | + $this->get_subscription_counts(); |
|
60 | + |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Retrieve the view types |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @since 1.0.0 |
|
68 | + * @return array $views All the views available |
|
69 | + */ |
|
70 | + public function get_views() { |
|
71 | + |
|
72 | + $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | + $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
75 | + $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | + $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | + |
|
82 | + $views = array( |
|
83 | + 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | + 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | + 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | + 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | + 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | + 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | + 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | + 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
91 | + ); |
|
92 | + |
|
93 | + return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Show the search field |
|
98 | + * |
|
99 | + * @since 2.5 |
|
100 | + * @access public |
|
101 | + * |
|
102 | + * @param string $text Label for the search box |
|
103 | + * @param string $input_id ID of the search box |
|
104 | + * |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function search_box( $text, $input_id ) { |
|
108 | + |
|
109 | + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
110 | + return; |
|
111 | + } |
|
112 | + |
|
113 | + $input_id = $input_id . '-search-input'; |
|
114 | + |
|
115 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
117 | + } |
|
118 | + |
|
119 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
121 | + } |
|
122 | 122 | ?> |
123 | 123 | <p class="search-box"> |
124 | 124 | <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
128 | 128 | </p> |
129 | 129 | <?php |
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Render most columns |
|
134 | - * |
|
135 | - * @access private |
|
136 | - * @since 1.0.0 |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - function column_default( $item, $column_name ) { |
|
140 | - return $item->$column_name; |
|
141 | - } |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Render most columns |
|
134 | + * |
|
135 | + * @access private |
|
136 | + * @since 1.0.0 |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + function column_default( $item, $column_name ) { |
|
140 | + return $item->$column_name; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Subscription id column |
@@ -151,244 +151,244 @@ discard block |
||
151 | 151 | return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Customer column |
|
156 | - * |
|
157 | - * @access private |
|
158 | - * @since 1.0.0 |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - function column_customer_id( $item ) { |
|
162 | - $subscriber = get_userdata( $item->customer_id ); |
|
163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | - |
|
165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Status column |
|
170 | - * |
|
171 | - * @access private |
|
172 | - * @since 1.0.0 |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - function column_status( $item ) { |
|
176 | - return $item->get_status_label(); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Period column |
|
181 | - * |
|
182 | - * @access private |
|
183 | - * @since 1.0.0 |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - function column_period( $item ) { |
|
187 | - |
|
188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
189 | - |
|
190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Billing Times column |
|
195 | - * |
|
196 | - * @access private |
|
197 | - * @since 1.0.0 |
|
198 | - * @return string |
|
199 | - */ |
|
200 | - function column_bill_times( $item ) { |
|
201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Initial Amount column |
|
206 | - * |
|
207 | - * @access private |
|
208 | - * @since 1.0.0 |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - function column_initial_amount( $item ) { |
|
212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Renewal date column |
|
217 | - * |
|
218 | - * @access private |
|
219 | - * @since 1.0.0 |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - function column_renewal_date( $item ) { |
|
223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Payment column |
|
228 | - * |
|
229 | - * @access private |
|
230 | - * @since 1.0.0 |
|
231 | - * @return string |
|
232 | - */ |
|
233 | - function column_parent_payment_id( $item ) { |
|
234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Product ID column |
|
239 | - * |
|
240 | - * @access private |
|
241 | - * @since 1.0.0 |
|
242 | - * @return string |
|
243 | - */ |
|
244 | - function column_product_id( $item ) { |
|
245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Render the edit column |
|
250 | - * |
|
251 | - * @access private |
|
252 | - * @since 2.0 |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - function column_actions( $item ) { |
|
256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Retrieve the table columns |
|
262 | - * |
|
263 | - * @access private |
|
264 | - * @since 1.0.0 |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - |
|
268 | - function get_columns(){ |
|
269 | - $columns = array( |
|
270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | - 'status' => __( 'Status', 'invoicing' ), |
|
273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
280 | - ); |
|
281 | - |
|
282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * Retrieve the current page number |
|
287 | - * |
|
288 | - * @access private |
|
289 | - * @since 1.0.0 |
|
290 | - * @return int |
|
291 | - */ |
|
292 | - function get_paged() { |
|
293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Retrieve the subscription counts |
|
298 | - * |
|
299 | - * @access public |
|
300 | - * @since 1.4 |
|
301 | - * @return void |
|
302 | - */ |
|
303 | - public function get_subscription_counts() { |
|
304 | - |
|
305 | - global $wp_query; |
|
306 | - |
|
307 | - $db = new WPInv_Subscriptions_DB; |
|
308 | - |
|
309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
310 | - |
|
311 | - $this->total_count = $db->count(); |
|
312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
319 | - |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * Setup the final data for the table |
|
324 | - * |
|
325 | - * @access private |
|
326 | - * @since 1.0.0 |
|
327 | - * @uses $this->_column_headers |
|
328 | - * @uses $this->items |
|
329 | - * @uses $this->get_columns() |
|
330 | - * @uses $this->get_sortable_columns() |
|
331 | - * @uses $this->get_pagenum() |
|
332 | - * @uses $this->set_pagination_args() |
|
333 | - * @return array |
|
334 | - */ |
|
335 | - function prepare_items() { |
|
336 | - |
|
337 | - $columns = $this->get_columns(); |
|
338 | - $hidden = array(); // No hidden columns |
|
339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
340 | - $sortable = $this->get_sortable_columns(); |
|
341 | - |
|
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
343 | - |
|
344 | - $current_page = $this->get_pagenum(); |
|
345 | - |
|
346 | - $db = new WPInv_Subscriptions_DB; |
|
347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
348 | - $args = array( |
|
349 | - 'number' => $this->per_page, |
|
350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
351 | - 'search' => $search |
|
352 | - ); |
|
353 | - |
|
354 | - if ( 'any' !== $status ) { |
|
355 | - $args['status'] = $status; |
|
356 | - } |
|
357 | - |
|
358 | - $this->items = $db->get_subscriptions( $args ); |
|
359 | - |
|
360 | - switch ( $status ) { |
|
361 | - case 'active': |
|
362 | - $total_items = $this->active_count; |
|
363 | - break; |
|
364 | - case 'pending': |
|
365 | - $total_items = $this->pending_count; |
|
366 | - break; |
|
367 | - case 'expired': |
|
368 | - $total_items = $this->expired_count; |
|
369 | - break; |
|
370 | - case 'cancelled': |
|
371 | - $total_items = $this->cancelled_count; |
|
372 | - break; |
|
373 | - case 'failing': |
|
374 | - $total_items = $this->failing_count; |
|
375 | - break; |
|
376 | - case 'trialling': |
|
377 | - $total_items = $this->trialling_count; |
|
378 | - break; |
|
379 | - case 'completed': |
|
380 | - $total_items = $this->completed_count; |
|
381 | - break; |
|
382 | - case 'any': |
|
383 | - default: |
|
384 | - $total_items = $this->total_count; |
|
385 | - break; |
|
386 | - } |
|
387 | - |
|
388 | - $this->set_pagination_args( array( |
|
389 | - 'total_items' => $total_items, |
|
390 | - 'per_page' => $this->per_page, |
|
391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | - ) ); |
|
393 | - } |
|
154 | + /** |
|
155 | + * Customer column |
|
156 | + * |
|
157 | + * @access private |
|
158 | + * @since 1.0.0 |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + function column_customer_id( $item ) { |
|
162 | + $subscriber = get_userdata( $item->customer_id ); |
|
163 | + $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | + |
|
165 | + return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Status column |
|
170 | + * |
|
171 | + * @access private |
|
172 | + * @since 1.0.0 |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + function column_status( $item ) { |
|
176 | + return $item->get_status_label(); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Period column |
|
181 | + * |
|
182 | + * @access private |
|
183 | + * @since 1.0.0 |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + function column_period( $item ) { |
|
187 | + |
|
188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
189 | + |
|
190 | + return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Billing Times column |
|
195 | + * |
|
196 | + * @access private |
|
197 | + * @since 1.0.0 |
|
198 | + * @return string |
|
199 | + */ |
|
200 | + function column_bill_times( $item ) { |
|
201 | + return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Initial Amount column |
|
206 | + * |
|
207 | + * @access private |
|
208 | + * @since 1.0.0 |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + function column_initial_amount( $item ) { |
|
212 | + return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Renewal date column |
|
217 | + * |
|
218 | + * @access private |
|
219 | + * @since 1.0.0 |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + function column_renewal_date( $item ) { |
|
223 | + return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Payment column |
|
228 | + * |
|
229 | + * @access private |
|
230 | + * @since 1.0.0 |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + function column_parent_payment_id( $item ) { |
|
234 | + return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Product ID column |
|
239 | + * |
|
240 | + * @access private |
|
241 | + * @since 1.0.0 |
|
242 | + * @return string |
|
243 | + */ |
|
244 | + function column_product_id( $item ) { |
|
245 | + return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * Render the edit column |
|
250 | + * |
|
251 | + * @access private |
|
252 | + * @since 2.0 |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + function column_actions( $item ) { |
|
256 | + return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Retrieve the table columns |
|
262 | + * |
|
263 | + * @access private |
|
264 | + * @since 1.0.0 |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + |
|
268 | + function get_columns(){ |
|
269 | + $columns = array( |
|
270 | + 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | + 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | + 'status' => __( 'Status', 'invoicing' ), |
|
273 | + 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | + 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | + 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | + 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | + 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | + 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | + 'actions' => __( 'Actions', 'invoicing' ), |
|
280 | + ); |
|
281 | + |
|
282 | + return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * Retrieve the current page number |
|
287 | + * |
|
288 | + * @access private |
|
289 | + * @since 1.0.0 |
|
290 | + * @return int |
|
291 | + */ |
|
292 | + function get_paged() { |
|
293 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * Retrieve the subscription counts |
|
298 | + * |
|
299 | + * @access public |
|
300 | + * @since 1.4 |
|
301 | + * @return void |
|
302 | + */ |
|
303 | + public function get_subscription_counts() { |
|
304 | + |
|
305 | + global $wp_query; |
|
306 | + |
|
307 | + $db = new WPInv_Subscriptions_DB; |
|
308 | + |
|
309 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
310 | + |
|
311 | + $this->total_count = $db->count(); |
|
312 | + $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | + $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | + $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | + $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | + $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | + $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | + $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
319 | + |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Setup the final data for the table |
|
324 | + * |
|
325 | + * @access private |
|
326 | + * @since 1.0.0 |
|
327 | + * @uses $this->_column_headers |
|
328 | + * @uses $this->items |
|
329 | + * @uses $this->get_columns() |
|
330 | + * @uses $this->get_sortable_columns() |
|
331 | + * @uses $this->get_pagenum() |
|
332 | + * @uses $this->set_pagination_args() |
|
333 | + * @return array |
|
334 | + */ |
|
335 | + function prepare_items() { |
|
336 | + |
|
337 | + $columns = $this->get_columns(); |
|
338 | + $hidden = array(); // No hidden columns |
|
339 | + $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
340 | + $sortable = $this->get_sortable_columns(); |
|
341 | + |
|
342 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
343 | + |
|
344 | + $current_page = $this->get_pagenum(); |
|
345 | + |
|
346 | + $db = new WPInv_Subscriptions_DB; |
|
347 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
348 | + $args = array( |
|
349 | + 'number' => $this->per_page, |
|
350 | + 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
351 | + 'search' => $search |
|
352 | + ); |
|
353 | + |
|
354 | + if ( 'any' !== $status ) { |
|
355 | + $args['status'] = $status; |
|
356 | + } |
|
357 | + |
|
358 | + $this->items = $db->get_subscriptions( $args ); |
|
359 | + |
|
360 | + switch ( $status ) { |
|
361 | + case 'active': |
|
362 | + $total_items = $this->active_count; |
|
363 | + break; |
|
364 | + case 'pending': |
|
365 | + $total_items = $this->pending_count; |
|
366 | + break; |
|
367 | + case 'expired': |
|
368 | + $total_items = $this->expired_count; |
|
369 | + break; |
|
370 | + case 'cancelled': |
|
371 | + $total_items = $this->cancelled_count; |
|
372 | + break; |
|
373 | + case 'failing': |
|
374 | + $total_items = $this->failing_count; |
|
375 | + break; |
|
376 | + case 'trialling': |
|
377 | + $total_items = $this->trialling_count; |
|
378 | + break; |
|
379 | + case 'completed': |
|
380 | + $total_items = $this->completed_count; |
|
381 | + break; |
|
382 | + case 'any': |
|
383 | + default: |
|
384 | + $total_items = $this->total_count; |
|
385 | + break; |
|
386 | + } |
|
387 | + |
|
388 | + $this->set_pagination_args( array( |
|
389 | + 'total_items' => $total_items, |
|
390 | + 'per_page' => $this->per_page, |
|
391 | + 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | + ) ); |
|
393 | + } |
|
394 | 394 | } |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
11 | +if (!defined('ABSPATH')) exit; |
|
12 | 12 | |
13 | 13 | |
14 | 14 | // Load WP_List_Table if not loaded |
15 | -if( ! class_exists( 'WP_List_Table' ) ) { |
|
15 | +if (!class_exists('WP_List_Table')) { |
|
16 | 16 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
17 | 17 | } |
18 | 18 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public $pending_count = 0; |
36 | 36 | public $expired_count = 0; |
37 | 37 | public $completed_count = 0; |
38 | - public $trialling_count = 0; |
|
38 | + public $trialling_count = 0; |
|
39 | 39 | public $cancelled_count = 0; |
40 | 40 | public $failing_count = 0; |
41 | 41 | |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | * @since 1.0.0 |
47 | 47 | * @return void |
48 | 48 | */ |
49 | - function __construct(){ |
|
49 | + function __construct() { |
|
50 | 50 | global $status, $page; |
51 | 51 | |
52 | 52 | // Set parent defaults |
53 | - parent::__construct( array( |
|
53 | + parent::__construct(array( |
|
54 | 54 | 'singular' => 'subscription', |
55 | 55 | 'plural' => 'subscriptions', |
56 | 56 | 'ajax' => false |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | |
59 | 59 | $this->get_subscription_counts(); |
60 | 60 | |
@@ -69,28 +69,28 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_views() { |
71 | 71 | |
72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
72 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | 74 | $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
75 | 75 | $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | 77 | $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | 81 | |
82 | 82 | $views = array( |
83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
83 | + 'all' => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array('status', 'paged')), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'invoicing') . $total_count), |
|
84 | + 'active' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'active', 'paged' => FALSE)), $current === 'active' ? ' class="current"' : '', __('Active', 'invoicing') . $active_count), |
|
85 | + 'pending' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'pending', 'paged' => FALSE)), $current === 'pending' ? ' class="current"' : '', __('Pending', 'invoicing') . $pending_count), |
|
86 | + 'expired' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'expired', 'paged' => FALSE)), $current === 'expired' ? ' class="current"' : '', __('Expired', 'invoicing') . $expired_count), |
|
87 | + 'completed' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'completed', 'paged' => FALSE)), $current === 'completed' ? ' class="current"' : '', __('Completed', 'invoicing') . $completed_count), |
|
88 | + 'trialling' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'trialling', 'paged' => FALSE)), $current === 'trialling' ? ' class="current"' : '', __('Trialling', 'invoicing') . $trialling_count), |
|
89 | + 'cancelled' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'cancelled', 'paged' => FALSE)), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'invoicing') . $cancelled_count), |
|
90 | + 'failing' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'failing', 'paged' => FALSE)), $current === 'failing' ? ' class="current"' : '', __('Failing', 'invoicing') . $failing_count), |
|
91 | 91 | ); |
92 | 92 | |
93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
93 | + return apply_filters('wpinv_recurring_subscriptions_table_views', $views); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -104,27 +104,27 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function search_box( $text, $input_id ) { |
|
107 | + public function search_box($text, $input_id) { |
|
108 | 108 | |
109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
109 | + if (empty($_REQUEST['s']) && !$this->has_items()) { |
|
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | 113 | $input_id = $input_id . '-search-input'; |
114 | 114 | |
115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
115 | + if (!empty($_REQUEST['orderby'])) { |
|
116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />'; |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
119 | + if (!empty($_REQUEST['order'])) { |
|
120 | + echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />'; |
|
121 | 121 | } |
122 | 122 | ?> |
123 | 123 | <p class="search-box"> |
124 | - <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
|
124 | + <?php do_action('wpinv_recurring_subscription_search_box'); ?> |
|
125 | 125 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
126 | 126 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
127 | - <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
|
127 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/> |
|
128 | 128 | </p> |
129 | 129 | <?php |
130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @since 1.0.0 |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - function column_default( $item, $column_name ) { |
|
139 | + function column_default($item, $column_name) { |
|
140 | 140 | return $item->$column_name; |
141 | 141 | } |
142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @since 1.0.0 |
148 | 148 | * @return string |
149 | 149 | */ |
150 | - function column_sub_id( $item ) { |
|
151 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
|
150 | + function column_sub_id($item) { |
|
151 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" target="_blank">' . $item->id . '</a>'; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - function column_customer_id( $item ) { |
|
162 | - $subscriber = get_userdata( $item->customer_id ); |
|
163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
161 | + function column_customer_id($item) { |
|
162 | + $subscriber = get_userdata($item->customer_id); |
|
163 | + $customer = !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | 164 | |
165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
165 | + return '<a href="' . esc_url(get_edit_user_link($item->customer_id)) . '" target="_blank">' . $customer . '</a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @since 1.0.0 |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - function column_status( $item ) { |
|
175 | + function column_status($item) { |
|
176 | 176 | return $item->get_status_label(); |
177 | 177 | } |
178 | 178 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @since 1.0.0 |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - function column_period( $item ) { |
|
186 | + function column_period($item) { |
|
187 | 187 | |
188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->period, $item->frequency); |
|
189 | 189 | |
190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
190 | + return wpinv_price(wpinv_format_amount($item->recurring_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)) . ' / ' . $period; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @since 1.0.0 |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - function column_bill_times( $item ) { |
|
201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
200 | + function column_bill_times($item) { |
|
201 | + return $item->get_times_billed() . ' / ' . (($item->bill_times == 0) ? 'Until Cancelled' : $item->bill_times); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @since 1.0.0 |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - function column_initial_amount( $item ) { |
|
212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
211 | + function column_initial_amount($item) { |
|
212 | + return wpinv_price(wpinv_format_amount($item->initial_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * @since 1.0.0 |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - function column_renewal_date( $item ) { |
|
223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
222 | + function column_renewal_date($item) { |
|
223 | + return $renewal_date = !empty($item->expiration) ? date_i18n(get_option('date_format'), strtotime($item->expiration)) : __('N/A', 'invoicing'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @since 1.0.0 |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - function column_parent_payment_id( $item ) { |
|
234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
233 | + function column_parent_payment_id($item) { |
|
234 | + return '<a href="' . get_edit_post_link($item->parent_payment_id) . '" target="_blank">' . wpinv_get_invoice_number($item->parent_payment_id) . '</a>'; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @since 1.0.0 |
242 | 242 | * @return string |
243 | 243 | */ |
244 | - function column_product_id( $item ) { |
|
245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
244 | + function column_product_id($item) { |
|
245 | + return '<a href="' . esc_url(admin_url('post.php?action=edit&post=' . $item->product_id)) . '" target="_blank">' . get_the_title($item->product_id) . '</a>'; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @since 2.0 |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - function column_actions( $item ) { |
|
256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
255 | + function column_actions($item) { |
|
256 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" title="' . esc_attr(__('View or edit subscription', 'invoicing')) . '" target="_blank">' . __('View', 'invoicing') . '</a>'; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -265,21 +265,21 @@ discard block |
||
265 | 265 | * @return array |
266 | 266 | */ |
267 | 267 | |
268 | - function get_columns(){ |
|
268 | + function get_columns() { |
|
269 | 269 | $columns = array( |
270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | - 'status' => __( 'Status', 'invoicing' ), |
|
273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
270 | + 'sub_id' => __('ID', 'invoicing'), |
|
271 | + 'customer_id' => __('Customer', 'invoicing'), |
|
272 | + 'status' => __('Status', 'invoicing'), |
|
273 | + 'period' => __('Billing Cycle', 'invoicing'), |
|
274 | + 'initial_amount' => __('Initial Amount', 'invoicing'), |
|
275 | + 'bill_times' => __('Times Billed', 'invoicing'), |
|
276 | + 'renewal_date' => __('Renewal Date', 'invoicing'), |
|
277 | + 'parent_payment_id' => __('Invoice', 'invoicing'), |
|
278 | + 'product_id' => __('Item', 'invoicing'), |
|
279 | + 'actions' => __('Actions', 'invoicing'), |
|
280 | 280 | ); |
281 | 281 | |
282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
282 | + return apply_filters('wpinv_report_subscription_columns', $columns); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return int |
291 | 291 | */ |
292 | 292 | function get_paged() { |
293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
293 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -306,16 +306,16 @@ discard block |
||
306 | 306 | |
307 | 307 | $db = new WPInv_Subscriptions_DB; |
308 | 308 | |
309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
309 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
310 | 310 | |
311 | 311 | $this->total_count = $db->count(); |
312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
312 | + $this->active_count = $db->count(array('status' => 'active', 'search' => $search)); |
|
313 | + $this->pending_count = $db->count(array('status' => 'pending', 'search' => $search)); |
|
314 | + $this->expired_count = $db->count(array('status' => 'expired', 'search' => $search)); |
|
315 | + $this->trialling_count = $db->count(array('status' => 'trialling', 'search' => $search)); |
|
316 | + $this->cancelled_count = $db->count(array('status' => 'cancelled', 'search' => $search)); |
|
317 | + $this->completed_count = $db->count(array('status' => 'completed', 'search' => $search)); |
|
318 | + $this->failing_count = $db->count(array('status' => 'failing', 'search' => $search)); |
|
319 | 319 | |
320 | 320 | } |
321 | 321 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | |
337 | 337 | $columns = $this->get_columns(); |
338 | 338 | $hidden = array(); // No hidden columns |
339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
339 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
340 | 340 | $sortable = $this->get_sortable_columns(); |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $current_page = $this->get_pagenum(); |
345 | 345 | |
346 | 346 | $db = new WPInv_Subscriptions_DB; |
347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
347 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
348 | 348 | $args = array( |
349 | 349 | 'number' => $this->per_page, |
350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
350 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
351 | 351 | 'search' => $search |
352 | 352 | ); |
353 | 353 | |
354 | - if ( 'any' !== $status ) { |
|
354 | + if ('any' !== $status) { |
|
355 | 355 | $args['status'] = $status; |
356 | 356 | } |
357 | 357 | |
358 | - $this->items = $db->get_subscriptions( $args ); |
|
358 | + $this->items = $db->get_subscriptions($args); |
|
359 | 359 | |
360 | - switch ( $status ) { |
|
360 | + switch ($status) { |
|
361 | 361 | case 'active': |
362 | 362 | $total_items = $this->active_count; |
363 | 363 | break; |
@@ -385,10 +385,10 @@ discard block |
||
385 | 385 | break; |
386 | 386 | } |
387 | 387 | |
388 | - $this->set_pagination_args( array( |
|
388 | + $this->set_pagination_args(array( |
|
389 | 389 | 'total_items' => $total_items, |
390 | 390 | 'per_page' => $this->per_page, |
391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | - ) ); |
|
391 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | } |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | function wpinv_subscription_init() { |
6 | 8 | return WPInv_Subscriptions::instance(); |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | function wpinv_subscription_init() { |
6 | 6 | return WPInv_Subscriptions::instance(); |
7 | 7 | } |
8 | -add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 ); |
|
8 | +add_action('plugins_loaded', 'wpinv_subscription_init', 100); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * WPInv_Subscriptions Class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Main WPInv_Subscriptions Instance |
21 | 21 | */ |
22 | 22 | public static function instance() { |
23 | - if ( ! isset( self::$instance ) ) { |
|
23 | + if (!isset(self::$instance)) { |
|
24 | 24 | self::$instance = new WPInv_Subscriptions; |
25 | 25 | |
26 | 26 | self::$instance->init(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - private function __construct(){ |
|
37 | + private function __construct() { |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | private function setup_constants() { |
64 | 64 | |
65 | 65 | // Make sure CAL_GREGORIAN is defined. |
66 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
67 | - define( 'CAL_GREGORIAN', 1 ); |
|
66 | + if (!defined('CAL_GREGORIAN')) { |
|
67 | + define('CAL_GREGORIAN', 1); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function actions() { |
78 | 78 | |
79 | - add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 10 ); |
|
80 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
81 | - add_action( 'init', array( $this, 'wpinv_post_actions' ) ); |
|
82 | - add_action( 'init', array( $this, 'wpinv_get_actions' ) ); |
|
83 | - add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) ); |
|
84 | - add_action( 'wpinv_checkout_before_send_to_gateway', array( $this, 'wpinv_checkout_add_subscription' ), -999, 2 ); |
|
85 | - add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) ); |
|
79 | + add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 10); |
|
80 | + add_action('admin_notices', array($this, 'notices')); |
|
81 | + add_action('init', array($this, 'wpinv_post_actions')); |
|
82 | + add_action('init', array($this, 'wpinv_get_actions')); |
|
83 | + add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation')); |
|
84 | + add_action('wpinv_checkout_before_send_to_gateway', array($this, 'wpinv_checkout_add_subscription'), -999, 2); |
|
85 | + add_action('wpinv_subscriptions_front_notices', array($this, 'notices')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | public function wpinv_subscriptions_list() { |
105 | 105 | add_submenu_page( |
106 | 106 | 'wpinv', |
107 | - __( 'Subscriptions', 'invoicing' ), |
|
108 | - __( 'Subscriptions', 'invoicing' ), |
|
107 | + __('Subscriptions', 'invoicing'), |
|
108 | + __('Subscriptions', 'invoicing'), |
|
109 | 109 | 'manage_invoicing', |
110 | 110 | 'wpinv-subscriptions', |
111 | 111 | 'wpinv_subscriptions_page' |
@@ -114,37 +114,37 @@ discard block |
||
114 | 114 | |
115 | 115 | public function notices() { |
116 | 116 | |
117 | - if( empty( $_GET['wpinv-message'] ) ) { |
|
117 | + if (empty($_GET['wpinv-message'])) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | $type = 'updated'; |
122 | 122 | $message = ''; |
123 | 123 | |
124 | - switch( strtolower( $_GET['wpinv-message'] ) ) { |
|
124 | + switch (strtolower($_GET['wpinv-message'])) { |
|
125 | 125 | |
126 | 126 | case 'updated' : |
127 | 127 | |
128 | - $message = __( 'Subscription updated successfully.', 'invoicing' ); |
|
128 | + $message = __('Subscription updated successfully.', 'invoicing'); |
|
129 | 129 | |
130 | 130 | break; |
131 | 131 | |
132 | 132 | case 'deleted' : |
133 | 133 | |
134 | - $message = __( 'Subscription deleted successfully.', 'invoicing' ); |
|
134 | + $message = __('Subscription deleted successfully.', 'invoicing'); |
|
135 | 135 | |
136 | 136 | break; |
137 | 137 | |
138 | 138 | case 'cancelled' : |
139 | 139 | |
140 | - $message = __( 'Subscription cancelled successfully.', 'invoicing' ); |
|
140 | + $message = __('Subscription cancelled successfully.', 'invoicing'); |
|
141 | 141 | |
142 | 142 | break; |
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! empty( $message ) ) { |
|
147 | - echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>'; |
|
146 | + if (!empty($message)) { |
|
147 | + echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return void |
158 | 158 | */ |
159 | 159 | function wpinv_get_actions() { |
160 | - if ( isset( $_GET['wpinv_action'] ) ) { |
|
161 | - do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET ); |
|
160 | + if (isset($_GET['wpinv_action'])) { |
|
161 | + do_action('wpinv_' . $_GET['wpinv_action'], $_GET); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function wpinv_post_actions() { |
173 | - if ( isset( $_POST['wpinv_action'] ) ) { |
|
174 | - do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST ); |
|
173 | + if (isset($_POST['wpinv_action'])) { |
|
174 | + do_action('wpinv_' . $_POST['wpinv_action'], $_POST); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | * @param int $frequency_count The frequency of the period. |
183 | 183 | * @return mixed|string|void |
184 | 184 | */ |
185 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) { |
|
185 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
186 | 186 | $frequency = ''; |
187 | 187 | //Format period details |
188 | - switch ( $period ) { |
|
188 | + switch ($period) { |
|
189 | 189 | case 'day' : |
190 | - $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
190 | + $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
191 | 191 | break; |
192 | 192 | case 'week' : |
193 | - $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
193 | + $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
194 | 194 | break; |
195 | 195 | case 'month' : |
196 | - $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
196 | + $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
197 | 197 | break; |
198 | 198 | case 'year' : |
199 | - $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
199 | + $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
200 | 200 | break; |
201 | 201 | default : |
202 | - $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count ); |
|
202 | + $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count); |
|
203 | 203 | break; |
204 | 204 | } |
205 | 205 | |
@@ -214,50 +214,50 @@ discard block |
||
214 | 214 | * @since 1.0.0 |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - public function wpinv_process_cancellation( $data ) { |
|
217 | + public function wpinv_process_cancellation($data) { |
|
218 | 218 | |
219 | 219 | |
220 | - if( empty( $data['sub_id'] ) ) { |
|
220 | + if (empty($data['sub_id'])) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | - if( ! is_user_logged_in() ) { |
|
224 | + if (!is_user_logged_in()) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) { |
|
229 | - wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) ); |
|
228 | + if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) { |
|
229 | + wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403)); |
|
230 | 230 | } |
231 | 231 | |
232 | - $data['sub_id'] = absint( $data['sub_id'] ); |
|
233 | - $subscription = new WPInv_Subscription( $data['sub_id'] ); |
|
232 | + $data['sub_id'] = absint($data['sub_id']); |
|
233 | + $subscription = new WPInv_Subscription($data['sub_id']); |
|
234 | 234 | |
235 | - if( ! $subscription->can_cancel() ) { |
|
236 | - wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) ); |
|
235 | + if (!$subscription->can_cancel()) { |
|
236 | + wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | try { |
240 | 240 | |
241 | - do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true ); |
|
241 | + do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true); |
|
242 | 242 | |
243 | 243 | $subscription->cancel(); |
244 | 244 | |
245 | - if( is_admin() ) { |
|
245 | + if (is_admin()) { |
|
246 | 246 | |
247 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) ); |
|
247 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id)); |
|
248 | 248 | exit; |
249 | 249 | |
250 | 250 | } else { |
251 | 251 | |
252 | - $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) ); |
|
253 | - $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription ); |
|
254 | - wp_safe_redirect( $redirect ); |
|
252 | + $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled'))); |
|
253 | + $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription); |
|
254 | + wp_safe_redirect($redirect); |
|
255 | 255 | exit; |
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - } catch ( Exception $e ) { |
|
260 | - wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) ); |
|
259 | + } catch (Exception $e) { |
|
260 | + wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403)); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | } |
@@ -269,35 +269,35 @@ discard block |
||
269 | 269 | * @since 1.0.0 |
270 | 270 | * @return void |
271 | 271 | */ |
272 | - public function wpinv_checkout_add_subscription( $invoice, $invoice_data ) { |
|
273 | - if ( ! ( ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) { |
|
272 | + public function wpinv_checkout_add_subscription($invoice, $invoice_data) { |
|
273 | + if (!(!empty($invoice->ID) && $invoice->is_recurring())) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | - $item = $invoice->get_recurring( true ); |
|
278 | - if ( empty( $item ) ) { |
|
277 | + $item = $invoice->get_recurring(true); |
|
278 | + if (empty($item)) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
282 | + $invoice_date = $invoice->get_invoice_date(false); |
|
283 | 283 | $status = 'pending'; |
284 | 284 | |
285 | - $period = $item->get_recurring_period( true ); |
|
285 | + $period = $item->get_recurring_period(true); |
|
286 | 286 | $interval = $item->get_recurring_interval(); |
287 | 287 | $bill_times = (int)$item->get_recurring_limit(); |
288 | 288 | $add_period = $interval . ' ' . $period; |
289 | 289 | $trial_period = ''; |
290 | 290 | |
291 | - if ( $invoice->is_free_trial() ) { |
|
291 | + if ($invoice->is_free_trial()) { |
|
292 | 292 | $status = 'trialling'; |
293 | - $trial_period = $item->get_trial_period( true ); |
|
293 | + $trial_period = $item->get_trial_period(true); |
|
294 | 294 | $free_interval = $item->get_trial_interval(); |
295 | 295 | $trial_period = $free_interval . ' ' . $trial_period; |
296 | 296 | |
297 | 297 | $add_period = $trial_period; |
298 | 298 | } |
299 | 299 | |
300 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
300 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
301 | 301 | |
302 | 302 | $args = array( |
303 | 303 | 'product_id' => $item->ID, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | 'frequency' => $interval, |
308 | 308 | 'period' => $period, |
309 | 309 | 'initial_amount' => $invoice->get_total(), |
310 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
310 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
311 | 311 | 'bill_times' => $bill_times, |
312 | 312 | 'created' => $invoice_date, |
313 | 313 | 'expiration' => $expiration, |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | 'transaction_id' => '', |
317 | 317 | ); |
318 | 318 | |
319 | - $subscription = wpinv_get_subscription( $invoice ); |
|
319 | + $subscription = wpinv_get_subscription($invoice); |
|
320 | 320 | |
321 | - if ( empty( $subscription ) ) { |
|
321 | + if (empty($subscription)) { |
|
322 | 322 | $subscription = new WPInv_Subscription(); |
323 | - $subscription->create( $args ); |
|
323 | + $subscription->create($args); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $subscription; |
@@ -9,58 +9,58 @@ |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // If uninstall not called from WordPress, then exit. |
12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | global $wpdb, $wp_version; |
17 | 17 | |
18 | -$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' ); |
|
18 | +$remove_data = get_option('wpinv_remove_data_on_invoice_unistall'); |
|
19 | 19 | |
20 | 20 | /* |
21 | 21 | * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's |
22 | 22 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
23 | 23 | * and to ensure only the site owner can perform this action. |
24 | 24 | */ |
25 | -if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) { |
|
25 | +if (defined('WPINV_REMOVE_ALL_DATA')) { |
|
26 | 26 | $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false; |
27 | 27 | } |
28 | 28 | |
29 | -if ( $remove_data ) { |
|
29 | +if ($remove_data) { |
|
30 | 30 | // Load Invoicing file. |
31 | - include_once( 'invoicing.php' ); |
|
31 | + include_once('invoicing.php'); |
|
32 | 32 | |
33 | 33 | // Roles + caps. |
34 | - include_once( dirname( __FILE__ ) . '/includes/admin/install.php' ); |
|
34 | + include_once(dirname(__FILE__) . '/includes/admin/install.php'); |
|
35 | 35 | wpinv_remove_admin_caps(); |
36 | 36 | |
37 | - $settings = get_option( 'wpinv_settings' ); |
|
37 | + $settings = get_option('wpinv_settings'); |
|
38 | 38 | |
39 | 39 | // Delete pages. |
40 | - $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' ); |
|
41 | - foreach ( $wpi_pages as $page ) { |
|
42 | - if ( !empty( $page ) && !empty( $settings[ $page ] ) ) { |
|
43 | - wp_delete_post( $settings[ $page ], true ); |
|
40 | + $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page'); |
|
41 | + foreach ($wpi_pages as $page) { |
|
42 | + if (!empty($page) && !empty($settings[$page])) { |
|
43 | + wp_delete_post($settings[$page], true); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Delete posts + data. |
48 | - $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" ); |
|
49 | - $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
|
48 | + $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );"); |
|
49 | + $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); |
|
50 | 50 | |
51 | 51 | // Delete comments. |
52 | - $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" ); |
|
53 | - $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); |
|
52 | + $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';"); |
|
53 | + $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;"); |
|
54 | 54 | |
55 | 55 | // Delete user meta. |
56 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" ); |
|
56 | + $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';"); |
|
57 | 57 | |
58 | 58 | // Cleanup Cron Schedule |
59 | - wp_clear_scheduled_hook( 'wp_session_garbage_collection' ); |
|
60 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
59 | + wp_clear_scheduled_hook('wp_session_garbage_collection'); |
|
60 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
61 | 61 | |
62 | 62 | // Delete options. |
63 | - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" ); |
|
63 | + $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';"); |
|
64 | 64 | |
65 | 65 | // Clear any cached data that has been removed |
66 | 66 | wp_cache_flush(); |