@@ -7,28 +7,28 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Ajax { |
15 | 15 | public static function init() { |
16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
18 | 18 | self::add_ajax_events(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function define_ajax() { |
22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
24 | - define( 'DOING_AJAX', true ); |
|
22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
23 | + if (!defined('DOING_AJAX')) { |
|
24 | + define('DOING_AJAX', true); |
|
25 | 25 | } |
26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
27 | - define( 'WC_DOING_AJAX', true ); |
|
26 | + if (!defined('WC_DOING_AJAX')) { |
|
27 | + define('WC_DOING_AJAX', true); |
|
28 | 28 | } |
29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
31 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
31 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
32 | 32 | } |
33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | public static function do_wpinv_ajax() { |
38 | 38 | global $wp_query; |
39 | 39 | |
40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
45 | 45 | self::wpinv_ajax_headers(); |
46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function wpinv_ajax_headers() { |
52 | 52 | send_origin_headers(); |
53 | - /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
54 | - /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' ); |
|
53 | + /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
54 | + /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex'); |
|
55 | 55 | send_nosniff_header(); |
56 | 56 | nocache_headers(); |
57 | - status_header( 200 ); |
|
57 | + status_header(200); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function add_ajax_events() { |
@@ -79,39 +79,39 @@ discard block |
||
79 | 79 | 'buy_items' => true, |
80 | 80 | ); |
81 | 81 | |
82 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
83 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
82 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
83 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
84 | 84 | |
85 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
86 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
85 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
86 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( $nopriv ) { |
|
90 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
89 | + if ($nopriv) { |
|
90 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
91 | 91 | |
92 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
92 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | 97 | public static function add_note() { |
98 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
98 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
99 | 99 | |
100 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
100 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
101 | 101 | die(-1); |
102 | 102 | } |
103 | 103 | |
104 | - $post_id = absint( $_POST['post_id'] ); |
|
105 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
106 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
104 | + $post_id = absint($_POST['post_id']); |
|
105 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
106 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
107 | 107 | |
108 | 108 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
109 | 109 | |
110 | - if ( $post_id > 0 ) { |
|
111 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
110 | + if ($post_id > 0) { |
|
111 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
112 | 112 | |
113 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
114 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
113 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
114 | + wpinv_get_invoice_note_line_item($note_id); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | public static function delete_note() { |
122 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
122 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
123 | 123 | |
124 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
124 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
125 | 125 | die(-1); |
126 | 126 | } |
127 | 127 | |
128 | - $note_id = (int)$_POST['note_id']; |
|
128 | + $note_id = (int) $_POST['note_id']; |
|
129 | 129 | |
130 | - if ( $note_id > 0 ) { |
|
131 | - wp_delete_comment( $note_id, true ); |
|
130 | + if ($note_id > 0) { |
|
131 | + wp_delete_comment($note_id, true); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | die(); |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | public static function checkout() { |
144 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
145 | - define( 'WPINV_CHECKOUT', true ); |
|
144 | + if (!defined('WPINV_CHECKOUT')) { |
|
145 | + define('WPINV_CHECKOUT', true); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | wpinv_process_checkout(); |
@@ -151,53 +151,53 @@ discard block |
||
151 | 151 | |
152 | 152 | public static function add_invoice_item() { |
153 | 153 | global $wpi_userID, $wpinv_ip_address_country; |
154 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
155 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
154 | + check_ajax_referer('invoice-item', '_nonce'); |
|
155 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
156 | 156 | die(-1); |
157 | 157 | } |
158 | 158 | |
159 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
160 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
159 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
160 | + $invoice_id = absint($_POST['invoice_id']); |
|
161 | 161 | |
162 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
162 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
163 | 163 | die(); |
164 | 164 | } |
165 | 165 | |
166 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
167 | - if ( empty( $invoice ) ) { |
|
166 | + $invoice = wpinv_get_invoice($invoice_id); |
|
167 | + if (empty($invoice)) { |
|
168 | 168 | die(); |
169 | 169 | } |
170 | 170 | |
171 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
171 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
172 | 172 | die(); // Don't allow modify items for paid invoice. |
173 | 173 | } |
174 | 174 | |
175 | - if ( !empty( $_POST['user_id'] ) ) { |
|
176 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
175 | + if (!empty($_POST['user_id'])) { |
|
176 | + $wpi_userID = absint($_POST['user_id']); |
|
177 | 177 | } |
178 | 178 | |
179 | - $item = new WPInv_Item( $item_id ); |
|
180 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
179 | + $item = new WPInv_Item($item_id); |
|
180 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
181 | 181 | die(); |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Validate item before adding to invoice because recurring item must be paid individually. |
185 | - if ( !empty( $invoice->cart_details ) ) { |
|
185 | + if (!empty($invoice->cart_details)) { |
|
186 | 186 | $valid = true; |
187 | 187 | |
188 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
189 | - if ( $recurring_item != $item_id ) { |
|
188 | + if ($recurring_item = $invoice->get_recurring()) { |
|
189 | + if ($recurring_item != $item_id) { |
|
190 | 190 | $valid = false; |
191 | 191 | } |
192 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
192 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
193 | 193 | $valid = false; |
194 | 194 | } |
195 | 195 | |
196 | - if ( !$valid ) { |
|
196 | + if (!$valid) { |
|
197 | 197 | $response = array(); |
198 | 198 | $response['success'] = false; |
199 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
200 | - wp_send_json( $response ); |
|
199 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
200 | + wp_send_json($response); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | |
206 | 206 | $data = array(); |
207 | 207 | $data['invoice_id'] = $invoice_id; |
208 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
208 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
209 | 209 | |
210 | - wpinv_set_checkout_session( $data ); |
|
210 | + wpinv_set_checkout_session($data); |
|
211 | 211 | |
212 | - $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
|
212 | + $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1; |
|
213 | 213 | |
214 | 214 | $args = array( |
215 | 215 | 'id' => $item_id, |
@@ -222,21 +222,21 @@ discard block |
||
222 | 222 | 'fees' => array() |
223 | 223 | ); |
224 | 224 | |
225 | - $invoice->add_item( $item_id, $args ); |
|
225 | + $invoice->add_item($item_id, $args); |
|
226 | 226 | $invoice->save(); |
227 | 227 | |
228 | - if ( empty( $_POST['country'] ) ) { |
|
228 | + if (empty($_POST['country'])) { |
|
229 | 229 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
230 | 230 | } |
231 | - if ( empty( $_POST['state'] ) ) { |
|
231 | + if (empty($_POST['state'])) { |
|
232 | 232 | $_POST['state'] = $invoice->state; |
233 | 233 | } |
234 | 234 | |
235 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
236 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
235 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
236 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
237 | 237 | |
238 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
239 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
238 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
239 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
240 | 240 | |
241 | 241 | $wpinv_ip_address_country = $invoice->country; |
242 | 242 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $response = array(); |
246 | 246 | $response['success'] = true; |
247 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
247 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
248 | 248 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
249 | 249 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
250 | 250 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -256,41 +256,41 @@ discard block |
||
256 | 256 | |
257 | 257 | wpinv_set_checkout_session($checkout_session); |
258 | 258 | |
259 | - wp_send_json( $response ); |
|
259 | + wp_send_json($response); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | |
263 | 263 | public static function remove_invoice_item() { |
264 | 264 | global $wpi_userID, $wpinv_ip_address_country; |
265 | 265 | |
266 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
267 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
266 | + check_ajax_referer('invoice-item', '_nonce'); |
|
267 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
268 | 268 | die(-1); |
269 | 269 | } |
270 | 270 | |
271 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
272 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
273 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
271 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
272 | + $invoice_id = absint($_POST['invoice_id']); |
|
273 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
274 | 274 | |
275 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
275 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
276 | 276 | die(); |
277 | 277 | } |
278 | 278 | |
279 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
280 | - if ( empty( $invoice ) ) { |
|
279 | + $invoice = wpinv_get_invoice($invoice_id); |
|
280 | + if (empty($invoice)) { |
|
281 | 281 | die(); |
282 | 282 | } |
283 | 283 | |
284 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
284 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
285 | 285 | die(); // Don't allow modify items for paid invoice. |
286 | 286 | } |
287 | 287 | |
288 | - if ( !empty( $_POST['user_id'] ) ) { |
|
289 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
288 | + if (!empty($_POST['user_id'])) { |
|
289 | + $wpi_userID = absint($_POST['user_id']); |
|
290 | 290 | } |
291 | 291 | |
292 | - $item = new WPInv_Item( $item_id ); |
|
293 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
292 | + $item = new WPInv_Item($item_id); |
|
293 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
294 | 294 | die(); |
295 | 295 | } |
296 | 296 | |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | |
299 | 299 | $data = array(); |
300 | 300 | $data['invoice_id'] = $invoice_id; |
301 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
301 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
302 | 302 | |
303 | - wpinv_set_checkout_session( $data ); |
|
303 | + wpinv_set_checkout_session($data); |
|
304 | 304 | |
305 | 305 | $args = array( |
306 | 306 | 'id' => $item_id, |
@@ -308,21 +308,21 @@ discard block |
||
308 | 308 | 'cart_index' => $cart_index |
309 | 309 | ); |
310 | 310 | |
311 | - $invoice->remove_item( $item_id, $args ); |
|
311 | + $invoice->remove_item($item_id, $args); |
|
312 | 312 | $invoice->save(); |
313 | 313 | |
314 | - if ( empty( $_POST['country'] ) ) { |
|
314 | + if (empty($_POST['country'])) { |
|
315 | 315 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
316 | 316 | } |
317 | - if ( empty( $_POST['state'] ) ) { |
|
317 | + if (empty($_POST['state'])) { |
|
318 | 318 | $_POST['state'] = $invoice->state; |
319 | 319 | } |
320 | 320 | |
321 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
322 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
321 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
322 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
323 | 323 | |
324 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
325 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
324 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
325 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
326 | 326 | |
327 | 327 | $wpinv_ip_address_country = $invoice->country; |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | $response = array(); |
332 | 332 | $response['success'] = true; |
333 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
333 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
334 | 334 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
335 | 335 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
336 | 336 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -342,55 +342,55 @@ discard block |
||
342 | 342 | |
343 | 343 | wpinv_set_checkout_session($checkout_session); |
344 | 344 | |
345 | - wp_send_json( $response ); |
|
345 | + wp_send_json($response); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | public static function create_invoice_item() { |
349 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
350 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
349 | + check_ajax_referer('invoice-item', '_nonce'); |
|
350 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
351 | 351 | die(-1); |
352 | 352 | } |
353 | 353 | |
354 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
354 | + $invoice_id = absint($_POST['invoice_id']); |
|
355 | 355 | |
356 | 356 | // Find the item |
357 | - if ( !is_numeric( $invoice_id ) ) { |
|
357 | + if (!is_numeric($invoice_id)) { |
|
358 | 358 | die(); |
359 | 359 | } |
360 | 360 | |
361 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
362 | - if ( empty( $invoice ) ) { |
|
361 | + $invoice = wpinv_get_invoice($invoice_id); |
|
362 | + if (empty($invoice)) { |
|
363 | 363 | die(); |
364 | 364 | } |
365 | 365 | |
366 | 366 | // Validate item before adding to invoice because recurring item must be paid individually. |
367 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
367 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
368 | 368 | $response = array(); |
369 | 369 | $response['success'] = false; |
370 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
371 | - wp_send_json( $response ); |
|
370 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
371 | + wp_send_json($response); |
|
372 | 372 | } |
373 | 373 | |
374 | - $save_item = wp_unslash( $_POST['_wpinv_quick'] ); |
|
374 | + $save_item = wp_unslash($_POST['_wpinv_quick']); |
|
375 | 375 | |
376 | 376 | $meta = array(); |
377 | 377 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
378 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
378 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
379 | 379 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
380 | 380 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
381 | 381 | |
382 | 382 | $data = array(); |
383 | 383 | $data['post_title'] = sanitize_text_field($save_item['name']); |
384 | 384 | $data['post_status'] = 'publish'; |
385 | - $data['post_excerpt'] = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : ''; |
|
385 | + $data['post_excerpt'] = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : ''; |
|
386 | 386 | $data['meta'] = $meta; |
387 | 387 | |
388 | 388 | $item = new WPInv_Item(); |
389 | - $item->create( $data ); |
|
389 | + $item->create($data); |
|
390 | 390 | |
391 | - if ( !empty( $item ) ) { |
|
391 | + if (!empty($item)) { |
|
392 | 392 | $_POST['item_id'] = $item->ID; |
393 | - $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
|
393 | + $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1; |
|
394 | 394 | |
395 | 395 | self::add_invoice_item(); |
396 | 396 | } |
@@ -398,15 +398,15 @@ discard block |
||
398 | 398 | } |
399 | 399 | |
400 | 400 | public static function get_billing_details() { |
401 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
401 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
402 | 402 | |
403 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
403 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
404 | 404 | die(-1); |
405 | 405 | } |
406 | 406 | |
407 | - $user_id = (int)$_POST['user_id']; |
|
407 | + $user_id = (int) $_POST['user_id']; |
|
408 | 408 | $billing_details = wpinv_get_user_address($user_id); |
409 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
409 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
410 | 410 | |
411 | 411 | if (isset($billing_details['user_id'])) { |
412 | 412 | unset($billing_details['user_id']); |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | $response['success'] = true; |
421 | 421 | $response['data']['billing_details'] = $billing_details; |
422 | 422 | |
423 | - wp_send_json( $response ); |
|
423 | + wp_send_json($response); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | public static function admin_recalculate_totals() { |
427 | 427 | global $wpi_userID, $wpinv_ip_address_country; |
428 | 428 | |
429 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
430 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
429 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
430 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
431 | 431 | die(-1); |
432 | 432 | } |
433 | 433 | |
434 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
435 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
436 | - if ( empty( $invoice ) ) { |
|
434 | + $invoice_id = absint($_POST['invoice_id']); |
|
435 | + $invoice = wpinv_get_invoice($invoice_id); |
|
436 | + if (empty($invoice)) { |
|
437 | 437 | die(); |
438 | 438 | } |
439 | 439 | |
@@ -441,29 +441,29 @@ discard block |
||
441 | 441 | |
442 | 442 | $data = array(); |
443 | 443 | $data['invoice_id'] = $invoice_id; |
444 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
444 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
445 | 445 | |
446 | - wpinv_set_checkout_session( $data ); |
|
446 | + wpinv_set_checkout_session($data); |
|
447 | 447 | |
448 | - if ( !empty( $_POST['user_id'] ) ) { |
|
449 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
448 | + if (!empty($_POST['user_id'])) { |
|
449 | + $wpi_userID = absint($_POST['user_id']); |
|
450 | 450 | } |
451 | 451 | |
452 | - if ( empty( $_POST['country'] ) ) { |
|
452 | + if (empty($_POST['country'])) { |
|
453 | 453 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
454 | 454 | } |
455 | 455 | |
456 | 456 | $disable_taxes = 0; |
457 | - if ( ! empty( $_POST['disable_taxes'] ) ) { |
|
457 | + if (!empty($_POST['disable_taxes'])) { |
|
458 | 458 | $disable_taxes = 1; |
459 | 459 | } |
460 | - $invoice->set( 'disable_taxes', $disable_taxes ); |
|
460 | + $invoice->set('disable_taxes', $disable_taxes); |
|
461 | 461 | |
462 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
463 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
464 | - if ( isset( $_POST['state'] ) ) { |
|
465 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
466 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
462 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
463 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
464 | + if (isset($_POST['state'])) { |
|
465 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
466 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | $wpinv_ip_address_country = $invoice->country; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | |
473 | 473 | $response = array(); |
474 | 474 | $response['success'] = true; |
475 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
475 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
476 | 476 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
477 | 477 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
478 | 478 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -484,25 +484,25 @@ discard block |
||
484 | 484 | |
485 | 485 | wpinv_set_checkout_session($checkout_session); |
486 | 486 | |
487 | - wp_send_json( $response ); |
|
487 | + wp_send_json($response); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | public static function admin_apply_discount() { |
491 | 491 | global $wpi_userID; |
492 | 492 | |
493 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
494 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
493 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
494 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
495 | 495 | die(-1); |
496 | 496 | } |
497 | 497 | |
498 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
499 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
500 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
498 | + $invoice_id = absint($_POST['invoice_id']); |
|
499 | + $discount_code = sanitize_text_field($_POST['code']); |
|
500 | + if (empty($invoice_id) || empty($discount_code)) { |
|
501 | 501 | die(); |
502 | 502 | } |
503 | 503 | |
504 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
505 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
504 | + $invoice = wpinv_get_invoice($invoice_id); |
|
505 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
506 | 506 | die(); |
507 | 507 | } |
508 | 508 | |
@@ -510,49 +510,49 @@ discard block |
||
510 | 510 | |
511 | 511 | $data = array(); |
512 | 512 | $data['invoice_id'] = $invoice_id; |
513 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
513 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
514 | 514 | |
515 | - wpinv_set_checkout_session( $data ); |
|
515 | + wpinv_set_checkout_session($data); |
|
516 | 516 | |
517 | 517 | $response = array(); |
518 | 518 | $response['success'] = false; |
519 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
519 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
520 | 520 | $response['data']['code'] = $discount_code; |
521 | 521 | |
522 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
523 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
522 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
523 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
524 | 524 | |
525 | 525 | $response['success'] = true; |
526 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
527 | - } else { |
|
526 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
527 | + } else { |
|
528 | 528 | $errors = wpinv_get_errors(); |
529 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
529 | + if (!empty($errors['wpinv-discount-error'])) { |
|
530 | 530 | $response['msg'] = $errors['wpinv-discount-error']; |
531 | 531 | } |
532 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
532 | + wpinv_unset_error('wpinv-discount-error'); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | wpinv_set_checkout_session($checkout_session); |
536 | 536 | |
537 | - wp_send_json( $response ); |
|
537 | + wp_send_json($response); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | public static function admin_remove_discount() { |
541 | 541 | global $wpi_userID; |
542 | 542 | |
543 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
544 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
543 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
544 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
545 | 545 | die(-1); |
546 | 546 | } |
547 | 547 | |
548 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
549 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
550 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
548 | + $invoice_id = absint($_POST['invoice_id']); |
|
549 | + $discount_code = sanitize_text_field($_POST['code']); |
|
550 | + if (empty($invoice_id) || empty($discount_code)) { |
|
551 | 551 | die(); |
552 | 552 | } |
553 | 553 | |
554 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
555 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
554 | + $invoice = wpinv_get_invoice($invoice_id); |
|
555 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
556 | 556 | die(); |
557 | 557 | } |
558 | 558 | |
@@ -560,38 +560,38 @@ discard block |
||
560 | 560 | |
561 | 561 | $data = array(); |
562 | 562 | $data['invoice_id'] = $invoice_id; |
563 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
563 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
564 | 564 | |
565 | - wpinv_set_checkout_session( $data ); |
|
565 | + wpinv_set_checkout_session($data); |
|
566 | 566 | |
567 | 567 | $response = array(); |
568 | 568 | $response['success'] = false; |
569 | 569 | $response['msg'] = NULL; |
570 | 570 | |
571 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
571 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
572 | 572 | $response['success'] = true; |
573 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
573 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
574 | 574 | |
575 | 575 | wpinv_set_checkout_session($checkout_session); |
576 | 576 | |
577 | - wp_send_json( $response ); |
|
577 | + wp_send_json($response); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | public static function check_email() { |
581 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
582 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
581 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
582 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
583 | 583 | die(-1); |
584 | 584 | } |
585 | 585 | |
586 | - $email = sanitize_text_field( $_POST['email'] ); |
|
586 | + $email = sanitize_text_field($_POST['email']); |
|
587 | 587 | |
588 | 588 | $response = array(); |
589 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
589 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
590 | 590 | $user_id = $user_data->ID; |
591 | 591 | $user_login = $user_data->user_login; |
592 | 592 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
593 | 593 | $billing_details = wpinv_get_user_address($user_id); |
594 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
594 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
595 | 595 | |
596 | 596 | if (isset($billing_details['user_id'])) { |
597 | 597 | unset($billing_details['user_id']); |
@@ -607,54 +607,54 @@ discard block |
||
607 | 607 | $response['data']['billing_details'] = $billing_details; |
608 | 608 | } |
609 | 609 | |
610 | - wp_send_json( $response ); |
|
610 | + wp_send_json($response); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | public static function run_tool() { |
614 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
615 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
614 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
615 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
616 | 616 | die(-1); |
617 | 617 | } |
618 | 618 | |
619 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
619 | + $tool = sanitize_text_field($_POST['tool']); |
|
620 | 620 | |
621 | - do_action( 'wpinv_run_tool' ); |
|
621 | + do_action('wpinv_run_tool'); |
|
622 | 622 | |
623 | - if ( !empty( $tool ) ) { |
|
624 | - do_action( 'wpinv_tool_' . $tool ); |
|
623 | + if (!empty($tool)) { |
|
624 | + do_action('wpinv_tool_' . $tool); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | |
628 | 628 | public static function apply_discount() { |
629 | 629 | global $wpi_userID; |
630 | 630 | |
631 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
631 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
632 | 632 | |
633 | 633 | $response = array(); |
634 | 634 | |
635 | - if ( isset( $_POST['code'] ) ) { |
|
636 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
635 | + if (isset($_POST['code'])) { |
|
636 | + $discount_code = sanitize_text_field($_POST['code']); |
|
637 | 637 | |
638 | 638 | $response['success'] = false; |
639 | 639 | $response['msg'] = ''; |
640 | 640 | $response['data']['code'] = $discount_code; |
641 | 641 | |
642 | 642 | $invoice = wpinv_get_invoice_cart(); |
643 | - if ( empty( $invoice->ID ) ) { |
|
644 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
645 | - wp_send_json( $response ); |
|
643 | + if (empty($invoice->ID)) { |
|
644 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
645 | + wp_send_json($response); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | $wpi_userID = $invoice->get_user_id(); |
649 | 649 | |
650 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
651 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
652 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
653 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
654 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
655 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
650 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
651 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
652 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
653 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
654 | + $total = wpinv_get_cart_total(null, $discounts); |
|
655 | + $cart_totals = wpinv_recalculate_tax(true); |
|
656 | 656 | |
657 | - if ( !empty( $cart_totals ) ) { |
|
657 | + if (!empty($cart_totals)) { |
|
658 | 658 | $response['success'] = true; |
659 | 659 | $response['data'] = $cart_totals; |
660 | 660 | $response['data']['code'] = $discount_code; |
@@ -663,29 +663,29 @@ discard block |
||
663 | 663 | } |
664 | 664 | } else { |
665 | 665 | $errors = wpinv_get_errors(); |
666 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
667 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
666 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
667 | + wpinv_unset_error('wpinv-discount-error'); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | // Allow for custom discount code handling |
671 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
671 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
672 | 672 | } |
673 | 673 | |
674 | - wp_send_json( $response ); |
|
674 | + wp_send_json($response); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | public static function remove_discount() { |
678 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
678 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
679 | 679 | |
680 | 680 | $response = array(); |
681 | 681 | |
682 | - if ( isset( $_POST['code'] ) ) { |
|
683 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
684 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
685 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
686 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
682 | + if (isset($_POST['code'])) { |
|
683 | + $discount_code = sanitize_text_field($_POST['code']); |
|
684 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
685 | + $total = wpinv_get_cart_total(null, $discounts); |
|
686 | + $cart_totals = wpinv_recalculate_tax(true); |
|
687 | 687 | |
688 | - if ( !empty( $cart_totals ) ) { |
|
688 | + if (!empty($cart_totals)) { |
|
689 | 689 | $response['success'] = true; |
690 | 690 | $response['data'] = $cart_totals; |
691 | 691 | $response['data']['code'] = $discount_code; |
@@ -694,10 +694,10 @@ discard block |
||
694 | 694 | } |
695 | 695 | |
696 | 696 | // Allow for custom discount code handling |
697 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
697 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
698 | 698 | } |
699 | 699 | |
700 | - wp_send_json( $response ); |
|
700 | + wp_send_json($response); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -709,75 +709,75 @@ discard block |
||
709 | 709 | global $invoicing, $wpi_checkout_id, $cart_total; |
710 | 710 | |
711 | 711 | // Check nonce. |
712 | - if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) { |
|
713 | - wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) ); |
|
712 | + if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) { |
|
713 | + wp_send_json_error(__('Security checks failed.', 'invoicing')); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | // Prepare submitted data... |
717 | - $data = wp_unslash( $_POST ); |
|
717 | + $data = wp_unslash($_POST); |
|
718 | 718 | |
719 | 719 | // ... form fields... |
720 | - if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) { |
|
721 | - wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) ); |
|
720 | + if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) { |
|
721 | + wp_send_json_error(__('This payment form is no longer active.', 'invoicing')); |
|
722 | 722 | } |
723 | 723 | |
724 | - if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) { |
|
725 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
724 | + if (empty($data['billing_email']) || !is_email($data['billing_email'])) { |
|
725 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | $prepared = array( |
729 | - 'billing_email' => sanitize_email( $data['billing_email'] ), |
|
730 | - __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ), |
|
731 | - __( 'Form Id', 'invoicing' ) => absint( $data['form_id'] ), |
|
729 | + 'billing_email' => sanitize_email($data['billing_email']), |
|
730 | + __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']), |
|
731 | + __('Form Id', 'invoicing') => absint($data['form_id']), |
|
732 | 732 | ); |
733 | 733 | |
734 | - $prepared['billing_email'] = sanitize_email( $data['billing_email'] ); |
|
734 | + $prepared['billing_email'] = sanitize_email($data['billing_email']); |
|
735 | 735 | |
736 | - $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] ); |
|
736 | + $fields = $invoicing->form_elements->get_form_elements($data['form_id']); |
|
737 | 737 | |
738 | 738 | // ... and form items. |
739 | - $items = $invoicing->form_elements->get_form_items( $data['form_id'] ); |
|
739 | + $items = $invoicing->form_elements->get_form_items($data['form_id']); |
|
740 | 740 | $prepared_items = array(); |
741 | 741 | $address_fields = array(); |
742 | 742 | |
743 | - if ( ! empty( $data['wpinv-items'] ) ) { |
|
743 | + if (!empty($data['wpinv-items'])) { |
|
744 | 744 | |
745 | - $selected_items = wpinv_clean( $data['wpinv-items'] ); |
|
745 | + $selected_items = wpinv_clean($data['wpinv-items']); |
|
746 | 746 | |
747 | - foreach ( $items as $item ) { |
|
747 | + foreach ($items as $item) { |
|
748 | 748 | |
749 | - if ( ! empty( $item['required'] ) && ! isset( $selected_items[ $item['id'] ] ) ) { |
|
750 | - wp_send_json_error( __( 'A required item is missing.', 'invoicing' ) ); |
|
749 | + if (!empty($item['required']) && !isset($selected_items[$item['id']])) { |
|
750 | + wp_send_json_error(__('A required item is missing.', 'invoicing')); |
|
751 | 751 | } |
752 | 752 | |
753 | - if ( ! isset( $selected_items[ $item['id'] ] ) ) { |
|
753 | + if (!isset($selected_items[$item['id']])) { |
|
754 | 754 | continue; |
755 | 755 | } |
756 | 756 | |
757 | 757 | $quantity = 1; |
758 | 758 | |
759 | - if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) { |
|
759 | + if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) { |
|
760 | 760 | |
761 | - $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] ); |
|
761 | + $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]); |
|
762 | 762 | |
763 | - if ( empty( $quantity ) ) { |
|
763 | + if (empty($quantity)) { |
|
764 | 764 | $quantity = 1; |
765 | 765 | } |
766 | 766 | } |
767 | 767 | |
768 | 768 | // Custom pricing. |
769 | - if ( ! empty( $item['custom_price'] ) ) { |
|
769 | + if (!empty($item['custom_price'])) { |
|
770 | 770 | |
771 | - $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] ); |
|
772 | - $set_price = wpinv_sanitize_amount( $selected_items[ $item['id'] ] ); |
|
771 | + $minimum_price = wpinv_sanitize_amount($item['minimum_price']); |
|
772 | + $set_price = wpinv_sanitize_amount($selected_items[$item['id']]); |
|
773 | 773 | |
774 | - if ( $set_price < $minimum_price ) { |
|
775 | - wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) ); |
|
774 | + if ($set_price < $minimum_price) { |
|
775 | + wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing')); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | $prepared_items[] = array( |
779 | 779 | 'id' =>$item['id'], |
780 | - 'item_price' => wpinv_sanitize_amount( $item['price'] ), |
|
780 | + 'item_price' => wpinv_sanitize_amount($item['price']), |
|
781 | 781 | 'custom_price' => $set_price, |
782 | 782 | 'name' => $item['title'], |
783 | 783 | 'quantity' => $quantity, |
@@ -787,8 +787,8 @@ discard block |
||
787 | 787 | |
788 | 788 | $prepared_items[] = array( |
789 | 789 | 'id' => $item['id'], |
790 | - 'item_price' => wpinv_sanitize_amount( $item['price'] ), |
|
791 | - 'custom_price' => wpinv_sanitize_amount( $item['price'] ), |
|
790 | + 'item_price' => wpinv_sanitize_amount($item['price']), |
|
791 | + 'custom_price' => wpinv_sanitize_amount($item['price']), |
|
792 | 792 | 'name' => $item['title'], |
793 | 793 | 'quantity' => $quantity, |
794 | 794 | ); |
@@ -799,64 +799,64 @@ discard block |
||
799 | 799 | |
800 | 800 | } else { |
801 | 801 | |
802 | - wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) ); |
|
802 | + wp_send_json_error(__('You have not selected any items.', 'invoicing')); |
|
803 | 803 | |
804 | 804 | } |
805 | 805 | |
806 | 806 | // Are all required fields provided? |
807 | - foreach ( $fields as $field ) { |
|
807 | + foreach ($fields as $field) { |
|
808 | 808 | |
809 | - if ( ! empty( $field['premade'] ) ) { |
|
809 | + if (!empty($field['premade'])) { |
|
810 | 810 | continue; |
811 | 811 | } |
812 | 812 | |
813 | - if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) { |
|
814 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
813 | + if (!empty($field['required']) && empty($data[$field['id']])) { |
|
814 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
815 | 815 | } |
816 | 816 | |
817 | - if ( $field['type'] == 'address' ) { |
|
817 | + if ($field['type'] == 'address') { |
|
818 | 818 | |
819 | - foreach ( $field['fields'] as $address_field ) { |
|
819 | + foreach ($field['fields'] as $address_field) { |
|
820 | 820 | |
821 | - if ( empty( $address_field['visible'] ) ) { |
|
821 | + if (empty($address_field['visible'])) { |
|
822 | 822 | continue; |
823 | 823 | } |
824 | 824 | |
825 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
826 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
825 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
826 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
827 | 827 | } |
828 | 828 | |
829 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
830 | - $label = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
831 | - $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] ); |
|
829 | + if (isset($data[$address_field['name']])) { |
|
830 | + $label = str_replace('wpinv_', '', $address_field['name']); |
|
831 | + $address_fields[$label] = wpinv_clean($data[$address_field['name']]); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | } |
835 | 835 | |
836 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
836 | + } else if (isset($data[$field['id']])) { |
|
837 | 837 | $label = $field['id']; |
838 | 838 | |
839 | - if ( isset( $field['label'] ) ) { |
|
839 | + if (isset($field['label'])) { |
|
840 | 840 | $label = $field['label']; |
841 | 841 | } |
842 | 842 | |
843 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
843 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | } |
847 | 847 | |
848 | - $user = get_user_by( 'email', $prepared['billing_email'] ); |
|
848 | + $user = get_user_by('email', $prepared['billing_email']); |
|
849 | 849 | |
850 | - if ( empty( $user ) ) { |
|
851 | - $user = wpinv_create_user( $prepared['billing_email'] ); |
|
850 | + if (empty($user)) { |
|
851 | + $user = wpinv_create_user($prepared['billing_email']); |
|
852 | 852 | } |
853 | 853 | |
854 | - if ( is_wp_error( $user ) ) { |
|
855 | - wp_send_json_error( $user->get_error_message() ); |
|
854 | + if (is_wp_error($user)) { |
|
855 | + wp_send_json_error($user->get_error_message()); |
|
856 | 856 | } |
857 | 857 | |
858 | - if ( is_numeric( $user ) ) { |
|
859 | - $user = get_user_by( 'id', $user ); |
|
858 | + if (is_numeric($user)) { |
|
859 | + $user = get_user_by('id', $user); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | // Create the invoice. |
@@ -871,34 +871,34 @@ discard block |
||
871 | 871 | true |
872 | 872 | ); |
873 | 873 | |
874 | - if ( is_wp_error( $created ) ) { |
|
875 | - wp_send_json_error( $created->get_error_message() ); |
|
874 | + if (is_wp_error($created)) { |
|
875 | + wp_send_json_error($created->get_error_message()); |
|
876 | 876 | } |
877 | 877 | |
878 | - if ( empty( $created ) ) { |
|
879 | - wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) ); |
|
878 | + if (empty($created)) { |
|
879 | + wp_send_json_error(__('Could not create your invoice.', 'invoicing')); |
|
880 | 880 | } |
881 | 881 | |
882 | - unset( $prepared['billing_email'] ); |
|
883 | - update_post_meta( $created->ID, 'payment_form_data', $prepared ); |
|
882 | + unset($prepared['billing_email']); |
|
883 | + update_post_meta($created->ID, 'payment_form_data', $prepared); |
|
884 | 884 | |
885 | 885 | $wpi_checkout_id = $created->ID; |
886 | 886 | $cart_total = wpinv_price( |
887 | 887 | wpinv_format_amount( |
888 | - wpinv_get_cart_total( $created->get_cart_details(), NULL, $created ) ), |
|
888 | + wpinv_get_cart_total($created->get_cart_details(), NULL, $created) ), |
|
889 | 889 | $created->get_currency() |
890 | 890 | ); |
891 | 891 | |
892 | 892 | $data = array(); |
893 | 893 | $data['invoice_id'] = $created->ID; |
894 | - $data['cart_discounts'] = $created->get_discounts( true ); |
|
894 | + $data['cart_discounts'] = $created->get_discounts(true); |
|
895 | 895 | |
896 | - wpinv_set_checkout_session( $data ); |
|
897 | - add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) ); |
|
898 | - add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) ); |
|
896 | + wpinv_set_checkout_session($data); |
|
897 | + add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response')); |
|
898 | + add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error')); |
|
899 | 899 | |
900 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
901 | - define( 'WPINV_CHECKOUT', true ); |
|
900 | + if (!defined('WPINV_CHECKOUT')) { |
|
901 | + define('WPINV_CHECKOUT', true); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | wpinv_process_checkout(); |
@@ -917,72 +917,72 @@ discard block |
||
917 | 917 | global $invoicing; |
918 | 918 | |
919 | 919 | // Check nonce. |
920 | - check_ajax_referer( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
920 | + check_ajax_referer('wpinv_payment_form', 'wpinv_payment_form'); |
|
921 | 921 | |
922 | 922 | // Prepare submitted data... |
923 | - $data = wp_unslash( $_POST ); |
|
923 | + $data = wp_unslash($_POST); |
|
924 | 924 | |
925 | 925 | // ... form fields... |
926 | - if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) { |
|
926 | + if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) { |
|
927 | 927 | exit; |
928 | 928 | } |
929 | 929 | |
930 | 930 | // ... and form items. |
931 | - $items = $invoicing->form_elements->get_form_items( $data['form_id'] ); |
|
931 | + $items = $invoicing->form_elements->get_form_items($data['form_id']); |
|
932 | 932 | $total = 0; |
933 | 933 | $tax = 0; |
934 | 934 | $sub_total = 0; |
935 | 935 | $country = wpinv_default_billing_country(); |
936 | 936 | |
937 | - if ( ! empty( $_POST['wpinv_country'] ) ) { |
|
937 | + if (!empty($_POST['wpinv_country'])) { |
|
938 | 938 | $country = $_POST['wpinv_country']; |
939 | 939 | } |
940 | 940 | |
941 | - if ( ! empty( $data['wpinv-items'] ) ) { |
|
941 | + if (!empty($data['wpinv-items'])) { |
|
942 | 942 | |
943 | - $selected_items = wpinv_clean( $data['wpinv-items'] ); |
|
943 | + $selected_items = wpinv_clean($data['wpinv-items']); |
|
944 | 944 | |
945 | - foreach ( $items as $item ) { |
|
945 | + foreach ($items as $item) { |
|
946 | 946 | |
947 | - if ( ! isset( $selected_items[ $item['id'] ] ) ) { |
|
947 | + if (!isset($selected_items[$item['id']])) { |
|
948 | 948 | continue; |
949 | 949 | } |
950 | 950 | |
951 | 951 | $quantity = 1; |
952 | 952 | |
953 | - if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) { |
|
953 | + if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) { |
|
954 | 954 | |
955 | - $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] ); |
|
955 | + $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]); |
|
956 | 956 | |
957 | - if ( 1 > $quantity ) { |
|
957 | + if (1 > $quantity) { |
|
958 | 958 | $quantity = 1; |
959 | 959 | } |
960 | 960 | |
961 | 961 | } |
962 | 962 | |
963 | 963 | // Custom pricing. |
964 | - $price = wpinv_sanitize_amount( $item['price'] ); |
|
965 | - if ( ! empty( $item['custom_price'] ) ) { |
|
964 | + $price = wpinv_sanitize_amount($item['price']); |
|
965 | + if (!empty($item['custom_price'])) { |
|
966 | 966 | |
967 | - $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] ); |
|
968 | - $set_price = wpinv_sanitize_amount( $selected_items[ $item['id'] ] ); |
|
967 | + $minimum_price = wpinv_sanitize_amount($item['minimum_price']); |
|
968 | + $set_price = wpinv_sanitize_amount($selected_items[$item['id']]); |
|
969 | 969 | |
970 | - if ( $set_price < $minimum_price ) { |
|
970 | + if ($set_price < $minimum_price) { |
|
971 | 971 | $set_price = $minimum_price; |
972 | 972 | } |
973 | 973 | |
974 | - $price = wpinv_sanitize_amount( $set_price ); |
|
974 | + $price = wpinv_sanitize_amount($set_price); |
|
975 | 975 | |
976 | 976 | } |
977 | 977 | |
978 | - $price = $quantity * floatval( $price ); |
|
978 | + $price = $quantity * floatval($price); |
|
979 | 979 | |
980 | - if ( wpinv_use_taxes() ) { |
|
980 | + if (wpinv_use_taxes()) { |
|
981 | 981 | |
982 | - $rate = wpinv_get_tax_rate( $country, false, (int) $item['id'] ); |
|
982 | + $rate = wpinv_get_tax_rate($country, false, (int) $item['id']); |
|
983 | 983 | |
984 | - if ( wpinv_prices_include_tax() ) { |
|
985 | - $pre_tax = ( $price - $price * $rate * 0.01 ); |
|
984 | + if (wpinv_prices_include_tax()) { |
|
985 | + $pre_tax = ($price - $price * $rate * 0.01); |
|
986 | 986 | $item_tax = $price - $pre_tax; |
987 | 987 | } else { |
988 | 988 | $pre_tax = $price; |
@@ -994,17 +994,17 @@ discard block |
||
994 | 994 | $total = $sub_total + $tax; |
995 | 995 | |
996 | 996 | } else { |
997 | - $total = $total + $price; |
|
997 | + $total = $total + $price; |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - wp_send_json_success( array( |
|
1005 | - 'total' => wpinv_price( wpinv_format_amount( $total ) ), |
|
1006 | - 'tax' => wpinv_price( wpinv_format_amount( $tax ) ), |
|
1007 | - 'sub_total' => wpinv_price( wpinv_format_amount( $sub_total ) ), |
|
1004 | + wp_send_json_success(array( |
|
1005 | + 'total' => wpinv_price(wpinv_format_amount($total)), |
|
1006 | + 'tax' => wpinv_price(wpinv_format_amount($tax)), |
|
1007 | + 'sub_total' => wpinv_price(wpinv_format_amount($sub_total)), |
|
1008 | 1008 | )); |
1009 | 1009 | exit; |
1010 | 1010 | } |
@@ -1017,53 +1017,53 @@ discard block |
||
1017 | 1017 | public static function buy_items() { |
1018 | 1018 | $user_id = get_current_user_id(); |
1019 | 1019 | |
1020 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
1021 | - wp_send_json( array( |
|
1022 | - 'success' => wp_login_url( wp_get_referer() ) |
|
1023 | - ) ); |
|
1020 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
1021 | + wp_send_json(array( |
|
1022 | + 'success' => wp_login_url(wp_get_referer()) |
|
1023 | + )); |
|
1024 | 1024 | } else { |
1025 | 1025 | // Only check nonce if logged in as it could be cached when logged out. |
1026 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
1027 | - wp_send_json( array( |
|
1028 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
1029 | - ) ); |
|
1026 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
1027 | + wp_send_json(array( |
|
1028 | + 'error' => __('Security checks failed.', 'invoicing') |
|
1029 | + )); |
|
1030 | 1030 | wp_die(); |
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | // allow to set a custom price through post_id |
1034 | 1034 | $items = $_POST['items']; |
1035 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
1036 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
1035 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
1036 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
1037 | 1037 | |
1038 | 1038 | $cart_items = array(); |
1039 | - if ( $items ) { |
|
1040 | - $items = explode( ',', $items ); |
|
1039 | + if ($items) { |
|
1040 | + $items = explode(',', $items); |
|
1041 | 1041 | |
1042 | - foreach( $items as $item ) { |
|
1042 | + foreach ($items as $item) { |
|
1043 | 1043 | $item_id = $item; |
1044 | 1044 | $quantity = 1; |
1045 | 1045 | |
1046 | - if ( strpos( $item, '|' ) !== false ) { |
|
1047 | - $item_parts = explode( '|', $item ); |
|
1046 | + if (strpos($item, '|') !== false) { |
|
1047 | + $item_parts = explode('|', $item); |
|
1048 | 1048 | $item_id = $item_parts[0]; |
1049 | 1049 | $quantity = $item_parts[1]; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | - if ( $item_id && $quantity ) { |
|
1052 | + if ($item_id && $quantity) { |
|
1053 | 1053 | $cart_items_arr = array( |
1054 | - 'id' => (int)$item_id, |
|
1055 | - 'quantity' => (int)$quantity |
|
1054 | + 'id' => (int) $item_id, |
|
1055 | + 'quantity' => (int) $quantity |
|
1056 | 1056 | ); |
1057 | 1057 | |
1058 | 1058 | // If there is a related post id then add it to meta |
1059 | - if ( $related_post_id ) { |
|
1059 | + if ($related_post_id) { |
|
1060 | 1060 | $cart_items_arr['meta'] = array( |
1061 | 1061 | 'post_id' => $related_post_id |
1062 | 1062 | ); |
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | // If there is a custom price then set it. |
1066 | - if ( $custom_item_price ) { |
|
1066 | + if ($custom_item_price) { |
|
1067 | 1067 | $cart_items_arr['custom_price'] = $custom_item_price; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1079,37 +1079,37 @@ discard block |
||
1079 | 1079 | * @param int $related_post_id The related post id if any. |
1080 | 1080 | * @since 1.0.0 |
1081 | 1081 | */ |
1082 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
1082 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
1083 | 1083 | |
1084 | 1084 | // Make sure its not in the cart already, if it is then redirect to checkout. |
1085 | 1085 | $cart_invoice = wpinv_get_invoice_cart(); |
1086 | 1086 | |
1087 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
1088 | - wp_send_json( array( |
|
1087 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
1088 | + wp_send_json(array( |
|
1089 | 1089 | 'success' => $cart_invoice->get_checkout_payment_url() |
1090 | - ) ); |
|
1090 | + )); |
|
1091 | 1091 | wp_die(); |
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | // Check if user has invoice with same items waiting to be paid. |
1095 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
1096 | - if ( !empty( $user_invoices ) ) { |
|
1097 | - foreach( $user_invoices as $user_invoice ) { |
|
1095 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
1096 | + if (!empty($user_invoices)) { |
|
1097 | + foreach ($user_invoices as $user_invoice) { |
|
1098 | 1098 | $user_cart_details = array(); |
1099 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
1099 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
1100 | 1100 | $cart_details = $invoice->get_cart_details(); |
1101 | 1101 | |
1102 | - if ( !empty( $cart_details ) ) { |
|
1103 | - foreach ( $cart_details as $invoice_item ) { |
|
1102 | + if (!empty($cart_details)) { |
|
1103 | + foreach ($cart_details as $invoice_item) { |
|
1104 | 1104 | $ii_arr = array(); |
1105 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
1106 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
1105 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
1106 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
1107 | 1107 | |
1108 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
1108 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
1109 | 1109 | $ii_arr['meta'] = $invoice_item['meta']; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
1112 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
1113 | 1113 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1117,17 +1117,17 @@ discard block |
||
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
1121 | - wp_send_json( array( |
|
1120 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
1121 | + wp_send_json(array( |
|
1122 | 1122 | 'success' => $invoice->get_checkout_payment_url() |
1123 | - ) ); |
|
1123 | + )); |
|
1124 | 1124 | wp_die(); |
1125 | 1125 | } |
1126 | 1126 | } |
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | // Create invoice and send user to checkout |
1130 | - if ( !empty( $cart_items ) ) { |
|
1130 | + if (!empty($cart_items)) { |
|
1131 | 1131 | $invoice_data = array( |
1132 | 1132 | 'status' => 'wpi-pending', |
1133 | 1133 | 'created_via' => 'wpi', |
@@ -1135,21 +1135,21 @@ discard block |
||
1135 | 1135 | 'cart_details' => $cart_items, |
1136 | 1136 | ); |
1137 | 1137 | |
1138 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
1138 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
1139 | 1139 | |
1140 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
1141 | - wp_send_json( array( |
|
1140 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
1141 | + wp_send_json(array( |
|
1142 | 1142 | 'success' => $invoice->get_checkout_payment_url() |
1143 | - ) ); |
|
1143 | + )); |
|
1144 | 1144 | } else { |
1145 | - wp_send_json( array( |
|
1146 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
1147 | - ) ); |
|
1145 | + wp_send_json(array( |
|
1146 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
1147 | + )); |
|
1148 | 1148 | } |
1149 | 1149 | } else { |
1150 | - wp_send_json( array( |
|
1151 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
1152 | - ) ); |
|
1150 | + wp_send_json(array( |
|
1151 | + 'error' => __('Items not valid.', 'invoicing') |
|
1152 | + )); |
|
1153 | 1153 | } |
1154 | 1154 | } |
1155 | 1155 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct() { |
15 | 15 | |
16 | - foreach( $this->get_elements() as $element ) { |
|
16 | + foreach ($this->get_elements() as $element) { |
|
17 | 17 | $element = $element['type']; |
18 | 18 | |
19 | - if ( method_exists( $this, "render_{$element}_template" ) ) { |
|
20 | - add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 ); |
|
19 | + if (method_exists($this, "render_{$element}_template")) { |
|
20 | + add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2); |
|
21 | 21 | } |
22 | 22 | |
23 | - if ( method_exists( $this, "edit_{$element}_template" ) ) { |
|
24 | - add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 ); |
|
23 | + if (method_exists($this, "edit_{$element}_template")) { |
|
24 | + add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( method_exists( $this, "frontend_render_{$element}_template" ) ) { |
|
28 | - add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 ); |
|
27 | + if (method_exists($this, "frontend_render_{$element}_template")) { |
|
28 | + add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function get_elements() { |
39 | 39 | |
40 | - if ( ! empty( $this->elements ) ) { |
|
40 | + if (!empty($this->elements)) { |
|
41 | 41 | return $this->elements; |
42 | 42 | } |
43 | 43 | |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | |
46 | 46 | array( |
47 | 47 | 'type' => 'heading', |
48 | - 'name' => __( 'Heading', 'invoicing' ), |
|
48 | + 'name' => __('Heading', 'invoicing'), |
|
49 | 49 | 'defaults' => array( |
50 | 50 | 'level' => 'h2', |
51 | - 'text' => __( 'Heading', 'invoicing' ), |
|
51 | + 'text' => __('Heading', 'invoicing'), |
|
52 | 52 | ) |
53 | 53 | ), |
54 | 54 | |
55 | 55 | array( |
56 | 56 | 'type' => 'paragraph', |
57 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
57 | + 'name' => __('Paragraph', 'invoicing'), |
|
58 | 58 | 'defaults' => array( |
59 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
59 | + 'text' => __('Paragraph text', 'invoicing'), |
|
60 | 60 | ) |
61 | 61 | ), |
62 | 62 | |
63 | 63 | array( |
64 | 64 | 'type' => 'alert', |
65 | - 'name' => __( 'Alert', 'invoicing' ), |
|
65 | + 'name' => __('Alert', 'invoicing'), |
|
66 | 66 | 'defaults' => array( |
67 | 67 | 'value' => '', |
68 | 68 | 'class' => 'alert-warning', |
69 | - 'text' => __( 'Alert', 'invoicing' ), |
|
69 | + 'text' => __('Alert', 'invoicing'), |
|
70 | 70 | 'dismissible' => false, |
71 | 71 | ) |
72 | 72 | ), |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | |
83 | 83 | array( |
84 | 84 | 'type' => 'text', |
85 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
85 | + 'name' => __('Text Input', 'invoicing'), |
|
86 | 86 | 'defaults' => array( |
87 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
87 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
88 | 88 | 'value' => '', |
89 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
89 | + 'label' => __('Field Label', 'invoicing'), |
|
90 | 90 | 'description' => '', |
91 | 91 | 'required' => false, |
92 | 92 | ) |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | |
95 | 95 | array( |
96 | 96 | 'type' => 'textarea', |
97 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
97 | + 'name' => __('Textarea', 'invoicing'), |
|
98 | 98 | 'defaults' => array( |
99 | - 'placeholder' => __( 'Enter your text hear', 'invoicing' ), |
|
99 | + 'placeholder' => __('Enter your text hear', 'invoicing'), |
|
100 | 100 | 'value' => '', |
101 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
101 | + 'label' => __('Textarea Label', 'invoicing'), |
|
102 | 102 | 'description' => '', |
103 | 103 | 'required' => false, |
104 | 104 | ) |
@@ -106,27 +106,27 @@ discard block |
||
106 | 106 | |
107 | 107 | array( |
108 | 108 | 'type' => 'select', |
109 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
109 | + 'name' => __('Dropdown', 'invoicing'), |
|
110 | 110 | 'defaults' => array( |
111 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
111 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
112 | 112 | 'value' => '', |
113 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
113 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
114 | 114 | 'description' => '', |
115 | 115 | 'required' => false, |
116 | 116 | 'options' => array( |
117 | - esc_attr__( 'Option One', 'invoicing' ), |
|
118 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
119 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
117 | + esc_attr__('Option One', 'invoicing'), |
|
118 | + esc_attr__('Option Two', 'invoicing'), |
|
119 | + esc_attr__('Option Three', 'invoicing') |
|
120 | 120 | ), |
121 | 121 | ) |
122 | 122 | ), |
123 | 123 | |
124 | 124 | array( |
125 | 125 | 'type' => 'checkbox', |
126 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
126 | + 'name' => __('Checkbox', 'invoicing'), |
|
127 | 127 | 'defaults' => array( |
128 | 128 | 'value' => '', |
129 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
129 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
130 | 130 | 'description' => '', |
131 | 131 | 'required' => false, |
132 | 132 | ) |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | |
135 | 135 | array( |
136 | 136 | 'type' => 'radio', |
137 | - 'name' => __( 'Multiple Choice', 'invoicing' ), |
|
137 | + 'name' => __('Multiple Choice', 'invoicing'), |
|
138 | 138 | 'defaults' => array( |
139 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
139 | + 'label' => __('Select one choice', 'invoicing'), |
|
140 | 140 | 'options' => array( |
141 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
142 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
143 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
141 | + esc_attr__('Choice One', 'invoicing'), |
|
142 | + esc_attr__('Choice Two', 'invoicing'), |
|
143 | + esc_attr__('Choice Three', 'invoicing') |
|
144 | 144 | ), |
145 | 145 | ) |
146 | 146 | ), |
147 | 147 | |
148 | 148 | array( |
149 | 149 | 'type' => 'date', |
150 | - 'name' => __( 'Date', 'invoicing' ), |
|
150 | + 'name' => __('Date', 'invoicing'), |
|
151 | 151 | 'defaults' => array( |
152 | 152 | 'placeholder' => '', |
153 | 153 | 'value' => '', |
154 | - 'label' => __( 'Date', 'invoicing' ), |
|
154 | + 'label' => __('Date', 'invoicing'), |
|
155 | 155 | 'description' => '', |
156 | 156 | 'required' => false, |
157 | 157 | ) |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | |
160 | 160 | array( |
161 | 161 | 'type' => 'time', |
162 | - 'name' => __( 'Time', 'invoicing' ), |
|
162 | + 'name' => __('Time', 'invoicing'), |
|
163 | 163 | 'defaults' => array( |
164 | 164 | 'placeholder' => '', |
165 | 165 | 'value' => '', |
166 | - 'label' => __( 'Time', 'invoicing' ), |
|
166 | + 'label' => __('Time', 'invoicing'), |
|
167 | 167 | 'description' => '', |
168 | 168 | 'required' => false, |
169 | 169 | ) |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | |
172 | 172 | array( |
173 | 173 | 'type' => 'number', |
174 | - 'name' => __( 'Number', 'invoicing' ), |
|
174 | + 'name' => __('Number', 'invoicing'), |
|
175 | 175 | 'defaults' => array( |
176 | 176 | 'placeholder' => '', |
177 | 177 | 'value' => '', |
178 | - 'label' => __( 'Number', 'invoicing' ), |
|
178 | + 'label' => __('Number', 'invoicing'), |
|
179 | 179 | 'description' => '', |
180 | 180 | 'required' => false, |
181 | 181 | ) |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | |
184 | 184 | array( |
185 | 185 | 'type' => 'website', |
186 | - 'name' => __( 'Website', 'invoicing' ), |
|
186 | + 'name' => __('Website', 'invoicing'), |
|
187 | 187 | 'defaults' => array( |
188 | 188 | 'placeholder' => 'http://example.com', |
189 | 189 | 'value' => '', |
190 | - 'label' => __( 'Website', 'invoicing' ), |
|
190 | + 'label' => __('Website', 'invoicing'), |
|
191 | 191 | 'description' => '', |
192 | 192 | 'required' => false, |
193 | 193 | ) |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | |
196 | 196 | array( |
197 | 197 | 'type' => 'email', |
198 | - 'name' => __( 'Email', 'invoicing' ), |
|
198 | + 'name' => __('Email', 'invoicing'), |
|
199 | 199 | 'defaults' => array( |
200 | 200 | 'placeholder' => '[email protected]', |
201 | 201 | 'value' => '', |
202 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
202 | + 'label' => __('Email Address', 'invoicing'), |
|
203 | 203 | 'description' => '', |
204 | 204 | 'required' => false, |
205 | 205 | ) |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | |
208 | 208 | array( |
209 | 209 | 'type' => 'address', |
210 | - 'name' => __( 'Address', 'invoicing' ), |
|
210 | + 'name' => __('Address', 'invoicing'), |
|
211 | 211 | 'defaults' => array( |
212 | 212 | |
213 | 213 | 'fields' => array( |
214 | 214 | array( |
215 | 215 | 'placeholder' => 'Jon', |
216 | 216 | 'value' => '', |
217 | - 'label' => __( 'First Name', 'invoicing' ), |
|
217 | + 'label' => __('First Name', 'invoicing'), |
|
218 | 218 | 'description' => '', |
219 | 219 | 'required' => false, |
220 | 220 | 'visible' => true, |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | array( |
225 | 225 | 'placeholder' => 'Snow', |
226 | 226 | 'value' => '', |
227 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
227 | + 'label' => __('Last Name', 'invoicing'), |
|
228 | 228 | 'description' => '', |
229 | 229 | 'required' => false, |
230 | 230 | 'visible' => true, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | array( |
235 | 235 | 'placeholder' => '', |
236 | 236 | 'value' => '', |
237 | - 'label' => __( 'Address', 'invoicing' ), |
|
237 | + 'label' => __('Address', 'invoicing'), |
|
238 | 238 | 'description' => '', |
239 | 239 | 'required' => false, |
240 | 240 | 'visible' => true, |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | array( |
245 | 245 | 'placeholder' => '', |
246 | 246 | 'value' => '', |
247 | - 'label' => __( 'City', 'invoicing' ), |
|
247 | + 'label' => __('City', 'invoicing'), |
|
248 | 248 | 'description' => '', |
249 | 249 | 'required' => false, |
250 | 250 | 'visible' => true, |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | ), |
253 | 253 | |
254 | 254 | array( |
255 | - 'placeholder' => __( 'Select your country' ), |
|
255 | + 'placeholder' => __('Select your country'), |
|
256 | 256 | 'value' => '', |
257 | - 'label' => __( 'Country', 'invoicing' ), |
|
257 | + 'label' => __('Country', 'invoicing'), |
|
258 | 258 | 'description' => '', |
259 | 259 | 'required' => false, |
260 | 260 | 'visible' => true, |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | ), |
263 | 263 | |
264 | 264 | array( |
265 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
265 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
266 | 266 | 'value' => '', |
267 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
267 | + 'label' => __('State / Province', 'invoicing'), |
|
268 | 268 | 'description' => '', |
269 | 269 | 'required' => false, |
270 | 270 | 'visible' => true, |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | array( |
275 | 275 | 'placeholder' => '', |
276 | 276 | 'value' => '', |
277 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
277 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
278 | 278 | 'description' => '', |
279 | 279 | 'required' => false, |
280 | 280 | 'visible' => true, |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | array( |
285 | 285 | 'placeholder' => '', |
286 | 286 | 'value' => '', |
287 | - 'label' => __( 'Phone', 'invoicing' ), |
|
287 | + 'label' => __('Phone', 'invoicing'), |
|
288 | 288 | 'description' => '', |
289 | 289 | 'required' => false, |
290 | 290 | 'visible' => true, |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | |
297 | 297 | array( |
298 | 298 | 'type' => 'billing_email', |
299 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
299 | + 'name' => __('Billing Email', 'invoicing'), |
|
300 | 300 | 'defaults' => array( |
301 | 301 | 'placeholder' => '[email protected]', |
302 | 302 | 'value' => '', |
303 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
303 | + 'label' => __('Billing Email', 'invoicing'), |
|
304 | 304 | 'description' => '', |
305 | 305 | 'premade' => true, |
306 | 306 | ) |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | array( |
321 | 321 | 'type' => 'items', |
322 | - 'name' => __( 'Items', 'invoicing' ), |
|
322 | + 'name' => __('Items', 'invoicing'), |
|
323 | 323 | 'defaults' => array( |
324 | 324 | 'value' => '', |
325 | 325 | 'items_type' => 'total', |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | |
331 | 331 | array( |
332 | 332 | 'type' => 'pay_button', |
333 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
333 | + 'name' => __('Payment Button', 'invoicing'), |
|
334 | 334 | 'defaults' => array( |
335 | 335 | 'value' => '', |
336 | 336 | 'class' => 'btn-primary', |
337 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
338 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
337 | + 'label' => __('Pay Now »', 'invoicing'), |
|
338 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
339 | 339 | 'premade' => true, |
340 | 340 | ) |
341 | 341 | ) |
342 | 342 | ); |
343 | 343 | |
344 | - $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
|
344 | + $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements); |
|
345 | 345 | return $this->elements; |
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Returns the restrict markup. |
350 | 350 | */ |
351 | - public function get_restrict_markup( $field, $field_type ) { |
|
351 | + public function get_restrict_markup($field, $field_type) { |
|
352 | 352 | $restrict = "$field.type=='$field_type'"; |
353 | 353 | return "v-if=\"$restrict\""; |
354 | 354 | } |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | /** |
357 | 357 | * Renders the title element template. |
358 | 358 | */ |
359 | - public function render_heading_template( $field ) { |
|
360 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
359 | + public function render_heading_template($field) { |
|
360 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
361 | 361 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Renders the title element on the frontend. |
366 | 366 | */ |
367 | - public function frontend_render_heading_template( $field ) { |
|
367 | + public function frontend_render_heading_template($field) { |
|
368 | 368 | $tag = $field['level']; |
369 | 369 | echo "<$tag>{$field['text']}</$tag>"; |
370 | 370 | } |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * Renders the edit title element template. |
374 | 374 | */ |
375 | - public function edit_heading_template( $field ) { |
|
376 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
377 | - $label = __( 'Heading', 'invoicing' ); |
|
378 | - $label2 = __( 'Select Heading Level', 'invoicing' ); |
|
375 | + public function edit_heading_template($field) { |
|
376 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
377 | + $label = __('Heading', 'invoicing'); |
|
378 | + $label2 = __('Select Heading Level', 'invoicing'); |
|
379 | 379 | $id = $field . '.id + "_edit"'; |
380 | 380 | $id2 = $field . '.id + "_edit2"'; |
381 | 381 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | /** |
408 | 408 | * Renders a paragraph element template. |
409 | 409 | */ |
410 | - public function render_paragraph_template( $field ) { |
|
411 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
410 | + public function render_paragraph_template($field) { |
|
411 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
412 | 412 | $label = "$field.text"; |
413 | 413 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
414 | 414 | } |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * Renders the paragraph element on the frontend. |
418 | 418 | */ |
419 | - public function frontend_render_paragraph_template( $field ) { |
|
419 | + public function frontend_render_paragraph_template($field) { |
|
420 | 420 | echo "<p>{$field['text']}</p>"; |
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Renders the edit paragraph element template. |
425 | 425 | */ |
426 | - public function edit_paragraph_template( $field ) { |
|
427 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
428 | - $label = __( 'Enter your text', 'invoicing' ); |
|
426 | + public function edit_paragraph_template($field) { |
|
427 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
428 | + $label = __('Enter your text', 'invoicing'); |
|
429 | 429 | $id = $field . '.id + "_edit"'; |
430 | 430 | echo " |
431 | 431 | <div $restrict> |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | /** |
442 | 442 | * Renders the text element template. |
443 | 443 | */ |
444 | - public function render_text_template( $field ) { |
|
445 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
444 | + public function render_text_template($field) { |
|
445 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
446 | 446 | $label = "$field.label"; |
447 | 447 | echo " |
448 | 448 | <div $restrict> |
@@ -456,23 +456,23 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * Renders the text element on the frontend. |
458 | 458 | */ |
459 | - public function frontend_render_text_template( $field ) { |
|
459 | + public function frontend_render_text_template($field) { |
|
460 | 460 | |
461 | 461 | echo "<div class='form-group'>"; |
462 | 462 | |
463 | 463 | echo aui()->input( |
464 | 464 | array( |
465 | - 'name' => esc_attr( $field['id'] ), |
|
466 | - 'id' => esc_attr( $field['id'] ), |
|
467 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
465 | + 'name' => esc_attr($field['id']), |
|
466 | + 'id' => esc_attr($field['id']), |
|
467 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
468 | 468 | 'required' => (bool) $field['required'], |
469 | - 'label' => wp_kses_post( $field['label'] ), |
|
469 | + 'label' => wp_kses_post($field['label']), |
|
470 | 470 | 'no_wrap' => true, |
471 | 471 | ) |
472 | 472 | ); |
473 | 473 | |
474 | - if ( ! empty( $field['description'] ) ) { |
|
475 | - $description = wp_kses_post( $field['description'] ); |
|
474 | + if (!empty($field['description'])) { |
|
475 | + $description = wp_kses_post($field['description']); |
|
476 | 476 | echo "<small class='form-text text-muted'>$description</small>"; |
477 | 477 | } |
478 | 478 | |
@@ -483,16 +483,16 @@ discard block |
||
483 | 483 | /** |
484 | 484 | * Renders the edit text element template. |
485 | 485 | */ |
486 | - public function edit_text_template( $field ) { |
|
487 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
488 | - $label = __( 'Field Label', 'invoicing' ); |
|
486 | + public function edit_text_template($field) { |
|
487 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
488 | + $label = __('Field Label', 'invoicing'); |
|
489 | 489 | $id = $field . '.id + "_edit"'; |
490 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
490 | + $label2 = __('Placeholder text', 'invoicing'); |
|
491 | 491 | $id2 = $field . '.id + "_edit2"'; |
492 | - $label3 = __( 'Help text', 'invoicing' ); |
|
493 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
492 | + $label3 = __('Help text', 'invoicing'); |
|
493 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
494 | 494 | $id3 = $field . '.id + "_edit3"'; |
495 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
495 | + $label5 = __('Is this field required?', 'invoicing'); |
|
496 | 496 | $id4 = $field . '.id + "_edit4"'; |
497 | 497 | echo " |
498 | 498 | <div $restrict> |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * Renders the textarea element template. |
522 | 522 | */ |
523 | - public function render_textarea_template( $field ) { |
|
524 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
523 | + public function render_textarea_template($field) { |
|
524 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
525 | 525 | $label = "$field.label"; |
526 | 526 | echo " |
527 | 527 | <div $restrict> |
@@ -535,24 +535,24 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * Renders the textarea element on the frontend. |
537 | 537 | */ |
538 | - public function frontend_render_textarea_template( $field ) { |
|
538 | + public function frontend_render_textarea_template($field) { |
|
539 | 539 | |
540 | 540 | echo "<div class='form-group'>"; |
541 | 541 | |
542 | 542 | echo aui()->textarea( |
543 | 543 | array( |
544 | - 'name' => esc_attr( $field['id'] ), |
|
545 | - 'id' => esc_attr( $field['id'] ), |
|
546 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
544 | + 'name' => esc_attr($field['id']), |
|
545 | + 'id' => esc_attr($field['id']), |
|
546 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
547 | 547 | 'required' => (bool) $field['required'], |
548 | - 'label' => wp_kses_post( $field['label'] ), |
|
548 | + 'label' => wp_kses_post($field['label']), |
|
549 | 549 | 'no_wrap' => true, |
550 | 550 | 'rows' => 3, |
551 | 551 | ) |
552 | 552 | ); |
553 | 553 | |
554 | - if ( ! empty( $field['description'] ) ) { |
|
555 | - $description = wp_kses_post( $field['description'] ); |
|
554 | + if (!empty($field['description'])) { |
|
555 | + $description = wp_kses_post($field['description']); |
|
556 | 556 | echo "<small class='form-text text-muted'>$description</small>"; |
557 | 557 | } |
558 | 558 | |
@@ -563,16 +563,16 @@ discard block |
||
563 | 563 | /** |
564 | 564 | * Renders the edit textarea element template. |
565 | 565 | */ |
566 | - public function edit_textarea_template( $field ) { |
|
567 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
568 | - $label = __( 'Field Label', 'invoicing' ); |
|
566 | + public function edit_textarea_template($field) { |
|
567 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
568 | + $label = __('Field Label', 'invoicing'); |
|
569 | 569 | $id = $field . '.id + "_edit"'; |
570 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
570 | + $label2 = __('Placeholder text', 'invoicing'); |
|
571 | 571 | $id2 = $field . '.id + "_edit2"'; |
572 | - $label3 = __( 'Help text', 'invoicing' ); |
|
573 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
572 | + $label3 = __('Help text', 'invoicing'); |
|
573 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
574 | 574 | $id3 = $field . '.id + "_edit3"'; |
575 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
575 | + $label5 = __('Is this field required?', 'invoicing'); |
|
576 | 576 | $id4 = $field . '.id + "_edit4"'; |
577 | 577 | echo " |
578 | 578 | <div $restrict> |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Renders the select element template. |
602 | 602 | */ |
603 | - public function render_select_template( $field ) { |
|
604 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
603 | + public function render_select_template($field) { |
|
604 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
605 | 605 | $label = "$field.label"; |
606 | 606 | $placeholder = "$field.placeholder"; |
607 | 607 | $id = $field . '.id'; |
@@ -620,24 +620,24 @@ discard block |
||
620 | 620 | /** |
621 | 621 | * Renders the select element on the frontend. |
622 | 622 | */ |
623 | - public function frontend_render_select_template( $field ) { |
|
623 | + public function frontend_render_select_template($field) { |
|
624 | 624 | |
625 | 625 | echo "<div class='form-group'>"; |
626 | 626 | |
627 | 627 | echo aui()->select( |
628 | 628 | array( |
629 | - 'name' => esc_attr( $field['id'] ), |
|
630 | - 'id' => esc_attr( $field['id'] ), |
|
631 | - 'placeholder'=> esc_attr( $field['placeholder'] ), |
|
629 | + 'name' => esc_attr($field['id']), |
|
630 | + 'id' => esc_attr($field['id']), |
|
631 | + 'placeholder'=> esc_attr($field['placeholder']), |
|
632 | 632 | 'required' => (bool) $field['required'], |
633 | - 'label' => wp_kses_post( $field['label'] ), |
|
633 | + 'label' => wp_kses_post($field['label']), |
|
634 | 634 | 'no_wrap' => true, |
635 | - 'options' => array_combine( $field['options'], $field['options'] ), |
|
635 | + 'options' => array_combine($field['options'], $field['options']), |
|
636 | 636 | ) |
637 | 637 | ); |
638 | 638 | |
639 | - if ( ! empty( $field['description'] ) ) { |
|
640 | - $description = wp_kses_post( $field['description'] ); |
|
639 | + if (!empty($field['description'])) { |
|
640 | + $description = wp_kses_post($field['description']); |
|
641 | 641 | echo "<small class='form-text text-muted'>$description</small>"; |
642 | 642 | } |
643 | 643 | |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | /** |
649 | 649 | * Renders the edit select element template. |
650 | 650 | */ |
651 | - public function edit_select_template( $field ) { |
|
652 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
653 | - $label = __( 'Field Label', 'invoicing' ); |
|
651 | + public function edit_select_template($field) { |
|
652 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
653 | + $label = __('Field Label', 'invoicing'); |
|
654 | 654 | $id = $field . '.id + "_edit"'; |
655 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
655 | + $label2 = __('Placeholder text', 'invoicing'); |
|
656 | 656 | $id2 = $field . '.id + "_edit2"'; |
657 | - $label3 = __( 'Help text', 'invoicing' ); |
|
658 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
657 | + $label3 = __('Help text', 'invoicing'); |
|
658 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
659 | 659 | $id3 = $field . '.id + "_edit3"'; |
660 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
660 | + $label5 = __('Is this field required?', 'invoicing'); |
|
661 | 661 | $id4 = $field . '.id + "_edit4"'; |
662 | - $label6 = __( 'Available Options', 'invoicing' ); |
|
662 | + $label6 = __('Available Options', 'invoicing'); |
|
663 | 663 | echo " |
664 | 664 | <div $restrict> |
665 | 665 | <div class='form-group'> |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * Renders the checkbox element template. |
699 | 699 | */ |
700 | - public function render_checkbox_template( $field ) { |
|
701 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
700 | + public function render_checkbox_template($field) { |
|
701 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
702 | 702 | $label = "$field.label"; |
703 | 703 | echo " |
704 | 704 | <div class='form-check' $restrict> |
@@ -712,24 +712,24 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Renders the checkbox element on the frontend. |
714 | 714 | */ |
715 | - public function frontend_render_checkbox_template( $field ) { |
|
715 | + public function frontend_render_checkbox_template($field) { |
|
716 | 716 | |
717 | 717 | echo "<div class='form-group'>"; |
718 | 718 | |
719 | 719 | echo aui()->input( |
720 | 720 | array( |
721 | - 'name' => esc_attr( $field['id'] ), |
|
722 | - 'id' => esc_attr( $field['id'] ), |
|
721 | + 'name' => esc_attr($field['id']), |
|
722 | + 'id' => esc_attr($field['id']), |
|
723 | 723 | 'required' => (bool) $field['required'], |
724 | - 'label' => wp_kses_post( $field['label'] ), |
|
724 | + 'label' => wp_kses_post($field['label']), |
|
725 | 725 | 'no_wrap' => true, |
726 | - 'value' => esc_attr__( 'Yes', 'invoicing' ), |
|
726 | + 'value' => esc_attr__('Yes', 'invoicing'), |
|
727 | 727 | 'type' => 'checkbox', |
728 | 728 | ) |
729 | 729 | ); |
730 | 730 | |
731 | - if ( ! empty( $field['description'] ) ) { |
|
732 | - $description = wp_kses_post( $field['description'] ); |
|
731 | + if (!empty($field['description'])) { |
|
732 | + $description = wp_kses_post($field['description']); |
|
733 | 733 | echo "<small class='form-text text-muted'>$description</small>"; |
734 | 734 | } |
735 | 735 | |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | /** |
741 | 741 | * Renders the edit checkbox element template. |
742 | 742 | */ |
743 | - public function edit_checkbox_template( $field ) { |
|
744 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
745 | - $label = __( 'Field Label', 'invoicing' ); |
|
743 | + public function edit_checkbox_template($field) { |
|
744 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
745 | + $label = __('Field Label', 'invoicing'); |
|
746 | 746 | $id = $field . '.id + "_edit"'; |
747 | - $label2 = __( 'Help text', 'invoicing' ); |
|
748 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
747 | + $label2 = __('Help text', 'invoicing'); |
|
748 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
749 | 749 | $id2 = $field . '.id + "_edit2"'; |
750 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
750 | + $label4 = __('Is this field required?', 'invoicing'); |
|
751 | 751 | $id3 = $field . '.id + "_edit3"'; |
752 | 752 | echo " |
753 | 753 | <div $restrict> |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | /** |
772 | 772 | * Renders the radio element template. |
773 | 773 | */ |
774 | - public function render_radio_template( $field ) { |
|
775 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
774 | + public function render_radio_template($field) { |
|
775 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
776 | 776 | $label = "$field.label"; |
777 | 777 | $id = $field . '.id'; |
778 | 778 | echo " |
@@ -790,20 +790,20 @@ discard block |
||
790 | 790 | /** |
791 | 791 | * Renders the radio element on the frontend. |
792 | 792 | */ |
793 | - public function frontend_render_radio_template( $field ) { |
|
793 | + public function frontend_render_radio_template($field) { |
|
794 | 794 | |
795 | 795 | echo "<div class='form-group'>"; |
796 | 796 | |
797 | - if ( ! empty( $field['label'] ) ) { |
|
798 | - $label = wp_kses_post( $field['label'] ); |
|
797 | + if (!empty($field['label'])) { |
|
798 | + $label = wp_kses_post($field['label']); |
|
799 | 799 | echo "<legend class='col-form-label'>$label</legend>"; |
800 | 800 | } |
801 | 801 | |
802 | - foreach( $field['options'] as $index => $option ) { |
|
802 | + foreach ($field['options'] as $index => $option) { |
|
803 | 803 | $id = $field['id'] . $index; |
804 | 804 | $name = $field['id']; |
805 | - $value = esc_attr( $option ); |
|
806 | - $label = wp_kses_post( $option ); |
|
805 | + $value = esc_attr($option); |
|
806 | + $label = wp_kses_post($option); |
|
807 | 807 | |
808 | 808 | echo " |
809 | 809 | <div class='form-check'> |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | "; |
814 | 814 | } |
815 | 815 | |
816 | - if ( ! empty( $field['description'] ) ) { |
|
817 | - $description = wp_kses_post( $field['description'] ); |
|
816 | + if (!empty($field['description'])) { |
|
817 | + $description = wp_kses_post($field['description']); |
|
818 | 818 | echo "<small class='form-text text-muted'>$description</small>"; |
819 | 819 | } |
820 | 820 | |
@@ -825,16 +825,16 @@ discard block |
||
825 | 825 | /** |
826 | 826 | * Renders the edit radio element template. |
827 | 827 | */ |
828 | - public function edit_radio_template( $field ) { |
|
829 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
830 | - $label = __( 'Field Label', 'invoicing' ); |
|
828 | + public function edit_radio_template($field) { |
|
829 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
830 | + $label = __('Field Label', 'invoicing'); |
|
831 | 831 | $id = $field . '.id + "_edit"'; |
832 | - $label2 = __( 'Help text', 'invoicing' ); |
|
833 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
832 | + $label2 = __('Help text', 'invoicing'); |
|
833 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
834 | 834 | $id2 = $field . '.id + "_edit3"'; |
835 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
835 | + $label4 = __('Is this field required?', 'invoicing'); |
|
836 | 836 | $id3 = $field . '.id + "_edit4"'; |
837 | - $label5 = __( 'Available Options', 'invoicing' ); |
|
837 | + $label5 = __('Available Options', 'invoicing'); |
|
838 | 838 | echo " |
839 | 839 | <div $restrict> |
840 | 840 | <div class='form-group'> |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | /** |
869 | 869 | * Renders the address element template. |
870 | 870 | */ |
871 | - public function render_address_template( $field ) { |
|
872 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
871 | + public function render_address_template($field) { |
|
872 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
873 | 873 | |
874 | 874 | echo " |
875 | 875 | <div class='wpinv-address-wrapper' $restrict> |
@@ -890,36 +890,36 @@ discard block |
||
890 | 890 | /** |
891 | 891 | * Renders the address element on the frontend. |
892 | 892 | */ |
893 | - public function frontend_render_address_template( $field ) { |
|
893 | + public function frontend_render_address_template($field) { |
|
894 | 894 | |
895 | 895 | echo "<div class='wpinv-address-fields'>"; |
896 | 896 | |
897 | - foreach( $field['fields'] as $address_field ) { |
|
897 | + foreach ($field['fields'] as $address_field) { |
|
898 | 898 | |
899 | - if ( empty( $address_field['visible'] ) ) { |
|
899 | + if (empty($address_field['visible'])) { |
|
900 | 900 | continue; |
901 | 901 | } |
902 | 902 | |
903 | - $class = esc_attr( $address_field['name'] ); |
|
903 | + $class = esc_attr($address_field['name']); |
|
904 | 904 | echo "<div class='form-group $class'>"; |
905 | 905 | |
906 | 906 | $label = $address_field['label']; |
907 | 907 | |
908 | - if ( ! empty( $address_field['required'] ) ) { |
|
908 | + if (!empty($address_field['required'])) { |
|
909 | 909 | $label .= "<span class='text-danger'> *</span>"; |
910 | 910 | } |
911 | 911 | |
912 | - if ( 'wpinv_country' == $address_field['name'] ) { |
|
912 | + if ('wpinv_country' == $address_field['name']) { |
|
913 | 913 | |
914 | - echo aui()->select( array( |
|
914 | + echo aui()->select(array( |
|
915 | 915 | 'options' => wpinv_get_country_list(), |
916 | - 'name' => esc_attr( $address_field['name'] ), |
|
917 | - 'id' => esc_attr( $address_field['name'] ), |
|
916 | + 'name' => esc_attr($address_field['name']), |
|
917 | + 'id' => esc_attr($address_field['name']), |
|
918 | 918 | 'value' => wpinv_default_billing_country(), |
919 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
919 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
920 | 920 | 'required' => (bool) $address_field['required'], |
921 | 921 | 'no_wrap' => true, |
922 | - 'label' => wp_kses_post( $label ), |
|
922 | + 'label' => wp_kses_post($label), |
|
923 | 923 | 'select2' => false, |
924 | 924 | )); |
925 | 925 | |
@@ -927,12 +927,12 @@ discard block |
||
927 | 927 | |
928 | 928 | echo aui()->input( |
929 | 929 | array( |
930 | - 'name' => esc_attr( $address_field['name'] ), |
|
931 | - 'id' => esc_attr( $address_field['name'] ), |
|
930 | + 'name' => esc_attr($address_field['name']), |
|
931 | + 'id' => esc_attr($address_field['name']), |
|
932 | 932 | 'required' => (bool) $address_field['required'], |
933 | - 'label' => wp_kses_post( $label ), |
|
933 | + 'label' => wp_kses_post($label), |
|
934 | 934 | 'no_wrap' => true, |
935 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
935 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
936 | 936 | 'type' => 'text', |
937 | 937 | ) |
938 | 938 | ); |
@@ -940,8 +940,8 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | |
943 | - if ( ! empty( $address_field['description'] ) ) { |
|
944 | - $description = wp_kses_post( $address_field['description'] ); |
|
943 | + if (!empty($address_field['description'])) { |
|
944 | + $description = wp_kses_post($address_field['description']); |
|
945 | 945 | echo "<small class='form-text text-muted'>$description</small>"; |
946 | 946 | } |
947 | 947 | |
@@ -956,13 +956,13 @@ discard block |
||
956 | 956 | /** |
957 | 957 | * Renders the edit address element template. |
958 | 958 | */ |
959 | - public function edit_address_template( $field ) { |
|
960 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
961 | - $label = __( 'Field Label', 'invoicing' ); |
|
962 | - $label2 = __( 'Placeholder', 'invoicing' ); |
|
963 | - $label3 = __( 'Description', 'invoicing' ); |
|
964 | - $label4 = __( 'Is required', 'invoicing' ); |
|
965 | - $label5 = __( 'Is visible', 'invoicing' ); |
|
959 | + public function edit_address_template($field) { |
|
960 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
961 | + $label = __('Field Label', 'invoicing'); |
|
962 | + $label2 = __('Placeholder', 'invoicing'); |
|
963 | + $label3 = __('Description', 'invoicing'); |
|
964 | + $label4 = __('Is required', 'invoicing'); |
|
965 | + $label5 = __('Is visible', 'invoicing'); |
|
966 | 966 | $id = $field . '.id + "_edit_label"'; |
967 | 967 | $id2 = $field . '.id + "_edit_placeholder"'; |
968 | 968 | $id3 = $field . '.id + "_edit_description"'; |
@@ -1030,8 +1030,8 @@ discard block |
||
1030 | 1030 | /** |
1031 | 1031 | * Renders the email element template. |
1032 | 1032 | */ |
1033 | - public function render_email_template( $field ) { |
|
1034 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
1033 | + public function render_email_template($field) { |
|
1034 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
1035 | 1035 | $label = "$field.label"; |
1036 | 1036 | echo " |
1037 | 1037 | <div $restrict> |
@@ -1045,8 +1045,8 @@ discard block |
||
1045 | 1045 | /** |
1046 | 1046 | * Renders the billing_email element template. |
1047 | 1047 | */ |
1048 | - public function render_billing_email_template( $field ) { |
|
1049 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
1048 | + public function render_billing_email_template($field) { |
|
1049 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
1050 | 1050 | $label = "$field.label"; |
1051 | 1051 | echo " |
1052 | 1052 | <div $restrict> |
@@ -1060,24 +1060,24 @@ discard block |
||
1060 | 1060 | /** |
1061 | 1061 | * Renders the email element on the frontend. |
1062 | 1062 | */ |
1063 | - public function frontend_render_email_template( $field ) { |
|
1063 | + public function frontend_render_email_template($field) { |
|
1064 | 1064 | |
1065 | 1065 | echo "<div class='form-group'>"; |
1066 | 1066 | |
1067 | 1067 | echo aui()->input( |
1068 | 1068 | array( |
1069 | - 'name' => esc_attr( $field['id'] ), |
|
1070 | - 'id' => esc_attr( $field['id'] ), |
|
1069 | + 'name' => esc_attr($field['id']), |
|
1070 | + 'id' => esc_attr($field['id']), |
|
1071 | 1071 | 'required' => (bool) $field['required'], |
1072 | - 'label' => wp_kses_post( $field['label'] ), |
|
1072 | + 'label' => wp_kses_post($field['label']), |
|
1073 | 1073 | 'no_wrap' => true, |
1074 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1074 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1075 | 1075 | 'type' => 'email', |
1076 | 1076 | ) |
1077 | 1077 | ); |
1078 | 1078 | |
1079 | - if ( ! empty( $field['description'] ) ) { |
|
1080 | - $description = wp_kses_post( $field['description'] ); |
|
1079 | + if (!empty($field['description'])) { |
|
1080 | + $description = wp_kses_post($field['description']); |
|
1081 | 1081 | echo "<small class='form-text text-muted'>$description</small>"; |
1082 | 1082 | } |
1083 | 1083 | |
@@ -1088,30 +1088,30 @@ discard block |
||
1088 | 1088 | /** |
1089 | 1089 | * Renders the billing email element on the frontend. |
1090 | 1090 | */ |
1091 | - public function frontend_render_billing_email_template( $field ) { |
|
1091 | + public function frontend_render_billing_email_template($field) { |
|
1092 | 1092 | |
1093 | 1093 | echo "<div class='form-group'>"; |
1094 | 1094 | $value = ''; |
1095 | 1095 | |
1096 | - if ( is_user_logged_in() ) { |
|
1096 | + if (is_user_logged_in()) { |
|
1097 | 1097 | $user = wp_get_current_user(); |
1098 | - $value = sanitize_email( $user->user_email ); |
|
1098 | + $value = sanitize_email($user->user_email); |
|
1099 | 1099 | } |
1100 | 1100 | echo aui()->input( |
1101 | 1101 | array( |
1102 | 1102 | 'name' => 'billing_email', |
1103 | 1103 | 'value' => $value, |
1104 | - 'id' => esc_attr( $field['id'] ), |
|
1104 | + 'id' => esc_attr($field['id']), |
|
1105 | 1105 | 'required' => true, |
1106 | - 'label' => wp_kses_post( $field['label'] ), |
|
1106 | + 'label' => wp_kses_post($field['label']), |
|
1107 | 1107 | 'no_wrap' => true, |
1108 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1108 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1109 | 1109 | 'type' => 'email', |
1110 | 1110 | ) |
1111 | 1111 | ); |
1112 | 1112 | |
1113 | - if ( ! empty( $field['description'] ) ) { |
|
1114 | - $description = wp_kses_post( $field['description'] ); |
|
1113 | + if (!empty($field['description'])) { |
|
1114 | + $description = wp_kses_post($field['description']); |
|
1115 | 1115 | echo "<small class='form-text text-muted'>$description</small>"; |
1116 | 1116 | } |
1117 | 1117 | |
@@ -1122,16 +1122,16 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * Renders the edit email element template. |
1124 | 1124 | */ |
1125 | - public function edit_email_template( $field ) { |
|
1126 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
1127 | - $label = __( 'Field Label', 'invoicing' ); |
|
1125 | + public function edit_email_template($field) { |
|
1126 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
1127 | + $label = __('Field Label', 'invoicing'); |
|
1128 | 1128 | $id = $field . '.id + "_edit"'; |
1129 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1129 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1130 | 1130 | $id2 = $field . '.id + "_edit2"'; |
1131 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1132 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1131 | + $label3 = __('Help text', 'invoicing'); |
|
1132 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1133 | 1133 | $id3 = $field . '.id + "_edit3"'; |
1134 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1134 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1135 | 1135 | $id4 = $field . '.id + "_edit4"'; |
1136 | 1136 | echo " |
1137 | 1137 | <div $restrict> |
@@ -1159,16 +1159,16 @@ discard block |
||
1159 | 1159 | /** |
1160 | 1160 | * Renders the edit billing_email element template. |
1161 | 1161 | */ |
1162 | - public function edit_billing_email_template( $field ) { |
|
1163 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
1164 | - $label = __( 'Field Label', 'invoicing' ); |
|
1162 | + public function edit_billing_email_template($field) { |
|
1163 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
1164 | + $label = __('Field Label', 'invoicing'); |
|
1165 | 1165 | $id = $field . '.id + "_edit"'; |
1166 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1166 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1167 | 1167 | $id2 = $field . '.id + "_edit2"'; |
1168 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1169 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1168 | + $label3 = __('Help text', 'invoicing'); |
|
1169 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1170 | 1170 | $id3 = $field . '.id + "_edit3"'; |
1171 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1171 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1172 | 1172 | $id4 = $field . '.id + "_edit4"'; |
1173 | 1173 | echo " |
1174 | 1174 | <div $restrict> |
@@ -1192,8 +1192,8 @@ discard block |
||
1192 | 1192 | /** |
1193 | 1193 | * Renders the website element template. |
1194 | 1194 | */ |
1195 | - public function render_website_template( $field ) { |
|
1196 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
1195 | + public function render_website_template($field) { |
|
1196 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
1197 | 1197 | $label = "$field.label"; |
1198 | 1198 | echo " |
1199 | 1199 | <div $restrict> |
@@ -1207,24 +1207,24 @@ discard block |
||
1207 | 1207 | /** |
1208 | 1208 | * Renders the website element on the frontend. |
1209 | 1209 | */ |
1210 | - public function frontend_render_website_template( $field ) { |
|
1210 | + public function frontend_render_website_template($field) { |
|
1211 | 1211 | |
1212 | 1212 | echo "<div class='form-group'>"; |
1213 | 1213 | |
1214 | 1214 | echo aui()->input( |
1215 | 1215 | array( |
1216 | - 'name' => esc_attr( $field['id'] ), |
|
1217 | - 'id' => esc_attr( $field['id'] ), |
|
1216 | + 'name' => esc_attr($field['id']), |
|
1217 | + 'id' => esc_attr($field['id']), |
|
1218 | 1218 | 'required' => (bool) $field['required'], |
1219 | - 'label' => wp_kses_post( $field['label'] ), |
|
1219 | + 'label' => wp_kses_post($field['label']), |
|
1220 | 1220 | 'no_wrap' => true, |
1221 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1221 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1222 | 1222 | 'type' => 'url', |
1223 | 1223 | ) |
1224 | 1224 | ); |
1225 | 1225 | |
1226 | - if ( ! empty( $field['description'] ) ) { |
|
1227 | - $description = wp_kses_post( $field['description'] ); |
|
1226 | + if (!empty($field['description'])) { |
|
1227 | + $description = wp_kses_post($field['description']); |
|
1228 | 1228 | echo "<small class='form-text text-muted'>$description</small>"; |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1235,16 +1235,16 @@ discard block |
||
1235 | 1235 | /** |
1236 | 1236 | * Renders the edit website element template. |
1237 | 1237 | */ |
1238 | - public function edit_website_template( $field ) { |
|
1239 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
1240 | - $label = __( 'Field Label', 'invoicing' ); |
|
1238 | + public function edit_website_template($field) { |
|
1239 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
1240 | + $label = __('Field Label', 'invoicing'); |
|
1241 | 1241 | $id = $field . '.id + "_edit"'; |
1242 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1242 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1243 | 1243 | $id2 = $field . '.id + "_edit2"'; |
1244 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1245 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1244 | + $label3 = __('Help text', 'invoicing'); |
|
1245 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1246 | 1246 | $id3 = $field . '.id + "_edit3"'; |
1247 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1247 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1248 | 1248 | $id4 = $field . '.id + "_edit4"'; |
1249 | 1249 | echo " |
1250 | 1250 | <div $restrict> |
@@ -1272,8 +1272,8 @@ discard block |
||
1272 | 1272 | /** |
1273 | 1273 | * Renders the date element template. |
1274 | 1274 | */ |
1275 | - public function render_date_template( $field ) { |
|
1276 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
1275 | + public function render_date_template($field) { |
|
1276 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
1277 | 1277 | $label = "$field.label"; |
1278 | 1278 | echo " |
1279 | 1279 | <div $restrict> |
@@ -1287,24 +1287,24 @@ discard block |
||
1287 | 1287 | /** |
1288 | 1288 | * Renders the date element on the frontend. |
1289 | 1289 | */ |
1290 | - public function frontend_render_date_template( $field ) { |
|
1290 | + public function frontend_render_date_template($field) { |
|
1291 | 1291 | |
1292 | 1292 | echo "<div class='form-group'>"; |
1293 | 1293 | |
1294 | 1294 | echo aui()->input( |
1295 | 1295 | array( |
1296 | - 'name' => esc_attr( $field['id'] ), |
|
1297 | - 'id' => esc_attr( $field['id'] ), |
|
1296 | + 'name' => esc_attr($field['id']), |
|
1297 | + 'id' => esc_attr($field['id']), |
|
1298 | 1298 | 'required' => (bool) $field['required'], |
1299 | - 'label' => wp_kses_post( $field['label'] ), |
|
1300 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1299 | + 'label' => wp_kses_post($field['label']), |
|
1300 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1301 | 1301 | 'no_wrap' => true, |
1302 | 1302 | 'type' => 'date', |
1303 | 1303 | ) |
1304 | 1304 | ); |
1305 | 1305 | |
1306 | - if ( ! empty( $field['description'] ) ) { |
|
1307 | - $description = wp_kses_post( $field['description'] ); |
|
1306 | + if (!empty($field['description'])) { |
|
1307 | + $description = wp_kses_post($field['description']); |
|
1308 | 1308 | echo "<small class='form-text text-muted'>$description</small>"; |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1315,16 +1315,16 @@ discard block |
||
1315 | 1315 | /** |
1316 | 1316 | * Renders the edit date element template. |
1317 | 1317 | */ |
1318 | - public function edit_date_template( $field ) { |
|
1319 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
1320 | - $label = __( 'Field Label', 'invoicing' ); |
|
1318 | + public function edit_date_template($field) { |
|
1319 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
1320 | + $label = __('Field Label', 'invoicing'); |
|
1321 | 1321 | $id = $field . '.id + "_edit"'; |
1322 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1322 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1323 | 1323 | $id2 = $field . '.id + "_edit2"'; |
1324 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1325 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1324 | + $label3 = __('Help text', 'invoicing'); |
|
1325 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1326 | 1326 | $id3 = $field . '.id + "_edit3"'; |
1327 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1327 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1328 | 1328 | $id4 = $field . '.id + "_edit4"'; |
1329 | 1329 | echo " |
1330 | 1330 | <div $restrict> |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | /** |
1353 | 1353 | * Renders the time element template. |
1354 | 1354 | */ |
1355 | - public function render_time_template( $field ) { |
|
1356 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
1355 | + public function render_time_template($field) { |
|
1356 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
1357 | 1357 | $label = "$field.label"; |
1358 | 1358 | echo " |
1359 | 1359 | <div $restrict> |
@@ -1367,24 +1367,24 @@ discard block |
||
1367 | 1367 | /** |
1368 | 1368 | * Renders the time element on the frontend. |
1369 | 1369 | */ |
1370 | - public function frontend_render_time_template( $field ) { |
|
1370 | + public function frontend_render_time_template($field) { |
|
1371 | 1371 | |
1372 | 1372 | echo "<div class='form-group'>"; |
1373 | 1373 | |
1374 | 1374 | echo aui()->input( |
1375 | 1375 | array( |
1376 | - 'name' => esc_attr( $field['id'] ), |
|
1377 | - 'id' => esc_attr( $field['id'] ), |
|
1376 | + 'name' => esc_attr($field['id']), |
|
1377 | + 'id' => esc_attr($field['id']), |
|
1378 | 1378 | 'required' => (bool) $field['required'], |
1379 | - 'label' => wp_kses_post( $field['label'] ), |
|
1379 | + 'label' => wp_kses_post($field['label']), |
|
1380 | 1380 | 'no_wrap' => true, |
1381 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1381 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1382 | 1382 | 'type' => 'time', |
1383 | 1383 | ) |
1384 | 1384 | ); |
1385 | 1385 | |
1386 | - if ( ! empty( $field['description'] ) ) { |
|
1387 | - $description = wp_kses_post( $field['description'] ); |
|
1386 | + if (!empty($field['description'])) { |
|
1387 | + $description = wp_kses_post($field['description']); |
|
1388 | 1388 | echo "<small class='form-text text-muted'>$description</small>"; |
1389 | 1389 | } |
1390 | 1390 | |
@@ -1395,16 +1395,16 @@ discard block |
||
1395 | 1395 | /** |
1396 | 1396 | * Renders the edit time element template. |
1397 | 1397 | */ |
1398 | - public function edit_time_template( $field ) { |
|
1399 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
1400 | - $label = __( 'Field Label', 'invoicing' ); |
|
1398 | + public function edit_time_template($field) { |
|
1399 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
1400 | + $label = __('Field Label', 'invoicing'); |
|
1401 | 1401 | $id = $field . '.id + "_edit"'; |
1402 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1402 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1403 | 1403 | $id2 = $field . '.id + "_edit2"'; |
1404 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1405 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1404 | + $label3 = __('Help text', 'invoicing'); |
|
1405 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1406 | 1406 | $id3 = $field . '.id + "_edit3"'; |
1407 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1407 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1408 | 1408 | $id4 = $field . '.id + "_edit4"'; |
1409 | 1409 | echo " |
1410 | 1410 | <div $restrict> |
@@ -1432,8 +1432,8 @@ discard block |
||
1432 | 1432 | /** |
1433 | 1433 | * Renders the number element template. |
1434 | 1434 | */ |
1435 | - public function render_number_template( $field ) { |
|
1436 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
1435 | + public function render_number_template($field) { |
|
1436 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
1437 | 1437 | $label = "$field.label"; |
1438 | 1438 | echo " |
1439 | 1439 | <div $restrict> |
@@ -1447,24 +1447,24 @@ discard block |
||
1447 | 1447 | /** |
1448 | 1448 | * Renders the number element on the frontend. |
1449 | 1449 | */ |
1450 | - public function frontend_render_number_template( $field ) { |
|
1450 | + public function frontend_render_number_template($field) { |
|
1451 | 1451 | |
1452 | 1452 | echo "<div class='form-group'>"; |
1453 | 1453 | |
1454 | 1454 | echo aui()->input( |
1455 | 1455 | array( |
1456 | - 'name' => esc_attr( $field['id'] ), |
|
1457 | - 'id' => esc_attr( $field['id'] ), |
|
1456 | + 'name' => esc_attr($field['id']), |
|
1457 | + 'id' => esc_attr($field['id']), |
|
1458 | 1458 | 'required' => (bool) $field['required'], |
1459 | - 'label' => wp_kses_post( $field['label'] ), |
|
1460 | - 'placeholder' => esc_attr( $field['placeholder'] ), |
|
1459 | + 'label' => wp_kses_post($field['label']), |
|
1460 | + 'placeholder' => esc_attr($field['placeholder']), |
|
1461 | 1461 | 'no_wrap' => true, |
1462 | 1462 | 'type' => 'number', |
1463 | 1463 | ) |
1464 | 1464 | ); |
1465 | 1465 | |
1466 | - if ( ! empty( $field['description'] ) ) { |
|
1467 | - $description = wp_kses_post( $field['description'] ); |
|
1466 | + if (!empty($field['description'])) { |
|
1467 | + $description = wp_kses_post($field['description']); |
|
1468 | 1468 | echo "<small class='form-text text-muted'>$description</small>"; |
1469 | 1469 | } |
1470 | 1470 | |
@@ -1475,16 +1475,16 @@ discard block |
||
1475 | 1475 | /** |
1476 | 1476 | * Renders the edit number element template. |
1477 | 1477 | */ |
1478 | - public function edit_number_template( $field ) { |
|
1479 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
1480 | - $label = __( 'Field Label', 'invoicing' ); |
|
1478 | + public function edit_number_template($field) { |
|
1479 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
1480 | + $label = __('Field Label', 'invoicing'); |
|
1481 | 1481 | $id = $field . '.id + "_edit"'; |
1482 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1482 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1483 | 1483 | $id2 = $field . '.id + "_edit2"'; |
1484 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1485 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1484 | + $label3 = __('Help text', 'invoicing'); |
|
1485 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1486 | 1486 | $id3 = $field . '.id + "_edit3"'; |
1487 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1487 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1488 | 1488 | $id4 = $field . '.id + "_edit4"'; |
1489 | 1489 | echo " |
1490 | 1490 | <div $restrict> |
@@ -1512,23 +1512,23 @@ discard block |
||
1512 | 1512 | /** |
1513 | 1513 | * Renders the separator element template. |
1514 | 1514 | */ |
1515 | - public function render_separator_template( $field ) { |
|
1516 | - $restrict = $this->get_restrict_markup( $field, 'separator' ); |
|
1515 | + public function render_separator_template($field) { |
|
1516 | + $restrict = $this->get_restrict_markup($field, 'separator'); |
|
1517 | 1517 | echo "<hr class='featurette-divider mt-0 mb-2' $restrict>"; |
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | /** |
1521 | 1521 | * Renders the separator element on the frontend. |
1522 | 1522 | */ |
1523 | - public function frontend_render_separator_template( $field ) { |
|
1523 | + public function frontend_render_separator_template($field) { |
|
1524 | 1524 | echo '<hr class="featurette-divider mt-0 mb-2" />'; |
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
1528 | 1528 | * Renders the pay button element template. |
1529 | 1529 | */ |
1530 | - public function render_pay_button_template( $field ) { |
|
1531 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
1530 | + public function render_pay_button_template($field) { |
|
1531 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
1532 | 1532 | $label = "$field.label"; |
1533 | 1533 | echo " |
1534 | 1534 | <div $restrict> |
@@ -1541,28 +1541,28 @@ discard block |
||
1541 | 1541 | /** |
1542 | 1542 | * Renders the pay_button element on the frontend. |
1543 | 1543 | */ |
1544 | - public function frontend_render_pay_button_template( $field ) { |
|
1544 | + public function frontend_render_pay_button_template($field) { |
|
1545 | 1545 | |
1546 | 1546 | echo "<div class='mt-4 mb-4'>"; |
1547 | - do_action( 'wpinv_payment_mode_select' ); |
|
1547 | + do_action('wpinv_payment_mode_select'); |
|
1548 | 1548 | echo "</div>"; |
1549 | 1549 | |
1550 | 1550 | echo "<div class='form-group'>"; |
1551 | 1551 | |
1552 | - $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] ); |
|
1552 | + $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class($field['class']); |
|
1553 | 1553 | echo aui()->input( |
1554 | 1554 | array( |
1555 | - 'name' => esc_attr( $field['id'] ), |
|
1556 | - 'id' => esc_attr( $field['id'] ), |
|
1557 | - 'value' => esc_attr( $field['label'] ), |
|
1555 | + 'name' => esc_attr($field['id']), |
|
1556 | + 'id' => esc_attr($field['id']), |
|
1557 | + 'value' => esc_attr($field['label']), |
|
1558 | 1558 | 'no_wrap' => true, |
1559 | 1559 | 'type' => 'submit', |
1560 | 1560 | 'class' => $class, |
1561 | 1561 | ) |
1562 | 1562 | ); |
1563 | 1563 | |
1564 | - if ( ! empty( $field['description'] ) ) { |
|
1565 | - $description = wp_kses_post( $field['description'] ); |
|
1564 | + if (!empty($field['description'])) { |
|
1565 | + $description = wp_kses_post($field['description']); |
|
1566 | 1566 | echo "<small class='form-text text-muted'>$description</small>"; |
1567 | 1567 | } |
1568 | 1568 | |
@@ -1573,14 +1573,14 @@ discard block |
||
1573 | 1573 | /** |
1574 | 1574 | * Renders the pay button element template. |
1575 | 1575 | */ |
1576 | - public function edit_pay_button_template( $field ) { |
|
1577 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
1578 | - $label = __( 'Button Text', 'invoicing' ); |
|
1576 | + public function edit_pay_button_template($field) { |
|
1577 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
1578 | + $label = __('Button Text', 'invoicing'); |
|
1579 | 1579 | $id = $field . '.id + "_edit"'; |
1580 | - $label2 = __( 'Help text', 'invoicing' ); |
|
1581 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1580 | + $label2 = __('Help text', 'invoicing'); |
|
1581 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1582 | 1582 | $id2 = $field . '.id + "_edit2"'; |
1583 | - $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
|
1583 | + $label4 = esc_attr__('Button Type', 'invoicing'); |
|
1584 | 1584 | $id3 = $field . '.id + "_edit3"'; |
1585 | 1585 | echo " |
1586 | 1586 | <div $restrict> |
@@ -1596,15 +1596,15 @@ discard block |
||
1596 | 1596 | <label :for='$id3'>$label4</label> |
1597 | 1597 | |
1598 | 1598 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1599 | - <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
1600 | - <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
1601 | - <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
1602 | - <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
1603 | - <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
1604 | - <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
1605 | - <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
1606 | - <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
1607 | - <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
|
1599 | + <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option> |
|
1600 | + <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
1601 | + <option value='btn-success'>" . __('Success', 'invoicing') . "</option> |
|
1602 | + <option value='btn-danger'>" . __('Danger', 'invoicing') . "</option> |
|
1603 | + <option value='btn-warning'>" . __('Warning', 'invoicing') . "</option> |
|
1604 | + <option value='btn-info'>" . __('Info', 'invoicing') . "</option> |
|
1605 | + <option value='btn-light'>" . __('Light', 'invoicing') . "</option> |
|
1606 | + <option value='btn-dark'>" . __('Dark', 'invoicing') . "</option> |
|
1607 | + <option value='btn-link'>" . __('Link', 'invoicing') . "</option> |
|
1608 | 1608 | </select> |
1609 | 1609 | </div> |
1610 | 1610 | </div> |
@@ -1615,8 +1615,8 @@ discard block |
||
1615 | 1615 | /** |
1616 | 1616 | * Renders the alert element template. |
1617 | 1617 | */ |
1618 | - public function render_alert_template( $field ) { |
|
1619 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
1618 | + public function render_alert_template($field) { |
|
1619 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
1620 | 1620 | $text = "$field.text"; |
1621 | 1621 | echo " |
1622 | 1622 | <div $restrict class='alert' :class='$field.class' role='alert'> |
@@ -1631,15 +1631,15 @@ discard block |
||
1631 | 1631 | /** |
1632 | 1632 | * Renders the alert element on the frontend. |
1633 | 1633 | */ |
1634 | - public function frontend_render_alert_template( $field ) { |
|
1634 | + public function frontend_render_alert_template($field) { |
|
1635 | 1635 | |
1636 | 1636 | echo "<div class='form-group'>"; |
1637 | 1637 | |
1638 | 1638 | echo aui()->alert( |
1639 | 1639 | array( |
1640 | - 'content' => wp_kses_post( $field['text'] ), |
|
1640 | + 'content' => wp_kses_post($field['text']), |
|
1641 | 1641 | 'dismissible' => $field['dismissible'], |
1642 | - 'type' => str_replace( 'alert-', '', $field['class'] ), |
|
1642 | + 'type' => str_replace('alert-', '', $field['class']), |
|
1643 | 1643 | ) |
1644 | 1644 | ); |
1645 | 1645 | |
@@ -1650,14 +1650,14 @@ discard block |
||
1650 | 1650 | /** |
1651 | 1651 | * Renders the alert element template. |
1652 | 1652 | */ |
1653 | - public function edit_alert_template( $field ) { |
|
1654 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
1655 | - $label = __( 'Alert Text', 'invoicing' ); |
|
1656 | - $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
|
1653 | + public function edit_alert_template($field) { |
|
1654 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
1655 | + $label = __('Alert Text', 'invoicing'); |
|
1656 | + $label2 = esc_attr__('Enter your alert text here', 'invoicing'); |
|
1657 | 1657 | $id = $field . '.id + "_edit"'; |
1658 | - $label3 = __( 'Is Dismissible?', 'invoicing' ); |
|
1658 | + $label3 = __('Is Dismissible?', 'invoicing'); |
|
1659 | 1659 | $id2 = $field . '.id + "_edit2"'; |
1660 | - $label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
|
1660 | + $label4 = esc_attr__('Alert Type', 'invoicing'); |
|
1661 | 1661 | $id3 = $field . '.id + "_edit3"'; |
1662 | 1662 | echo " |
1663 | 1663 | <div $restrict> |
@@ -1673,14 +1673,14 @@ discard block |
||
1673 | 1673 | <label :for='$id3'>$label4</label> |
1674 | 1674 | |
1675 | 1675 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1676 | - <option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
1677 | - <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
1678 | - <option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
1679 | - <option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
1680 | - <option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
1681 | - <option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
1682 | - <option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
1683 | - <option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
1676 | + <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option> |
|
1677 | + <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
1678 | + <option value='alert-success'>" . __('Success', 'invoicing') . "</option> |
|
1679 | + <option value='alert-danger'>" . __('Danger', 'invoicing') . "</option> |
|
1680 | + <option value='alert-warning'>" . __('Warning', 'invoicing') . "</option> |
|
1681 | + <option value='alert-info'>" . __('Info', 'invoicing') . "</option> |
|
1682 | + <option value='alert-light'>" . __('Light', 'invoicing') . "</option> |
|
1683 | + <option value='alert-dark'>" . __('Dark', 'invoicing') . "</option> |
|
1684 | 1684 | </select> |
1685 | 1685 | </div> |
1686 | 1686 | </div> |
@@ -1691,8 +1691,8 @@ discard block |
||
1691 | 1691 | /** |
1692 | 1692 | * Renders the discount element template. |
1693 | 1693 | */ |
1694 | - public function render_discount_template( $field ) { |
|
1695 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
1694 | + public function render_discount_template($field) { |
|
1695 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
1696 | 1696 | ?> |
1697 | 1697 | |
1698 | 1698 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3"> |
@@ -1709,13 +1709,13 @@ discard block |
||
1709 | 1709 | /** |
1710 | 1710 | * Renders the discount element on the frontend. |
1711 | 1711 | */ |
1712 | - public function frontend_render_discount_template( $field ) { |
|
1712 | + public function frontend_render_discount_template($field) { |
|
1713 | 1713 | |
1714 | - $placeholder = esc_attr( $field['input_label'] ); |
|
1715 | - $label = sanitize_text_field( $field['button_label'] ); |
|
1714 | + $placeholder = esc_attr($field['input_label']); |
|
1715 | + $label = sanitize_text_field($field['button_label']); |
|
1716 | 1716 | $description = ''; |
1717 | 1717 | |
1718 | - if ( ! empty( $field['description'] ) ) { |
|
1718 | + if (!empty($field['description'])) { |
|
1719 | 1719 | $description = "<small class='form-text text-muted'>{$field['description']}</small>"; |
1720 | 1720 | } |
1721 | 1721 | ?> |
@@ -1736,12 +1736,12 @@ discard block |
||
1736 | 1736 | /** |
1737 | 1737 | * Renders the discount element template. |
1738 | 1738 | */ |
1739 | - public function edit_discount_template( $field ) { |
|
1740 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
1741 | - $label = __( 'Discount Input Placeholder', 'invoicing' ); |
|
1742 | - $label2 = __( 'Help Text', 'invoicing' ); |
|
1743 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1744 | - $label4 = __( 'Button Text', 'invoicing' ); |
|
1739 | + public function edit_discount_template($field) { |
|
1740 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
1741 | + $label = __('Discount Input Placeholder', 'invoicing'); |
|
1742 | + $label2 = __('Help Text', 'invoicing'); |
|
1743 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1744 | + $label4 = __('Button Text', 'invoicing'); |
|
1745 | 1745 | $id = $field . '.id + "_edit"'; |
1746 | 1746 | $id2 = $field . '.id + "_edit2"'; |
1747 | 1747 | $id3 = $field . '.id + "_edit3"'; |
@@ -1770,21 +1770,21 @@ discard block |
||
1770 | 1770 | /** |
1771 | 1771 | * Renders the items element template. |
1772 | 1772 | */ |
1773 | - public function render_items_template( $field ) { |
|
1774 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
1775 | - $label = __( 'Item totals will appear here. Click to set items.', 'invoicing' ); |
|
1773 | + public function render_items_template($field) { |
|
1774 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
1775 | + $label = __('Item totals will appear here. Click to set items.', 'invoicing'); |
|
1776 | 1776 | echo "<div $restrict class='item_totals p-4 bg-warning text-center'>$label</div>"; |
1777 | 1777 | } |
1778 | 1778 | |
1779 | 1779 | /** |
1780 | 1780 | * Renders the items element on the frontend. |
1781 | 1781 | */ |
1782 | - public function frontend_render_items_template( $field, $items ) { |
|
1782 | + public function frontend_render_items_template($field, $items) { |
|
1783 | 1783 | |
1784 | 1784 | echo "<div class='form-group item_totals'>"; |
1785 | 1785 | |
1786 | - $id = esc_attr( $field['id'] ); |
|
1787 | - if ( 'total' == $field[ 'items_type' ] ) { |
|
1786 | + $id = esc_attr($field['id']); |
|
1787 | + if ('total' == $field['items_type']) { |
|
1788 | 1788 | $total = 0; |
1789 | 1789 | $tax = 0; |
1790 | 1790 | $sub_total = 0; |
@@ -1793,16 +1793,16 @@ discard block |
||
1793 | 1793 | <div class="border item_totals_type_total"> |
1794 | 1794 | |
1795 | 1795 | <?php |
1796 | - foreach( $items as $item ) { |
|
1796 | + foreach ($items as $item) { |
|
1797 | 1797 | |
1798 | - $amount = floatval( $item['price'] ); |
|
1798 | + $amount = floatval($item['price']); |
|
1799 | 1799 | |
1800 | - if ( wpinv_use_taxes() ) { |
|
1800 | + if (wpinv_use_taxes()) { |
|
1801 | 1801 | |
1802 | - $rate = wpinv_get_tax_rate( wpinv_default_billing_country(), false, (int) $item['id'] ); |
|
1802 | + $rate = wpinv_get_tax_rate(wpinv_default_billing_country(), false, (int) $item['id']); |
|
1803 | 1803 | |
1804 | - if ( wpinv_prices_include_tax() ) { |
|
1805 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
1804 | + if (wpinv_prices_include_tax()) { |
|
1805 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
1806 | 1806 | $item_tax = $amount - $pre_tax; |
1807 | 1807 | } else { |
1808 | 1808 | $pre_tax = $amount; |
@@ -1814,27 +1814,27 @@ discard block |
||
1814 | 1814 | $total = $sub_total + $tax; |
1815 | 1815 | |
1816 | 1816 | } else { |
1817 | - $total = $total + $amount; |
|
1817 | + $total = $total + $amount; |
|
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | $class = 'col-8'; |
1821 | 1821 | $class2 = ''; |
1822 | 1822 | |
1823 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
1823 | + if (!empty($item['allow_quantities'])) { |
|
1824 | 1824 | $class = 'col-6 pt-2'; |
1825 | 1825 | $class2 = 'pt-2'; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - if ( ! empty( $item['custom_price'] ) ) { |
|
1828 | + if (!empty($item['custom_price'])) { |
|
1829 | 1829 | $class .= ' pt-2'; |
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | ?> |
1833 | 1833 | <div class="item_totals_item"> |
1834 | 1834 | <div class='row pl-2 pr-2 pt-2'> |
1835 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
1835 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
1836 | 1836 | |
1837 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
1837 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
1838 | 1838 | |
1839 | 1839 | <div class='col-2'> |
1840 | 1840 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -1842,11 +1842,11 @@ discard block |
||
1842 | 1842 | |
1843 | 1843 | <?php } else { ?> |
1844 | 1844 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
1845 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
1845 | + <?php } if (empty($item['custom_price'])) { ?> |
|
1846 | 1846 | |
1847 | 1847 | <div class='col-4 <?php echo $class2; ?>'> |
1848 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
1849 | - <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
1848 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
1849 | + <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
1850 | 1850 | </div> |
1851 | 1851 | |
1852 | 1852 | <?php } else {?> |
@@ -1854,15 +1854,15 @@ discard block |
||
1854 | 1854 | <div class='col-4'> |
1855 | 1855 | <div class='input-group'> |
1856 | 1856 | |
1857 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
1857 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
1858 | 1858 | <div class='input-group-prepend'> |
1859 | 1859 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
1860 | 1860 | </div> |
1861 | 1861 | <?php } ?> |
1862 | 1862 | |
1863 | - <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
1863 | + <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
1864 | 1864 | |
1865 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
1865 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
1866 | 1866 | <div class='input-group-append'> |
1867 | 1867 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
1868 | 1868 | </div> |
@@ -1873,28 +1873,28 @@ discard block |
||
1873 | 1873 | <?php } ?> |
1874 | 1874 | |
1875 | 1875 | </div> |
1876 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
1877 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
1876 | + <?php if (!empty($item['description'])) { ?> |
|
1877 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
1878 | 1878 | <?php } ?> |
1879 | 1879 | </div> |
1880 | 1880 | <?php } ?> |
1881 | 1881 | |
1882 | 1882 | <div class='mt-4 border-top item_totals_total p-2'> |
1883 | 1883 | |
1884 | - <?php if ( wpinv_use_taxes() ) { ?> |
|
1884 | + <?php if (wpinv_use_taxes()) { ?> |
|
1885 | 1885 | <div class='row'> |
1886 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
|
1887 | - <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
|
1886 | + <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div> |
|
1887 | + <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div> |
|
1888 | 1888 | </div> |
1889 | 1889 | <div class='row'> |
1890 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
|
1891 | - <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
|
1890 | + <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div> |
|
1891 | + <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div> |
|
1892 | 1892 | </div> |
1893 | 1893 | <?php } ?> |
1894 | 1894 | |
1895 | 1895 | <div class='row'> |
1896 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
1897 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
1896 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
1897 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
1898 | 1898 | </div> |
1899 | 1899 | |
1900 | 1900 | </div> |
@@ -1902,22 +1902,22 @@ discard block |
||
1902 | 1902 | </div> |
1903 | 1903 | <?php } ?> |
1904 | 1904 | |
1905 | - <?php if ( 'radio' == $field[ 'items_type' ] ) { ?> |
|
1905 | + <?php if ('radio' == $field['items_type']) { ?> |
|
1906 | 1906 | <div class="item_totals_type_radio"> |
1907 | 1907 | |
1908 | 1908 | <?php |
1909 | - foreach( $items as $index => $item ) { |
|
1909 | + foreach ($items as $index => $item) { |
|
1910 | 1910 | |
1911 | - if ( ! empty( $item['required'] ) ) { |
|
1911 | + if (!empty($item['required'])) { |
|
1912 | 1912 | continue; |
1913 | 1913 | } |
1914 | 1914 | ?> |
1915 | 1915 | <div class="form-check"> |
1916 | - <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'> |
|
1917 | - <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?> <strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); ?></strong></label> |
|
1916 | + <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'> |
|
1917 | + <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?> <strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label> |
|
1918 | 1918 | </div> |
1919 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
1920 | - <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
1919 | + <?php if (!empty($item['description'])) { ?> |
|
1920 | + <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
1921 | 1921 | <?php } ?> |
1922 | 1922 | <?php } ?> |
1923 | 1923 | |
@@ -1929,32 +1929,32 @@ discard block |
||
1929 | 1929 | $tax = 0; |
1930 | 1930 | $sub_total = 0; |
1931 | 1931 | |
1932 | - foreach ( $items as $item ) { |
|
1932 | + foreach ($items as $item) { |
|
1933 | 1933 | |
1934 | 1934 | $class = 'col-8'; |
1935 | 1935 | $class2 = ''; |
1936 | 1936 | |
1937 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
1937 | + if (!empty($item['allow_quantities'])) { |
|
1938 | 1938 | $class = 'col-6 pt-2'; |
1939 | 1939 | $class2 = 'pt-2'; |
1940 | 1940 | } |
1941 | 1941 | |
1942 | - if ( ! empty( $item['custom_price'] ) ) { |
|
1942 | + if (!empty($item['custom_price'])) { |
|
1943 | 1943 | $class .= ' pt-2'; |
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | $class3 = 'd-none'; |
1947 | 1947 | $name = ''; |
1948 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) { |
|
1948 | + if (!empty($item['required']) || !isset($totals_selected_radio_item)) { |
|
1949 | 1949 | |
1950 | - $amount = floatval( $item['price'] ); |
|
1950 | + $amount = floatval($item['price']); |
|
1951 | 1951 | |
1952 | - if ( wpinv_use_taxes() ) { |
|
1952 | + if (wpinv_use_taxes()) { |
|
1953 | 1953 | |
1954 | - $rate = wpinv_get_tax_rate( wpinv_default_billing_country(), false, (int) $item['id'] ); |
|
1954 | + $rate = wpinv_get_tax_rate(wpinv_default_billing_country(), false, (int) $item['id']); |
|
1955 | 1955 | |
1956 | - if ( wpinv_prices_include_tax() ) { |
|
1957 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
1956 | + if (wpinv_prices_include_tax()) { |
|
1957 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
1958 | 1958 | $item_tax = $amount - $pre_tax; |
1959 | 1959 | } else { |
1960 | 1960 | $pre_tax = $amount; |
@@ -1966,13 +1966,13 @@ discard block |
||
1966 | 1966 | $total = $sub_total + $tax; |
1967 | 1967 | |
1968 | 1968 | } else { |
1969 | - $total = $total + $amount; |
|
1969 | + $total = $total + $amount; |
|
1970 | 1970 | } |
1971 | 1971 | |
1972 | 1972 | $class3 = ''; |
1973 | 1973 | $name = "wpinv-items[{$item['id']}]"; |
1974 | 1974 | |
1975 | - if ( empty( $item['required'] ) ) { |
|
1975 | + if (empty($item['required'])) { |
|
1976 | 1976 | $totals_selected_radio_item = 1; |
1977 | 1977 | } |
1978 | 1978 | |
@@ -1984,9 +1984,9 @@ discard block |
||
1984 | 1984 | |
1985 | 1985 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
1986 | 1986 | <div class='row pl-2 pr-2 pt-2'> |
1987 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
1987 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
1988 | 1988 | |
1989 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
1989 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
1990 | 1990 | |
1991 | 1991 | <div class='col-2'> |
1992 | 1992 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -1994,11 +1994,11 @@ discard block |
||
1994 | 1994 | |
1995 | 1995 | <?php } else { ?> |
1996 | 1996 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
1997 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
1997 | + <?php } if (empty($item['custom_price'])) { ?> |
|
1998 | 1998 | |
1999 | 1999 | <div class='col-4 <?php echo $class2; ?>'> |
2000 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
2001 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
2000 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
2001 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
2002 | 2002 | </div> |
2003 | 2003 | |
2004 | 2004 | <?php } else {?> |
@@ -2006,15 +2006,15 @@ discard block |
||
2006 | 2006 | <div class='col-4'> |
2007 | 2007 | <div class='input-group'> |
2008 | 2008 | |
2009 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
2009 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
2010 | 2010 | <div class='input-group-prepend'> |
2011 | 2011 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2012 | 2012 | </div> |
2013 | 2013 | <?php } ?> |
2014 | 2014 | |
2015 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
2015 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
2016 | 2016 | |
2017 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
2017 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
2018 | 2018 | <div class='input-group-append'> |
2019 | 2019 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2020 | 2020 | </div> |
@@ -2025,27 +2025,27 @@ discard block |
||
2025 | 2025 | <?php } ?> |
2026 | 2026 | |
2027 | 2027 | </div> |
2028 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
2029 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
2028 | + <?php if (!empty($item['description'])) { ?> |
|
2029 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
2030 | 2030 | <?php } ?> |
2031 | 2031 | </div> |
2032 | 2032 | <?php } ?> |
2033 | 2033 | |
2034 | 2034 | <div class='mt-4 border-top item_totals_total p-2'> |
2035 | - <?php if ( wpinv_use_taxes() ) { ?> |
|
2035 | + <?php if (wpinv_use_taxes()) { ?> |
|
2036 | 2036 | <div class='row'> |
2037 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
|
2038 | - <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
|
2037 | + <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div> |
|
2038 | + <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div> |
|
2039 | 2039 | </div> |
2040 | 2040 | <div class='row'> |
2041 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
|
2042 | - <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
|
2041 | + <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div> |
|
2042 | + <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div> |
|
2043 | 2043 | </div> |
2044 | 2044 | <?php } ?> |
2045 | 2045 | |
2046 | 2046 | <div class='row'> |
2047 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
2048 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
2047 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
2048 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
2049 | 2049 | </div> |
2050 | 2050 | </div> |
2051 | 2051 | |
@@ -2053,22 +2053,22 @@ discard block |
||
2053 | 2053 | </div> |
2054 | 2054 | <?php } ?> |
2055 | 2055 | |
2056 | - <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?> |
|
2056 | + <?php if ('checkbox' == $field['items_type']) { ?> |
|
2057 | 2057 | |
2058 | 2058 | <div class="item_totals_type_checkbox"> |
2059 | 2059 | |
2060 | 2060 | <?php |
2061 | - foreach ( $items as $index => $item ) { |
|
2061 | + foreach ($items as $index => $item) { |
|
2062 | 2062 | |
2063 | - if ( ! empty( $item['required'] ) ) { |
|
2063 | + if (!empty($item['required'])) { |
|
2064 | 2064 | continue; |
2065 | 2065 | } |
2066 | 2066 | |
2067 | - $title = sanitize_text_field( $item['title'] ); |
|
2068 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
2069 | - $item_id = esc_attr( $id . "_$index" ); |
|
2070 | - $value = esc_attr( $item['id'] ); |
|
2071 | - $checked = checked( ! isset( $selected_checkbox_item ), true, false ); |
|
2067 | + $title = sanitize_text_field($item['title']); |
|
2068 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
2069 | + $item_id = esc_attr($id . "_$index"); |
|
2070 | + $value = esc_attr($item['id']); |
|
2071 | + $checked = checked(!isset($selected_checkbox_item), true, false); |
|
2072 | 2072 | $selected_checkbox_item = 1; |
2073 | 2073 | |
2074 | 2074 | echo " |
@@ -2077,7 +2077,7 @@ discard block |
||
2077 | 2077 | <label for='$item_id' class='custom-control-label'>$title ($price)</label> |
2078 | 2078 | </div>"; |
2079 | 2079 | |
2080 | - if ( ! empty( $item['description'] ) ) { |
|
2080 | + if (!empty($item['description'])) { |
|
2081 | 2081 | echo "<small class='form-text text-muted'>{$item['description']}</small>"; |
2082 | 2082 | } |
2083 | 2083 | } |
@@ -2091,31 +2091,31 @@ discard block |
||
2091 | 2091 | $tax = 0; |
2092 | 2092 | $sub_total = 0; |
2093 | 2093 | |
2094 | - foreach ( $items as $item ) { |
|
2094 | + foreach ($items as $item) { |
|
2095 | 2095 | |
2096 | 2096 | $class = 'col-8'; |
2097 | 2097 | $class2 = ''; |
2098 | 2098 | |
2099 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
2099 | + if (!empty($item['allow_quantities'])) { |
|
2100 | 2100 | $class = 'col-6 pt-2'; |
2101 | 2101 | $class2 = 'pt-2'; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | - if ( ! empty( $item['custom_price'] ) ) { |
|
2104 | + if (!empty($item['custom_price'])) { |
|
2105 | 2105 | $class .= ' pt-2'; |
2106 | 2106 | } |
2107 | 2107 | |
2108 | 2108 | $class3 = 'd-none'; |
2109 | - $name = ''; |
|
2110 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) { |
|
2109 | + $name = ''; |
|
2110 | + if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) { |
|
2111 | 2111 | |
2112 | - $amount = floatval( $item['price'] ); |
|
2113 | - if ( wpinv_use_taxes() ) { |
|
2112 | + $amount = floatval($item['price']); |
|
2113 | + if (wpinv_use_taxes()) { |
|
2114 | 2114 | |
2115 | - $rate = wpinv_get_tax_rate( wpinv_default_billing_country(), false, (int) $item['id'] ); |
|
2115 | + $rate = wpinv_get_tax_rate(wpinv_default_billing_country(), false, (int) $item['id']); |
|
2116 | 2116 | |
2117 | - if ( wpinv_prices_include_tax() ) { |
|
2118 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
2117 | + if (wpinv_prices_include_tax()) { |
|
2118 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
2119 | 2119 | $item_tax = $amount - $pre_tax; |
2120 | 2120 | } else { |
2121 | 2121 | $pre_tax = $amount; |
@@ -2127,13 +2127,13 @@ discard block |
||
2127 | 2127 | $total = $sub_total + $tax; |
2128 | 2128 | |
2129 | 2129 | } else { |
2130 | - $total = $total + $amount; |
|
2130 | + $total = $total + $amount; |
|
2131 | 2131 | } |
2132 | 2132 | |
2133 | 2133 | $class3 = ''; |
2134 | - $name = "wpinv-items[{$item['id']}]"; |
|
2134 | + $name = "wpinv-items[{$item['id']}]"; |
|
2135 | 2135 | |
2136 | - if ( empty( $item['required'] ) ) { |
|
2136 | + if (empty($item['required'])) { |
|
2137 | 2137 | $totals_selected_checkbox_item = 1; |
2138 | 2138 | } |
2139 | 2139 | |
@@ -2145,9 +2145,9 @@ discard block |
||
2145 | 2145 | |
2146 | 2146 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
2147 | 2147 | <div class='row pl-2 pr-2 pt-2'> |
2148 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
2148 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
2149 | 2149 | |
2150 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
2150 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
2151 | 2151 | |
2152 | 2152 | <div class='col-2'> |
2153 | 2153 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2155,11 +2155,11 @@ discard block |
||
2155 | 2155 | |
2156 | 2156 | <?php } else { ?> |
2157 | 2157 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
2158 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
2158 | + <?php } if (empty($item['custom_price'])) { ?> |
|
2159 | 2159 | |
2160 | 2160 | <div class='col-4 <?php echo $class2; ?>'> |
2161 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
2162 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
2161 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
2162 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
2163 | 2163 | </div> |
2164 | 2164 | |
2165 | 2165 | <?php } else {?> |
@@ -2167,15 +2167,15 @@ discard block |
||
2167 | 2167 | <div class='col-4'> |
2168 | 2168 | <div class='input-group'> |
2169 | 2169 | |
2170 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
2170 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
2171 | 2171 | <div class='input-group-prepend'> |
2172 | 2172 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2173 | 2173 | </div> |
2174 | 2174 | <?php } ?> |
2175 | 2175 | |
2176 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
2176 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
2177 | 2177 | |
2178 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
2178 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
2179 | 2179 | <div class='input-group-append'> |
2180 | 2180 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2181 | 2181 | </div> |
@@ -2186,35 +2186,35 @@ discard block |
||
2186 | 2186 | <?php } ?> |
2187 | 2187 | |
2188 | 2188 | </div> |
2189 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
2190 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
2189 | + <?php if (!empty($item['description'])) { ?> |
|
2190 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
2191 | 2191 | <?php } ?> |
2192 | 2192 | </div> |
2193 | 2193 | <?php } ?> |
2194 | 2194 | |
2195 | 2195 | <div class='mt-4 border-top item_totals_total p-2'> |
2196 | 2196 | |
2197 | - <?php if ( wpinv_use_taxes() ) { ?> |
|
2197 | + <?php if (wpinv_use_taxes()) { ?> |
|
2198 | 2198 | <div class='row'> |
2199 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
|
2200 | - <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
|
2199 | + <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div> |
|
2200 | + <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div> |
|
2201 | 2201 | </div> |
2202 | 2202 | <div class='row'> |
2203 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
|
2204 | - <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
|
2203 | + <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div> |
|
2204 | + <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div> |
|
2205 | 2205 | </div> |
2206 | 2206 | <?php } ?> |
2207 | 2207 | |
2208 | 2208 | <div class='row'> |
2209 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
2210 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
2209 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
2210 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
2211 | 2211 | </div> |
2212 | 2212 | </div> |
2213 | 2213 | </div> |
2214 | 2214 | </div> |
2215 | 2215 | <?php } ?> |
2216 | 2216 | |
2217 | - <?php if ( 'select' == $field[ 'items_type' ] ) { ?> |
|
2217 | + <?php if ('select' == $field['items_type']) { ?> |
|
2218 | 2218 | |
2219 | 2219 | <div class="item_totals_type_select"> |
2220 | 2220 | |
@@ -2222,17 +2222,17 @@ discard block |
||
2222 | 2222 | |
2223 | 2223 | $options = array(); |
2224 | 2224 | $selected = ''; |
2225 | - foreach ( $items as $index => $item ) { |
|
2225 | + foreach ($items as $index => $item) { |
|
2226 | 2226 | |
2227 | - if ( ! empty( $item['required'] ) ) { |
|
2227 | + if (!empty($item['required'])) { |
|
2228 | 2228 | continue; |
2229 | 2229 | } |
2230 | 2230 | |
2231 | - $title = sanitize_text_field( $item['title'] ); |
|
2232 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
2233 | - $options[ $item['id'] ] = "$title ($price)"; |
|
2231 | + $title = sanitize_text_field($item['title']); |
|
2232 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
2233 | + $options[$item['id']] = "$title ($price)"; |
|
2234 | 2234 | |
2235 | - if ( ! isset( $selected_item ) ) { |
|
2235 | + if (!isset($selected_item)) { |
|
2236 | 2236 | $selected = $item['id']; |
2237 | 2237 | $selected_item = 1; |
2238 | 2238 | } |
@@ -2243,7 +2243,7 @@ discard block |
||
2243 | 2243 | array( |
2244 | 2244 | 'name' => 'payment-form-items', |
2245 | 2245 | 'id' => $id, |
2246 | - 'placeholder' => __( 'Select an item', 'invoicing' ), |
|
2246 | + 'placeholder' => __('Select an item', 'invoicing'), |
|
2247 | 2247 | 'no_wrap' => true, |
2248 | 2248 | 'options' => $options, |
2249 | 2249 | 'class' => 'wpi_select2 wpinv-items-select-selector', |
@@ -2260,31 +2260,31 @@ discard block |
||
2260 | 2260 | $tax = 0; |
2261 | 2261 | $sub_total = 0; |
2262 | 2262 | |
2263 | - foreach ( $items as $item ) { |
|
2263 | + foreach ($items as $item) { |
|
2264 | 2264 | |
2265 | 2265 | $class = 'col-8'; |
2266 | 2266 | $class2 = ''; |
2267 | 2267 | |
2268 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
2268 | + if (!empty($item['allow_quantities'])) { |
|
2269 | 2269 | $class = 'col-6 pt-2'; |
2270 | 2270 | $class2 = 'pt-2'; |
2271 | 2271 | } |
2272 | 2272 | |
2273 | - if ( ! empty( $item['custom_price'] ) ) { |
|
2273 | + if (!empty($item['custom_price'])) { |
|
2274 | 2274 | $class .= ' pt-2'; |
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | $class3 = 'd-none'; |
2278 | - $name = ''; |
|
2279 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
|
2278 | + $name = ''; |
|
2279 | + if (!empty($item['required']) || !isset($totals_selected_select_item)) { |
|
2280 | 2280 | |
2281 | - $amount = floatval( $item['price'] ); |
|
2282 | - if ( wpinv_use_taxes() ) { |
|
2281 | + $amount = floatval($item['price']); |
|
2282 | + if (wpinv_use_taxes()) { |
|
2283 | 2283 | |
2284 | - $rate = wpinv_get_tax_rate( wpinv_default_billing_country(), false, (int) $item['id'] ); |
|
2284 | + $rate = wpinv_get_tax_rate(wpinv_default_billing_country(), false, (int) $item['id']); |
|
2285 | 2285 | |
2286 | - if ( wpinv_prices_include_tax() ) { |
|
2287 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
2286 | + if (wpinv_prices_include_tax()) { |
|
2287 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
2288 | 2288 | $item_tax = $amount - $pre_tax; |
2289 | 2289 | } else { |
2290 | 2290 | $pre_tax = $amount; |
@@ -2296,13 +2296,13 @@ discard block |
||
2296 | 2296 | $total = $sub_total + $tax; |
2297 | 2297 | |
2298 | 2298 | } else { |
2299 | - $total = $total + $amount; |
|
2299 | + $total = $total + $amount; |
|
2300 | 2300 | } |
2301 | 2301 | |
2302 | 2302 | $class3 = ''; |
2303 | - $name = "wpinv-items[{$item['id']}]"; |
|
2303 | + $name = "wpinv-items[{$item['id']}]"; |
|
2304 | 2304 | |
2305 | - if ( empty( $item['required'] ) ) { |
|
2305 | + if (empty($item['required'])) { |
|
2306 | 2306 | $totals_selected_select_item = 1; |
2307 | 2307 | } |
2308 | 2308 | |
@@ -2314,9 +2314,9 @@ discard block |
||
2314 | 2314 | |
2315 | 2315 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
2316 | 2316 | <div class='row pl-2 pr-2 pt-2'> |
2317 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
2317 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
2318 | 2318 | |
2319 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
2319 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
2320 | 2320 | |
2321 | 2321 | <div class='col-2'> |
2322 | 2322 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2324,11 +2324,11 @@ discard block |
||
2324 | 2324 | |
2325 | 2325 | <?php } else { ?> |
2326 | 2326 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
2327 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
2327 | + <?php } if (empty($item['custom_price'])) { ?> |
|
2328 | 2328 | |
2329 | 2329 | <div class='col-4 <?php echo $class2; ?>'> |
2330 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
2331 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
2330 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
2331 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
2332 | 2332 | </div> |
2333 | 2333 | |
2334 | 2334 | <?php } else {?> |
@@ -2336,15 +2336,15 @@ discard block |
||
2336 | 2336 | <div class='col-4'> |
2337 | 2337 | <div class='input-group'> |
2338 | 2338 | |
2339 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
2339 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
2340 | 2340 | <div class='input-group-prepend'> |
2341 | 2341 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2342 | 2342 | </div> |
2343 | 2343 | <?php } ?> |
2344 | 2344 | |
2345 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
2345 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
2346 | 2346 | |
2347 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
2347 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
2348 | 2348 | <div class='input-group-append'> |
2349 | 2349 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2350 | 2350 | </div> |
@@ -2355,34 +2355,34 @@ discard block |
||
2355 | 2355 | <?php } ?> |
2356 | 2356 | |
2357 | 2357 | </div> |
2358 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
2359 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
2358 | + <?php if (!empty($item['description'])) { ?> |
|
2359 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
2360 | 2360 | <?php } ?> |
2361 | 2361 | </div> |
2362 | 2362 | <?php } ?> |
2363 | 2363 | |
2364 | 2364 | <div class='mt-4 border-top item_totals_total p-2'> |
2365 | 2365 | |
2366 | - <?php if ( wpinv_use_taxes() ) { ?> |
|
2366 | + <?php if (wpinv_use_taxes()) { ?> |
|
2367 | 2367 | <div class='row'> |
2368 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
|
2369 | - <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
|
2368 | + <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div> |
|
2369 | + <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div> |
|
2370 | 2370 | </div> |
2371 | 2371 | <div class='row'> |
2372 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
|
2373 | - <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
|
2372 | + <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div> |
|
2373 | + <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div> |
|
2374 | 2374 | </div> |
2375 | 2375 | <?php } ?> |
2376 | 2376 | <div class='row'> |
2377 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
2378 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
2377 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
2378 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
2379 | 2379 | </div> |
2380 | 2380 | </div> |
2381 | 2381 | |
2382 | 2382 | </div> |
2383 | 2383 | <?php } ?> |
2384 | 2384 | |
2385 | - <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?> |
|
2385 | + <?php if ('multi_select' == $field['items_type']) { ?> |
|
2386 | 2386 | |
2387 | 2387 | <div class="item_totals_type_multi_select"> |
2388 | 2388 | |
@@ -2391,18 +2391,18 @@ discard block |
||
2391 | 2391 | $options = array(); |
2392 | 2392 | $selected = array(); |
2393 | 2393 | |
2394 | - foreach ( $items as $index => $item ) { |
|
2394 | + foreach ($items as $index => $item) { |
|
2395 | 2395 | |
2396 | - if ( ! empty( $item['required'] ) ) { |
|
2396 | + if (!empty($item['required'])) { |
|
2397 | 2397 | continue; |
2398 | 2398 | } |
2399 | 2399 | |
2400 | - $title = sanitize_text_field( $item['title'] ); |
|
2401 | - $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field( $item['price'] ) ) ); |
|
2402 | - $options[ $item['id'] ] = "$title ($price)"; |
|
2400 | + $title = sanitize_text_field($item['title']); |
|
2401 | + $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); |
|
2402 | + $options[$item['id']] = "$title ($price)"; |
|
2403 | 2403 | |
2404 | - if ( ! isset( $selected_item ) ) { |
|
2405 | - $selected = array( $item['id'] ); |
|
2404 | + if (!isset($selected_item)) { |
|
2405 | + $selected = array($item['id']); |
|
2406 | 2406 | $selected_item = 1; |
2407 | 2407 | } |
2408 | 2408 | |
@@ -2429,31 +2429,31 @@ discard block |
||
2429 | 2429 | $tax = 0; |
2430 | 2430 | $sub_total = 0; |
2431 | 2431 | |
2432 | - foreach ( $items as $item ) { |
|
2432 | + foreach ($items as $item) { |
|
2433 | 2433 | |
2434 | 2434 | $class = 'col-8'; |
2435 | 2435 | $class2 = ''; |
2436 | 2436 | |
2437 | - if ( ! empty( $item['allow_quantities'] ) ) { |
|
2437 | + if (!empty($item['allow_quantities'])) { |
|
2438 | 2438 | $class = 'col-6 pt-2'; |
2439 | 2439 | $class2 = 'pt-2'; |
2440 | 2440 | } |
2441 | 2441 | |
2442 | - if ( ! empty( $item['custom_price'] ) ) { |
|
2442 | + if (!empty($item['custom_price'])) { |
|
2443 | 2443 | $class .= ' pt-2'; |
2444 | 2444 | } |
2445 | 2445 | |
2446 | 2446 | $class3 = 'd-none'; |
2447 | - $name = ''; |
|
2448 | - if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) { |
|
2447 | + $name = ''; |
|
2448 | + if (!empty($item['required']) || !isset($totals_selected_select_item)) { |
|
2449 | 2449 | |
2450 | - $amount = floatval( $item['price'] ); |
|
2451 | - if ( wpinv_use_taxes() ) { |
|
2450 | + $amount = floatval($item['price']); |
|
2451 | + if (wpinv_use_taxes()) { |
|
2452 | 2452 | |
2453 | - $rate = wpinv_get_tax_rate( wpinv_default_billing_country(), false, (int) $item['id'] ); |
|
2453 | + $rate = wpinv_get_tax_rate(wpinv_default_billing_country(), false, (int) $item['id']); |
|
2454 | 2454 | |
2455 | - if ( wpinv_prices_include_tax() ) { |
|
2456 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
2455 | + if (wpinv_prices_include_tax()) { |
|
2456 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
2457 | 2457 | $item_tax = $amount - $pre_tax; |
2458 | 2458 | } else { |
2459 | 2459 | $pre_tax = $amount; |
@@ -2465,13 +2465,13 @@ discard block |
||
2465 | 2465 | $total = $sub_total + $tax; |
2466 | 2466 | |
2467 | 2467 | } else { |
2468 | - $total = $total + $amount; |
|
2468 | + $total = $total + $amount; |
|
2469 | 2469 | } |
2470 | 2470 | |
2471 | 2471 | $class3 = ''; |
2472 | - $name = "wpinv-items[{$item['id']}]"; |
|
2472 | + $name = "wpinv-items[{$item['id']}]"; |
|
2473 | 2473 | |
2474 | - if ( empty( $item['required'] ) ) { |
|
2474 | + if (empty($item['required'])) { |
|
2475 | 2475 | $totals_selected_select_item = 1; |
2476 | 2476 | } |
2477 | 2477 | |
@@ -2483,9 +2483,9 @@ discard block |
||
2483 | 2483 | |
2484 | 2484 | <div class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>"> |
2485 | 2485 | <div class='row pl-2 pr-2 pt-2'> |
2486 | - <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div> |
|
2486 | + <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div> |
|
2487 | 2487 | |
2488 | - <?php if ( ! empty( $item['allow_quantities'] ) ) { ?> |
|
2488 | + <?php if (!empty($item['allow_quantities'])) { ?> |
|
2489 | 2489 | |
2490 | 2490 | <div class='col-2'> |
2491 | 2491 | <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required> |
@@ -2493,11 +2493,11 @@ discard block |
||
2493 | 2493 | |
2494 | 2494 | <?php } else { ?> |
2495 | 2495 | <input type='hidden' class='wpinv-item-quantity-input' value='1'> |
2496 | - <?php } if ( empty( $item['custom_price'] ) ) { ?> |
|
2496 | + <?php } if (empty($item['custom_price'])) { ?> |
|
2497 | 2497 | |
2498 | 2498 | <div class='col-4 <?php echo $class2; ?>'> |
2499 | - <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?> |
|
2500 | - <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'> |
|
2499 | + <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?> |
|
2500 | + <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'> |
|
2501 | 2501 | </div> |
2502 | 2502 | |
2503 | 2503 | <?php } else {?> |
@@ -2505,15 +2505,15 @@ discard block |
||
2505 | 2505 | <div class='col-4'> |
2506 | 2506 | <div class='input-group'> |
2507 | 2507 | |
2508 | - <?php if ( 'left' == wpinv_currency_position() ) { ?> |
|
2508 | + <?php if ('left' == wpinv_currency_position()) { ?> |
|
2509 | 2509 | <div class='input-group-prepend'> |
2510 | 2510 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2511 | 2511 | </div> |
2512 | 2512 | <?php } ?> |
2513 | 2513 | |
2514 | - <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'> |
|
2514 | + <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'> |
|
2515 | 2515 | |
2516 | - <?php if ( 'left' != wpinv_currency_position() ) { ?> |
|
2516 | + <?php if ('left' != wpinv_currency_position()) { ?> |
|
2517 | 2517 | <div class='input-group-append'> |
2518 | 2518 | <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span> |
2519 | 2519 | </div> |
@@ -2524,35 +2524,35 @@ discard block |
||
2524 | 2524 | <?php } ?> |
2525 | 2525 | |
2526 | 2526 | </div> |
2527 | - <?php if ( ! empty( $item['description'] )) { ?> |
|
2528 | - <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small> |
|
2527 | + <?php if (!empty($item['description'])) { ?> |
|
2528 | + <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small> |
|
2529 | 2529 | <?php } ?> |
2530 | 2530 | </div> |
2531 | 2531 | <?php } ?> |
2532 | 2532 | |
2533 | 2533 | <div class='mt-4 border-top item_totals_total p-2'> |
2534 | 2534 | |
2535 | - <?php if ( wpinv_use_taxes() ) { ?> |
|
2535 | + <?php if (wpinv_use_taxes()) { ?> |
|
2536 | 2536 | <div class='row'> |
2537 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div> |
|
2538 | - <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div> |
|
2537 | + <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div> |
|
2538 | + <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div> |
|
2539 | 2539 | </div> |
2540 | 2540 | <div class='row'> |
2541 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div> |
|
2542 | - <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div> |
|
2541 | + <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div> |
|
2542 | + <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div> |
|
2543 | 2543 | </div> |
2544 | 2544 | <?php } ?> |
2545 | 2545 | |
2546 | 2546 | <div class='row'> |
2547 | - <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div> |
|
2548 | - <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div> |
|
2547 | + <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div> |
|
2548 | + <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div> |
|
2549 | 2549 | </div> |
2550 | 2550 | </div> |
2551 | 2551 | |
2552 | 2552 | </div> |
2553 | 2553 | <?php } ?> |
2554 | - <?php if ( ! empty( $field[ 'description' ] ) ) { ?> |
|
2555 | - <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small> |
|
2554 | + <?php if (!empty($field['description'])) { ?> |
|
2555 | + <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small> |
|
2556 | 2556 | <?php } ?> |
2557 | 2557 | </div> |
2558 | 2558 | <?php |
@@ -2561,20 +2561,20 @@ discard block |
||
2561 | 2561 | /** |
2562 | 2562 | * Renders the items element template. |
2563 | 2563 | */ |
2564 | - public function edit_items_template( $field ) { |
|
2565 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
2566 | - $label = __( 'Let customers...', 'invoicing' ); |
|
2567 | - $label2 = __( 'Available Items', 'invoicing' ); |
|
2568 | - $label3 = esc_attr__( 'Add some help text for this element', 'invoicing' ); |
|
2564 | + public function edit_items_template($field) { |
|
2565 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
2566 | + $label = __('Let customers...', 'invoicing'); |
|
2567 | + $label2 = __('Available Items', 'invoicing'); |
|
2568 | + $label3 = esc_attr__('Add some help text for this element', 'invoicing'); |
|
2569 | 2569 | $id = $field . '.id + "_edit"'; |
2570 | 2570 | $id2 = $field . '.id + "_edit2"'; |
2571 | 2571 | $id3 = $field . '.id + "_edit3"'; |
2572 | 2572 | $id4 = $field . '.id + "_edit4"'; |
2573 | - $label4 = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' ); |
|
2574 | - $label5 = esc_attr__( 'Allow users to pay what they want', 'invoicing' ); |
|
2575 | - $label6 = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' ); |
|
2576 | - $label7 = esc_attr__( 'Allow users to buy several quantities', 'invoicing' ); |
|
2577 | - $label8 = esc_attr__( 'This item is required', 'invoicing' ); |
|
2573 | + $label4 = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing'); |
|
2574 | + $label5 = esc_attr__('Allow users to pay what they want', 'invoicing'); |
|
2575 | + $label6 = esc_attr__('Enter the minimum price that a user can pay', 'invoicing'); |
|
2576 | + $label7 = esc_attr__('Allow users to buy several quantities', 'invoicing'); |
|
2577 | + $label8 = esc_attr__('This item is required', 'invoicing'); |
|
2578 | 2578 | echo "<div $restrict> |
2579 | 2579 | |
2580 | 2580 | <label>$label2</label> |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | <div class='form-group mt-2'> |
2645 | 2645 | |
2646 | 2646 | <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'> |
2647 | - <option value=''>" . __( 'Add an existing item to the form', 'invoicing' ) ."</option> |
|
2647 | + <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option> |
|
2648 | 2648 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
2649 | 2649 | </select> |
2650 | 2650 | |
@@ -2659,11 +2659,11 @@ discard block |
||
2659 | 2659 | <label :for='$id2'>$label</label> |
2660 | 2660 | |
2661 | 2661 | <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'> |
2662 | - <option value='total'>" . __( 'Buy all items on the list', 'invoicing' ) ."</option> |
|
2663 | - <option value='radio'>" . __( 'Select a single item from the list', 'invoicing' ) ."</option> |
|
2664 | - <option value='checkbox'>" . __( 'Select one or more items on the list', 'invoicing' ) ."</option> |
|
2665 | - <option value='select'>" . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option> |
|
2666 | - <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option> |
|
2662 | + <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option> |
|
2663 | + <option value='radio'>" . __('Select a single item from the list', 'invoicing') . "</option> |
|
2664 | + <option value='checkbox'>" . __('Select one or more items on the list', 'invoicing') . "</option> |
|
2665 | + <option value='select'>" . __('Select a single item from a dropdown', 'invoicing') . "</option> |
|
2666 | + <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option> |
|
2667 | 2667 | </select> |
2668 | 2668 | |
2669 | 2669 | </div> |
@@ -2688,27 +2688,27 @@ discard block |
||
2688 | 2688 | 'orderby' => 'title', |
2689 | 2689 | 'order' => 'ASC', |
2690 | 2690 | 'posts_per_page' => -1, |
2691 | - 'post_status' => array( 'publish' ), |
|
2691 | + 'post_status' => array('publish'), |
|
2692 | 2692 | ); |
2693 | 2693 | |
2694 | - $items = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) ); |
|
2694 | + $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args)); |
|
2695 | 2695 | |
2696 | - if ( empty( $items ) ) { |
|
2696 | + if (empty($items)) { |
|
2697 | 2697 | return array(); |
2698 | 2698 | } |
2699 | 2699 | |
2700 | - $options = array(); |
|
2701 | - foreach ( $items as $item ) { |
|
2702 | - $title = esc_html( $item->post_title ); |
|
2703 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
2704 | - $id = absint( $item->ID ); |
|
2705 | - $price = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) ); |
|
2706 | - $recurring = (bool) get_post_meta( $id, '_wpinv_is_recurring', true ); |
|
2700 | + $options = array(); |
|
2701 | + foreach ($items as $item) { |
|
2702 | + $title = esc_html($item->post_title); |
|
2703 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
2704 | + $id = absint($item->ID); |
|
2705 | + $price = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true)); |
|
2706 | + $recurring = (bool) get_post_meta($id, '_wpinv_is_recurring', true); |
|
2707 | 2707 | $description = $item->post_excerpt; |
2708 | - $custom_price = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true ); |
|
2709 | - $minimum_price = (float) get_post_meta( $id, '_minimum_price', true ); |
|
2708 | + $custom_price = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true); |
|
2709 | + $minimum_price = (float) get_post_meta($id, '_minimum_price', true); |
|
2710 | 2710 | $allow_quantities = false; |
2711 | - $options[] = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' ); |
|
2711 | + $options[] = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities'); |
|
2712 | 2712 | |
2713 | 2713 | } |
2714 | 2714 | return $options; |
@@ -2718,47 +2718,47 @@ discard block |
||
2718 | 2718 | /** |
2719 | 2719 | * Returns an array of items for the currently being edited form. |
2720 | 2720 | */ |
2721 | - public function get_form_items( $id = false ) { |
|
2721 | + public function get_form_items($id = false) { |
|
2722 | 2722 | |
2723 | - if ( empty( $id ) ) { |
|
2724 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
2723 | + if (empty($id)) { |
|
2724 | + return wpinv_get_data('sample-payment-form-items'); |
|
2725 | 2725 | } |
2726 | 2726 | |
2727 | - $form_elements = get_post_meta( $id, 'wpinv_form_items', true ); |
|
2727 | + $form_elements = get_post_meta($id, 'wpinv_form_items', true); |
|
2728 | 2728 | |
2729 | - if ( is_array( $form_elements ) ) { |
|
2729 | + if (is_array($form_elements)) { |
|
2730 | 2730 | return $form_elements; |
2731 | 2731 | } |
2732 | 2732 | |
2733 | - return wpinv_get_data( 'sample-payment-form-items' ); |
|
2733 | + return wpinv_get_data('sample-payment-form-items'); |
|
2734 | 2734 | |
2735 | 2735 | } |
2736 | 2736 | |
2737 | 2737 | /** |
2738 | 2738 | * Returns an array of elements for the currently being edited form. |
2739 | 2739 | */ |
2740 | - public function get_form_elements( $id = false ) { |
|
2740 | + public function get_form_elements($id = false) { |
|
2741 | 2741 | |
2742 | - if ( empty( $id ) ) { |
|
2743 | - return wpinv_get_data( 'sample-payment-form' ); |
|
2742 | + if (empty($id)) { |
|
2743 | + return wpinv_get_data('sample-payment-form'); |
|
2744 | 2744 | } |
2745 | 2745 | |
2746 | - $form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
|
2746 | + $form_elements = get_post_meta($id, 'wpinv_form_elements', true); |
|
2747 | 2747 | |
2748 | - if ( is_array( $form_elements ) ) { |
|
2748 | + if (is_array($form_elements)) { |
|
2749 | 2749 | return $form_elements; |
2750 | 2750 | } |
2751 | 2751 | |
2752 | - return wpinv_get_data( 'sample-payment-form' ); |
|
2752 | + return wpinv_get_data('sample-payment-form'); |
|
2753 | 2753 | } |
2754 | 2754 | |
2755 | 2755 | /** |
2756 | 2756 | * Sends a redrect response to payment details. |
2757 | 2757 | * |
2758 | 2758 | */ |
2759 | - public function send_redirect_response( $url ) { |
|
2760 | - $url = urlencode( $url ); |
|
2761 | - wp_send_json_success( $url ); |
|
2759 | + public function send_redirect_response($url) { |
|
2760 | + $url = urlencode($url); |
|
2761 | + wp_send_json_success($url); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | /** |
@@ -2769,12 +2769,12 @@ discard block |
||
2769 | 2769 | |
2770 | 2770 | $errors = wpinv_get_errors(); |
2771 | 2771 | |
2772 | - if ( ! empty( $errors ) ) { |
|
2772 | + if (!empty($errors)) { |
|
2773 | 2773 | wpinv_print_errors(); |
2774 | 2774 | exit; |
2775 | 2775 | } |
2776 | 2776 | |
2777 | - wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) ); |
|
2777 | + wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing')); |
|
2778 | 2778 | exit; |
2779 | 2779 | |
2780 | 2780 | } |