@@ -194,6 +194,9 @@ |
||
194 | 194 | return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
195 | 195 | } |
196 | 196 | |
197 | +/** |
|
198 | + * @return integer |
|
199 | + */ |
|
197 | 200 | function wpinv_currency_decimal_filter( $decimals = 2 ) { |
198 | 201 | $currency = wpinv_get_currency(); |
199 | 202 |
@@ -1,121 +1,121 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function wpinv_use_taxes() { |
8 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
8 | + $ret = wpinv_get_option('enable_taxes', false); |
|
9 | 9 | |
10 | - return (bool) apply_filters( 'wpinv_use_taxes', $ret ); |
|
10 | + return (bool)apply_filters('wpinv_use_taxes', $ret); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | function wpinv_get_tax_rates() { |
14 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
14 | + $rates = get_option('wpinv_tax_rates', array()); |
|
15 | 15 | |
16 | - return apply_filters( 'wpinv_get_tax_rates', $rates ); |
|
16 | + return apply_filters('wpinv_get_tax_rates', $rates); |
|
17 | 17 | } |
18 | 18 | |
19 | -function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) { |
|
19 | +function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) { |
|
20 | 20 | global $wpinv_euvat, $wpi_tax_rates, $wpi_userID; |
21 | - $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array(); |
|
21 | + $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array(); |
|
22 | 22 | |
23 | - if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) { |
|
23 | + if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) { |
|
24 | 24 | return $wpi_tax_rates[$item_id]; |
25 | 25 | } |
26 | 26 | |
27 | - if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) { |
|
27 | + if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) { |
|
28 | 28 | $wpi_tax_rates[$item_id] = 0; |
29 | 29 | return 0; |
30 | 30 | } |
31 | 31 | |
32 | 32 | $is_global = false; |
33 | - if ( $item_id == 'global' ) { |
|
33 | + if ($item_id == 'global') { |
|
34 | 34 | $is_global = true; |
35 | 35 | $item_id = 0; |
36 | 36 | } |
37 | 37 | |
38 | - $rate = (float)wpinv_get_option( 'tax_rate', 0 ); |
|
39 | - $user_address = wpinv_get_user_address( $wpi_userID ); |
|
38 | + $rate = (float)wpinv_get_option('tax_rate', 0); |
|
39 | + $user_address = wpinv_get_user_address($wpi_userID); |
|
40 | 40 | |
41 | - if( empty( $country ) ) { |
|
42 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
41 | + if (empty($country)) { |
|
42 | + if (!empty($_POST['wpinv_country'])) { |
|
43 | 43 | $country = $_POST['wpinv_country']; |
44 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
44 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
45 | 45 | $country = $_POST['wpinv_country']; |
46 | - } elseif( !empty( $_POST['country'] ) ) { |
|
46 | + } elseif (!empty($_POST['country'])) { |
|
47 | 47 | $country = $_POST['country']; |
48 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
48 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
49 | 49 | $country = $user_address['country']; |
50 | 50 | } |
51 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
51 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
52 | 52 | } |
53 | 53 | |
54 | - if( empty( $state ) ) { |
|
55 | - if( !empty( $_POST['wpinv_state'] ) ) { |
|
54 | + if (empty($state)) { |
|
55 | + if (!empty($_POST['wpinv_state'])) { |
|
56 | 56 | $state = $_POST['wpinv_state']; |
57 | - } elseif( !empty( $_POST['wpinv_state'] ) ) { |
|
57 | + } elseif (!empty($_POST['wpinv_state'])) { |
|
58 | 58 | $state = $_POST['wpinv_state']; |
59 | - } elseif( !empty( $_POST['state'] ) ) { |
|
59 | + } elseif (!empty($_POST['state'])) { |
|
60 | 60 | $state = $_POST['state']; |
61 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
61 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
62 | 62 | $state = $user_address['state']; |
63 | 63 | } |
64 | - $state = !empty( $state ) ? $state : wpinv_get_default_state(); |
|
64 | + $state = !empty($state) ? $state : wpinv_get_default_state(); |
|
65 | 65 | } |
66 | 66 | |
67 | - if( !empty( $country ) ) { |
|
68 | - $tax_rates = wpinv_get_tax_rates(); |
|
67 | + if (!empty($country)) { |
|
68 | + $tax_rates = wpinv_get_tax_rates(); |
|
69 | 69 | |
70 | - if( !empty( $tax_rates ) ) { |
|
70 | + if (!empty($tax_rates)) { |
|
71 | 71 | // Locate the tax rate for this country / state, if it exists |
72 | - foreach( $tax_rates as $key => $tax_rate ) { |
|
73 | - if( $country != $tax_rate['country'] ) |
|
72 | + foreach ($tax_rates as $key => $tax_rate) { |
|
73 | + if ($country != $tax_rate['country']) |
|
74 | 74 | continue; |
75 | 75 | |
76 | - if( !empty( $tax_rate['global'] ) ) { |
|
77 | - if( !empty( $tax_rate['rate'] ) ) { |
|
78 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
76 | + if (!empty($tax_rate['global'])) { |
|
77 | + if (!empty($tax_rate['rate'])) { |
|
78 | + $rate = number_format($tax_rate['rate'], 4); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | |
82 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
82 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
83 | 83 | continue; |
84 | 84 | |
85 | 85 | $state_rate = $tax_rate['rate']; |
86 | - if( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
87 | - $rate = number_format( $state_rate, 4 ); |
|
86 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
87 | + $rate = number_format($state_rate, 4); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id ); |
|
94 | + $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id); |
|
95 | 95 | |
96 | - if ( !empty( $item_id ) ) { |
|
96 | + if (!empty($item_id)) { |
|
97 | 97 | $wpi_tax_rates[$item_id] = $rate; |
98 | - } else if ( $is_global ) { |
|
98 | + } else if ($is_global) { |
|
99 | 99 | $wpi_tax_rates['global'] = $rate; |
100 | 100 | } |
101 | 101 | |
102 | 102 | return $rate; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) { |
|
106 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
107 | - $rate = round( $rate, 4 ); |
|
105 | +function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) { |
|
106 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
107 | + $rate = round($rate, 4); |
|
108 | 108 | $formatted = $rate .= '%'; |
109 | - return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id ); |
|
109 | + return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id); |
|
110 | 110 | } |
111 | 111 | |
112 | -function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) { |
|
113 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
112 | +function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) { |
|
113 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
114 | 114 | $tax = 0.00; |
115 | 115 | |
116 | - if ( wpinv_use_taxes() ) { |
|
117 | - if ( wpinv_prices_include_tax() ) { |
|
118 | - $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) ); |
|
116 | + if (wpinv_use_taxes()) { |
|
117 | + if (wpinv_prices_include_tax()) { |
|
118 | + $pre_tax = ($amount / ((1 + $rate) * 0.01)); |
|
119 | 119 | $tax = $amount - $pre_tax; |
120 | 120 | } else { |
121 | 121 | $tax = $amount * $rate * 0.01; |
@@ -123,46 +123,46 @@ discard block |
||
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | - return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id ); |
|
126 | + return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | function wpinv_prices_include_tax() { |
130 | 130 | return false; // TODO |
131 | - $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
131 | + $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_prices_include_tax', $ret ); |
|
133 | + return apply_filters('wpinv_prices_include_tax', $ret); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
137 | - return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) ); |
|
136 | +function wpinv_sales_tax_for_year($year = null) { |
|
137 | + return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year))); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
140 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
141 | 141 | global $wpdb; |
142 | 142 | |
143 | 143 | // Start at zero |
144 | 144 | $tax = 0; |
145 | 145 | |
146 | - if ( ! empty( $year ) ) { |
|
146 | + if (!empty($year)) { |
|
147 | 147 | $args = array( |
148 | 148 | 'post_type' => 'wpi_invoice', |
149 | - 'post_status' => array( 'publish', 'revoked' ), |
|
149 | + 'post_status' => array('publish', 'revoked'), |
|
150 | 150 | 'posts_per_page' => -1, |
151 | 151 | 'year' => $year, |
152 | 152 | 'fields' => 'ids' |
153 | 153 | ); |
154 | 154 | |
155 | - $payments = get_posts( $args ); |
|
156 | - $payment_ids = implode( ',', $payments ); |
|
155 | + $payments = get_posts($args); |
|
156 | + $payment_ids = implode(',', $payments); |
|
157 | 157 | |
158 | - if ( count( $payments ) > 0 ) { |
|
158 | + if (count($payments) > 0) { |
|
159 | 159 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
160 | - $tax = $wpdb->get_var( $sql ); |
|
160 | + $tax = $wpdb->get_var($sql); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
165 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | function wpinv_is_cart_taxed() { |
@@ -171,33 +171,33 @@ discard block |
||
171 | 171 | |
172 | 172 | function wpinv_prices_show_tax_on_checkout() { |
173 | 173 | return false; // TODO |
174 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
174 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
175 | 175 | |
176 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
176 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function wpinv_display_tax_rate() { |
180 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
180 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
181 | 181 | |
182 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
182 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | function wpinv_cart_needs_tax_address_fields() { |
186 | - if( !wpinv_is_cart_taxed() ) |
|
186 | + if (!wpinv_is_cart_taxed()) |
|
187 | 187 | return false; |
188 | 188 | |
189 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
189 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
190 | 190 | } |
191 | 191 | |
192 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
193 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
194 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
192 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
193 | + $ret = (bool)get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
194 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
195 | 195 | } |
196 | 196 | |
197 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
197 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
198 | 198 | $currency = wpinv_get_currency(); |
199 | 199 | |
200 | - switch ( $currency ) { |
|
200 | + switch ($currency) { |
|
201 | 201 | case 'RIAL' : |
202 | 202 | case 'JPY' : |
203 | 203 | case 'TWD' : |
@@ -206,48 +206,48 @@ discard block |
||
206 | 206 | break; |
207 | 207 | } |
208 | 208 | |
209 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
209 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_tax_amount() { |
213 | 213 | $output = 0.00; |
214 | 214 | |
215 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
215 | + return apply_filters('wpinv_tax_amount', $output); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | function wpinv_recalculated_tax() { |
219 | - define( 'WPINV_RECALCTAX', true ); |
|
219 | + define('WPINV_RECALCTAX', true); |
|
220 | 220 | } |
221 | -add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1 ); |
|
221 | +add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1); |
|
222 | 222 | |
223 | -function wpinv_recalculate_tax( $return = false ) { |
|
223 | +function wpinv_recalculate_tax($return = false) { |
|
224 | 224 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
225 | - if ( empty( $invoice_id ) ) { |
|
225 | + if (empty($invoice_id)) { |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
229 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
229 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
230 | 230 | |
231 | - if ( empty( $invoice ) ) { |
|
231 | + if (empty($invoice)) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
235 | - if ( empty( $_POST['country'] ) ) { |
|
235 | + if (empty($_POST['country'])) { |
|
236 | 236 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
237 | 237 | } |
238 | 238 | |
239 | 239 | $invoice->country = sanitize_text_field($_POST['country']); |
240 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
240 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
241 | 241 | if (isset($_POST['state'])) { |
242 | 242 | $invoice->state = sanitize_text_field($_POST['state']); |
243 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
243 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $invoice->cart_details = wpinv_get_cart_content_details(); |
247 | 247 | |
248 | - $subtotal = wpinv_get_cart_subtotal( $invoice->cart_details ); |
|
249 | - $tax = wpinv_get_cart_tax( $invoice->cart_details ); |
|
250 | - $total = wpinv_get_cart_total( $invoice->cart_details ); |
|
248 | + $subtotal = wpinv_get_cart_subtotal($invoice->cart_details); |
|
249 | + $tax = wpinv_get_cart_tax($invoice->cart_details); |
|
250 | + $total = wpinv_get_cart_total($invoice->cart_details); |
|
251 | 251 | |
252 | 252 | $invoice->tax = $tax; |
253 | 253 | $invoice->subtotal = $subtotal; |
@@ -255,60 +255,60 @@ discard block |
||
255 | 255 | |
256 | 256 | $invoice->save(); |
257 | 257 | |
258 | - if ( $invoice->is_free_trial() ) { |
|
258 | + if ($invoice->is_free_trial()) { |
|
259 | 259 | $total = 0; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $response = array( |
263 | - 'total' => html_entity_decode( wpinv_price( wpinv_format_amount( $total ) ), ENT_COMPAT, 'UTF-8' ), |
|
263 | + 'total' => html_entity_decode(wpinv_price(wpinv_format_amount($total)), ENT_COMPAT, 'UTF-8'), |
|
264 | 264 | 'total_raw' => $total, |
265 | - 'html' => wpinv_checkout_cart( $invoice->cart_details, false ), |
|
265 | + 'html' => wpinv_checkout_cart($invoice->cart_details, false), |
|
266 | 266 | ); |
267 | 267 | |
268 | - if ( $return ) { |
|
268 | + if ($return) { |
|
269 | 269 | return $response; |
270 | 270 | } |
271 | 271 | |
272 | - wp_send_json( $response ); |
|
272 | + wp_send_json($response); |
|
273 | 273 | } |
274 | -add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax' ); |
|
275 | -add_action( 'wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax' ); |
|
274 | +add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax'); |
|
275 | +add_action('wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax'); |
|
276 | 276 | |
277 | 277 | // VAT Settings |
278 | -function wpinv_vat_rate_add_callback( $args ) { |
|
278 | +function wpinv_vat_rate_add_callback($args) { |
|
279 | 279 | ?> |
280 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
280 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
281 | 281 | <?php |
282 | 282 | } |
283 | 283 | |
284 | -function wpinv_vat_rate_delete_callback( $args ) { |
|
284 | +function wpinv_vat_rate_delete_callback($args) { |
|
285 | 285 | global $wpinv_euvat; |
286 | 286 | |
287 | 287 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
288 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : ''; |
|
289 | - if ( isset( $vat_classes[$vat_class] ) ) { |
|
288 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : ''; |
|
289 | + if (isset($vat_classes[$vat_class])) { |
|
290 | 290 | ?> |
291 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
291 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
292 | 292 | <?php |
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | -function wpinv_vat_rates_callback( $args ) { |
|
296 | +function wpinv_vat_rates_callback($args) { |
|
297 | 297 | global $wpinv_euvat; |
298 | 298 | |
299 | 299 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
300 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard'; |
|
300 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard'; |
|
301 | 301 | |
302 | 302 | $eu_states = $wpinv_euvat->get_eu_states(); |
303 | 303 | $countries = wpinv_get_country_list(); |
304 | 304 | $vat_groups = $wpinv_euvat->get_vat_groups(); |
305 | - $rates = $wpinv_euvat->get_vat_rates( $vat_class ); |
|
305 | + $rates = $wpinv_euvat->get_vat_rates($vat_class); |
|
306 | 306 | ob_start(); |
307 | 307 | ?> |
308 | 308 | </td><tr> |
309 | 309 | <td colspan="2" class="wpinv_vat_tdbox"> |
310 | - <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" /> |
|
311 | - <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p> |
|
310 | + <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" /> |
|
311 | + <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p> |
|
312 | 312 | <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts"> |
313 | 313 | <colgroup> |
314 | 314 | <col width="50px" /> |
@@ -320,43 +320,43 @@ discard block |
||
320 | 320 | </colgroup> |
321 | 321 | <thead> |
322 | 322 | <tr> |
323 | - <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
324 | - <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
325 | - <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
326 | - <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th> |
|
327 | - <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th> |
|
323 | + <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th> |
|
324 | + <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
325 | + <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
326 | + <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th> |
|
327 | + <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th> |
|
328 | 328 | </tr> |
329 | 329 | </thead> |
330 | 330 | <tbody> |
331 | - <?php if( !empty( $eu_states ) ) { ?> |
|
331 | + <?php if (!empty($eu_states)) { ?> |
|
332 | 332 | <?php |
333 | - foreach ( $eu_states as $state ) { |
|
334 | - $country_name = isset( $countries[$state] ) ? $countries[$state] : ''; |
|
333 | + foreach ($eu_states as $state) { |
|
334 | + $country_name = isset($countries[$state]) ? $countries[$state] : ''; |
|
335 | 335 | |
336 | 336 | // Filter the rate for each country |
337 | - $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } ); |
|
337 | + $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } ); |
|
338 | 338 | |
339 | 339 | // If one does not exist create a default |
340 | - $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array(); |
|
340 | + $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array(); |
|
341 | 341 | |
342 | - $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true; |
|
343 | - $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : ''; |
|
344 | - $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : ''; |
|
345 | - $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' ); |
|
342 | + $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true; |
|
343 | + $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : ''; |
|
344 | + $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : ''; |
|
345 | + $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced'); |
|
346 | 346 | ?> |
347 | 347 | <tr> |
348 | 348 | <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td> |
349 | 349 | <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td> |
350 | 350 | <td class="wpinv_vat_global"> |
351 | - <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" /> |
|
352 | - <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
353 | - <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" /> |
|
351 | + <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" /> |
|
352 | + <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
353 | + <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" /> |
|
354 | 354 | </td> |
355 | - <td class="wpinv_vat_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
356 | - <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
355 | + <td class="wpinv_vat_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
356 | + <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
357 | 357 | <td class="wpinv_vat_group"> |
358 | 358 | <?php |
359 | - echo wpinv_html_select( array( |
|
359 | + echo wpinv_html_select(array( |
|
360 | 360 | 'name' => 'vat_rates[' . $state . '][group]', |
361 | 361 | 'selected' => $vat_group, |
362 | 362 | 'id' => 'vat_rates[' . $state . '][group]', |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | 'chosen' => false, |
367 | 367 | 'show_option_all' => false, |
368 | 368 | 'show_option_none' => false |
369 | - ) ); |
|
369 | + )); |
|
370 | 370 | ?> |
371 | 371 | </td> |
372 | 372 | </tr> |
373 | 373 | <?php } ?> |
374 | 374 | <tr> |
375 | 375 | <td colspan="6" style="background-color:#fafafa;"> |
376 | - <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
376 | + <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
377 | 377 | </td> |
378 | 378 | </tr> |
379 | 379 | <?php } ?> |
@@ -385,35 +385,35 @@ discard block |
||
385 | 385 | echo $content; |
386 | 386 | } |
387 | 387 | |
388 | -function wpinv_vat_number_callback( $args ) { |
|
388 | +function wpinv_vat_number_callback($args) { |
|
389 | 389 | global $wpinv_euvat; |
390 | 390 | |
391 | 391 | $vat_number = $wpinv_euvat->get_vat_number(); |
392 | 392 | $vat_valid = $wpinv_euvat->is_vat_validated(); |
393 | 393 | |
394 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
395 | - $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' ); |
|
394 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
395 | + $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing'); |
|
396 | 396 | $disabled = $vat_valid ? 'disabled="disabled"' : " "; |
397 | 397 | |
398 | - $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>'; |
|
399 | - $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>'; |
|
398 | + $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>'; |
|
399 | + $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>'; |
|
400 | 400 | $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>'; |
401 | - $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>'; |
|
402 | - $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">'; |
|
401 | + $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>'; |
|
402 | + $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">'; |
|
403 | 403 | |
404 | 404 | echo $html; |
405 | 405 | } |
406 | 406 | |
407 | -function wpinv_eu_fallback_rate_callback( $args ) { |
|
407 | +function wpinv_eu_fallback_rate_callback($args) { |
|
408 | 408 | global $wpinv_options; |
409 | 409 | |
410 | - $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' ); |
|
411 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small'; |
|
410 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : ''); |
|
411 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small'; |
|
412 | 412 | |
413 | - $html = '<input type="number" min="0", max="99.99" step="0.10" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
414 | - $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>'; |
|
415 | - $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>'; |
|
416 | - $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
413 | + $html = '<input type="number" min="0", max="99.99" step="0.10" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
414 | + $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>'; |
|
415 | + $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>'; |
|
416 | + $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
417 | 417 | $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>'; |
418 | 418 | echo $html; |
419 | 419 | ?> |
@@ -421,36 +421,36 @@ discard block |
||
421 | 421 | <?php |
422 | 422 | } |
423 | 423 | |
424 | -function wpinv_vat_ip_lookup_callback( $args ) { |
|
424 | +function wpinv_vat_ip_lookup_callback($args) { |
|
425 | 425 | global $wpinv_options, $wpinv_euvat; |
426 | 426 | |
427 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : 'default' ); |
|
427 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default'); |
|
428 | 428 | |
429 | 429 | $options = array(); |
430 | - if ( function_exists( 'geoip_country_code_by_name' ) ) { |
|
431 | - $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' ); |
|
430 | + if (function_exists('geoip_country_code_by_name')) { |
|
431 | + $options['geoip'] = __('PHP GeoIP extension', 'invoicing'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $geoip2_database = $wpinv_euvat->geoip2_country_dbfile(); |
435 | 435 | |
436 | - if ( !function_exists( 'bcadd' ) ) { |
|
437 | - $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' ); |
|
436 | + if (!function_exists('bcadd')) { |
|
437 | + $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing'); |
|
438 | 438 | } else { |
439 | - $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : ''; |
|
439 | + $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : ''; |
|
440 | 440 | } |
441 | 441 | |
442 | - if ( $geoip2_database !== false && empty( $geoip2_message ) ) { |
|
443 | - $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' ); |
|
442 | + if ($geoip2_database !== false && empty($geoip2_message)) { |
|
443 | + $options['geoip2'] = __('GeoIP2 Database', 'invoicing'); |
|
444 | 444 | } |
445 | 445 | |
446 | - if ( function_exists( 'simplexml_load_file' ) ) { |
|
447 | - $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' ); |
|
446 | + if (function_exists('simplexml_load_file')) { |
|
447 | + $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing'); |
|
448 | 448 | } |
449 | 449 | |
450 | - $options['site'] = __( 'Use default country', 'invoicing' ); |
|
451 | - $options['default'] = __( 'Auto', 'invoicing' ); |
|
450 | + $options['site'] = __('Use default country', 'invoicing'); |
|
451 | + $options['default'] = __('Auto', 'invoicing'); |
|
452 | 452 | |
453 | - $html = wpinv_html_select( array( |
|
453 | + $html = wpinv_html_select(array( |
|
454 | 454 | 'name' => "wpinv_settings[{$args['id']}]", |
455 | 455 | 'selected' => $value, |
456 | 456 | 'id' => "wpinv_settings[{$args['id']}]", |
@@ -463,23 +463,23 @@ discard block |
||
463 | 463 | )); |
464 | 464 | |
465 | 465 | $desc = '<label for="wpinv_settings[' . $args['id'] . ']">'; |
466 | - $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' ); |
|
466 | + $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing'); |
|
467 | 467 | $desc .= '<p>'; |
468 | - if ( empty( $geoip2_message ) ) { |
|
469 | - if ( $geoip2_database ) { |
|
468 | + if (empty($geoip2_message)) { |
|
469 | + if ($geoip2_database) { |
|
470 | 470 | $last_updated = ''; |
471 | - if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) { |
|
472 | - $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated ); |
|
473 | - $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated ); |
|
471 | + if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) { |
|
472 | + $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated); |
|
473 | + $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated); |
|
474 | 474 | } |
475 | - $desc .= __( 'GeoIP2 database exists:', 'invoicing' ) . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~55MB)', 'invoicing' ) . '"></input>'; |
|
475 | + $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~55MB)', 'invoicing') . '"></input>'; |
|
476 | 476 | } else { |
477 | - $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~53MB)"></input><br>' . __( 'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' ); |
|
477 | + $desc .= __('GeoIP2 database does not exist:', 'invoicing') . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~53MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing'); |
|
478 | 478 | } |
479 | 479 | } else { |
480 | 480 | $desc .= $geoip2_message; |
481 | 481 | } |
482 | - $desc .= '</p><p>'. __( 'GeoPlugin is a great free service please consider supporting them: ', 'invoicing' ) . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
482 | + $desc .= '</p><p>' . __('GeoPlugin is a great free service please consider supporting them: ', 'invoicing') . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
483 | 483 | $desc .= '</label>'; |
484 | 484 | |
485 | 485 | $html .= $desc; |
@@ -70,8 +70,9 @@ discard block |
||
70 | 70 | if( !empty( $tax_rates ) ) { |
71 | 71 | // Locate the tax rate for this country / state, if it exists |
72 | 72 | foreach( $tax_rates as $key => $tax_rate ) { |
73 | - if( $country != $tax_rate['country'] ) |
|
74 | - continue; |
|
73 | + if( $country != $tax_rate['country'] ) { |
|
74 | + continue; |
|
75 | + } |
|
75 | 76 | |
76 | 77 | if( !empty( $tax_rate['global'] ) ) { |
77 | 78 | if( !empty( $tax_rate['rate'] ) ) { |
@@ -79,8 +80,9 @@ discard block |
||
79 | 80 | } |
80 | 81 | } else { |
81 | 82 | |
82 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
83 | - continue; |
|
83 | + if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
84 | + continue; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | $state_rate = $tax_rate['rate']; |
86 | 88 | if( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -183,8 +185,9 @@ discard block |
||
183 | 185 | } |
184 | 186 | |
185 | 187 | function wpinv_cart_needs_tax_address_fields() { |
186 | - if( !wpinv_is_cart_taxed() ) |
|
187 | - return false; |
|
188 | + if( !wpinv_is_cart_taxed() ) { |
|
189 | + return false; |
|
190 | + } |
|
188 | 191 | |
189 | 192 | return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
190 | 193 | } |
@@ -136,6 +136,9 @@ discard block |
||
136 | 136 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
137 | 137 | } |
138 | 138 | |
139 | +/** |
|
140 | + * @param string $template_name |
|
141 | + */ |
|
139 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
140 | 143 | ob_start(); |
141 | 144 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -168,6 +171,10 @@ discard block |
||
168 | 171 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
169 | 172 | } |
170 | 173 | |
174 | +/** |
|
175 | + * @param string $slug |
|
176 | + * @param boolean $name |
|
177 | + */ |
|
171 | 178 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
172 | 179 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
173 | 180 | |
@@ -867,6 +874,9 @@ discard block |
||
867 | 874 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
868 | 875 | } |
869 | 876 | |
877 | +/** |
|
878 | + * @param integer $id |
|
879 | + */ |
|
870 | 880 | function wpinv_get_watermark( $id ) { |
871 | 881 | if ( !$id > 0 ) { |
872 | 882 | return NULL; |
@@ -117,29 +117,29 @@ discard block |
||
117 | 117 | |
118 | 118 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
119 | 119 | if ( ! empty( $args ) && is_array( $args ) ) { |
120 | - extract( $args ); |
|
121 | - } |
|
120 | + extract( $args ); |
|
121 | + } |
|
122 | 122 | |
123 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
124 | - if ( ! file_exists( $located ) ) { |
|
123 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
124 | + if ( ! file_exists( $located ) ) { |
|
125 | 125 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
126 | - return; |
|
127 | - } |
|
126 | + return; |
|
127 | + } |
|
128 | 128 | |
129 | - // Allow 3rd party plugin filter template file from their plugin. |
|
130 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
129 | + // Allow 3rd party plugin filter template file from their plugin. |
|
130 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
131 | 131 | |
132 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
132 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
133 | 133 | |
134 | - include( $located ); |
|
134 | + include( $located ); |
|
135 | 135 | |
136 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
140 | - ob_start(); |
|
141 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | - return ob_get_clean(); |
|
140 | + ob_start(); |
|
141 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | + return ob_get_clean(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -169,120 +169,120 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
172 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
172 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
173 | 173 | |
174 | - // Setup possible parts |
|
175 | - $templates = array(); |
|
176 | - if ( isset( $name ) ) |
|
177 | - $templates[] = $slug . '-' . $name . '.php'; |
|
178 | - $templates[] = $slug . '.php'; |
|
174 | + // Setup possible parts |
|
175 | + $templates = array(); |
|
176 | + if ( isset( $name ) ) |
|
177 | + $templates[] = $slug . '-' . $name . '.php'; |
|
178 | + $templates[] = $slug . '.php'; |
|
179 | 179 | |
180 | - // Allow template parts to be filtered |
|
181 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
180 | + // Allow template parts to be filtered |
|
181 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
182 | 182 | |
183 | - // Return the part that is found |
|
184 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
183 | + // Return the part that is found |
|
184 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
188 | - // No file found yet |
|
189 | - $located = false; |
|
188 | + // No file found yet |
|
189 | + $located = false; |
|
190 | 190 | |
191 | - // Try to find a template file |
|
192 | - foreach ( (array)$template_names as $template_name ) { |
|
191 | + // Try to find a template file |
|
192 | + foreach ( (array)$template_names as $template_name ) { |
|
193 | 193 | |
194 | - // Continue if template is empty |
|
195 | - if ( empty( $template_name ) ) |
|
196 | - continue; |
|
194 | + // Continue if template is empty |
|
195 | + if ( empty( $template_name ) ) |
|
196 | + continue; |
|
197 | 197 | |
198 | - // Trim off any slashes from the template name |
|
199 | - $template_name = ltrim( $template_name, '/' ); |
|
198 | + // Trim off any slashes from the template name |
|
199 | + $template_name = ltrim( $template_name, '/' ); |
|
200 | 200 | |
201 | - // try locating this template file by looping through the template paths |
|
202 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
201 | + // try locating this template file by looping through the template paths |
|
202 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
203 | 203 | |
204 | - if( file_exists( $template_path . $template_name ) ) { |
|
205 | - $located = $template_path . $template_name; |
|
206 | - break; |
|
207 | - } |
|
208 | - } |
|
204 | + if( file_exists( $template_path . $template_name ) ) { |
|
205 | + $located = $template_path . $template_name; |
|
206 | + break; |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - if( $located ) { |
|
211 | - break; |
|
212 | - } |
|
213 | - } |
|
210 | + if( $located ) { |
|
211 | + break; |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
216 | - load_template( $located, $require_once ); |
|
215 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
216 | + load_template( $located, $require_once ); |
|
217 | 217 | |
218 | - return $located; |
|
218 | + return $located; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | function wpinv_get_theme_template_paths() { |
222 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
222 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
223 | 223 | |
224 | - $file_paths = array( |
|
225 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
226 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
227 | - 100 => wpinv_get_templates_dir() |
|
228 | - ); |
|
224 | + $file_paths = array( |
|
225 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
226 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
227 | + 100 => wpinv_get_templates_dir() |
|
228 | + ); |
|
229 | 229 | |
230 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
230 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
231 | 231 | |
232 | - // sort the file paths based on priority |
|
233 | - ksort( $file_paths, SORT_NUMERIC ); |
|
232 | + // sort the file paths based on priority |
|
233 | + ksort( $file_paths, SORT_NUMERIC ); |
|
234 | 234 | |
235 | - return array_map( 'trailingslashit', $file_paths ); |
|
235 | + return array_map( 'trailingslashit', $file_paths ); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | function wpinv_get_theme_template_dir_name() { |
239 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
239 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_checkout_meta_tags() { |
243 | 243 | |
244 | - $pages = array(); |
|
245 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
246 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
247 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
244 | + $pages = array(); |
|
245 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
246 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
247 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
248 | 248 | |
249 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
250 | - return; |
|
251 | - } |
|
249 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
250 | + return; |
|
251 | + } |
|
252 | 252 | |
253 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
253 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
254 | 254 | } |
255 | 255 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
256 | 256 | |
257 | 257 | function wpinv_add_body_classes( $class ) { |
258 | - $classes = (array)$class; |
|
258 | + $classes = (array)$class; |
|
259 | 259 | |
260 | - if( wpinv_is_checkout() ) { |
|
261 | - $classes[] = 'wpinv-checkout'; |
|
262 | - $classes[] = 'wpinv-page'; |
|
263 | - } |
|
260 | + if( wpinv_is_checkout() ) { |
|
261 | + $classes[] = 'wpinv-checkout'; |
|
262 | + $classes[] = 'wpinv-page'; |
|
263 | + } |
|
264 | 264 | |
265 | - if( wpinv_is_success_page() ) { |
|
266 | - $classes[] = 'wpinv-success'; |
|
267 | - $classes[] = 'wpinv-page'; |
|
268 | - } |
|
265 | + if( wpinv_is_success_page() ) { |
|
266 | + $classes[] = 'wpinv-success'; |
|
267 | + $classes[] = 'wpinv-page'; |
|
268 | + } |
|
269 | 269 | |
270 | - if( wpinv_is_failed_transaction_page() ) { |
|
271 | - $classes[] = 'wpinv-failed-transaction'; |
|
272 | - $classes[] = 'wpinv-page'; |
|
273 | - } |
|
270 | + if( wpinv_is_failed_transaction_page() ) { |
|
271 | + $classes[] = 'wpinv-failed-transaction'; |
|
272 | + $classes[] = 'wpinv-page'; |
|
273 | + } |
|
274 | 274 | |
275 | - if( wpinv_is_invoice_history_page() ) { |
|
276 | - $classes[] = 'wpinv-history'; |
|
277 | - $classes[] = 'wpinv-page'; |
|
278 | - } |
|
275 | + if( wpinv_is_invoice_history_page() ) { |
|
276 | + $classes[] = 'wpinv-history'; |
|
277 | + $classes[] = 'wpinv-page'; |
|
278 | + } |
|
279 | 279 | |
280 | - if( wpinv_is_test_mode() ) { |
|
281 | - $classes[] = 'wpinv-test-mode'; |
|
282 | - $classes[] = 'wpinv-page'; |
|
283 | - } |
|
280 | + if( wpinv_is_test_mode() ) { |
|
281 | + $classes[] = 'wpinv-test-mode'; |
|
282 | + $classes[] = 'wpinv-page'; |
|
283 | + } |
|
284 | 284 | |
285 | - return array_unique( $classes ); |
|
285 | + return array_unique( $classes ); |
|
286 | 286 | } |
287 | 287 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
288 | 288 | |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1443 | 1443 | |
1444 | 1444 | function wpinv_empty_cart_message() { |
1445 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1445 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | /** |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * @return void |
1453 | 1453 | */ |
1454 | 1454 | function wpinv_empty_checkout_cart() { |
1455 | - echo wpinv_empty_cart_message(); |
|
1455 | + echo wpinv_empty_cart_message(); |
|
1456 | 1456 | } |
1457 | 1457 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1458 | 1458 | |
@@ -1588,11 +1588,11 @@ discard block |
||
1588 | 1588 | $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
1589 | 1589 | |
1590 | 1590 | if(!empty($gateways)){ |
1591 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1592 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1593 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1594 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1595 | - ?> |
|
1591 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
1592 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1593 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1594 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
1595 | + ?> |
|
1596 | 1596 | <div class="list-group-item"> |
1597 | 1597 | <div class="radio"> |
1598 | 1598 | <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> |
@@ -1605,9 +1605,9 @@ discard block |
||
1605 | 1605 | </div> |
1606 | 1606 | </div> |
1607 | 1607 | <?php |
1608 | - } |
|
1608 | + } |
|
1609 | 1609 | }else{ |
1610 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1610 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -7,105 +7,105 @@ 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', 'invoicing/' ); |
|
22 | + return apply_filters('wpinv_template_path', 'invoicing/'); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_post_class( $classes, $class, $post_id ) { |
|
25 | +function wpinv_post_class($classes, $class, $post_id) { |
|
26 | 26 | global $pagenow, $typenow; |
27 | 27 | |
28 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' ) { |
|
28 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && get_post_meta($post_id, '_wpinv_type', true) == 'package') { |
|
29 | 29 | $classes[] = 'wpi-gd-package'; |
30 | 30 | } |
31 | 31 | return $classes; |
32 | 32 | } |
33 | -add_filter( 'post_class', 'wpinv_post_class', 10, 3 ); |
|
33 | +add_filter('post_class', 'wpinv_post_class', 10, 3); |
|
34 | 34 | |
35 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
36 | - if ( empty( $invoice ) ) { |
|
35 | +function wpinv_display_invoice_top_bar($invoice) { |
|
36 | + if (empty($invoice)) { |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | <div class="row wpinv-top-bar no-print"> |
41 | 41 | <div class="container"> |
42 | 42 | <div class="col-xs-6"> |
43 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
43 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
44 | 44 | </div> |
45 | 45 | <div class="col-xs-6 text-right"> |
46 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
46 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | <?php |
51 | 51 | } |
52 | 52 | |
53 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
54 | - if ( empty( $invoice ) ) { |
|
53 | +function wpinv_invoice_display_left_actions($invoice) { |
|
54 | + if (empty($invoice)) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $user_id = (int)$invoice->get_user_id(); |
59 | 59 | $current_user_id = (int)get_current_user_id(); |
60 | 60 | |
61 | - if ( $user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment() ) { |
|
61 | + if ($user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment()) { |
|
62 | 62 | ?> |
63 | - <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> |
|
63 | + <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> |
|
64 | 64 | <?php |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
69 | - if ( empty( $invoice ) ) { |
|
68 | +function wpinv_invoice_display_right_actions($invoice) { |
|
69 | + if (empty($invoice)) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $user_id = (int)$invoice->get_user_id(); |
74 | 74 | $current_user_id = (int)get_current_user_id(); |
75 | 75 | |
76 | - if ( $user_id > 0 && $user_id == $current_user_id ) { |
|
76 | + if ($user_id > 0 && $user_id == $current_user_id) { |
|
77 | 77 | ?> |
78 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
79 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
78 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
79 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
80 | 80 | <?php } ?> |
81 | 81 | <?php |
82 | 82 | } |
83 | 83 | |
84 | -function wpinv_before_invoice_content( $content ) { |
|
84 | +function wpinv_before_invoice_content($content) { |
|
85 | 85 | global $post; |
86 | 86 | |
87 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
87 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
88 | 88 | ob_start(); |
89 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
89 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
90 | 90 | $content = ob_get_clean() . $content; |
91 | 91 | } |
92 | 92 | |
93 | 93 | return $content; |
94 | 94 | } |
95 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
95 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
96 | 96 | |
97 | -function wpinv_after_invoice_content( $content ) { |
|
97 | +function wpinv_after_invoice_content($content) { |
|
98 | 98 | global $post; |
99 | 99 | |
100 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
100 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
101 | 101 | ob_start(); |
102 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
102 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
103 | 103 | $content .= ob_get_clean(); |
104 | 104 | } |
105 | 105 | |
106 | 106 | return $content; |
107 | 107 | } |
108 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
108 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
109 | 109 | |
110 | 110 | function wpinv_get_templates_dir() { |
111 | 111 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -115,105 +115,105 @@ discard block |
||
115 | 115 | return WPINV_PLUGIN_URL . 'templates'; |
116 | 116 | } |
117 | 117 | |
118 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
119 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
120 | - extract( $args ); |
|
118 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
119 | + if (!empty($args) && is_array($args)) { |
|
120 | + extract($args); |
|
121 | 121 | } |
122 | 122 | |
123 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
124 | - if ( ! file_exists( $located ) ) { |
|
125 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
123 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
124 | + if (!file_exists($located)) { |
|
125 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Allow 3rd party plugin filter template file from their plugin. |
130 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
130 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
131 | 131 | |
132 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
132 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
133 | 133 | |
134 | - include( $located ); |
|
134 | + include($located); |
|
135 | 135 | |
136 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
139 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
140 | 140 | ob_start(); |
141 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
141 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
142 | 142 | return ob_get_clean(); |
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
146 | - if ( ! $template_path ) { |
|
145 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
146 | + if (!$template_path) { |
|
147 | 147 | $template_path = wpinv_template_path(); |
148 | 148 | } |
149 | 149 | |
150 | - if ( ! $default_path ) { |
|
150 | + if (!$default_path) { |
|
151 | 151 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Look within passed path within the theme - this is priority. |
155 | 155 | $template = locate_template( |
156 | 156 | array( |
157 | - trailingslashit( $template_path ) . $template_name, |
|
157 | + trailingslashit($template_path) . $template_name, |
|
158 | 158 | $template_name |
159 | 159 | ) |
160 | 160 | ); |
161 | 161 | |
162 | 162 | // Get default templates/ |
163 | - if ( !$template && $default_path ) { |
|
164 | - $template = trailingslashit( $default_path ) . $template_name; |
|
163 | + if (!$template && $default_path) { |
|
164 | + $template = trailingslashit($default_path) . $template_name; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Return what we found. |
168 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
168 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
172 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
171 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
172 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
173 | 173 | |
174 | 174 | // Setup possible parts |
175 | 175 | $templates = array(); |
176 | - if ( isset( $name ) ) |
|
176 | + if (isset($name)) |
|
177 | 177 | $templates[] = $slug . '-' . $name . '.php'; |
178 | 178 | $templates[] = $slug . '.php'; |
179 | 179 | |
180 | 180 | // Allow template parts to be filtered |
181 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
181 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
182 | 182 | |
183 | 183 | // Return the part that is found |
184 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
184 | + return wpinv_locate_tmpl($templates, $load, false); |
|
185 | 185 | } |
186 | 186 | |
187 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
187 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
188 | 188 | // No file found yet |
189 | 189 | $located = false; |
190 | 190 | |
191 | 191 | // Try to find a template file |
192 | - foreach ( (array)$template_names as $template_name ) { |
|
192 | + foreach ((array)$template_names as $template_name) { |
|
193 | 193 | |
194 | 194 | // Continue if template is empty |
195 | - if ( empty( $template_name ) ) |
|
195 | + if (empty($template_name)) |
|
196 | 196 | continue; |
197 | 197 | |
198 | 198 | // Trim off any slashes from the template name |
199 | - $template_name = ltrim( $template_name, '/' ); |
|
199 | + $template_name = ltrim($template_name, '/'); |
|
200 | 200 | |
201 | 201 | // try locating this template file by looping through the template paths |
202 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
202 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
203 | 203 | |
204 | - if( file_exists( $template_path . $template_name ) ) { |
|
204 | + if (file_exists($template_path . $template_name)) { |
|
205 | 205 | $located = $template_path . $template_name; |
206 | 206 | break; |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - if( $located ) { |
|
210 | + if ($located) { |
|
211 | 211 | break; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
216 | - load_template( $located, $require_once ); |
|
215 | + if ((true == $load) && !empty($located)) |
|
216 | + load_template($located, $require_once); |
|
217 | 217 | |
218 | 218 | return $located; |
219 | 219 | } |
@@ -222,143 +222,143 @@ discard block |
||
222 | 222 | $template_dir = wpinv_get_theme_template_dir_name(); |
223 | 223 | |
224 | 224 | $file_paths = array( |
225 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
226 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
225 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
226 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
227 | 227 | 100 => wpinv_get_templates_dir() |
228 | 228 | ); |
229 | 229 | |
230 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
230 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
231 | 231 | |
232 | 232 | // sort the file paths based on priority |
233 | - ksort( $file_paths, SORT_NUMERIC ); |
|
233 | + ksort($file_paths, SORT_NUMERIC); |
|
234 | 234 | |
235 | - return array_map( 'trailingslashit', $file_paths ); |
|
235 | + return array_map('trailingslashit', $file_paths); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | function wpinv_get_theme_template_dir_name() { |
239 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
239 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_checkout_meta_tags() { |
243 | 243 | |
244 | 244 | $pages = array(); |
245 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
246 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
247 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
245 | + $pages[] = wpinv_get_option('success_page'); |
|
246 | + $pages[] = wpinv_get_option('failure_page'); |
|
247 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
248 | 248 | |
249 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
249 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | 253 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
254 | 254 | } |
255 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
255 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
256 | 256 | |
257 | -function wpinv_add_body_classes( $class ) { |
|
257 | +function wpinv_add_body_classes($class) { |
|
258 | 258 | $classes = (array)$class; |
259 | 259 | |
260 | - if( wpinv_is_checkout() ) { |
|
260 | + if (wpinv_is_checkout()) { |
|
261 | 261 | $classes[] = 'wpinv-checkout'; |
262 | 262 | $classes[] = 'wpinv-page'; |
263 | 263 | } |
264 | 264 | |
265 | - if( wpinv_is_success_page() ) { |
|
265 | + if (wpinv_is_success_page()) { |
|
266 | 266 | $classes[] = 'wpinv-success'; |
267 | 267 | $classes[] = 'wpinv-page'; |
268 | 268 | } |
269 | 269 | |
270 | - if( wpinv_is_failed_transaction_page() ) { |
|
270 | + if (wpinv_is_failed_transaction_page()) { |
|
271 | 271 | $classes[] = 'wpinv-failed-transaction'; |
272 | 272 | $classes[] = 'wpinv-page'; |
273 | 273 | } |
274 | 274 | |
275 | - if( wpinv_is_invoice_history_page() ) { |
|
275 | + if (wpinv_is_invoice_history_page()) { |
|
276 | 276 | $classes[] = 'wpinv-history'; |
277 | 277 | $classes[] = 'wpinv-page'; |
278 | 278 | } |
279 | 279 | |
280 | - if( wpinv_is_test_mode() ) { |
|
280 | + if (wpinv_is_test_mode()) { |
|
281 | 281 | $classes[] = 'wpinv-test-mode'; |
282 | 282 | $classes[] = 'wpinv-page'; |
283 | 283 | } |
284 | 284 | |
285 | - return array_unique( $classes ); |
|
285 | + return array_unique($classes); |
|
286 | 286 | } |
287 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
287 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
288 | 288 | |
289 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
290 | - $args = array( 'nopaging' => true ); |
|
289 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
290 | + $args = array('nopaging' => true); |
|
291 | 291 | |
292 | - if ( ! empty( $status ) ) |
|
292 | + if (!empty($status)) |
|
293 | 293 | $args['post_status'] = $status; |
294 | 294 | |
295 | - $discounts = wpinv_get_discounts( $args ); |
|
295 | + $discounts = wpinv_get_discounts($args); |
|
296 | 296 | $options = array(); |
297 | 297 | |
298 | - if ( $discounts ) { |
|
299 | - foreach ( $discounts as $discount ) { |
|
300 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
298 | + if ($discounts) { |
|
299 | + foreach ($discounts as $discount) { |
|
300 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
301 | 301 | } |
302 | 302 | } else { |
303 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
303 | + $options[0] = __('No discounts found', 'invoicing'); |
|
304 | 304 | } |
305 | 305 | |
306 | - $output = wpinv_html_select( array( |
|
306 | + $output = wpinv_html_select(array( |
|
307 | 307 | 'name' => $name, |
308 | 308 | 'selected' => $selected, |
309 | 309 | 'options' => $options, |
310 | 310 | 'show_option_all' => false, |
311 | 311 | 'show_option_none' => false, |
312 | - ) ); |
|
312 | + )); |
|
313 | 313 | |
314 | 314 | return $output; |
315 | 315 | } |
316 | 316 | |
317 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
318 | - $current = date( 'Y' ); |
|
319 | - $start_year = $current - absint( $years_before ); |
|
320 | - $end_year = $current + absint( $years_after ); |
|
321 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
317 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
318 | + $current = date('Y'); |
|
319 | + $start_year = $current - absint($years_before); |
|
320 | + $end_year = $current + absint($years_after); |
|
321 | + $selected = empty($selected) ? date('Y') : $selected; |
|
322 | 322 | $options = array(); |
323 | 323 | |
324 | - while ( $start_year <= $end_year ) { |
|
325 | - $options[ absint( $start_year ) ] = $start_year; |
|
324 | + while ($start_year <= $end_year) { |
|
325 | + $options[absint($start_year)] = $start_year; |
|
326 | 326 | $start_year++; |
327 | 327 | } |
328 | 328 | |
329 | - $output = wpinv_html_select( array( |
|
329 | + $output = wpinv_html_select(array( |
|
330 | 330 | 'name' => $name, |
331 | 331 | 'selected' => $selected, |
332 | 332 | 'options' => $options, |
333 | 333 | 'show_option_all' => false, |
334 | 334 | 'show_option_none' => false |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | |
337 | 337 | return $output; |
338 | 338 | } |
339 | 339 | |
340 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
340 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
341 | 341 | $month = 1; |
342 | 342 | $options = array(); |
343 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
343 | + $selected = empty($selected) ? date('n') : $selected; |
|
344 | 344 | |
345 | - while ( $month <= 12 ) { |
|
346 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
345 | + while ($month <= 12) { |
|
346 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
347 | 347 | $month++; |
348 | 348 | } |
349 | 349 | |
350 | - $output = wpinv_html_select( array( |
|
350 | + $output = wpinv_html_select(array( |
|
351 | 351 | 'name' => $name, |
352 | 352 | 'selected' => $selected, |
353 | 353 | 'options' => $options, |
354 | 354 | 'show_option_all' => false, |
355 | 355 | 'show_option_none' => false |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | |
358 | 358 | return $output; |
359 | 359 | } |
360 | 360 | |
361 | -function wpinv_html_select( $args = array() ) { |
|
361 | +function wpinv_html_select($args = array()) { |
|
362 | 362 | $defaults = array( |
363 | 363 | 'options' => array(), |
364 | 364 | 'name' => null, |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | 'chosen' => false, |
369 | 369 | 'placeholder' => null, |
370 | 370 | 'multiple' => false, |
371 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
372 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
371 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
372 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
373 | 373 | 'data' => array(), |
374 | 374 | 'onchange' => null, |
375 | 375 | 'required' => false, |
@@ -377,78 +377,78 @@ discard block |
||
377 | 377 | 'readonly' => false, |
378 | 378 | ); |
379 | 379 | |
380 | - $args = wp_parse_args( $args, $defaults ); |
|
380 | + $args = wp_parse_args($args, $defaults); |
|
381 | 381 | |
382 | 382 | $data_elements = ''; |
383 | - foreach ( $args['data'] as $key => $value ) { |
|
384 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
383 | + foreach ($args['data'] as $key => $value) { |
|
384 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
385 | 385 | } |
386 | 386 | |
387 | - if( $args['multiple'] ) { |
|
387 | + if ($args['multiple']) { |
|
388 | 388 | $multiple = ' MULTIPLE'; |
389 | 389 | } else { |
390 | 390 | $multiple = ''; |
391 | 391 | } |
392 | 392 | |
393 | - if( $args['chosen'] ) { |
|
393 | + if ($args['chosen']) { |
|
394 | 394 | $args['class'] .= ' wpinv-select-chosen'; |
395 | 395 | } |
396 | 396 | |
397 | - if( $args['placeholder'] ) { |
|
397 | + if ($args['placeholder']) { |
|
398 | 398 | $placeholder = $args['placeholder']; |
399 | 399 | } else { |
400 | 400 | $placeholder = ''; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $options = ''; |
404 | - if( !empty( $args['onchange'] ) ) { |
|
405 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
404 | + if (!empty($args['onchange'])) { |
|
405 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
406 | 406 | } |
407 | 407 | |
408 | - if( !empty( $args['required'] ) ) { |
|
408 | + if (!empty($args['required'])) { |
|
409 | 409 | $options .= ' required="required"'; |
410 | 410 | } |
411 | 411 | |
412 | - if( !empty( $args['disabled'] ) ) { |
|
412 | + if (!empty($args['disabled'])) { |
|
413 | 413 | $options .= ' disabled'; |
414 | 414 | } |
415 | 415 | |
416 | - if( !empty( $args['readonly'] ) ) { |
|
416 | + if (!empty($args['readonly'])) { |
|
417 | 417 | $options .= ' readonly'; |
418 | 418 | } |
419 | 419 | |
420 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
421 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
420 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
421 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
422 | 422 | |
423 | - if ( $args['show_option_all'] ) { |
|
424 | - if( $args['multiple'] ) { |
|
425 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
423 | + if ($args['show_option_all']) { |
|
424 | + if ($args['multiple']) { |
|
425 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
426 | 426 | } else { |
427 | - $selected = selected( $args['selected'], 0, false ); |
|
427 | + $selected = selected($args['selected'], 0, false); |
|
428 | 428 | } |
429 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
429 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
430 | 430 | } |
431 | 431 | |
432 | - if ( !empty( $args['options'] ) ) { |
|
432 | + if (!empty($args['options'])) { |
|
433 | 433 | |
434 | - if ( $args['show_option_none'] ) { |
|
435 | - if( $args['multiple'] ) { |
|
436 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
434 | + if ($args['show_option_none']) { |
|
435 | + if ($args['multiple']) { |
|
436 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
437 | 437 | } else { |
438 | - $selected = selected( $args['selected'] === "", true, false ); |
|
438 | + $selected = selected($args['selected'] === "", true, false); |
|
439 | 439 | } |
440 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
440 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
441 | 441 | } |
442 | 442 | |
443 | - foreach( $args['options'] as $key => $option ) { |
|
443 | + foreach ($args['options'] as $key => $option) { |
|
444 | 444 | |
445 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
446 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
445 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
446 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
447 | 447 | } else { |
448 | - $selected = selected( $args['selected'], $key, false ); |
|
448 | + $selected = selected($args['selected'], $key, false); |
|
449 | 449 | } |
450 | 450 | |
451 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
451 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | return $output; |
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_item_dropdown( $args = array() ) { |
|
460 | +function wpinv_item_dropdown($args = array()) { |
|
461 | 461 | $defaults = array( |
462 | 462 | 'name' => 'wpi_item', |
463 | 463 | 'id' => 'wpi_item', |
@@ -466,15 +466,15 @@ discard block |
||
466 | 466 | 'selected' => 0, |
467 | 467 | 'chosen' => false, |
468 | 468 | 'number' => 100, |
469 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
470 | - 'data' => array( 'search-type' => 'item' ), |
|
469 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
470 | + 'data' => array('search-type' => 'item'), |
|
471 | 471 | 'show_option_all' => false, |
472 | 472 | 'show_option_none' => false, |
473 | 473 | 'with_packages' => true, |
474 | 474 | 'show_recurring' => false, |
475 | 475 | ); |
476 | 476 | |
477 | - $args = wp_parse_args( $args, $defaults ); |
|
477 | + $args = wp_parse_args($args, $defaults); |
|
478 | 478 | |
479 | 479 | $item_args = array( |
480 | 480 | 'post_type' => 'wpi_item', |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | 'posts_per_page' => $args['number'] |
484 | 484 | ); |
485 | 485 | |
486 | - if ( !$args['with_packages'] ) { |
|
486 | + if (!$args['with_packages']) { |
|
487 | 487 | $item_args['meta_query'] = array( |
488 | 488 | array( |
489 | 489 | 'key' => '_wpinv_type', |
@@ -493,42 +493,42 @@ discard block |
||
493 | 493 | ); |
494 | 494 | } |
495 | 495 | |
496 | - $items = get_posts( $item_args ); |
|
496 | + $items = get_posts($item_args); |
|
497 | 497 | $options = array(); |
498 | - if ( $items ) { |
|
499 | - foreach ( $items as $item ) { |
|
500 | - $title = esc_html( $item->post_title ); |
|
498 | + if ($items) { |
|
499 | + foreach ($items as $item) { |
|
500 | + $title = esc_html($item->post_title); |
|
501 | 501 | |
502 | - if ( !empty( $args['show_recurring'] ) ) { |
|
503 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
502 | + if (!empty($args['show_recurring'])) { |
|
503 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
504 | 504 | } |
505 | 505 | |
506 | - $options[ absint( $item->ID ) ] = $title; |
|
506 | + $options[absint($item->ID)] = $title; |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
510 | 510 | // This ensures that any selected items are included in the drop down |
511 | - if( is_array( $args['selected'] ) ) { |
|
512 | - foreach( $args['selected'] as $item ) { |
|
513 | - if( ! in_array( $item, $options ) ) { |
|
514 | - $title = get_the_title( $item ); |
|
515 | - if ( !empty( $args['show_recurring'] ) ) { |
|
516 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
511 | + if (is_array($args['selected'])) { |
|
512 | + foreach ($args['selected'] as $item) { |
|
513 | + if (!in_array($item, $options)) { |
|
514 | + $title = get_the_title($item); |
|
515 | + if (!empty($args['show_recurring'])) { |
|
516 | + $title .= wpinv_get_item_suffix($item, false); |
|
517 | 517 | } |
518 | 518 | $options[$item] = $title; |
519 | 519 | } |
520 | 520 | } |
521 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
522 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
523 | - $title = get_the_title( $args['selected'] ); |
|
524 | - if ( !empty( $args['show_recurring'] ) ) { |
|
525 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
521 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
522 | + if (!in_array($args['selected'], $options)) { |
|
523 | + $title = get_the_title($args['selected']); |
|
524 | + if (!empty($args['show_recurring'])) { |
|
525 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
526 | 526 | } |
527 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
527 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - $output = wpinv_html_select( array( |
|
531 | + $output = wpinv_html_select(array( |
|
532 | 532 | 'name' => $args['name'], |
533 | 533 | 'selected' => $args['selected'], |
534 | 534 | 'id' => $args['id'], |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | 'show_option_all' => $args['show_option_all'], |
541 | 541 | 'show_option_none' => $args['show_option_none'], |
542 | 542 | 'data' => $args['data'], |
543 | - ) ); |
|
543 | + )); |
|
544 | 544 | |
545 | 545 | return $output; |
546 | 546 | } |
547 | 547 | |
548 | -function wpinv_html_checkbox( $args = array() ) { |
|
548 | +function wpinv_html_checkbox($args = array()) { |
|
549 | 549 | $defaults = array( |
550 | 550 | 'name' => null, |
551 | 551 | 'current' => null, |
@@ -556,38 +556,38 @@ discard block |
||
556 | 556 | ) |
557 | 557 | ); |
558 | 558 | |
559 | - $args = wp_parse_args( $args, $defaults ); |
|
559 | + $args = wp_parse_args($args, $defaults); |
|
560 | 560 | |
561 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
561 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
562 | 562 | $options = ''; |
563 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
563 | + if (!empty($args['options']['disabled'])) { |
|
564 | 564 | $options .= ' disabled="disabled"'; |
565 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
565 | + } elseif (!empty($args['options']['readonly'])) { |
|
566 | 566 | $options .= ' readonly'; |
567 | 567 | } |
568 | 568 | |
569 | - $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 ) . ' />'; |
|
569 | + $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) . ' />'; |
|
570 | 570 | |
571 | 571 | return $output; |
572 | 572 | } |
573 | 573 | |
574 | -function wpinv_html_text( $args = array() ) { |
|
574 | +function wpinv_html_text($args = array()) { |
|
575 | 575 | // Backwards compatibility |
576 | - if ( func_num_args() > 1 ) { |
|
576 | + if (func_num_args() > 1) { |
|
577 | 577 | $args = func_get_args(); |
578 | 578 | |
579 | 579 | $name = $args[0]; |
580 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
581 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
582 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
580 | + $value = isset($args[1]) ? $args[1] : ''; |
|
581 | + $label = isset($args[2]) ? $args[2] : ''; |
|
582 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | $defaults = array( |
586 | 586 | 'id' => '', |
587 | - 'name' => isset( $name ) ? $name : 'text', |
|
588 | - 'value' => isset( $value ) ? $value : null, |
|
589 | - 'label' => isset( $label ) ? $label : null, |
|
590 | - 'desc' => isset( $desc ) ? $desc : null, |
|
587 | + 'name' => isset($name) ? $name : 'text', |
|
588 | + 'value' => isset($value) ? $value : null, |
|
589 | + 'label' => isset($label) ? $label : null, |
|
590 | + 'desc' => isset($desc) ? $desc : null, |
|
591 | 591 | 'placeholder' => '', |
592 | 592 | 'class' => 'regular-text', |
593 | 593 | 'disabled' => false, |
@@ -597,51 +597,51 @@ discard block |
||
597 | 597 | 'data' => false |
598 | 598 | ); |
599 | 599 | |
600 | - $args = wp_parse_args( $args, $defaults ); |
|
600 | + $args = wp_parse_args($args, $defaults); |
|
601 | 601 | |
602 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
602 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
603 | 603 | $options = ''; |
604 | - if( $args['required'] ) { |
|
604 | + if ($args['required']) { |
|
605 | 605 | $options .= ' required="required"'; |
606 | 606 | } |
607 | - if( $args['readonly'] ) { |
|
607 | + if ($args['readonly']) { |
|
608 | 608 | $options .= ' readonly'; |
609 | 609 | } |
610 | - if( $args['readonly'] ) { |
|
610 | + if ($args['readonly']) { |
|
611 | 611 | $options .= ' readonly'; |
612 | 612 | } |
613 | 613 | |
614 | 614 | $data = ''; |
615 | - if ( !empty( $args['data'] ) ) { |
|
616 | - foreach ( $args['data'] as $key => $value ) { |
|
617 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
615 | + if (!empty($args['data'])) { |
|
616 | + foreach ($args['data'] as $key => $value) { |
|
617 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | |
621 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
622 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
623 | - if ( ! empty( $args['desc'] ) ) { |
|
624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
621 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
622 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
623 | + if (!empty($args['desc'])) { |
|
624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
625 | 625 | } |
626 | 626 | |
627 | - $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 ) . '/>'; |
|
627 | + $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) . '/>'; |
|
628 | 628 | |
629 | 629 | $output .= '</span>'; |
630 | 630 | |
631 | 631 | return $output; |
632 | 632 | } |
633 | 633 | |
634 | -function wpinv_html_date_field( $args = array() ) { |
|
635 | - if( empty( $args['class'] ) ) { |
|
634 | +function wpinv_html_date_field($args = array()) { |
|
635 | + if (empty($args['class'])) { |
|
636 | 636 | $args['class'] = 'wpiDatepicker'; |
637 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
637 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
638 | 638 | $args['class'] .= ' wpiDatepicker'; |
639 | 639 | } |
640 | 640 | |
641 | - return wpinv_html_text( $args ); |
|
641 | + return wpinv_html_text($args); |
|
642 | 642 | } |
643 | 643 | |
644 | -function wpinv_html_textarea( $args = array() ) { |
|
644 | +function wpinv_html_textarea($args = array()) { |
|
645 | 645 | $defaults = array( |
646 | 646 | 'name' => 'textarea', |
647 | 647 | 'value' => null, |
@@ -651,31 +651,31 @@ discard block |
||
651 | 651 | 'disabled' => false |
652 | 652 | ); |
653 | 653 | |
654 | - $args = wp_parse_args( $args, $defaults ); |
|
654 | + $args = wp_parse_args($args, $defaults); |
|
655 | 655 | |
656 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
656 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
657 | 657 | $disabled = ''; |
658 | - if( $args['disabled'] ) { |
|
658 | + if ($args['disabled']) { |
|
659 | 659 | $disabled = ' disabled="disabled"'; |
660 | 660 | } |
661 | 661 | |
662 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
663 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
664 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
662 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
663 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
664 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
665 | 665 | |
666 | - if ( ! empty( $args['desc'] ) ) { |
|
667 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
666 | + if (!empty($args['desc'])) { |
|
667 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
668 | 668 | } |
669 | 669 | $output .= '</span>'; |
670 | 670 | |
671 | 671 | return $output; |
672 | 672 | } |
673 | 673 | |
674 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
674 | +function wpinv_html_ajax_user_search($args = array()) { |
|
675 | 675 | $defaults = array( |
676 | 676 | 'name' => 'user_id', |
677 | 677 | 'value' => null, |
678 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
678 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
679 | 679 | 'label' => null, |
680 | 680 | 'desc' => null, |
681 | 681 | 'class' => '', |
@@ -684,13 +684,13 @@ discard block |
||
684 | 684 | 'data' => false |
685 | 685 | ); |
686 | 686 | |
687 | - $args = wp_parse_args( $args, $defaults ); |
|
687 | + $args = wp_parse_args($args, $defaults); |
|
688 | 688 | |
689 | 689 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
690 | 690 | |
691 | 691 | $output = '<span class="wpinv_user_search_wrap">'; |
692 | - $output .= wpinv_html_text( $args ); |
|
693 | - $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>'; |
|
692 | + $output .= wpinv_html_text($args); |
|
693 | + $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>'; |
|
694 | 694 | $output .= '</span>'; |
695 | 695 | |
696 | 696 | return $output; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | function wpinv_ip_geolocation() { |
700 | 700 | global $wpinv_euvat; |
701 | 701 | |
702 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
702 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
703 | 703 | $content = ''; |
704 | 704 | $iso = ''; |
705 | 705 | $country = ''; |
@@ -709,70 +709,70 @@ discard block |
||
709 | 709 | $latitude = ''; |
710 | 710 | $credit = ''; |
711 | 711 | |
712 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
712 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
713 | 713 | try { |
714 | 714 | $iso = $geoip2_city->country->isoCode; |
715 | 715 | $country = $geoip2_city->country->name; |
716 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
716 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
717 | 717 | $city = $geoip2_city->city->name; |
718 | 718 | $longitude = $geoip2_city->location->longitude; |
719 | 719 | $latitude = $geoip2_city->location->latitude; |
720 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
721 | - } catch( Exception $e ) { } |
|
720 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
721 | + } catch (Exception $e) { } |
|
722 | 722 | } |
723 | 723 | |
724 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
724 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
725 | 725 | try { |
726 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
726 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
727 | 727 | |
728 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
728 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
729 | 729 | $iso = $load_xml->geoplugin_countryCode; |
730 | 730 | $country = $load_xml->geoplugin_countryName; |
731 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
732 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
731 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
732 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
733 | 733 | $longitude = $load_xml->geoplugin_longitude; |
734 | 734 | $latitude = $load_xml->geoplugin_latitude; |
735 | 735 | $credit = $load_xml->geoplugin_credit; |
736 | - $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; |
|
736 | + $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; |
|
737 | 737 | } |
738 | - } catch( Exception $e ) { } |
|
738 | + } catch (Exception $e) { } |
|
739 | 739 | } |
740 | 740 | |
741 | - if ( $iso && $longitude && $latitude ) { |
|
741 | + if ($iso && $longitude && $latitude) { |
|
742 | 742 | $address = ''; |
743 | - if ( $city ) { |
|
743 | + if ($city) { |
|
744 | 744 | $address .= $city . ', '; |
745 | 745 | } |
746 | 746 | |
747 | - if ( $region ) { |
|
747 | + if ($region) { |
|
748 | 748 | $address .= $region . ', '; |
749 | 749 | } |
750 | 750 | |
751 | 751 | $address .= $country . ' (' . $iso . ')'; |
752 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
753 | - $content .= '<p>'. $credit . '</p>'; |
|
752 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
753 | + $content .= '<p>' . $credit . '</p>'; |
|
754 | 754 | } else { |
755 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
755 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
756 | 756 | } |
757 | 757 | ?> |
758 | 758 | <!DOCTYPE html> |
759 | -<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> |
|
759 | +<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> |
|
760 | 760 | <body> |
761 | - <?php if ( $latitude && $latitude ) { ?> |
|
761 | + <?php if ($latitude && $latitude) { ?> |
|
762 | 762 | <div id="map"></div> |
763 | 763 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
764 | 764 | <script type="text/javascript"> |
765 | 765 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
766 | 766 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
767 | 767 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
768 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
768 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
769 | 769 | |
770 | 770 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
771 | 771 | |
772 | 772 | var marker = new L.Marker(latlng); |
773 | 773 | map.addLayer(marker); |
774 | 774 | |
775 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
775 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
776 | 776 | </script> |
777 | 777 | <?php } ?> |
778 | 778 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -780,31 +780,31 @@ discard block |
||
780 | 780 | <?php |
781 | 781 | exit; |
782 | 782 | } |
783 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
784 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
783 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
784 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
785 | 785 | |
786 | 786 | // Set up the template for the invoice. |
787 | -function wpinv_template( $template ) { |
|
787 | +function wpinv_template($template) { |
|
788 | 788 | global $post, $wp_query; |
789 | 789 | |
790 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && get_post_type( $post->ID ) == 'wpi_invoice' ) { |
|
791 | - if ( wpinv_user_can_print_invoice( $post->ID ) ) { |
|
792 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
790 | + if ((is_single() || is_404()) && !empty($post->ID) && get_post_type($post->ID) == 'wpi_invoice') { |
|
791 | + if (wpinv_user_can_print_invoice($post->ID)) { |
|
792 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
793 | 793 | } else { |
794 | - if ( !is_user_logged_in() && !empty( $_REQUEST['_wpipay'] ) && $invoice = wpinv_get_invoice( $post->ID ) ) { |
|
794 | + if (!is_user_logged_in() && !empty($_REQUEST['_wpipay']) && $invoice = wpinv_get_invoice($post->ID)) { |
|
795 | 795 | $user_id = $invoice->get_user_id(); |
796 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
796 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
797 | 797 | |
798 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key() ) ) { // valid invoice link |
|
799 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
798 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key())) { // valid invoice link |
|
799 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
800 | 800 | |
801 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
801 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
802 | 802 | wpinv_die(); |
803 | 803 | } |
804 | 804 | } |
805 | - $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
805 | + $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
806 | 806 | |
807 | - wp_redirect( $redirect_to ); |
|
807 | + wp_redirect($redirect_to); |
|
808 | 808 | wpinv_die(); |
809 | 809 | } |
810 | 810 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | function wpinv_get_business_address() { |
816 | 816 | $business_address = wpinv_store_address(); |
817 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
817 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
818 | 818 | |
819 | 819 | /* |
820 | 820 | $default_country = wpinv_get_default_country(); |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
840 | 840 | |
841 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
841 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | function wpinv_display_from_address() { |
@@ -848,181 +848,181 @@ discard block |
||
848 | 848 | if (empty($from_name)) { |
849 | 849 | $from_name = wpinv_get_business_name(); |
850 | 850 | } |
851 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
851 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
852 | 852 | <div class="wrapper col-xs-10"> |
853 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
854 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
855 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
853 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
854 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
855 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
856 | 856 | <?php } ?> |
857 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
858 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s' ), $email_from );?></div> |
|
857 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
858 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s'), $email_from); ?></div> |
|
859 | 859 | <?php } ?> |
860 | 860 | </div> |
861 | 861 | <?php |
862 | 862 | } |
863 | 863 | |
864 | -function wpinv_watermark( $id = 0 ) { |
|
865 | - $output = wpinv_get_watermark( $id ); |
|
864 | +function wpinv_watermark($id = 0) { |
|
865 | + $output = wpinv_get_watermark($id); |
|
866 | 866 | |
867 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
867 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
868 | 868 | } |
869 | 869 | |
870 | -function wpinv_get_watermark( $id ) { |
|
871 | - if ( !$id > 0 ) { |
|
870 | +function wpinv_get_watermark($id) { |
|
871 | + if (!$id > 0) { |
|
872 | 872 | return NULL; |
873 | 873 | } |
874 | - $invoice = wpinv_get_invoice( $id ); |
|
874 | + $invoice = wpinv_get_invoice($id); |
|
875 | 875 | |
876 | - if ( !empty( $invoice ) ) { |
|
877 | - if ( $invoice->is_paid() ) { |
|
878 | - return __( 'Paid', 'invoicing' ); |
|
876 | + if (!empty($invoice)) { |
|
877 | + if ($invoice->is_paid()) { |
|
878 | + return __('Paid', 'invoicing'); |
|
879 | 879 | } |
880 | - if ( $invoice->has_status( array( 'cancelled' ) ) ) { |
|
881 | - return __( 'Cancelled', 'invoicing' ); |
|
880 | + if ($invoice->has_status(array('cancelled'))) { |
|
881 | + return __('Cancelled', 'invoicing'); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | |
885 | 885 | return NULL; |
886 | 886 | } |
887 | 887 | |
888 | -function wpinv_display_invoice_details( $invoice ) { |
|
888 | +function wpinv_display_invoice_details($invoice) { |
|
889 | 889 | global $wpinv_euvat; |
890 | 890 | |
891 | 891 | $invoice_id = $invoice->ID; |
892 | 892 | $vat_name = $wpinv_euvat->get_vat_name(); |
893 | 893 | |
894 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
894 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
895 | 895 | ?> |
896 | 896 | <table class="table table-bordered table-sm"> |
897 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
897 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
898 | 898 | <tr class="wpi-row-number"> |
899 | - <th><?php _e( 'Invoice Number', 'invoicing' ); ?></th> |
|
900 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
899 | + <th><?php _e('Invoice Number', 'invoicing'); ?></th> |
|
900 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
901 | 901 | </tr> |
902 | 902 | <?php } ?> |
903 | 903 | <tr class="wpi-row-status"> |
904 | - <th><?php _e( 'Invoice Status', 'invoicing' ); ?></th> |
|
905 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
904 | + <th><?php _e('Invoice Status', 'invoicing'); ?></th> |
|
905 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
906 | 906 | </tr> |
907 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
907 | + <?php if ($invoice->is_renewal()) { ?> |
|
908 | 908 | <tr class="wpi-row-parent"> |
909 | - <th><?php _e( 'Parent Invoice', 'invoicing' ); ?></th> |
|
910 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
909 | + <th><?php _e('Parent Invoice', 'invoicing'); ?></th> |
|
910 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
911 | 911 | </tr> |
912 | 912 | <?php } ?> |
913 | 913 | <tr class="wpi-row-gateway"> |
914 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
915 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
914 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
915 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
916 | 916 | </tr> |
917 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
917 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
918 | 918 | <tr class="wpi-row-date"> |
919 | - <th><?php _e( 'Invoice Date', 'invoicing' ); ?></th> |
|
919 | + <th><?php _e('Invoice Date', 'invoicing'); ?></th> |
|
920 | 920 | <td><?php echo $invoice_date; ?></td> |
921 | 921 | </tr> |
922 | 922 | <?php } ?> |
923 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
923 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
924 | 924 | <tr class="wpi-row-date"> |
925 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
925 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
926 | 926 | <td><?php echo $due_date; ?></td> |
927 | 927 | </tr> |
928 | 928 | <?php } ?> |
929 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
929 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
930 | 930 | <tr class="wpi-row-ovatno"> |
931 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
931 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
932 | 932 | <td><?php echo $owner_vat_number; ?></td> |
933 | 933 | </tr> |
934 | 934 | <?php } ?> |
935 | - <?php if ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
935 | + <?php if ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
936 | 936 | <tr class="wpi-row-uvatno"> |
937 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
937 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
938 | 938 | <td><?php echo $user_vat_number; ?></td> |
939 | 939 | </tr> |
940 | 940 | <?php } ?> |
941 | 941 | <tr class="table-active tr-total wpi-row-total"> |
942 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
943 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
942 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
943 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
944 | 944 | </tr> |
945 | 945 | </table> |
946 | 946 | <?php |
947 | 947 | } |
948 | 948 | |
949 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
950 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
949 | +function wpinv_display_to_address($invoice_id = 0) { |
|
950 | + $invoice = wpinv_get_invoice($invoice_id); |
|
951 | 951 | |
952 | - if ( empty( $invoice ) ) { |
|
952 | + if (empty($invoice)) { |
|
953 | 953 | return NULL; |
954 | 954 | } |
955 | 955 | |
956 | 956 | $billing_details = $invoice->get_user_info(); |
957 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
957 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
958 | 958 | $output .= '<div class="wrapper col-xs-10">'; |
959 | 959 | |
960 | 960 | ob_start(); |
961 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
961 | + do_action('wpinv_display_to_address_top', $invoice); |
|
962 | 962 | $output .= ob_get_clean(); |
963 | 963 | |
964 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
965 | - if ( $company = $billing_details['company'] ) { |
|
966 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
964 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
965 | + if ($company = $billing_details['company']) { |
|
966 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
967 | 967 | } |
968 | 968 | $address_row = ''; |
969 | - if ( $address = $billing_details['address'] ) { |
|
970 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
969 | + if ($address = $billing_details['address']) { |
|
970 | + $address_row .= wpautop(wp_kses_post($address)); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | $address_fields = array(); |
974 | - if ( !empty( $billing_details['city'] ) ) { |
|
974 | + if (!empty($billing_details['city'])) { |
|
975 | 975 | $address_fields[] = $billing_details['city']; |
976 | 976 | } |
977 | 977 | |
978 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
979 | - if ( !empty( $billing_details['state'] ) ) { |
|
980 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
978 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
979 | + if (!empty($billing_details['state'])) { |
|
980 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
981 | 981 | } |
982 | 982 | |
983 | - if ( !empty( $billing_country ) ) { |
|
984 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
983 | + if (!empty($billing_country)) { |
|
984 | + $address_fields[] = wpinv_country_name($billing_country); |
|
985 | 985 | } |
986 | 986 | |
987 | - if ( !empty( $address_fields ) ) { |
|
988 | - $address_fields = implode( ", ", $address_fields ); |
|
987 | + if (!empty($address_fields)) { |
|
988 | + $address_fields = implode(", ", $address_fields); |
|
989 | 989 | |
990 | - if ( !empty( $billing_details['zip'] ) ) { |
|
990 | + if (!empty($billing_details['zip'])) { |
|
991 | 991 | $address_fields .= ' ' . $billing_details['zip']; |
992 | 992 | } |
993 | 993 | |
994 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
994 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
995 | 995 | } |
996 | 996 | |
997 | - if ( $address_row ) { |
|
997 | + if ($address_row) { |
|
998 | 998 | $output .= '<div class="address">' . $address_row . '</div>'; |
999 | 999 | } |
1000 | 1000 | |
1001 | - if ( $phone = $invoice->get_phone() ) { |
|
1002 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s' ), esc_html( $phone ) ) . '</div>'; |
|
1001 | + if ($phone = $invoice->get_phone()) { |
|
1002 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s'), esc_html($phone)) . '</div>'; |
|
1003 | 1003 | } |
1004 | - if ( $email = $invoice->get_email() ) { |
|
1005 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' ), esc_html( $email ) ) . '</div>'; |
|
1004 | + if ($email = $invoice->get_email()) { |
|
1005 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s'), esc_html($email)) . '</div>'; |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | ob_start(); |
1009 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
1009 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
1010 | 1010 | $output .= ob_get_clean(); |
1011 | 1011 | |
1012 | 1012 | $output .= '</div>'; |
1013 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1013 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1014 | 1014 | |
1015 | 1015 | echo $output; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1018 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1019 | 1019 | global $wpinv_euvat, $ajax_cart_details; |
1020 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1020 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1021 | 1021 | $quantities_enabled = wpinv_item_quantities_enabled(); |
1022 | 1022 | $use_taxes = wpinv_use_taxes(); |
1023 | 1023 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
1024 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
1025 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
1024 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
1025 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
1026 | 1026 | |
1027 | 1027 | $cart_details = $invoice->get_cart_details(); |
1028 | 1028 | $ajax_cart_details = $cart_details; |
@@ -1031,67 +1031,67 @@ discard block |
||
1031 | 1031 | <table class="table table-sm table-bordered table-responsive"> |
1032 | 1032 | <thead> |
1033 | 1033 | <tr> |
1034 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1035 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1034 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1035 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1036 | 1036 | <?php if ($quantities_enabled) { ?> |
1037 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1037 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1038 | 1038 | <?php } ?> |
1039 | 1039 | <?php if ($use_taxes && !$zero_tax) { ?> |
1040 | 1040 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1041 | 1041 | <?php } ?> |
1042 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1042 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1043 | 1043 | </tr> |
1044 | 1044 | </thead> |
1045 | 1045 | <tbody> |
1046 | 1046 | <?php |
1047 | - if ( !empty( $cart_details ) ) { |
|
1048 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1047 | + if (!empty($cart_details)) { |
|
1048 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1049 | 1049 | |
1050 | 1050 | $count = 0; |
1051 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1052 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1053 | - $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount( $cart_item["item_price"] ) : 0; |
|
1054 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount( $cart_item["subtotal"] ) : 0; |
|
1055 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1051 | + foreach ($cart_details as $key => $cart_item) { |
|
1052 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1053 | + $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount($cart_item["item_price"]) : 0; |
|
1054 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount($cart_item["subtotal"]) : 0; |
|
1055 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1056 | 1056 | |
1057 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1057 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1058 | 1058 | $summary = ''; |
1059 | 1059 | $cols = 3; |
1060 | - if ( !empty($item) ) { |
|
1060 | + if (!empty($item)) { |
|
1061 | 1061 | $item_name = $item->get_name(); |
1062 | 1062 | $summary = $item->get_summary(); |
1063 | 1063 | } |
1064 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1064 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1065 | 1065 | |
1066 | 1066 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1067 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1068 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_cpt_singular_name(), $post_link ); |
|
1067 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1068 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_cpt_singular_name(), $post_link); |
|
1069 | 1069 | } |
1070 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1070 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1071 | 1071 | |
1072 | 1072 | $item_tax = ''; |
1073 | 1073 | $tax_rate = ''; |
1074 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1075 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1076 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1077 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
1074 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1075 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1076 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1077 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
1078 | 1078 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | $line_item_tax = $item_tax . $tax_rate; |
1082 | 1082 | |
1083 | - if ( $line_item_tax === '' ) { |
|
1083 | + if ($line_item_tax === '') { |
|
1084 | 1084 | $line_item_tax = 0; // Zero tax |
1085 | 1085 | } |
1086 | 1086 | |
1087 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1088 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1089 | - if ( $summary !== '' ) { |
|
1090 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1087 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1088 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1089 | + if ($summary !== '') { |
|
1090 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1091 | 1091 | } |
1092 | 1092 | $line_item .= '</td>'; |
1093 | 1093 | |
1094 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( $item_price, $invoice->get_currency() ) ) . '</td>'; |
|
1094 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price($item_price, $invoice->get_currency())) . '</td>'; |
|
1095 | 1095 | if ($quantities_enabled) { |
1096 | 1096 | $cols++; |
1097 | 1097 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1100,55 +1100,55 @@ discard block |
||
1100 | 1100 | $cols++; |
1101 | 1101 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1102 | 1102 | } |
1103 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( $line_total, $invoice->get_currency() ) ) . '</td>'; |
|
1103 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price($line_total, $invoice->get_currency())) . '</td>'; |
|
1104 | 1104 | $line_item .= '</tr>'; |
1105 | 1105 | |
1106 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1106 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1107 | 1107 | |
1108 | 1108 | $count++; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1111 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1112 | 1112 | ?> |
1113 | 1113 | <tr class="row-sub-total row_odd"> |
1114 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1115 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1114 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1115 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1116 | 1116 | </tr> |
1117 | 1117 | <?php |
1118 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1118 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1119 | 1119 | |
1120 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1121 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1120 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1121 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1122 | 1122 | ?> |
1123 | 1123 | <tr class="row-discount"> |
1124 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1125 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1124 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1125 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1126 | 1126 | </tr> |
1127 | 1127 | <?php |
1128 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1128 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | - if ( $use_taxes ) { |
|
1132 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1131 | + if ($use_taxes) { |
|
1132 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1133 | 1133 | ?> |
1134 | 1134 | <tr class="row-tax"> |
1135 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1136 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1135 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1136 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1137 | 1137 | </tr> |
1138 | 1138 | <?php |
1139 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1139 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1142 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1143 | 1143 | ?> |
1144 | 1144 | <tr class="table-active row-total"> |
1145 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1146 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1145 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1146 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1147 | 1147 | </tr> |
1148 | 1148 | <?php |
1149 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1149 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1150 | 1150 | |
1151 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1151 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1152 | 1152 | } |
1153 | 1153 | ?> |
1154 | 1154 | </tbody> |
@@ -1157,35 +1157,35 @@ discard block |
||
1157 | 1157 | echo ob_get_clean(); |
1158 | 1158 | } |
1159 | 1159 | |
1160 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1160 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1161 | 1161 | $use_taxes = wpinv_use_taxes(); |
1162 | 1162 | |
1163 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1163 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1164 | 1164 | ?> |
1165 | 1165 | <table class="table table-sm table-bordered table-responsive"> |
1166 | 1166 | <tbody> |
1167 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1167 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1168 | 1168 | <tr class="row-sub-total"> |
1169 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1170 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1169 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1170 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1171 | 1171 | </tr> |
1172 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1173 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1172 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1173 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1174 | 1174 | <tr class="row-discount"> |
1175 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1176 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1175 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1176 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1177 | 1177 | </tr> |
1178 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1178 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1179 | 1179 | <?php } ?> |
1180 | - <?php if ( $use_taxes ) { ?> |
|
1180 | + <?php if ($use_taxes) { ?> |
|
1181 | 1181 | <tr class="row-tax"> |
1182 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1183 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1182 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1183 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1184 | 1184 | </tr> |
1185 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1185 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1186 | 1186 | <?php } ?> |
1187 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1188 | - <?php foreach ( $fees as $fee ) { ?> |
|
1187 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1188 | + <?php foreach ($fees as $fee) { ?> |
|
1189 | 1189 | <tr class="row-fee"> |
1190 | 1190 | <td class="rate"><?php echo $fee['label']; ?></td> |
1191 | 1191 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1193,72 +1193,72 @@ discard block |
||
1193 | 1193 | <?php } ?> |
1194 | 1194 | <?php } ?> |
1195 | 1195 | <tr class="table-active row-total"> |
1196 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1197 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1196 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1197 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1198 | 1198 | </tr> |
1199 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1199 | + <?php do_action('wpinv_after_totals'); ?> |
|
1200 | 1200 | </tbody> |
1201 | 1201 | |
1202 | 1202 | </table> |
1203 | 1203 | |
1204 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1204 | + <?php do_action('wpinv_after_totals_table'); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1208 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1207 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1208 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1209 | 1209 | |
1210 | 1210 | ob_start(); |
1211 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1212 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() ) { |
|
1211 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1212 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid()) { |
|
1213 | 1213 | ?> |
1214 | 1214 | <div class="wpi-payment-info"> |
1215 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1216 | - <?php if ( $gateway_title ) { ?> |
|
1217 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1215 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1216 | + <?php if ($gateway_title) { ?> |
|
1217 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1218 | 1218 | <?php } ?> |
1219 | 1219 | </div> |
1220 | 1220 | <?php |
1221 | 1221 | } |
1222 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1222 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1223 | 1223 | $outout = ob_get_clean(); |
1224 | 1224 | |
1225 | - if ( $echo ) { |
|
1225 | + if ($echo) { |
|
1226 | 1226 | echo $outout; |
1227 | 1227 | } else { |
1228 | 1228 | return $outout; |
1229 | 1229 | } |
1230 | 1230 | } |
1231 | 1231 | |
1232 | -function wpinv_display_style( $invoice ) { |
|
1233 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1232 | +function wpinv_display_style($invoice) { |
|
1233 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1234 | 1234 | |
1235 | - wp_print_styles( 'open-sans' ); |
|
1236 | - wp_print_styles( 'wpinv-single-style' ); |
|
1235 | + wp_print_styles('open-sans'); |
|
1236 | + wp_print_styles('wpinv-single-style'); |
|
1237 | 1237 | } |
1238 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1238 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1239 | 1239 | |
1240 | 1240 | function wpinv_checkout_billing_details() { |
1241 | 1241 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1242 | 1242 | if (empty($invoice_id)) { |
1243 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1243 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1244 | 1244 | return null; |
1245 | 1245 | } |
1246 | 1246 | |
1247 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1247 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1248 | 1248 | if (empty($invoice)) { |
1249 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1249 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1250 | 1250 | return null; |
1251 | 1251 | } |
1252 | 1252 | $user_id = $invoice->get_user_id(); |
1253 | 1253 | $user_info = $invoice->get_user_info(); |
1254 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1254 | + $address_info = wpinv_get_user_address($user_id); |
|
1255 | 1255 | |
1256 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1256 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1257 | 1257 | $user_info['first_name'] = $user_info['first_name']; |
1258 | 1258 | $user_info['last_name'] = $user_info['last_name']; |
1259 | 1259 | } |
1260 | 1260 | |
1261 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1261 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1262 | 1262 | $user_info['country'] = $address_info['country']; |
1263 | 1263 | $user_info['state'] = $address_info['state']; |
1264 | 1264 | $user_info['city'] = $address_info['city']; |
@@ -1274,103 +1274,103 @@ discard block |
||
1274 | 1274 | 'address' |
1275 | 1275 | ); |
1276 | 1276 | |
1277 | - foreach ( $address_fields as $field ) { |
|
1278 | - if ( empty( $user_info[$field] ) ) { |
|
1277 | + foreach ($address_fields as $field) { |
|
1278 | + if (empty($user_info[$field])) { |
|
1279 | 1279 | $user_info[$field] = $address_info[$field]; |
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | |
1283 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1283 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | function wpinv_admin_get_line_items($invoice = array()) { |
1287 | 1287 | $item_quantities = wpinv_item_quantities_enabled(); |
1288 | 1288 | $use_taxes = wpinv_use_taxes(); |
1289 | 1289 | |
1290 | - if ( empty( $invoice ) ) { |
|
1290 | + if (empty($invoice)) { |
|
1291 | 1291 | return NULL; |
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | $cart_items = $invoice->get_cart_details(); |
1295 | - if ( empty( $cart_items ) ) { |
|
1295 | + if (empty($cart_items)) { |
|
1296 | 1296 | return NULL; |
1297 | 1297 | } |
1298 | 1298 | ob_start(); |
1299 | 1299 | |
1300 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1300 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1301 | 1301 | |
1302 | 1302 | $count = 0; |
1303 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1303 | + foreach ($cart_items as $key => $cart_item) { |
|
1304 | 1304 | $item_id = $cart_item['id']; |
1305 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1305 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1306 | 1306 | |
1307 | 1307 | if (empty($wpi_item)) { |
1308 | 1308 | continue; |
1309 | 1309 | } |
1310 | 1310 | |
1311 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
1312 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1313 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
1311 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
1312 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1313 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
1314 | 1314 | $can_remove = true; |
1315 | 1315 | |
1316 | 1316 | $summary = ''; |
1317 | 1317 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1318 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1319 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_cpt_singular_name(), $post_link ); |
|
1318 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1319 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_cpt_singular_name(), $post_link); |
|
1320 | 1320 | } |
1321 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
1321 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
1322 | 1322 | |
1323 | 1323 | $item_tax = ''; |
1324 | 1324 | $tax_rate = ''; |
1325 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1326 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1327 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1328 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
1325 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1326 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1327 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1328 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
1329 | 1329 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1330 | 1330 | } |
1331 | 1331 | $line_item_tax = $item_tax . $tax_rate; |
1332 | 1332 | |
1333 | - if ( $line_item_tax === '' ) { |
|
1333 | + if ($line_item_tax === '') { |
|
1334 | 1334 | $line_item_tax = 0; // Zero tax |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1337 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1338 | 1338 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1339 | - $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 ); |
|
1340 | - if ( $summary !== '' ) { |
|
1341 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1339 | + $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); |
|
1340 | + if ($summary !== '') { |
|
1341 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1342 | 1342 | } |
1343 | 1343 | $line_item .= '</td>'; |
1344 | 1344 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1345 | 1345 | |
1346 | - if ( $item_quantities ) { |
|
1347 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1346 | + if ($item_quantities) { |
|
1347 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1348 | 1348 | $can_remove = false; |
1349 | 1349 | } |
1350 | 1350 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1351 | 1351 | } else { |
1352 | - if ( count( $cart_items ) == 1 ) { |
|
1352 | + if (count($cart_items) == 1) { |
|
1353 | 1353 | $can_remove = false; |
1354 | 1354 | } |
1355 | 1355 | } |
1356 | 1356 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1357 | 1357 | |
1358 | - if ( $use_taxes ) { |
|
1358 | + if ($use_taxes) { |
|
1359 | 1359 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1360 | 1360 | } |
1361 | 1361 | $line_item .= '<td class="action">'; |
1362 | - if ( !$invoice->is_paid() && $can_remove ) { |
|
1362 | + if (!$invoice->is_paid() && $can_remove) { |
|
1363 | 1363 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1364 | 1364 | } |
1365 | 1365 | $line_item .= '</td>'; |
1366 | 1366 | $line_item .= '</tr>'; |
1367 | 1367 | |
1368 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1368 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1369 | 1369 | |
1370 | 1370 | $count++; |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1373 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1374 | 1374 | |
1375 | 1375 | return ob_get_clean(); |
1376 | 1376 | } |
@@ -1381,35 +1381,35 @@ discard block |
||
1381 | 1381 | // Set current invoice id. |
1382 | 1382 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1383 | 1383 | |
1384 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1384 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1385 | 1385 | |
1386 | 1386 | ob_start(); |
1387 | 1387 | echo '<div id="wpinv_checkout_wrap">'; |
1388 | 1388 | |
1389 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1389 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1390 | 1390 | ?> |
1391 | 1391 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1392 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1392 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1393 | 1393 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1394 | 1394 | <?php |
1395 | - do_action( 'wpinv_checkout_form_top' ); |
|
1396 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1397 | - do_action( 'wpinv_checkout_cart' ); |
|
1398 | - do_action( 'wpinv_payment_mode_select' ); |
|
1399 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1395 | + do_action('wpinv_checkout_form_top'); |
|
1396 | + do_action('wpinv_checkout_billing_info'); |
|
1397 | + do_action('wpinv_checkout_cart'); |
|
1398 | + do_action('wpinv_payment_mode_select'); |
|
1399 | + do_action('wpinv_checkout_form_bottom') |
|
1400 | 1400 | ?> |
1401 | 1401 | </form> |
1402 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1402 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1403 | 1403 | </div><!--end #wpinv_checkout_form_wrap--> |
1404 | 1404 | <?php |
1405 | 1405 | } else { |
1406 | - do_action( 'wpinv_cart_empty' ); |
|
1406 | + do_action('wpinv_cart_empty'); |
|
1407 | 1407 | } |
1408 | 1408 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1409 | 1409 | return ob_get_clean(); |
1410 | 1410 | } |
1411 | 1411 | |
1412 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1412 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1413 | 1413 | global $ajax_cart_details; |
1414 | 1414 | $ajax_cart_details = $cart_details; |
1415 | 1415 | /* |
@@ -1424,25 +1424,25 @@ discard block |
||
1424 | 1424 | } |
1425 | 1425 | */ |
1426 | 1426 | ob_start(); |
1427 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1427 | + do_action('wpinv_before_checkout_cart'); |
|
1428 | 1428 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1429 | 1429 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1430 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1430 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1431 | 1431 | echo '</div>'; |
1432 | 1432 | echo '</div>'; |
1433 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1433 | + do_action('wpinv_after_checkout_cart'); |
|
1434 | 1434 | $content = ob_get_clean(); |
1435 | 1435 | |
1436 | - if ( $echo ) { |
|
1436 | + if ($echo) { |
|
1437 | 1437 | echo $content; |
1438 | 1438 | } else { |
1439 | 1439 | return $content; |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1442 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1443 | 1443 | |
1444 | 1444 | function wpinv_empty_cart_message() { |
1445 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1445 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | /** |
@@ -1454,91 +1454,91 @@ discard block |
||
1454 | 1454 | function wpinv_empty_checkout_cart() { |
1455 | 1455 | echo wpinv_empty_cart_message(); |
1456 | 1456 | } |
1457 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1457 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1458 | 1458 | |
1459 | 1459 | function wpinv_save_cart_button() { |
1460 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1460 | + if (wpinv_is_cart_saving_disabled()) |
|
1461 | 1461 | return; |
1462 | 1462 | ?> |
1463 | - <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> |
|
1463 | + <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> |
|
1464 | 1464 | <?php |
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | function wpinv_update_cart_button() { |
1468 | - if ( !wpinv_item_quantities_enabled() ) |
|
1468 | + if (!wpinv_item_quantities_enabled()) |
|
1469 | 1469 | return; |
1470 | 1470 | ?> |
1471 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1471 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1472 | 1472 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1473 | 1473 | <?php |
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | function wpinv_checkout_cart_columns() { |
1477 | 1477 | $default = 3; |
1478 | - if ( wpinv_item_quantities_enabled() ) { |
|
1478 | + if (wpinv_item_quantities_enabled()) { |
|
1479 | 1479 | $default++; |
1480 | 1480 | } |
1481 | 1481 | |
1482 | - if ( wpinv_use_taxes() ) { |
|
1482 | + if (wpinv_use_taxes()) { |
|
1483 | 1483 | $default++; |
1484 | 1484 | } |
1485 | 1485 | |
1486 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1486 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1487 | 1487 | } |
1488 | 1488 | |
1489 | 1489 | function wpinv_display_cart_messages() { |
1490 | 1490 | global $wpi_session; |
1491 | 1491 | |
1492 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1492 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1493 | 1493 | |
1494 | - if ( $messages ) { |
|
1495 | - foreach ( $messages as $message_id => $message ) { |
|
1494 | + if ($messages) { |
|
1495 | + foreach ($messages as $message_id => $message) { |
|
1496 | 1496 | // Try and detect what type of message this is |
1497 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1497 | + if (strpos(strtolower($message), 'error')) { |
|
1498 | 1498 | $type = 'error'; |
1499 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1499 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1500 | 1500 | $type = 'success'; |
1501 | 1501 | } else { |
1502 | 1502 | $type = 'info'; |
1503 | 1503 | } |
1504 | 1504 | |
1505 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1505 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1506 | 1506 | |
1507 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1507 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1508 | 1508 | // Loop message codes and display messages |
1509 | 1509 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1510 | 1510 | echo '</div>'; |
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | // Remove all of the cart saving messages |
1514 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1514 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1515 | 1515 | } |
1516 | 1516 | } |
1517 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1517 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1518 | 1518 | |
1519 | 1519 | function wpinv_discount_field() { |
1520 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1520 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1521 | 1521 | return; // Only show before a payment method has been selected if ajax is disabled |
1522 | 1522 | } |
1523 | 1523 | |
1524 | - if ( !wpinv_is_checkout() ) { |
|
1524 | + if (!wpinv_is_checkout()) { |
|
1525 | 1525 | return; |
1526 | 1526 | } |
1527 | 1527 | |
1528 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1528 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1529 | 1529 | ?> |
1530 | 1530 | <div id="wpinv-discount-field" class="panel panel-default"> |
1531 | 1531 | <div class="panel-body"> |
1532 | 1532 | <p> |
1533 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1534 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1533 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1534 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1535 | 1535 | </p> |
1536 | 1536 | <div class="form-group row"> |
1537 | 1537 | <div class="col-sm-4"> |
1538 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1538 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1539 | 1539 | </div> |
1540 | 1540 | <div class="col-sm-3"> |
1541 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1541 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1542 | 1542 | </div> |
1543 | 1543 | <div class="col-sm-12 wpinv-discount-msg"> |
1544 | 1544 | <div class="alert alert-success"><i class="fa fa-check-circle"></i><span class="wpi-msg"></span></div> |
@@ -1550,10 +1550,10 @@ discard block |
||
1550 | 1550 | <?php |
1551 | 1551 | } |
1552 | 1552 | } |
1553 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1553 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1554 | 1554 | |
1555 | 1555 | function wpinv_agree_to_terms_js() { |
1556 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1556 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1557 | 1557 | ?> |
1558 | 1558 | <script type="text/javascript"> |
1559 | 1559 | jQuery(document).ready(function($){ |
@@ -1568,124 +1568,124 @@ discard block |
||
1568 | 1568 | <?php |
1569 | 1569 | } |
1570 | 1570 | } |
1571 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1571 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1572 | 1572 | |
1573 | 1573 | function wpinv_payment_mode_select() { |
1574 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1575 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1574 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1575 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1576 | 1576 | $page_URL = wpinv_get_current_page_url(); |
1577 | 1577 | |
1578 | 1578 | do_action('wpinv_payment_mode_top'); |
1579 | 1579 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1580 | 1580 | ?> |
1581 | 1581 | <div id="wpinv_payment_mode_select"> |
1582 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1582 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1583 | 1583 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1584 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1584 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1585 | 1585 | <div class="panel-body list-group wpi-payment_methods"> |
1586 | 1586 | <?php |
1587 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1588 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1587 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1588 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1589 | 1589 | |
1590 | - if(!empty($gateways)){ |
|
1591 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1592 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1593 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1594 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1590 | + if (!empty($gateways)) { |
|
1591 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1592 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1593 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1594 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1595 | 1595 | ?> |
1596 | 1596 | <div class="list-group-item"> |
1597 | 1597 | <div class="radio"> |
1598 | - <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> |
|
1598 | + <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> |
|
1599 | 1599 | </div> |
1600 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1601 | - <?php if ( !empty( $description ) ) { ?> |
|
1602 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1600 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1601 | + <?php if (!empty($description)) { ?> |
|
1602 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1603 | 1603 | <?php } ?> |
1604 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1604 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1605 | 1605 | </div> |
1606 | 1606 | </div> |
1607 | 1607 | <?php |
1608 | 1608 | } |
1609 | - }else{ |
|
1610 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1609 | + } else { |
|
1610 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1611 | 1611 | } |
1612 | 1612 | |
1613 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1613 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1614 | 1614 | ?> |
1615 | 1615 | </div> |
1616 | 1616 | </div> |
1617 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1617 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1618 | 1618 | </div> |
1619 | 1619 | <?php |
1620 | 1620 | do_action('wpinv_payment_mode_bottom'); |
1621 | 1621 | } |
1622 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1622 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1623 | 1623 | |
1624 | 1624 | function wpinv_checkout_billing_info() { |
1625 | - if ( wpinv_is_checkout() ) { |
|
1625 | + if (wpinv_is_checkout()) { |
|
1626 | 1626 | $logged_in = is_user_logged_in(); |
1627 | 1627 | $billing_details = wpinv_checkout_billing_details(); |
1628 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1628 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1629 | 1629 | ?> |
1630 | 1630 | <div id="wpinv-fields" class="clearfix"> |
1631 | 1631 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1632 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1632 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1633 | 1633 | <div id="wpinv-fields-box" class="panel-body"> |
1634 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1634 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1635 | 1635 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1636 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1636 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1637 | 1637 | <?php |
1638 | - echo wpinv_html_text( array( |
|
1638 | + echo wpinv_html_text(array( |
|
1639 | 1639 | 'id' => 'wpinv_first_name', |
1640 | 1640 | 'name' => 'wpinv_first_name', |
1641 | 1641 | 'value' => $billing_details['first_name'], |
1642 | 1642 | 'class' => 'wpi-input form-control required', |
1643 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1643 | + 'placeholder' => __('First name', 'invoicing'), |
|
1644 | 1644 | 'required' => true, |
1645 | - ) ); |
|
1645 | + )); |
|
1646 | 1646 | ?> |
1647 | 1647 | </p> |
1648 | 1648 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1649 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?></label> |
|
1649 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?></label> |
|
1650 | 1650 | <?php |
1651 | - echo wpinv_html_text( array( |
|
1651 | + echo wpinv_html_text(array( |
|
1652 | 1652 | 'id' => 'wpinv_last_name', |
1653 | 1653 | 'name' => 'wpinv_last_name', |
1654 | 1654 | 'value' => $billing_details['last_name'], |
1655 | 1655 | 'class' => 'wpi-input form-control', |
1656 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1657 | - ) ); |
|
1656 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1657 | + )); |
|
1658 | 1658 | ?> |
1659 | 1659 | </p> |
1660 | 1660 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1661 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1661 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1662 | 1662 | <?php |
1663 | - echo wpinv_html_text( array( |
|
1663 | + echo wpinv_html_text(array( |
|
1664 | 1664 | 'id' => 'wpinv_address', |
1665 | 1665 | 'name' => 'wpinv_address', |
1666 | 1666 | 'value' => $billing_details['address'], |
1667 | 1667 | 'class' => 'wpi-input form-control required', |
1668 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1668 | + 'placeholder' => __('Address', 'invoicing'), |
|
1669 | 1669 | 'required' => true, |
1670 | - ) ); |
|
1670 | + )); |
|
1671 | 1671 | ?> |
1672 | 1672 | </p> |
1673 | 1673 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1674 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1674 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1675 | 1675 | <?php |
1676 | - echo wpinv_html_text( array( |
|
1676 | + echo wpinv_html_text(array( |
|
1677 | 1677 | 'id' => 'wpinv_city', |
1678 | 1678 | 'name' => 'wpinv_city', |
1679 | 1679 | 'value' => $billing_details['city'], |
1680 | 1680 | 'class' => 'wpi-input form-control required', |
1681 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1681 | + 'placeholder' => __('City', 'invoicing'), |
|
1682 | 1682 | 'required' => true, |
1683 | - ) ); |
|
1683 | + )); |
|
1684 | 1684 | ?> |
1685 | 1685 | </p> |
1686 | 1686 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1687 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1688 | - <?php echo wpinv_html_select( array( |
|
1687 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1688 | + <?php echo wpinv_html_select(array( |
|
1689 | 1689 | 'options' => wpinv_get_country_list(), |
1690 | 1690 | 'name' => 'wpinv_country', |
1691 | 1691 | 'id' => 'wpinv_country', |
@@ -1693,16 +1693,16 @@ discard block |
||
1693 | 1693 | 'show_option_all' => false, |
1694 | 1694 | 'show_option_none' => false, |
1695 | 1695 | 'class' => 'wpi-input form-control required', |
1696 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1696 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1697 | 1697 | 'required' => true, |
1698 | - ) ); ?> |
|
1698 | + )); ?> |
|
1699 | 1699 | </p> |
1700 | 1700 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1701 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
1701 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
1702 | 1702 | <?php |
1703 | - $states = wpinv_get_country_states( $selected_country ); |
|
1704 | - if( !empty( $states ) ) { |
|
1705 | - echo wpinv_html_select( array( |
|
1703 | + $states = wpinv_get_country_states($selected_country); |
|
1704 | + if (!empty($states)) { |
|
1705 | + echo wpinv_html_select(array( |
|
1706 | 1706 | 'options' => $states, |
1707 | 1707 | 'name' => 'wpinv_state', |
1708 | 1708 | 'id' => 'wpinv_state', |
@@ -1710,60 +1710,60 @@ discard block |
||
1710 | 1710 | 'show_option_all' => false, |
1711 | 1711 | 'show_option_none' => false, |
1712 | 1712 | 'class' => 'wpi-input form-control required', |
1713 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1713 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1714 | 1714 | 'required' => true, |
1715 | - ) ); |
|
1715 | + )); |
|
1716 | 1716 | } else { |
1717 | - echo wpinv_html_text( array( |
|
1717 | + echo wpinv_html_text(array( |
|
1718 | 1718 | 'name' => 'wpinv_state', |
1719 | 1719 | 'value' => $billing_details['state'], |
1720 | 1720 | 'id' => 'wpinv_state', |
1721 | 1721 | 'class' => 'wpi-input form-control required', |
1722 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1722 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1723 | 1723 | 'required' => true, |
1724 | - ) ); |
|
1724 | + )); |
|
1725 | 1725 | } |
1726 | 1726 | ?> |
1727 | 1727 | </p> |
1728 | 1728 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1729 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?></label> |
|
1729 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?></label> |
|
1730 | 1730 | <?php |
1731 | - echo wpinv_html_text( array( |
|
1731 | + echo wpinv_html_text(array( |
|
1732 | 1732 | 'name' => 'wpinv_zip', |
1733 | 1733 | 'value' => $billing_details['zip'], |
1734 | 1734 | 'id' => 'wpinv_zip', |
1735 | 1735 | 'class' => 'wpi-input form-control', |
1736 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1737 | - ) ); |
|
1736 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1737 | + )); |
|
1738 | 1738 | ?> |
1739 | 1739 | </p> |
1740 | 1740 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1741 | - <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> |
|
1741 | + <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> |
|
1742 | 1742 | <?php |
1743 | - echo wpinv_html_text( array( |
|
1743 | + echo wpinv_html_text(array( |
|
1744 | 1744 | 'id' => 'wpinv_phone', |
1745 | 1745 | 'name' => 'wpinv_phone', |
1746 | 1746 | 'value' => $billing_details['phone'], |
1747 | 1747 | 'class' => 'wpi-input form-control', |
1748 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1749 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1750 | - ) ); |
|
1748 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1749 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1750 | + )); |
|
1751 | 1751 | ?> |
1752 | 1752 | </p> |
1753 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1753 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1754 | 1754 | <div class="clearfix"></div> |
1755 | 1755 | </div> |
1756 | 1756 | </div> |
1757 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1757 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1758 | 1758 | </div> |
1759 | 1759 | <?php |
1760 | 1760 | } |
1761 | 1761 | } |
1762 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1762 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1763 | 1763 | |
1764 | 1764 | function wpinv_checkout_hidden_fields() { |
1765 | 1765 | ?> |
1766 | - <?php if ( is_user_logged_in() ) { ?> |
|
1766 | + <?php if (is_user_logged_in()) { ?> |
|
1767 | 1767 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1768 | 1768 | <?php } ?> |
1769 | 1769 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1773,9 +1773,9 @@ discard block |
||
1773 | 1773 | function wpinv_checkout_button_purchase() { |
1774 | 1774 | ob_start(); |
1775 | 1775 | ?> |
1776 | - <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' ) ?>"/> |
|
1776 | + <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') ?>"/> |
|
1777 | 1777 | <?php |
1778 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1778 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1779 | 1779 | } |
1780 | 1780 | |
1781 | 1781 | function wpinv_checkout_total() { |
@@ -1784,96 +1784,96 @@ discard block |
||
1784 | 1784 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1785 | 1785 | <div class="panel-body"> |
1786 | 1786 | <?php |
1787 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1787 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1788 | 1788 | ?> |
1789 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1789 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1790 | 1790 | <?php |
1791 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1791 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1792 | 1792 | ?> |
1793 | 1793 | </div> |
1794 | 1794 | </div> |
1795 | 1795 | <?php |
1796 | 1796 | } |
1797 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1797 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1798 | 1798 | |
1799 | 1799 | function wpinv_checkout_submit() { |
1800 | 1800 | ?> |
1801 | 1801 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1802 | 1802 | <div class="panel-body text-center"> |
1803 | 1803 | <?php |
1804 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1804 | + do_action('wpinv_purchase_form_before_submit'); |
|
1805 | 1805 | wpinv_checkout_hidden_fields(); |
1806 | 1806 | echo wpinv_checkout_button_purchase(); |
1807 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1807 | + do_action('wpinv_purchase_form_after_submit'); |
|
1808 | 1808 | ?> |
1809 | 1809 | </div> |
1810 | 1810 | </div> |
1811 | 1811 | <?php |
1812 | 1812 | } |
1813 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1813 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1814 | 1814 | |
1815 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1816 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1815 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1816 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1817 | 1817 | |
1818 | - if ( empty( $invoice ) ) { |
|
1818 | + if (empty($invoice)) { |
|
1819 | 1819 | return NULL; |
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | $billing_details = $invoice->get_user_info(); |
1823 | 1823 | $address_row = ''; |
1824 | - if ( $address = $billing_details['address'] ) { |
|
1825 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1824 | + if ($address = $billing_details['address']) { |
|
1825 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1826 | 1826 | } |
1827 | 1827 | |
1828 | 1828 | $address_fields = array(); |
1829 | - if ( !empty( $billing_details['city'] ) ) { |
|
1829 | + if (!empty($billing_details['city'])) { |
|
1830 | 1830 | $address_fields[] = $billing_details['city']; |
1831 | 1831 | } |
1832 | 1832 | |
1833 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1834 | - if ( !empty( $billing_details['state'] ) ) { |
|
1835 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1833 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1834 | + if (!empty($billing_details['state'])) { |
|
1835 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1836 | 1836 | } |
1837 | 1837 | |
1838 | - if ( !empty( $billing_country ) ) { |
|
1839 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1838 | + if (!empty($billing_country)) { |
|
1839 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1840 | 1840 | } |
1841 | 1841 | |
1842 | - if ( !empty( $address_fields ) ) { |
|
1843 | - $address_fields = implode( ", ", $address_fields ); |
|
1842 | + if (!empty($address_fields)) { |
|
1843 | + $address_fields = implode(", ", $address_fields); |
|
1844 | 1844 | |
1845 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1845 | + if (!empty($billing_details['zip'])) { |
|
1846 | 1846 | $address_fields .= ' ' . $billing_details['zip']; |
1847 | 1847 | } |
1848 | 1848 | |
1849 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1849 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1850 | 1850 | } |
1851 | 1851 | ob_start(); |
1852 | 1852 | ?> |
1853 | 1853 | <table class="table table-bordered table-sm wpi-billing-details"> |
1854 | 1854 | <tbody> |
1855 | 1855 | <tr class="wpi-receipt-name"> |
1856 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1857 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1856 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1857 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1858 | 1858 | </tr> |
1859 | 1859 | <tr class="wpi-receipt-email"> |
1860 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1861 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1860 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1861 | + <td><?php echo $billing_details['email']; ?></td> |
|
1862 | 1862 | </tr> |
1863 | - <?php if ( $billing_details['company'] ) { ?> |
|
1863 | + <?php if ($billing_details['company']) { ?> |
|
1864 | 1864 | <tr class="wpi-receipt-company"> |
1865 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1866 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1865 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1866 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1867 | 1867 | </tr> |
1868 | 1868 | <?php } ?> |
1869 | 1869 | <tr class="wpi-receipt-address"> |
1870 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1871 | - <td><?php echo $address_row ;?></td> |
|
1870 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1871 | + <td><?php echo $address_row; ?></td> |
|
1872 | 1872 | </tr> |
1873 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1873 | + <?php if ($billing_details['phone']) { ?> |
|
1874 | 1874 | <tr class="wpi-receipt-phone"> |
1875 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1876 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1875 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1876 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1877 | 1877 | </tr> |
1878 | 1878 | <?php } ?> |
1879 | 1879 | </tbody> |
@@ -1881,98 +1881,98 @@ discard block |
||
1881 | 1881 | <?php |
1882 | 1882 | $output = ob_get_clean(); |
1883 | 1883 | |
1884 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1884 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1885 | 1885 | |
1886 | 1886 | echo $output; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | -function wpinv_filter_success_page_content( $content ) { |
|
1890 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1891 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1892 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1889 | +function wpinv_filter_success_page_content($content) { |
|
1890 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1891 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1892 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1893 | 1893 | } |
1894 | 1894 | } |
1895 | 1895 | |
1896 | 1896 | return $content; |
1897 | 1897 | } |
1898 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1898 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1899 | 1899 | |
1900 | -function wpinv_receipt_actions( $invoice ) { |
|
1901 | - if ( !empty( $invoice ) ) { |
|
1900 | +function wpinv_receipt_actions($invoice) { |
|
1901 | + if (!empty($invoice)) { |
|
1902 | 1902 | $actions = array( |
1903 | 1903 | 'print' => array( |
1904 | 1904 | 'url' => $invoice->get_view_url(), |
1905 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1905 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1906 | 1906 | 'class' => 'btn-primary', |
1907 | 1907 | ), |
1908 | 1908 | 'history' => array( |
1909 | 1909 | 'url' => wpinv_get_history_page_uri(), |
1910 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1910 | + 'name' => __('Invoice History', 'invoicing'), |
|
1911 | 1911 | 'class' => 'btn-warning', |
1912 | 1912 | ) |
1913 | 1913 | ); |
1914 | 1914 | |
1915 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1915 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1916 | 1916 | |
1917 | - if ( !empty( $actions ) ) { |
|
1917 | + if (!empty($actions)) { |
|
1918 | 1918 | ?> |
1919 | 1919 | <div class="wpinv-receipt-actions text-right"> |
1920 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1921 | - <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> |
|
1920 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1921 | + <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> |
|
1922 | 1922 | <?php } ?> |
1923 | 1923 | </div> |
1924 | 1924 | <?php |
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | } |
1928 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1928 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1929 | 1929 | |
1930 | -function wpinv_invoice_link( $invoice_id ) { |
|
1931 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1930 | +function wpinv_invoice_link($invoice_id) { |
|
1931 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1932 | 1932 | |
1933 | - if ( empty( $invoice ) ) { |
|
1933 | + if (empty($invoice)) { |
|
1934 | 1934 | return NULL; |
1935 | 1935 | } |
1936 | 1936 | |
1937 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1937 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1938 | 1938 | |
1939 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1939 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1943 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1942 | +function wpinv_invoice_subscription_details($invoice) { |
|
1943 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1944 | 1944 | $total_payments = (int)$invoice->get_total_payments(); |
1945 | 1945 | $payments = $invoice->get_child_payments(); |
1946 | 1946 | |
1947 | 1947 | $subscription = $invoice->get_subscription_data(); |
1948 | 1948 | |
1949 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
1949 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
1950 | 1950 | return; |
1951 | 1951 | } |
1952 | 1952 | |
1953 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
1954 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
1953 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
1954 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
1955 | 1955 | |
1956 | 1956 | $subscription_status = $invoice->get_subscription_status(); |
1957 | 1957 | |
1958 | 1958 | $status_desc = ''; |
1959 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
1960 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
1961 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
1962 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
1959 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
1960 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
1961 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
1962 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
1963 | 1963 | } |
1964 | 1964 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
1965 | 1965 | ?> |
1966 | 1966 | <div class="wpinv-subscriptions-details"> |
1967 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1967 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1968 | 1968 | <table class="table"> |
1969 | 1969 | <thead> |
1970 | 1970 | <tr> |
1971 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1972 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1973 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1974 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1975 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1971 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1972 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1973 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1974 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1975 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1976 | 1976 | </tr> |
1977 | 1977 | </thead> |
1978 | 1978 | <tbody> |
@@ -1981,32 +1981,32 @@ discard block |
||
1981 | 1981 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
1982 | 1982 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
1983 | 1983 | <td class="text-center"><?php echo $times_billed; ?></td> |
1984 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
1984 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
1985 | 1985 | <?php echo $status_desc; ?> |
1986 | 1986 | </td> |
1987 | 1987 | </tr> |
1988 | 1988 | </tbody> |
1989 | 1989 | </table> |
1990 | 1990 | </div> |
1991 | - <?php if ( !empty( $payments ) ) { ?> |
|
1991 | + <?php if (!empty($payments)) { ?> |
|
1992 | 1992 | <div class="wpinv-renewal-payments"> |
1993 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1993 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1994 | 1994 | <table class="table"> |
1995 | 1995 | <thead> |
1996 | 1996 | <tr> |
1997 | 1997 | <th>#</th> |
1998 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1999 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2000 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1998 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1999 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2000 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2001 | 2001 | </tr> |
2002 | 2002 | </thead> |
2003 | 2003 | <tbody> |
2004 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
2004 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
2005 | 2005 | <tr> |
2006 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
2007 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2008 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2009 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2006 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
2007 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2008 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2009 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2010 | 2010 | </tr> |
2011 | 2011 | <?php } ?> |
2012 | 2012 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2018,52 +2018,52 @@ discard block |
||
2018 | 2018 | } |
2019 | 2019 | } |
2020 | 2020 | |
2021 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2022 | - if ( empty( $invoice ) ) { |
|
2021 | +function wpinv_cart_total_label($label, $invoice) { |
|
2022 | + if (empty($invoice)) { |
|
2023 | 2023 | return $label; |
2024 | 2024 | } |
2025 | 2025 | |
2026 | 2026 | $prefix_label = ''; |
2027 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2028 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2029 | - } else if ( $invoice->is_renewal() ) { |
|
2030 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2027 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2028 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2029 | + } else if ($invoice->is_renewal()) { |
|
2030 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2031 | 2031 | } |
2032 | 2032 | |
2033 | - if ( $prefix_label != '' ) { |
|
2034 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2033 | + if ($prefix_label != '') { |
|
2034 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | return $label; |
2038 | 2038 | } |
2039 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2040 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2041 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2039 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2040 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2041 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2042 | 2042 | |
2043 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2043 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2044 | 2044 | |
2045 | -function wpinv_invoice_print_description( $invoice ) { |
|
2046 | - if ( empty( $invoice ) ) { |
|
2045 | +function wpinv_invoice_print_description($invoice) { |
|
2046 | + if (empty($invoice)) { |
|
2047 | 2047 | return NULL; |
2048 | 2048 | } |
2049 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2049 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2050 | 2050 | ?> |
2051 | 2051 | <div class="row wpinv-lower"> |
2052 | 2052 | <div class="col-sm-12 wpinv-description"> |
2053 | - <?php echo wpautop( $description ); ?> |
|
2053 | + <?php echo wpautop($description); ?> |
|
2054 | 2054 | </div> |
2055 | 2055 | </div> |
2056 | 2056 | <?php |
2057 | 2057 | } |
2058 | 2058 | } |
2059 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2059 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2060 | 2060 | |
2061 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2062 | - if ( empty( $invoice ) ) { |
|
2061 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2062 | + if (empty($invoice)) { |
|
2063 | 2063 | return NULL; |
2064 | 2064 | } |
2065 | 2065 | |
2066 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2066 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2067 | 2067 | ?> |
2068 | 2068 | <div class="row wpinv-payments"> |
2069 | 2069 | <div class="col-sm-12"> |
@@ -2075,40 +2075,40 @@ discard block |
||
2075 | 2075 | } |
2076 | 2076 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2077 | 2077 | |
2078 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2079 | - if ( empty( $note ) ) { |
|
2078 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2079 | + if (empty($note)) { |
|
2080 | 2080 | return NULL; |
2081 | 2081 | } |
2082 | 2082 | |
2083 | - if ( is_int( $note ) ) { |
|
2084 | - $note = get_comment( $note ); |
|
2083 | + if (is_int($note)) { |
|
2084 | + $note = get_comment($note); |
|
2085 | 2085 | } |
2086 | 2086 | |
2087 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2087 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2088 | 2088 | return NULL; |
2089 | 2089 | } |
2090 | 2090 | |
2091 | - $note_classes = array( 'note' ); |
|
2092 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2093 | - $note_classes[] = $note->comment_author === __( 'GeoDirectory', 'invoicing' ) ? 'system-note' : ''; |
|
2094 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2095 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2091 | + $note_classes = array('note'); |
|
2092 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2093 | + $note_classes[] = $note->comment_author === __('GeoDirectory', 'invoicing') ? 'system-note' : ''; |
|
2094 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2095 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2096 | 2096 | |
2097 | 2097 | ob_start(); |
2098 | 2098 | ?> |
2099 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2099 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2100 | 2100 | <div class="note_content"> |
2101 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2101 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2102 | 2102 | </div> |
2103 | 2103 | <p class="meta"> |
2104 | - <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> <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2104 | + <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> <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2105 | 2105 | </p> |
2106 | 2106 | </li> |
2107 | 2107 | <?php |
2108 | 2108 | $note_content = ob_get_clean(); |
2109 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2109 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2110 | 2110 | |
2111 | - if ( $echo ) { |
|
2111 | + if ($echo) { |
|
2112 | 2112 | echo $note_content; |
2113 | 2113 | } else { |
2114 | 2114 | return $note_content; |
@@ -173,8 +173,9 @@ discard block |
||
173 | 173 | |
174 | 174 | // Setup possible parts |
175 | 175 | $templates = array(); |
176 | - if ( isset( $name ) ) |
|
177 | - $templates[] = $slug . '-' . $name . '.php'; |
|
176 | + if ( isset( $name ) ) { |
|
177 | + $templates[] = $slug . '-' . $name . '.php'; |
|
178 | + } |
|
178 | 179 | $templates[] = $slug . '.php'; |
179 | 180 | |
180 | 181 | // Allow template parts to be filtered |
@@ -192,8 +193,9 @@ discard block |
||
192 | 193 | foreach ( (array)$template_names as $template_name ) { |
193 | 194 | |
194 | 195 | // Continue if template is empty |
195 | - if ( empty( $template_name ) ) |
|
196 | - continue; |
|
196 | + if ( empty( $template_name ) ) { |
|
197 | + continue; |
|
198 | + } |
|
197 | 199 | |
198 | 200 | // Trim off any slashes from the template name |
199 | 201 | $template_name = ltrim( $template_name, '/' ); |
@@ -212,8 +214,9 @@ discard block |
||
212 | 214 | } |
213 | 215 | } |
214 | 216 | |
215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
216 | - load_template( $located, $require_once ); |
|
217 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
218 | + load_template( $located, $require_once ); |
|
219 | + } |
|
217 | 220 | |
218 | 221 | return $located; |
219 | 222 | } |
@@ -289,8 +292,9 @@ discard block |
||
289 | 292 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
290 | 293 | $args = array( 'nopaging' => true ); |
291 | 294 | |
292 | - if ( ! empty( $status ) ) |
|
293 | - $args['post_status'] = $status; |
|
295 | + if ( ! empty( $status ) ) { |
|
296 | + $args['post_status'] = $status; |
|
297 | + } |
|
294 | 298 | |
295 | 299 | $discounts = wpinv_get_discounts( $args ); |
296 | 300 | $options = array(); |
@@ -1457,17 +1461,19 @@ discard block |
||
1457 | 1461 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1458 | 1462 | |
1459 | 1463 | function wpinv_save_cart_button() { |
1460 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1461 | - return; |
|
1462 | -?> |
|
1464 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
1465 | + return; |
|
1466 | + } |
|
1467 | + ?> |
|
1463 | 1468 | <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> |
1464 | 1469 | <?php |
1465 | 1470 | } |
1466 | 1471 | |
1467 | 1472 | function wpinv_update_cart_button() { |
1468 | - if ( !wpinv_item_quantities_enabled() ) |
|
1469 | - return; |
|
1470 | -?> |
|
1473 | + if ( !wpinv_item_quantities_enabled() ) { |
|
1474 | + return; |
|
1475 | + } |
|
1476 | + ?> |
|
1471 | 1477 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
1472 | 1478 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1473 | 1479 | <?php |
@@ -1606,7 +1612,7 @@ discard block |
||
1606 | 1612 | </div> |
1607 | 1613 | <?php |
1608 | 1614 | } |
1609 | - }else{ |
|
1615 | + } else{ |
|
1610 | 1616 | echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
1611 | 1617 | } |
1612 | 1618 |
@@ -161,6 +161,9 @@ |
||
161 | 161 | wp_redirect( $redirect_to ); |
162 | 162 | } |
163 | 163 | |
164 | +/** |
|
165 | + * @param integer $user_id |
|
166 | + */ |
|
164 | 167 | function wpinv_login_user( $user_id ) { |
165 | 168 | if ( is_user_logged_in() ) { |
166 | 169 | return true; |
@@ -1,28 +1,28 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -function wpinv_user_invoices( $current_page = 1 ) { |
|
5 | +function wpinv_user_invoices($current_page = 1) { |
|
6 | 6 | global $current_page; |
7 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
7 | + wpinv_get_template_part('wpinv-invoice-history'); |
|
8 | 8 | } |
9 | 9 | |
10 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
11 | - if ( empty( $user ) ) { |
|
10 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
11 | + if (empty($user)) { |
|
12 | 12 | $user = get_current_user_id(); |
13 | 13 | } |
14 | 14 | |
15 | - if ( 0 === $user ) { |
|
15 | + if (0 === $user) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | 18 | |
19 | 19 | $status = $status === 'complete' ? 'publish' : $status; |
20 | 20 | |
21 | - if ( $pagination ) { |
|
22 | - if ( get_query_var( 'paged' ) ) |
|
21 | + if ($pagination) { |
|
22 | + if (get_query_var('paged')) |
|
23 | 23 | $paged = get_query_var('paged'); |
24 | - else if ( get_query_var( 'page' ) ) |
|
25 | - $paged = get_query_var( 'page' ); |
|
24 | + else if (get_query_var('page')) |
|
25 | + $paged = get_query_var('page'); |
|
26 | 26 | else |
27 | 27 | $paged = 1; |
28 | 28 | } |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | 'post_type' => 'wpi_invoice', |
32 | 32 | 'posts_per_page' => 20, |
33 | 33 | 'paged' => null, |
34 | - 'post_status' => array( 'complete', 'publish', 'pending' ), |
|
34 | + 'post_status' => array('complete', 'publish', 'pending'), |
|
35 | 35 | 'user' => $user, |
36 | 36 | 'order' => 'date', |
37 | 37 | ); |
38 | 38 | |
39 | - $invoices = get_posts( $args ); |
|
39 | + $invoices = get_posts($args); |
|
40 | 40 | |
41 | 41 | // No invoices |
42 | - if ( ! $invoices ) |
|
42 | + if (!$invoices) |
|
43 | 43 | return false; |
44 | 44 | |
45 | 45 | return $invoices; |
46 | 46 | } |
47 | 47 | |
48 | -function wpinv_dropdown_users( $args = '' ) { |
|
48 | +function wpinv_dropdown_users($args = '') { |
|
49 | 49 | $defaults = array( |
50 | 50 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
51 | 51 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | 'option_none_value' => -1 |
57 | 57 | ); |
58 | 58 | |
59 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
59 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
60 | 60 | |
61 | - $r = wp_parse_args( $args, $defaults ); |
|
61 | + $r = wp_parse_args($args, $defaults); |
|
62 | 62 | |
63 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
63 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
64 | 64 | |
65 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
65 | + $fields = array('ID', 'user_login', 'user_email'); |
|
66 | 66 | |
67 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
68 | - if ( 'display_name_with_login' === $show ) { |
|
67 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
68 | + if ('display_name_with_login' === $show) { |
|
69 | 69 | $fields[] = 'display_name'; |
70 | - } else if ( 'display_name_with_email' === $show ) { |
|
70 | + } else if ('display_name_with_email' === $show) { |
|
71 | 71 | $fields[] = 'display_name'; |
72 | 72 | } else { |
73 | 73 | $fields[] = $show; |
@@ -79,99 +79,99 @@ discard block |
||
79 | 79 | $show_option_none = $r['show_option_none']; |
80 | 80 | $option_none_value = $r['option_none_value']; |
81 | 81 | |
82 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
82 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
83 | 83 | |
84 | - $users = get_users( $query_args ); |
|
84 | + $users = get_users($query_args); |
|
85 | 85 | |
86 | 86 | $output = ''; |
87 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
88 | - $name = esc_attr( $r['name'] ); |
|
89 | - if ( $r['multi'] && ! $r['id'] ) { |
|
87 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
88 | + $name = esc_attr($r['name']); |
|
89 | + if ($r['multi'] && !$r['id']) { |
|
90 | 90 | $id = ''; |
91 | 91 | } else { |
92 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
92 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
93 | 93 | } |
94 | 94 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
95 | 95 | |
96 | - if ( $show_option_all ) { |
|
96 | + if ($show_option_all) { |
|
97 | 97 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
98 | 98 | } |
99 | 99 | |
100 | - if ( $show_option_none ) { |
|
101 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
102 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
100 | + if ($show_option_none) { |
|
101 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
102 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
103 | 103 | } |
104 | 104 | |
105 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
105 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
106 | 106 | $found_selected = false; |
107 | - $r['selected'] = (int) $r['selected']; |
|
108 | - foreach ( (array) $users as $user ) { |
|
109 | - $user->ID = (int) $user->ID; |
|
110 | - if ( $user->ID === $r['selected'] ) { |
|
107 | + $r['selected'] = (int)$r['selected']; |
|
108 | + foreach ((array)$users as $user) { |
|
109 | + $user->ID = (int)$user->ID; |
|
110 | + if ($user->ID === $r['selected']) { |
|
111 | 111 | $found_selected = true; |
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if ( ! $found_selected ) { |
|
116 | - $users[] = get_userdata( $r['selected'] ); |
|
115 | + if (!$found_selected) { |
|
116 | + $users[] = get_userdata($r['selected']); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - foreach ( (array) $users as $user ) { |
|
121 | - if ( 'display_name_with_login' === $show ) { |
|
120 | + foreach ((array)$users as $user) { |
|
121 | + if ('display_name_with_login' === $show) { |
|
122 | 122 | /* translators: 1: display name, 2: user_login */ |
123 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
124 | - } elseif ( 'display_name_with_email' === $show ) { |
|
123 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
124 | + } elseif ('display_name_with_email' === $show) { |
|
125 | 125 | /* translators: 1: display name, 2: user_email */ |
126 | - if ( $user->display_name == $user->user_email ) { |
|
126 | + if ($user->display_name == $user->user_email) { |
|
127 | 127 | $display = $user->display_name; |
128 | 128 | } else { |
129 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
129 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
130 | 130 | } |
131 | - } elseif ( ! empty( $user->$show ) ) { |
|
131 | + } elseif (!empty($user->$show)) { |
|
132 | 132 | $display = $user->$show; |
133 | 133 | } else { |
134 | 134 | $display = '(' . $user->user_login . ')'; |
135 | 135 | } |
136 | 136 | |
137 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
138 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
137 | + $_selected = selected($user->ID, $r['selected'], false); |
|
138 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $output .= "</select>"; |
142 | 142 | } |
143 | 143 | |
144 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
144 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
145 | 145 | |
146 | - if ( $r['echo'] ) { |
|
146 | + if ($r['echo']) { |
|
147 | 147 | echo $html; |
148 | 148 | } |
149 | 149 | return $html; |
150 | 150 | } |
151 | 151 | |
152 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
153 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
154 | - wpinv_login_user( $user_id ); |
|
152 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
153 | + if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
154 | + wpinv_login_user($user_id); |
|
155 | 155 | } else { |
156 | - $redirect_to = wp_login_url( $redirect_to ); |
|
156 | + $redirect_to = wp_login_url($redirect_to); |
|
157 | 157 | } |
158 | 158 | |
159 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
159 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
160 | 160 | |
161 | - wp_redirect( $redirect_to ); |
|
161 | + wp_redirect($redirect_to); |
|
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_login_user( $user_id ) { |
|
165 | - if ( is_user_logged_in() ) { |
|
164 | +function wpinv_login_user($user_id) { |
|
165 | + if (is_user_logged_in()) { |
|
166 | 166 | return true; |
167 | 167 | } |
168 | 168 | |
169 | - $user = get_user_by( 'id', $user_id ); |
|
169 | + $user = get_user_by('id', $user_id); |
|
170 | 170 | |
171 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
172 | - wp_set_current_user( $user_id, $user->user_login ); |
|
173 | - wp_set_auth_cookie( $user_id ); |
|
174 | - do_action( 'wp_login', $user->user_login ); |
|
171 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
172 | + wp_set_current_user($user_id, $user->user_login); |
|
173 | + wp_set_auth_cookie($user_id); |
|
174 | + do_action('wp_login', $user->user_login); |
|
175 | 175 | |
176 | 176 | return true; |
177 | 177 | } |
@@ -1,6 +1,8 @@ discard block |
||
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_user_invoices( $current_page = 1 ) { |
6 | 8 | global $current_page; |
@@ -19,12 +21,13 @@ discard block |
||
19 | 21 | $status = $status === 'complete' ? 'publish' : $status; |
20 | 22 | |
21 | 23 | if ( $pagination ) { |
22 | - if ( get_query_var( 'paged' ) ) |
|
23 | - $paged = get_query_var('paged'); |
|
24 | - else if ( get_query_var( 'page' ) ) |
|
25 | - $paged = get_query_var( 'page' ); |
|
26 | - else |
|
27 | - $paged = 1; |
|
24 | + if ( get_query_var( 'paged' ) ) { |
|
25 | + $paged = get_query_var('paged'); |
|
26 | + } else if ( get_query_var( 'page' ) ) { |
|
27 | + $paged = get_query_var( 'page' ); |
|
28 | + } else { |
|
29 | + $paged = 1; |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | |
30 | 33 | $args = array( |
@@ -39,8 +42,9 @@ discard block |
||
39 | 42 | $invoices = get_posts( $args ); |
40 | 43 | |
41 | 44 | // No invoices |
42 | - if ( ! $invoices ) |
|
43 | - return false; |
|
45 | + if ( ! $invoices ) { |
|
46 | + return false; |
|
47 | + } |
|
44 | 48 | |
45 | 49 | return $invoices; |
46 | 50 | } |
@@ -9,6 +9,6 @@ |
||
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 | } |
@@ -5,140 +5,140 @@ |
||
5 | 5 | |
6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns, $wpi_session; |
7 | 7 | $invoice = wpinv_get_invoice_cart(); |
8 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
8 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
9 | 9 | $quantities_enabled = wpinv_item_quantities_enabled(); |
10 | 10 | $use_taxes = wpinv_use_taxes(); |
11 | 11 | $tax_label = $wpinv_euvat->tax_label(); |
12 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
12 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
13 | 13 | ?> |
14 | 14 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
15 | 15 | <thead> |
16 | 16 | <tr class="wpinv_cart_header_row"> |
17 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
18 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
19 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
20 | - <?php if ( $quantities_enabled ) { ?> |
|
21 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
17 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
18 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
19 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
20 | + <?php if ($quantities_enabled) { ?> |
|
21 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
22 | 22 | <?php } ?> |
23 | - <?php if ( $use_taxes ) { ?> |
|
23 | + <?php if ($use_taxes) { ?> |
|
24 | 24 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
25 | 25 | <?php } ?> |
26 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
27 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
26 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
27 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | <tbody> |
31 | 31 | <?php |
32 | - do_action( 'wpinv_cart_items_before' ); |
|
32 | + do_action('wpinv_cart_items_before'); |
|
33 | 33 | |
34 | - if ( $cart_items ) { |
|
35 | - foreach ( $cart_items as $key => $item ) { |
|
36 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
34 | + if ($cart_items) { |
|
35 | + foreach ($cart_items as $key => $item) { |
|
36 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
37 | 37 | ?> |
38 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
39 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
38 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
39 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
40 | 40 | <td class="wpinv_cart_item_name text-left"> |
41 | 41 | <?php |
42 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
42 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
43 | 43 | echo '<div class="wpinv_cart_item_image">'; |
44 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
44 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
45 | 45 | echo '</div>'; |
46 | 46 | } |
47 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
47 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
48 | 48 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
49 | - if ( !empty( $wpi_item ) && $wpi_item->is_package() && !empty( $item['meta']['post_id'] ) ) { |
|
50 | - $post_link = !empty( $item['meta']['invoice_title'] ) ? $item['meta']['invoice_title'] : get_the_title( $item['meta']['post_id'] ); |
|
51 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_cpt_singular_name(), $post_link ); |
|
52 | - echo '<small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
49 | + if (!empty($wpi_item) && $wpi_item->is_package() && !empty($item['meta']['post_id'])) { |
|
50 | + $post_link = !empty($item['meta']['invoice_title']) ? $item['meta']['invoice_title'] : get_the_title($item['meta']['post_id']); |
|
51 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_cpt_singular_name(), $post_link); |
|
52 | + echo '<small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
53 | 53 | } |
54 | - do_action( 'wpinv_checkout_cart_item_title_after', $item, $key ); |
|
54 | + do_action('wpinv_checkout_cart_item_title_after', $item, $key); |
|
55 | 55 | ?> |
56 | 56 | </td> |
57 | 57 | <td class="wpinv_cart_item_price text-right"> |
58 | 58 | <?php |
59 | - echo wpinv_cart_item_price( $item ); |
|
60 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
59 | + echo wpinv_cart_item_price($item); |
|
60 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
61 | 61 | ?> |
62 | 62 | </td> |
63 | - <?php if ( $quantities_enabled ) { ?> |
|
63 | + <?php if ($quantities_enabled) { ?> |
|
64 | 64 | <td class="wpinv_cart_item_qty text-right"> |
65 | 65 | <?php |
66 | - echo wpinv_get_cart_item_quantity( $item ); |
|
67 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
66 | + echo wpinv_get_cart_item_quantity($item); |
|
67 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
68 | 68 | ?> |
69 | 69 | </td> |
70 | 70 | <?php } ?> |
71 | - <?php if ( $use_taxes ) { ?> |
|
71 | + <?php if ($use_taxes) { ?> |
|
72 | 72 | <td class="wpinv_cart_item_tax text-right"> |
73 | 73 | <?php |
74 | - echo wpinv_cart_item_tax( $item ); |
|
74 | + echo wpinv_cart_item_tax($item); |
|
75 | 75 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
76 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
76 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
77 | 77 | ?> |
78 | 78 | </td> |
79 | 79 | <?php } ?> |
80 | 80 | <td class="wpinv_cart_item_subtotal text-right"> |
81 | 81 | <?php |
82 | - echo wpinv_cart_item_subtotal( $item ); |
|
83 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
82 | + echo wpinv_cart_item_subtotal($item); |
|
83 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
84 | 84 | ?> |
85 | 85 | </td> |
86 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
86 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
87 | 87 | </tr> |
88 | 88 | <?php } ?> |
89 | 89 | <?php } ?> |
90 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
91 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
90 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
91 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
92 | 92 | </tbody> |
93 | 93 | <tfoot> |
94 | 94 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
95 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
95 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
96 | 96 | <tr class="wpinv_cart_footer_row"> |
97 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
98 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
99 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
97 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
98 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
99 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
100 | 100 | </td> |
101 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
101 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
102 | 102 | </tr> |
103 | 103 | <?php } ?> |
104 | 104 | |
105 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
107 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
108 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
109 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
105 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
107 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
108 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
109 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
110 | 110 | </td> |
111 | 111 | <td class="wpinv_cart_subtotal text-right"> |
112 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span> |
|
112 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span> |
|
113 | 113 | </td> |
114 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
114 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
115 | 115 | </tr> |
116 | 116 | <?php } ?> |
117 | 117 | |
118 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
118 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
119 | 119 | |
120 | - <?php if ( $use_taxes ) { ?> |
|
121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
122 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
123 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
120 | + <?php if ($use_taxes) { ?> |
|
121 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
122 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
123 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
124 | 124 | <strong><?php echo $tax_label; ?>:</strong> |
125 | 125 | </td> |
126 | 126 | <td class="wpinv_cart_tax text-right"> |
127 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span> |
|
127 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span> |
|
128 | 128 | </td> |
129 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
129 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
130 | 130 | </tr> |
131 | 131 | <?php } ?> |
132 | 132 | |
133 | 133 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
134 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
135 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
136 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
134 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
135 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
136 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
137 | 137 | </td> |
138 | 138 | <td class="wpinv_cart_total text-right"> |
139 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
139 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
140 | 140 | </td> |
141 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
141 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
142 | 142 | </tr> |
143 | 143 | </tfoot> |
144 | 144 | </table> |
@@ -103,7 +103,10 @@ discard block |
||
103 | 103 | <?php } ?> |
104 | 104 | |
105 | 105 | <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) { |
|
107 | + echo ' style="display:none;"'; |
|
108 | +} |
|
109 | +?>> |
|
107 | 110 | <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
108 | 111 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
109 | 112 | <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
@@ -118,7 +121,10 @@ discard block |
||
118 | 121 | <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
119 | 122 | |
120 | 123 | <?php if ( $use_taxes ) { ?> |
121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
124 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) { |
|
125 | + echo ' style="display:none;"'; |
|
126 | +} |
|
127 | +?>> |
|
122 | 128 | <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
123 | 129 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
124 | 130 | <strong><?php echo $tax_label; ?>:</strong> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
|
7 | -$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
|
6 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text')); |
|
7 | +$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : ''; |
|
8 | 8 | ?> |
9 | 9 | </div> |
10 | 10 | </td> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
7 | 8 | $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -if ( !isset( $email_heading ) ) { |
|
6 | +if (!isset($email_heading)) { |
|
7 | 7 | global $email_heading; |
8 | 8 | } |
9 | 9 | ?> |
10 | 10 | <!DOCTYPE html> |
11 | 11 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>"> |
12 | 12 | <head> |
13 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
13 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
14 | 14 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
15 | 15 | <meta name="robots" content="noindex,nofollow"> |
16 | 16 | <title><?php echo wpinv_get_blogname(); ?></title> |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | <td align="center" valign="top"> |
23 | 23 | <div id="template_header_image"> |
24 | 24 | <?php |
25 | - if ( $img = wpinv_get_option( 'email_header_image' ) ) { |
|
26 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
25 | + if ($img = wpinv_get_option('email_header_image')) { |
|
26 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
27 | 27 | } |
28 | 28 | ?> |
29 | 29 | </div> |
30 | 30 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
31 | - <?php if ( !empty( $email_heading ) ) { ?> |
|
31 | + <?php if (!empty($email_heading)) { ?> |
|
32 | 32 | <tr> |
33 | 33 | <td align="center" valign="top"> |
34 | 34 | <!-- Header --> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | if ( !isset( $email_heading ) ) { |
7 | 8 | global $email_heading; |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | -if ( $invoice->needs_payment() ) { |
|
8 | +if ($invoice->needs_payment()) { |
|
9 | 9 | ?> |
10 | - <p><?php printf( __( 'An invoice has been created for you on %s. To pay for this invoice please use the following link: %s', 'invoicing' ), wpinv_get_business_name(), '<a href="' . esc_url( $invoice->get_checkout_payment_url( false, true ) ) . '">' . __( 'Pay Now', 'invoicing' ) . '</a>' ); ?></p> |
|
10 | + <p><?php printf(__('An invoice has been created for you on %s. To pay for this invoice please use the following link: %s', 'invoicing'), wpinv_get_business_name(), '<a href="' . esc_url($invoice->get_checkout_payment_url(false, true)) . '">' . __('Pay Now', 'invoicing') . '</a>'); ?></p> |
|
11 | 11 | <?php |
12 | 12 | } |
13 | 13 | |
14 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
16 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
18 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
19 | 19 | |
20 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
21 | 20 | \ No newline at end of file |
21 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
22 | 22 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | 8 | ?> |
9 | -<p><?php _e( 'Hello, a note has just been added to your invoice:', 'invoicing' ); ?></p> |
|
10 | -<blockquote class="wpinv-note"><?php echo wpautop( wptexturize( $customer_note ) ) ?></blockquote> |
|
11 | -<p><?php _e( 'For your reference, your invoice details are shown below.', 'invoicing' ); ?></p> |
|
9 | +<p><?php _e('Hello, a note has just been added to your invoice:', 'invoicing'); ?></p> |
|
10 | +<blockquote class="wpinv-note"><?php echo wpautop(wptexturize($customer_note)) ?></blockquote> |
|
11 | +<p><?php _e('For your reference, your invoice details are shown below.', 'invoicing'); ?></p> |
|
12 | 12 | <?php |
13 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
13 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
14 | 14 | |
15 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
15 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
16 | 16 | |
17 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
17 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
18 | 18 | |
19 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
20 | 19 | \ No newline at end of file |
20 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
21 | 21 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 |