@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -106,36 +106,36 @@ discard block |
||
106 | 106 | 'file_upload' => true, |
107 | 107 | ); |
108 | 108 | |
109 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
110 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
109 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
110 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | 112 | |
113 | - if ( $nopriv ) { |
|
114 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
115 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
116 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | + if ($nopriv) { |
|
114 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
115 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
116 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | 121 | public static function add_note() { |
122 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
122 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
123 | 123 | |
124 | - $post_id = absint( $_POST['post_id'] ); |
|
125 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
126 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
124 | + $post_id = absint($_POST['post_id']); |
|
125 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
126 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
127 | 127 | |
128 | - if ( ! wpinv_current_user_can( 'invoice_add_note', array( 'post_id' => $post_id, 'note_type' => $note_type ) ) ) { |
|
128 | + if (!wpinv_current_user_can('invoice_add_note', array('post_id' => $post_id, 'note_type' => $note_type))) { |
|
129 | 129 | die( -1 ); |
130 | 130 | } |
131 | 131 | |
132 | 132 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
133 | 133 | |
134 | - if ( $post_id > 0 ) { |
|
135 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
134 | + if ($post_id > 0) { |
|
135 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
136 | 136 | |
137 | - if ( $note_id > 0 && ! is_wp_error( $note_id ) ) { |
|
138 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
137 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
138 | + wpinv_get_invoice_note_line_item($note_id); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function delete_note() { |
146 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
146 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
147 | 147 | |
148 | - $note_id = (int)$_POST['note_id']; |
|
148 | + $note_id = (int) $_POST['note_id']; |
|
149 | 149 | |
150 | - if ( ! wpinv_current_user_can( 'invoice_delete_note', array( 'note_id' => $note_id ) ) ) { |
|
150 | + if (!wpinv_current_user_can('invoice_delete_note', array('note_id' => $note_id))) { |
|
151 | 151 | die( -1 ); |
152 | 152 | } |
153 | 153 | |
154 | - if ( $note_id > 0 ) { |
|
155 | - wp_delete_comment( $note_id, true ); |
|
154 | + if ($note_id > 0) { |
|
155 | + wp_delete_comment($note_id, true); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | die(); |
@@ -170,34 +170,34 @@ discard block |
||
170 | 170 | public static function get_billing_details() { |
171 | 171 | |
172 | 172 | // Verify nonce. |
173 | - check_ajax_referer( 'wpinv-nonce' ); |
|
173 | + check_ajax_referer('wpinv-nonce'); |
|
174 | 174 | |
175 | 175 | // Do we have a user id? |
176 | 176 | $user_id = (int) $_GET['user_id']; |
177 | 177 | |
178 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
178 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
179 | 179 | die( -1 ); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Can the user manage the plugin? |
183 | - if ( ! wpinv_current_user_can( 'user_get_billing_details', array( 'user_id' => $user_id ) ) ) { |
|
183 | + if (!wpinv_current_user_can('user_get_billing_details', array('user_id' => $user_id))) { |
|
184 | 184 | die( -1 ); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // Fetch the billing details. |
188 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
189 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
188 | + $billing_details = wpinv_get_user_address($user_id); |
|
189 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
190 | 190 | |
191 | 191 | // unset the user id and email. |
192 | - $to_ignore = array( 'user_id', 'email' ); |
|
192 | + $to_ignore = array('user_id', 'email'); |
|
193 | 193 | |
194 | - foreach ( $to_ignore as $key ) { |
|
195 | - if ( isset( $billing_details[ $key ] ) ) { |
|
196 | - unset( $billing_details[ $key ] ); |
|
194 | + foreach ($to_ignore as $key) { |
|
195 | + if (isset($billing_details[$key])) { |
|
196 | + unset($billing_details[$key]); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - wp_send_json_success( $billing_details ); |
|
200 | + wp_send_json_success($billing_details); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | public static function check_new_user_email() { |
208 | 208 | |
209 | 209 | // Verify nonce. |
210 | - check_ajax_referer( 'wpinv-nonce' ); |
|
210 | + check_ajax_referer('wpinv-nonce'); |
|
211 | 211 | |
212 | 212 | // Can the user manage the plugin? |
213 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
213 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
214 | 214 | die( -1 ); |
215 | 215 | } |
216 | 216 | |
217 | 217 | // We need an email address. |
218 | - if ( empty( $_GET['email'] ) ) { |
|
219 | - esc_html_e( "Provide the new user's email address", 'invoicing' ); |
|
218 | + if (empty($_GET['email'])) { |
|
219 | + esc_html_e("Provide the new user's email address", 'invoicing'); |
|
220 | 220 | exit; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Ensure the email is valid. |
224 | - $email = sanitize_email( $_GET['email'] ); |
|
225 | - if ( ! is_email( $email ) ) { |
|
226 | - esc_html_e( 'Invalid email address', 'invoicing' ); |
|
224 | + $email = sanitize_email($_GET['email']); |
|
225 | + if (!is_email($email)) { |
|
226 | + esc_html_e('Invalid email address', 'invoicing'); |
|
227 | 227 | exit; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // And it does not exist. |
231 | - $id = email_exists( $email ); |
|
232 | - if ( $id ) { |
|
233 | - wp_send_json_success( compact( 'id' ) ); |
|
231 | + $id = email_exists($email); |
|
232 | + if ($id) { |
|
233 | + wp_send_json_success(compact('id')); |
|
234 | 234 | } |
235 | 235 | |
236 | - wp_send_json_success( true ); |
|
236 | + wp_send_json_success(true); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | public static function run_tool() { |
240 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
241 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
240 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
241 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
242 | 242 | die( -1 ); |
243 | 243 | } |
244 | 244 | |
245 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
245 | + $tool = sanitize_text_field($_POST['tool']); |
|
246 | 246 | |
247 | - do_action( 'wpinv_run_tool' ); |
|
247 | + do_action('wpinv_run_tool'); |
|
248 | 248 | |
249 | - if ( ! empty( $tool ) ) { |
|
250 | - do_action( 'wpinv_tool_' . $tool ); |
|
249 | + if (!empty($tool)) { |
|
250 | + do_action('wpinv_tool_' . $tool); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | global $getpaid_force_checkbox; |
259 | 259 | |
260 | 260 | // Is the request set up correctly? |
261 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
261 | + if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) { |
|
262 | 262 | aui()->alert( |
263 | 263 | array( |
264 | 264 | 'type' => 'warning', |
265 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
265 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
266 | 266 | ), |
267 | 267 | true |
268 | 268 | ); |
@@ -270,29 +270,29 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // Payment form or button? |
273 | - if ( ! empty( $_GET['form'] ) ) { |
|
274 | - $form = sanitize_text_field( urldecode( $_GET['form'] ) ); |
|
273 | + if (!empty($_GET['form'])) { |
|
274 | + $form = sanitize_text_field(urldecode($_GET['form'])); |
|
275 | 275 | |
276 | - if ( false !== strpos( $form, '|' ) ) { |
|
277 | - $form_pos = strpos( $form, '|' ); |
|
278 | - $_items = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) ); |
|
279 | - $form = substr( $form, 0, $form_pos ); |
|
276 | + if (false !== strpos($form, '|')) { |
|
277 | + $form_pos = strpos($form, '|'); |
|
278 | + $_items = getpaid_convert_items_to_array(substr($form, $form_pos + 1)); |
|
279 | + $form = substr($form, 0, $form_pos); |
|
280 | 280 | |
281 | 281 | // Retrieve appropriate payment form. |
282 | - $payment_form = new GetPaid_Payment_Form( $form ); |
|
283 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
282 | + $payment_form = new GetPaid_Payment_Form($form); |
|
283 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
284 | 284 | |
285 | 285 | $items = array(); |
286 | 286 | $item_ids = array(); |
287 | 287 | |
288 | - foreach ( $_items as $item_id => $qty ) { |
|
289 | - if ( ! in_array( $item_id, $item_ids ) ) { |
|
290 | - $item = new GetPaid_Form_Item( $item_id ); |
|
291 | - $item->set_quantity( $qty ); |
|
288 | + foreach ($_items as $item_id => $qty) { |
|
289 | + if (!in_array($item_id, $item_ids)) { |
|
290 | + $item = new GetPaid_Form_Item($item_id); |
|
291 | + $item->set_quantity($qty); |
|
292 | 292 | |
293 | - if ( 0 == $qty ) { |
|
294 | - $item->set_allow_quantities( true ); |
|
295 | - $item->set_is_required( false ); |
|
293 | + if (0 == $qty) { |
|
294 | + $item->set_allow_quantities(true); |
|
295 | + $item->set_is_required(false); |
|
296 | 296 | $getpaid_force_checkbox = true; |
297 | 297 | } |
298 | 298 | |
@@ -301,32 +301,32 @@ discard block |
||
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - if ( ! $payment_form->is_default() ) { |
|
304 | + if (!$payment_form->is_default()) { |
|
305 | 305 | |
306 | - foreach ( $payment_form->get_items() as $item ) { |
|
307 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
306 | + foreach ($payment_form->get_items() as $item) { |
|
307 | + if (!in_array($item->get_id(), $item_ids)) { |
|
308 | 308 | $item_ids[] = $item->get_id(); |
309 | 309 | $items[] = $item; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - $payment_form->set_items( $items ); |
|
315 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $_items ) ); |
|
316 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
314 | + $payment_form->set_items($items); |
|
315 | + $extra_items = esc_attr(getpaid_convert_items_to_string($_items)); |
|
316 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
317 | 317 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
318 | 318 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
319 | - $payment_form->display( $extra_items ); |
|
319 | + $payment_form->display($extra_items); |
|
320 | 320 | $getpaid_force_checkbox = false; |
321 | 321 | |
322 | 322 | } else { |
323 | - getpaid_display_payment_form( $form ); |
|
323 | + getpaid_display_payment_form($form); |
|
324 | 324 | } |
325 | -} elseif ( ! empty( $_GET['invoice'] ) ) { |
|
326 | - getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) ); |
|
325 | +} elseif (!empty($_GET['invoice'])) { |
|
326 | + getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice'])); |
|
327 | 327 | } else { |
328 | - $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) ); |
|
329 | - getpaid_display_item_payment_form( $items ); |
|
328 | + $items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item']))); |
|
329 | + getpaid_display_item_payment_form($items); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | exit; |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | public static function payment_form() { |
342 | 342 | |
343 | 343 | // ... form fields... |
344 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
345 | - esc_html_e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
344 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
345 | + esc_html_e('Error: Reload the page and try again.', 'invoicing'); |
|
346 | 346 | exit; |
347 | 347 | } |
348 | 348 | |
349 | 349 | // Process the payment form. |
350 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
351 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
350 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
351 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
352 | 352 | $checkout->process_checkout(); |
353 | 353 | |
354 | 354 | exit; |
@@ -361,55 +361,55 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function get_payment_form_states_field() { |
363 | 363 | |
364 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
364 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
365 | 365 | exit; |
366 | 366 | } |
367 | 367 | |
368 | - $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] ); |
|
368 | + $elements = getpaid_get_payment_form_elements((int) $_GET['form']); |
|
369 | 369 | |
370 | - if ( empty( $elements ) ) { |
|
370 | + if (empty($elements)) { |
|
371 | 371 | exit; |
372 | 372 | } |
373 | 373 | |
374 | 374 | $address_fields = array(); |
375 | - foreach ( $elements as $element ) { |
|
376 | - if ( 'address' === $element['type'] ) { |
|
375 | + foreach ($elements as $element) { |
|
376 | + if ('address' === $element['type']) { |
|
377 | 377 | $address_fields = $element; |
378 | 378 | break; |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | - if ( empty( $address_fields ) ) { |
|
382 | + if (empty($address_fields)) { |
|
383 | 383 | exit; |
384 | 384 | } |
385 | 385 | |
386 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
386 | + foreach ($address_fields['fields'] as $address_field) { |
|
387 | 387 | |
388 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
388 | + if ('wpinv_state' == $address_field['name']) { |
|
389 | 389 | |
390 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
391 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
392 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
393 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
394 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
395 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
390 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
391 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
392 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
393 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
394 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
395 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
396 | 396 | |
397 | - if ( ! empty( $address_field['required'] ) ) { |
|
397 | + if (!empty($address_field['required'])) { |
|
398 | 398 | $label .= "<span class='text-danger'> *</span>"; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $html = getpaid_get_states_select_markup( |
402 | - sanitize_text_field( $_GET['country'] ), |
|
402 | + sanitize_text_field($_GET['country']), |
|
403 | 403 | $value, |
404 | 404 | $placeholder, |
405 | 405 | $label, |
406 | 406 | $description, |
407 | - ! empty( $address_field['required'] ), |
|
407 | + !empty($address_field['required']), |
|
408 | 408 | $wrap_class, |
409 | - sanitize_text_field( $_GET['name'] ) |
|
409 | + sanitize_text_field($_GET['name']) |
|
410 | 410 | ); |
411 | 411 | |
412 | - wp_send_json_success( $html ); |
|
412 | + wp_send_json_success($html); |
|
413 | 413 | exit; |
414 | 414 | |
415 | 415 | } |
@@ -424,66 +424,66 @@ discard block |
||
424 | 424 | public static function recalculate_invoice_totals() { |
425 | 425 | |
426 | 426 | // Verify nonce. |
427 | - check_ajax_referer( 'wpinv-nonce' ); |
|
427 | + check_ajax_referer('wpinv-nonce'); |
|
428 | 428 | |
429 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
429 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
430 | 430 | exit; |
431 | 431 | } |
432 | 432 | |
433 | 433 | // We need an invoice. |
434 | - if ( empty( $_POST['post_id'] ) ) { |
|
434 | + if (empty($_POST['post_id'])) { |
|
435 | 435 | exit; |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Fetch the invoice. |
439 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
439 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
440 | 440 | |
441 | 441 | // Ensure it exists. |
442 | - if ( ! $invoice->get_id() ) { |
|
442 | + if (!$invoice->get_id()) { |
|
443 | 443 | exit; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Maybe set the country, state, currency. |
447 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) { |
|
448 | - if ( isset( $_POST[ $key ] ) ) { |
|
447 | + foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) { |
|
448 | + if (isset($_POST[$key])) { |
|
449 | 449 | $method = "set_$key"; |
450 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
450 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Maybe disable taxes. |
455 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
455 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
456 | 456 | |
457 | 457 | // Discount code. |
458 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
459 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
460 | - if ( $discount->exists() ) { |
|
461 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
458 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
459 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
460 | + if ($discount->exists()) { |
|
461 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
462 | 462 | } else { |
463 | - $invoice->remove_discount( 'discount_code' ); |
|
463 | + $invoice->remove_discount('discount_code'); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | // Recalculate totals. |
468 | 468 | $invoice->recalculate_total(); |
469 | 469 | |
470 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
471 | - $suscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
472 | - if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
473 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
474 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
470 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
471 | + $suscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
472 | + if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
473 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
474 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | $totals = array( |
478 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
479 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
480 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
478 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
479 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
480 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
481 | 481 | 'total' => $total, |
482 | 482 | ); |
483 | 483 | |
484 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
484 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
485 | 485 | |
486 | - wp_send_json_success( compact( 'totals' ) ); |
|
486 | + wp_send_json_success(compact('totals')); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -492,33 +492,33 @@ discard block |
||
492 | 492 | public static function get_invoice_items() { |
493 | 493 | |
494 | 494 | // Verify nonce. |
495 | - check_ajax_referer( 'wpinv-nonce' ); |
|
495 | + check_ajax_referer('wpinv-nonce'); |
|
496 | 496 | |
497 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
497 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
498 | 498 | exit; |
499 | 499 | } |
500 | 500 | |
501 | 501 | // We need an invoice and items. |
502 | - if ( empty( $_POST['post_id'] ) ) { |
|
502 | + if (empty($_POST['post_id'])) { |
|
503 | 503 | exit; |
504 | 504 | } |
505 | 505 | |
506 | 506 | // Fetch the invoice. |
507 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
507 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
508 | 508 | |
509 | 509 | // Ensure it exists. |
510 | - if ( ! $invoice->get_id() ) { |
|
510 | + if (!$invoice->get_id()) { |
|
511 | 511 | exit; |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Return an array of invoice items. |
515 | 515 | $items = array(); |
516 | 516 | |
517 | - foreach ( $invoice->get_items() as $item ) { |
|
518 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
517 | + foreach ($invoice->get_items() as $item) { |
|
518 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
519 | 519 | } |
520 | 520 | |
521 | - wp_send_json_success( compact( 'items' ) ); |
|
521 | + wp_send_json_success(compact('items')); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -527,50 +527,50 @@ discard block |
||
527 | 527 | public static function edit_invoice_item() { |
528 | 528 | |
529 | 529 | // Verify nonce. |
530 | - check_ajax_referer( 'wpinv-nonce' ); |
|
530 | + check_ajax_referer('wpinv-nonce'); |
|
531 | 531 | |
532 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
532 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
533 | 533 | exit; |
534 | 534 | } |
535 | 535 | |
536 | 536 | // We need an invoice and item details. |
537 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
537 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
538 | 538 | exit; |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Fetch the invoice. |
542 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
542 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
543 | 543 | |
544 | 544 | // Ensure it exists and its not been paid for. |
545 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
545 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
546 | 546 | exit; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Format the data. |
550 | - $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) ); |
|
550 | + $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'))); |
|
551 | 551 | |
552 | 552 | // Ensure that we have an item id. |
553 | - if ( empty( $data['id'] ) ) { |
|
553 | + if (empty($data['id'])) { |
|
554 | 554 | exit; |
555 | 555 | } |
556 | 556 | |
557 | 557 | // Abort if the invoice does not have the specified item. |
558 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
558 | + $item = $invoice->get_item((int) $data['id']); |
|
559 | 559 | |
560 | - if ( empty( $item ) ) { |
|
560 | + if (empty($item)) { |
|
561 | 561 | exit; |
562 | 562 | } |
563 | 563 | |
564 | 564 | // Update the item. |
565 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
566 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
567 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
568 | - $item->set_quantity( floatval( $data['quantity'] ) ); |
|
565 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
566 | + $item->set_name(sanitize_text_field($data['name'])); |
|
567 | + $item->set_description(wp_kses_post($data['description'])); |
|
568 | + $item->set_quantity(floatval($data['quantity'])); |
|
569 | 569 | |
570 | 570 | // Add it to the invoice. |
571 | - $error = $invoice->add_item( $item ); |
|
571 | + $error = $invoice->add_item($item); |
|
572 | 572 | $alert = false; |
573 | - if ( is_wp_error( $error ) ) { |
|
573 | + if (is_wp_error($error)) { |
|
574 | 574 | $alert = $error->get_error_message(); |
575 | 575 | } |
576 | 576 | |
@@ -583,11 +583,11 @@ discard block |
||
583 | 583 | // Return an array of invoice items. |
584 | 584 | $items = array(); |
585 | 585 | |
586 | - foreach ( $invoice->get_items() as $item ) { |
|
587 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
586 | + foreach ($invoice->get_items() as $item) { |
|
587 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
588 | 588 | } |
589 | 589 | |
590 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
590 | + wp_send_json_success(compact('items', 'alert')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -596,57 +596,57 @@ discard block |
||
596 | 596 | public static function create_invoice_item() { |
597 | 597 | |
598 | 598 | // Verify nonce. |
599 | - check_ajax_referer( 'wpinv-nonce' ); |
|
599 | + check_ajax_referer('wpinv-nonce'); |
|
600 | 600 | |
601 | 601 | // We need an invoice and item details. |
602 | - if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) { |
|
602 | + if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) { |
|
603 | 603 | exit; |
604 | 604 | } |
605 | 605 | |
606 | 606 | // Fetch the invoice. |
607 | - $invoice = new WPInv_Invoice( intval( $_POST['invoice_id'] ) ); |
|
607 | + $invoice = new WPInv_Invoice(intval($_POST['invoice_id'])); |
|
608 | 608 | |
609 | 609 | // Ensure it exists and its not been paid for. |
610 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
610 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
611 | 611 | exit; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! wpinv_current_user_can( 'invoice_create_item', array( 'invoice' => $invoice ) ) ) { |
|
614 | + if (!wpinv_current_user_can('invoice_create_item', array('invoice' => $invoice))) { |
|
615 | 615 | exit; |
616 | 616 | } |
617 | 617 | |
618 | 618 | // Format the data. |
619 | - $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) ); |
|
619 | + $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick'])); |
|
620 | 620 | |
621 | 621 | $item = new WPInv_Item(); |
622 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
623 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
624 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
625 | - $item->set_type( sanitize_text_field( $data['type'] ) ); |
|
626 | - $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) ); |
|
627 | - $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) ); |
|
628 | - $item->set_status( 'publish' ); |
|
622 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
623 | + $item->set_name(sanitize_text_field($data['name'])); |
|
624 | + $item->set_description(wp_kses_post($data['description'])); |
|
625 | + $item->set_type(sanitize_text_field($data['type'])); |
|
626 | + $item->set_vat_rule(sanitize_text_field($data['vat_rule'])); |
|
627 | + $item->set_vat_class(sanitize_text_field($data['vat_class'])); |
|
628 | + $item->set_status('publish'); |
|
629 | 629 | $item->save(); |
630 | 630 | |
631 | - if ( ! $item->exists() ) { |
|
632 | - $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' ); |
|
633 | - wp_send_json_success( compact( 'alert' ) ); |
|
631 | + if (!$item->exists()) { |
|
632 | + $alert = __('Could not create invoice item. Please try again.', 'invoicing'); |
|
633 | + wp_send_json_success(compact('alert')); |
|
634 | 634 | } |
635 | 635 | |
636 | - if ( ! empty( $data['one-time'] ) ) { |
|
637 | - update_post_meta( $item->get_id(), '_wpinv_one_time', 'yes' ); |
|
636 | + if (!empty($data['one-time'])) { |
|
637 | + update_post_meta($item->get_id(), '_wpinv_one_time', 'yes'); |
|
638 | 638 | } |
639 | 639 | |
640 | - $item = new GetPaid_Form_Item( $item->get_id() ); |
|
641 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
640 | + $item = new GetPaid_Form_Item($item->get_id()); |
|
641 | + $item->set_quantity(floatval($data['qty'])); |
|
642 | 642 | |
643 | 643 | // Add it to the invoice. |
644 | - $error = $invoice->add_item( $item ); |
|
644 | + $error = $invoice->add_item($item); |
|
645 | 645 | $alert = false; |
646 | 646 | |
647 | - if ( is_wp_error( $error ) ) { |
|
647 | + if (is_wp_error($error)) { |
|
648 | 648 | $alert = $error->get_error_message(); |
649 | - wp_send_json_success( compact( 'alert' ) ); |
|
649 | + wp_send_json_success(compact('alert')); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | // Update totals. |
@@ -659,9 +659,9 @@ discard block |
||
659 | 659 | $invoice->recalculate_total(); |
660 | 660 | $invoice->save(); |
661 | 661 | ob_start(); |
662 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
662 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
663 | 663 | $row = ob_get_clean(); |
664 | - wp_send_json_success( compact( 'row' ) ); |
|
664 | + wp_send_json_success(compact('row')); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -670,33 +670,33 @@ discard block |
||
670 | 670 | public static function remove_invoice_item() { |
671 | 671 | |
672 | 672 | // Verify nonce. |
673 | - check_ajax_referer( 'wpinv-nonce' ); |
|
673 | + check_ajax_referer('wpinv-nonce'); |
|
674 | 674 | |
675 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
675 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
676 | 676 | exit; |
677 | 677 | } |
678 | 678 | |
679 | 679 | // We need an invoice and an item. |
680 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
680 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
681 | 681 | exit; |
682 | 682 | } |
683 | 683 | |
684 | 684 | // Fetch the invoice. |
685 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
685 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
686 | 686 | |
687 | 687 | // Ensure it exists and its not been paid for. |
688 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
688 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
689 | 689 | exit; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Abort if the invoice does not have the specified item. |
693 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
693 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
694 | 694 | |
695 | - if ( empty( $item ) ) { |
|
695 | + if (empty($item)) { |
|
696 | 696 | exit; |
697 | 697 | } |
698 | 698 | |
699 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
699 | + $invoice->remove_item((int) $_POST['item_id']); |
|
700 | 700 | |
701 | 701 | // Update totals. |
702 | 702 | $invoice->recalculate_total(); |
@@ -707,11 +707,11 @@ discard block |
||
707 | 707 | // Return an array of invoice items. |
708 | 708 | $items = array(); |
709 | 709 | |
710 | - foreach ( $invoice->get_items() as $item ) { |
|
711 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
710 | + foreach ($invoice->get_items() as $item) { |
|
711 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
712 | 712 | } |
713 | 713 | |
714 | - wp_send_json_success( compact( 'items' ) ); |
|
714 | + wp_send_json_success(compact('items')); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -720,68 +720,68 @@ discard block |
||
720 | 720 | public static function recalculate_full_prices() { |
721 | 721 | |
722 | 722 | // Verify nonce. |
723 | - check_ajax_referer( 'wpinv-nonce' ); |
|
723 | + check_ajax_referer('wpinv-nonce'); |
|
724 | 724 | |
725 | 725 | // We need an invoice and item. |
726 | - if ( empty( $_POST['post_id'] ) ) { |
|
726 | + if (empty($_POST['post_id'])) { |
|
727 | 727 | exit; |
728 | 728 | } |
729 | 729 | |
730 | 730 | // Fetch the invoice. |
731 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
731 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
732 | 732 | $alert = false; |
733 | 733 | |
734 | 734 | // Ensure it exists and its not been paid for. |
735 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
735 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
736 | 736 | exit; |
737 | 737 | } |
738 | 738 | |
739 | - if ( ! wpinv_current_user_can( 'invoice_recalculate_full_prices', array( 'invoice' => $invoice ) ) ) { |
|
739 | + if (!wpinv_current_user_can('invoice_recalculate_full_prices', array('invoice' => $invoice))) { |
|
740 | 740 | exit; |
741 | 741 | } |
742 | 742 | |
743 | - $invoice->set_items( array() ); |
|
743 | + $invoice->set_items(array()); |
|
744 | 744 | |
745 | - if ( ! empty( $_POST['getpaid_items'] ) ) { |
|
745 | + if (!empty($_POST['getpaid_items'])) { |
|
746 | 746 | |
747 | - foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) { |
|
748 | - $item = new GetPaid_Form_Item( $item_id ); |
|
747 | + foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) { |
|
748 | + $item = new GetPaid_Form_Item($item_id); |
|
749 | 749 | |
750 | - if ( $item->exists() ) { |
|
751 | - $item->set_price( getpaid_standardize_amount( $args['price'] ) ); |
|
752 | - $item->set_quantity( floatval( $args['quantity'] ) ); |
|
753 | - $item->set_name( sanitize_text_field( $args['name'] ) ); |
|
754 | - $item->set_description( wp_kses_post( $args['description'] ) ); |
|
755 | - $invoice->add_item( $item ); |
|
750 | + if ($item->exists()) { |
|
751 | + $item->set_price(getpaid_standardize_amount($args['price'])); |
|
752 | + $item->set_quantity(floatval($args['quantity'])); |
|
753 | + $item->set_name(sanitize_text_field($args['name'])); |
|
754 | + $item->set_description(wp_kses_post($args['description'])); |
|
755 | + $invoice->add_item($item); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
760 | - $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) ); |
|
760 | + $invoice->set_disable_taxes(!empty($_POST['disable_taxes'])); |
|
761 | 761 | |
762 | 762 | // Maybe set the country, state, currency. |
763 | - foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) { |
|
764 | - if ( isset( $_POST[ $key ] ) ) { |
|
765 | - $_key = str_replace( 'wpinv_', '', $key ); |
|
763 | + foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) { |
|
764 | + if (isset($_POST[$key])) { |
|
765 | + $_key = str_replace('wpinv_', '', $key); |
|
766 | 766 | $method = "set_$_key"; |
767 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
767 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | |
771 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
772 | - if ( $discount->exists() ) { |
|
773 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
771 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
772 | + if ($discount->exists()) { |
|
773 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
774 | 774 | } else { |
775 | - $invoice->remove_discount( 'discount_code' ); |
|
775 | + $invoice->remove_discount('discount_code'); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | // Save the invoice. |
779 | 779 | $invoice->recalculate_total(); |
780 | 780 | $invoice->save(); |
781 | 781 | ob_start(); |
782 | - GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice ); |
|
782 | + GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice); |
|
783 | 783 | $table = ob_get_clean(); |
784 | - wp_send_json_success( compact( 'table' ) ); |
|
784 | + wp_send_json_success(compact('table')); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -790,43 +790,43 @@ discard block |
||
790 | 790 | public static function admin_add_invoice_item() { |
791 | 791 | |
792 | 792 | // Verify nonce. |
793 | - check_ajax_referer( 'wpinv-nonce' ); |
|
793 | + check_ajax_referer('wpinv-nonce'); |
|
794 | 794 | |
795 | 795 | // We need an invoice and item. |
796 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
796 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
797 | 797 | exit; |
798 | 798 | } |
799 | 799 | |
800 | 800 | // Fetch the invoice. |
801 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
801 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
802 | 802 | $alert = false; |
803 | 803 | |
804 | 804 | // Ensure it exists and its not been paid for. |
805 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
805 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
806 | 806 | exit; |
807 | 807 | } |
808 | 808 | |
809 | 809 | // Add the item. |
810 | - $item = new GetPaid_Form_Item( (int) $_POST['item_id'] ); |
|
810 | + $item = new GetPaid_Form_Item((int) $_POST['item_id']); |
|
811 | 811 | |
812 | - if ( ! wpinv_current_user_can( 'invoice_add_item', array( 'invoice' => $invoice, 'invoice_item' => $item ) ) ) { |
|
812 | + if (!wpinv_current_user_can('invoice_add_item', array('invoice' => $invoice, 'invoice_item' => $item))) { |
|
813 | 813 | exit; |
814 | 814 | } |
815 | 815 | |
816 | - $error = $invoice->add_item( $item ); |
|
816 | + $error = $invoice->add_item($item); |
|
817 | 817 | |
818 | - if ( is_wp_error( $error ) ) { |
|
818 | + if (is_wp_error($error)) { |
|
819 | 819 | $alert = $error->get_error_message(); |
820 | - wp_send_json_success( compact( 'alert' ) ); |
|
820 | + wp_send_json_success(compact('alert')); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | // Save the invoice. |
824 | 824 | $invoice->recalculate_total(); |
825 | 825 | $invoice->save(); |
826 | 826 | ob_start(); |
827 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
827 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
828 | 828 | $row = ob_get_clean(); |
829 | - wp_send_json_success( compact( 'row' ) ); |
|
829 | + wp_send_json_success(compact('row')); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -835,39 +835,39 @@ discard block |
||
835 | 835 | public static function add_invoice_items() { |
836 | 836 | |
837 | 837 | // Verify nonce. |
838 | - check_ajax_referer( 'wpinv-nonce' ); |
|
838 | + check_ajax_referer('wpinv-nonce'); |
|
839 | 839 | |
840 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
840 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
841 | 841 | exit; |
842 | 842 | } |
843 | 843 | |
844 | 844 | // We need an invoice and items. |
845 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
845 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
846 | 846 | exit; |
847 | 847 | } |
848 | 848 | |
849 | 849 | // Fetch the invoice. |
850 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
850 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
851 | 851 | $alert = false; |
852 | 852 | |
853 | 853 | // Ensure it exists and its not been paid for. |
854 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
854 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
855 | 855 | exit; |
856 | 856 | } |
857 | 857 | |
858 | 858 | // Add the items. |
859 | - foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) { |
|
859 | + foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) { |
|
860 | 860 | |
861 | - $item = new GetPaid_Form_Item( (int) $data['id'] ); |
|
861 | + $item = new GetPaid_Form_Item((int) $data['id']); |
|
862 | 862 | |
863 | - if ( is_numeric( $data['qty'] ) && (float) $data['qty'] > 0 ) { |
|
864 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
863 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
864 | + $item->set_quantity(floatval($data['qty'])); |
|
865 | 865 | } |
866 | 866 | |
867 | - if ( $item->get_id() > 0 ) { |
|
868 | - $error = $invoice->add_item( $item ); |
|
867 | + if ($item->get_id() > 0) { |
|
868 | + $error = $invoice->add_item($item); |
|
869 | 869 | |
870 | - if ( is_wp_error( $error ) ) { |
|
870 | + if (is_wp_error($error)) { |
|
871 | 871 | $alert = $error->get_error_message(); |
872 | 872 | } |
873 | 873 | } |
@@ -880,11 +880,11 @@ discard block |
||
880 | 880 | // Return an array of invoice items. |
881 | 881 | $items = array(); |
882 | 882 | |
883 | - foreach ( $invoice->get_items() as $item ) { |
|
884 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
883 | + foreach ($invoice->get_items() as $item) { |
|
884 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
885 | 885 | } |
886 | 886 | |
887 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
887 | + wp_send_json_success(compact('items', 'alert')); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -893,15 +893,15 @@ discard block |
||
893 | 893 | public static function get_invoicing_items() { |
894 | 894 | |
895 | 895 | // Verify nonce. |
896 | - check_ajax_referer( 'wpinv-nonce' ); |
|
896 | + check_ajax_referer('wpinv-nonce'); |
|
897 | 897 | |
898 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
898 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
899 | 899 | exit; |
900 | 900 | } |
901 | 901 | |
902 | 902 | // We need a search term. |
903 | - if ( empty( $_GET['search'] ) ) { |
|
904 | - wp_send_json_success( array() ); |
|
903 | + if (empty($_GET['search'])) { |
|
904 | + wp_send_json_success(array()); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | // Retrieve items. |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | 'orderby' => 'title', |
911 | 911 | 'order' => 'ASC', |
912 | 912 | 'posts_per_page' => -1, |
913 | - 'post_status' => array( 'publish' ), |
|
914 | - 's' => sanitize_text_field( urldecode( $_GET['search'] ) ), |
|
913 | + 'post_status' => array('publish'), |
|
914 | + 's' => sanitize_text_field(urldecode($_GET['search'])), |
|
915 | 915 | 'meta_query' => array( |
916 | 916 | array( |
917 | 917 | 'key' => '_wpinv_type', |
@@ -921,25 +921,25 @@ discard block |
||
921 | 921 | ), |
922 | 922 | ); |
923 | 923 | |
924 | - if ( ! empty( $_GET['ignore'] ) ) { |
|
925 | - $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) ); |
|
924 | + if (!empty($_GET['ignore'])) { |
|
925 | + $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore'])); |
|
926 | 926 | } |
927 | 927 | |
928 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
928 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
929 | 929 | $data = array(); |
930 | 930 | |
931 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) ); |
|
931 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id'])); |
|
932 | 932 | |
933 | - foreach ( $items as $item ) { |
|
934 | - $item = new GetPaid_Form_Item( $item ); |
|
933 | + foreach ($items as $item) { |
|
934 | + $item = new GetPaid_Form_Item($item); |
|
935 | 935 | $data[] = array( |
936 | 936 | 'id' => (int) $item->get_id(), |
937 | - 'text' => strip_tags( $item->get_name() ), |
|
938 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
937 | + 'text' => strip_tags($item->get_name()), |
|
938 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
939 | 939 | ); |
940 | 940 | } |
941 | 941 | |
942 | - wp_send_json_success( $data ); |
|
942 | + wp_send_json_success($data); |
|
943 | 943 | |
944 | 944 | } |
945 | 945 | |
@@ -949,37 +949,37 @@ discard block |
||
949 | 949 | public static function get_customers() { |
950 | 950 | |
951 | 951 | // Verify nonce. |
952 | - check_ajax_referer( 'wpinv-nonce' ); |
|
952 | + check_ajax_referer('wpinv-nonce'); |
|
953 | 953 | |
954 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
954 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
955 | 955 | exit; |
956 | 956 | } |
957 | 957 | |
958 | 958 | // We need a search term. |
959 | - if ( empty( $_GET['search'] ) ) { |
|
960 | - wp_send_json_success( array() ); |
|
959 | + if (empty($_GET['search'])) { |
|
960 | + wp_send_json_success(array()); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | // Retrieve customers. |
964 | 964 | |
965 | 965 | $customer_args = array( |
966 | - 'fields' => array( 'ID', 'user_email', 'display_name' ), |
|
966 | + 'fields' => array('ID', 'user_email', 'display_name'), |
|
967 | 967 | 'orderby' => 'display_name', |
968 | - 'search' => '*' . sanitize_text_field( $_GET['search'] ) . '*', |
|
969 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
968 | + 'search' => '*' . sanitize_text_field($_GET['search']) . '*', |
|
969 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
970 | 970 | ); |
971 | 971 | |
972 | - $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) ); |
|
972 | + $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args)); |
|
973 | 973 | $data = array(); |
974 | 974 | |
975 | - foreach ( $customers as $customer ) { |
|
975 | + foreach ($customers as $customer) { |
|
976 | 976 | $data[] = array( |
977 | 977 | 'id' => (int) $customer->ID, |
978 | - 'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ), |
|
978 | + 'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)), |
|
979 | 979 | ); |
980 | 980 | } |
981 | 981 | |
982 | - wp_send_json_success( $data ); |
|
982 | + wp_send_json_success($data); |
|
983 | 983 | |
984 | 984 | } |
985 | 985 | |
@@ -989,25 +989,25 @@ discard block |
||
989 | 989 | public static function get_aui_states_field() { |
990 | 990 | |
991 | 991 | // We need a country. |
992 | - if ( empty( $_GET['country'] ) ) { |
|
992 | + if (empty($_GET['country'])) { |
|
993 | 993 | exit; |
994 | 994 | } |
995 | 995 | |
996 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
997 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
998 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
999 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
996 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
997 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
998 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
999 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
1000 | 1000 | |
1001 | - if ( empty( $states ) ) { |
|
1001 | + if (empty($states)) { |
|
1002 | 1002 | |
1003 | 1003 | $html = aui()->input( |
1004 | 1004 | array( |
1005 | 1005 | 'type' => 'text', |
1006 | 1006 | 'id' => 'wpinv_state', |
1007 | 1007 | 'name' => $name, |
1008 | - 'label' => __( 'State', 'invoicing' ), |
|
1008 | + 'label' => __('State', 'invoicing'), |
|
1009 | 1009 | 'label_type' => 'vertical', |
1010 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
1010 | + 'placeholder' => __('State', 'invoicing'), |
|
1011 | 1011 | 'class' => $class, |
1012 | 1012 | 'value' => $state, |
1013 | 1013 | ) |
@@ -1019,9 +1019,9 @@ discard block |
||
1019 | 1019 | array( |
1020 | 1020 | 'id' => 'wpinv_state', |
1021 | 1021 | 'name' => $name, |
1022 | - 'label' => __( 'State', 'invoicing' ), |
|
1022 | + 'label' => __('State', 'invoicing'), |
|
1023 | 1023 | 'label_type' => 'vertical', |
1024 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
1024 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
1025 | 1025 | 'class' => $class, |
1026 | 1026 | 'value' => $state, |
1027 | 1027 | 'options' => $states, |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | wp_send_json_success( |
1036 | 1036 | array( |
1037 | 1037 | 'html' => $html, |
1038 | - 'select' => ! empty( $states ), |
|
1038 | + 'select' => !empty($states), |
|
1039 | 1039 | ) |
1040 | 1040 | ); |
1041 | 1041 | |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | public static function payment_form_refresh_prices() { |
1050 | 1050 | |
1051 | 1051 | // ... form fields... |
1052 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
1053 | - esc_html_e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
1052 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
1053 | + esc_html_e('Error: Reload the page and try again.', 'invoicing'); |
|
1054 | 1054 | exit; |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | $submission = new GetPaid_Payment_Form_Submission(); |
1059 | 1059 | |
1060 | 1060 | // Do we have an error? |
1061 | - if ( ! empty( $submission->last_error ) ) { |
|
1061 | + if (!empty($submission->last_error)) { |
|
1062 | 1062 | wp_send_json_error( |
1063 | 1063 | array( |
1064 | 1064 | 'code' => $submission->last_error_code, |
@@ -1068,12 +1068,12 @@ discard block |
||
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | // Prepare the response. |
1071 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
1071 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
1072 | 1072 | |
1073 | 1073 | // Filter the response. |
1074 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
1074 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
1075 | 1075 | |
1076 | - wp_send_json_success( $response ); |
|
1076 | + wp_send_json_success($response); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /** |
@@ -1085,63 +1085,63 @@ discard block |
||
1085 | 1085 | public static function file_upload() { |
1086 | 1086 | |
1087 | 1087 | // Check nonce. |
1088 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1088 | + check_ajax_referer('getpaid_form_nonce'); |
|
1089 | 1089 | |
1090 | - if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) { |
|
1091 | - wp_die( esc_html_e( 'Bad Request', 'invoicing' ), 400 ); |
|
1090 | + if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) { |
|
1091 | + wp_die(esc_html_e('Bad Request', 'invoicing'), 400); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | // Fetch form. |
1095 | - $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) ); |
|
1095 | + $form = new GetPaid_Payment_Form(intval($_POST['form_id'])); |
|
1096 | 1096 | |
1097 | - if ( ! $form->is_active() ) { |
|
1098 | - wp_send_json_error( __( 'Payment form not active', 'invoicing' ) ); |
|
1097 | + if (!$form->is_active()) { |
|
1098 | + wp_send_json_error(__('Payment form not active', 'invoicing')); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | // Fetch appropriate field. |
1102 | - $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) ); |
|
1103 | - if ( empty( $upload_field ) ) { |
|
1104 | - wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) ); |
|
1102 | + $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name'])))); |
|
1103 | + if (empty($upload_field)) { |
|
1104 | + wp_send_json_error(__('Invalid upload field.', 'invoicing')); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | // Prepare allowed file types. |
1108 | - $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' ); |
|
1108 | + $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png'); |
|
1109 | 1109 | $all_types = getpaid_get_allowed_mime_types(); |
1110 | 1110 | $mime_types = array(); |
1111 | 1111 | |
1112 | - foreach ( $file_types as $file_type ) { |
|
1113 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
1114 | - $mime_types[] = $all_types[ $file_type ]; |
|
1112 | + foreach ($file_types as $file_type) { |
|
1113 | + if (isset($all_types[$file_type])) { |
|
1114 | + $mime_types[] = $all_types[$file_type]; |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | |
1118 | - if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) { |
|
1119 | - wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) ); |
|
1118 | + if (!in_array($_FILES['file']['type'], $mime_types)) { |
|
1119 | + wp_send_json_error(__('Unsupported file type.', 'invoicing')); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | // Upload file. |
1123 | - $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) ); |
|
1124 | - $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name ); |
|
1123 | + $file_name = explode('.', strtolower($_FILES['file']['name'])); |
|
1124 | + $file_name = uniqid('getpaid-') . '.' . array_pop($file_name); |
|
1125 | 1125 | |
1126 | 1126 | $uploaded = wp_upload_bits( |
1127 | 1127 | $file_name, |
1128 | 1128 | null, |
1129 | - file_get_contents( $_FILES['file']['tmp_name'] ) |
|
1129 | + file_get_contents($_FILES['file']['tmp_name']) |
|
1130 | 1130 | ); |
1131 | 1131 | |
1132 | - if ( ! empty( $uploaded['error'] ) ) { |
|
1133 | - wp_send_json_error( $uploaded['error'] ); |
|
1132 | + if (!empty($uploaded['error'])) { |
|
1133 | + wp_send_json_error($uploaded['error']); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // Retrieve response. |
1137 | 1137 | $response = sprintf( |
1138 | 1138 | '<input type="hidden" name="%s[%s]" value="%s" />', |
1139 | - esc_attr( sanitize_text_field( $_POST['field_name'] ) ), |
|
1140 | - esc_url( $uploaded['url'] ), |
|
1141 | - esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) ) |
|
1139 | + esc_attr(sanitize_text_field($_POST['field_name'])), |
|
1140 | + esc_url($uploaded['url']), |
|
1141 | + esc_attr(sanitize_text_field(strtolower($_FILES['file']['name']))) |
|
1142 | 1142 | ); |
1143 | 1143 | |
1144 | - wp_send_json_success( $response ); |
|
1144 | + wp_send_json_success($response); |
|
1145 | 1145 | |
1146 | 1146 | } |
1147 | 1147 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,82 +16,82 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
78 | 78 | ?> |
79 | 79 | |
80 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
80 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
81 | 81 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
82 | 82 | |
83 | 83 | <thead> |
84 | 84 | <tr> |
85 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
86 | - <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
|
85 | + <?php foreach ($columns as $key => $label) : ?> |
|
86 | + <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th> |
|
87 | 87 | <?php endforeach; ?> |
88 | 88 | </tr> |
89 | 89 | </thead> |
90 | 90 | |
91 | 91 | <tbody class="wpinv-line-items"> |
92 | 92 | <?php |
93 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
94 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
93 | + foreach ($invoice->get_items() as $int => $item) { |
|
94 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
95 | 95 | } |
96 | 96 | ?> |
97 | 97 | </tbody> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <div class="wp-clearfix"> |
109 | 109 | <label class="wpi-item-name"> |
110 | 110 | <span class="input-text-wrap"> |
111 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
111 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
112 | 112 | </span> |
113 | 113 | </label> |
114 | 114 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | <div class="wp-clearfix"> |
117 | 117 | <label class="wpi-item-price"> |
118 | 118 | <span class="input-text-wrap"> |
119 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
119 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
121 | 121 | </span> |
122 | 122 | </label> |
123 | 123 | </div> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | <div class="wp-clearfix"> |
126 | 126 | <label class="wpi-item-name"> |
127 | 127 | <span class="input-text-wrap"> |
128 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
128 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
129 | 129 | </span> |
130 | 130 | </label> |
131 | 131 | </div> |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | <div class="wp-clearfix"> |
134 | 134 | <label class="wpi-item-type"> |
135 | 135 | <span class="input-text-wrap"> |
136 | - <?php wpinv_html_select( array( |
|
136 | + <?php wpinv_html_select(array( |
|
137 | 137 | 'options' => $item_types, |
138 | 138 | 'name' => '_wpinv_quick[type]', |
139 | 139 | 'id' => '_wpinv_quick_type', |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | 'show_option_all' => false, |
142 | 142 | 'show_option_none' => false, |
143 | 143 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
144 | - ) ); ?> |
|
144 | + )); ?> |
|
145 | 145 | </span> |
146 | 146 | </label> |
147 | 147 | </div> |
148 | 148 | |
149 | - <?php if ( $use_taxes ) : ?> |
|
149 | + <?php if ($use_taxes) : ?> |
|
150 | 150 | <div class="wp-clearfix"> |
151 | 151 | <label class="wpi-vat-rule"> |
152 | 152 | <span class="input-text-wrap"> |
153 | 153 | <?php |
154 | - wpinv_html_select( array( |
|
154 | + wpinv_html_select(array( |
|
155 | 155 | 'options' => array_merge( |
156 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
156 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
157 | 157 | getpaid_get_tax_rules() |
158 | 158 | ), |
159 | 159 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'show_option_none' => false, |
163 | 163 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
164 | 164 | 'selected' => 'digital', |
165 | - ) ); |
|
165 | + )); |
|
166 | 166 | ?> |
167 | 167 | </span> |
168 | 168 | </label> |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | <label class="wpi-vat-class"> |
172 | 172 | <span class="input-text-wrap"> |
173 | 173 | <?php |
174 | - wpinv_html_select( array( |
|
174 | + wpinv_html_select(array( |
|
175 | 175 | 'options' => array_merge( |
176 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
176 | + array('' => __('Select VAT Class', 'invoicing')), |
|
177 | 177 | getpaid_get_tax_classes() |
178 | 178 | ), |
179 | 179 | 'name' => '_wpinv_quick[vat_class]', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'show_option_none' => false, |
183 | 183 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
184 | 184 | 'selected' => '_standard', |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | ?> |
187 | 187 | </span> |
188 | 188 | </label> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'type' => 'checkbox', |
197 | 197 | 'name' => '_wpinv_quick[one-time]', |
198 | 198 | 'id' => '_wpinv_quick-one-time', |
199 | - 'label' => __( 'Item Name', 'invoicing' ), |
|
199 | + 'label' => __('Item Name', 'invoicing'), |
|
200 | 200 | 'value' => 1, |
201 | 201 | 'no_wrap' => true, |
202 | 202 | 'checked' => false, |
@@ -220,29 +220,29 @@ discard block |
||
220 | 220 | </td> |
221 | 221 | </tr> |
222 | 222 | <tr class="totals"> |
223 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
223 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
224 | 224 | <td colspan="4"> |
225 | 225 | <table cellspacing="0" cellpadding="0"> |
226 | 226 | <tr class="subtotal"> |
227 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td> |
|
228 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
227 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
228 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
229 | 229 | <td class="action"></td> |
230 | 230 | </tr> |
231 | 231 | <tr class="discount"> |
232 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td> |
|
233 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
232 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
233 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
234 | 234 | <td class="action"></td> |
235 | 235 | </tr> |
236 | - <?php if ( $use_taxes ) : ?> |
|
236 | + <?php if ($use_taxes) : ?> |
|
237 | 237 | <tr class="tax"> |
238 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td> |
|
239 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
238 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
239 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
240 | 240 | <td class="action"></td> |
241 | 241 | </tr> |
242 | 242 | <?php endif; ?> |
243 | 243 | <tr class="total"> |
244 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td> |
|
245 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
244 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
245 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
246 | 246 | <td class="action"></td> |
247 | 247 | </tr> |
248 | 248 | </table> |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | </table> |
254 | 254 | <div class="wpinv-actions"> |
255 | 255 | <?php |
256 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
256 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
257 | 257 | wpinv_item_dropdown( |
258 | 258 | array( |
259 | 259 | 'name' => 'wpinv_invoice_item', |
@@ -263,61 +263,61 @@ discard block |
||
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | |
266 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
267 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
268 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
266 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
267 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
268 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | ?> |
272 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
272 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
273 | 273 | </div> |
274 | 274 | </div> |
275 | 275 | <?php |
276 | 276 | } |
277 | 277 | |
278 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
278 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
279 | 279 | |
280 | 280 | ?> |
281 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
282 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
283 | - <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
281 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
282 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
283 | + <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
284 | 284 | <?php |
285 | - switch ( $column ) { |
|
285 | + switch ($column) { |
|
286 | 286 | case 'id': |
287 | 287 | echo (int) $item->get_id(); |
288 | 288 | break; |
289 | 289 | case 'title': |
290 | 290 | printf( |
291 | 291 | '<a href="%s" target="_blank">%s</a>', |
292 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
293 | - esc_html( $item->get_raw_name() ) |
|
292 | + esc_url(get_edit_post_link($item->get_id())), |
|
293 | + esc_html($item->get_raw_name()) |
|
294 | 294 | ); |
295 | 295 | |
296 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
297 | - if ( $summary !== '' ) { |
|
296 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
297 | + if ($summary !== '') { |
|
298 | 298 | printf( |
299 | 299 | '<span class="meta">%s</span>', |
300 | - wp_kses_post( wpautop( $summary ) ) |
|
300 | + wp_kses_post(wpautop($summary)) |
|
301 | 301 | ); |
302 | 302 | } |
303 | 303 | |
304 | 304 | printf( |
305 | 305 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
306 | - esc_attr( $item->get_raw_name() ), |
|
306 | + esc_attr($item->get_raw_name()), |
|
307 | 307 | (int) $item->get_id() |
308 | 308 | ); |
309 | 309 | |
310 | 310 | printf( |
311 | 311 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
312 | 312 | (int) $item->get_id(), |
313 | - esc_attr( $item->get_description() ) |
|
313 | + esc_attr($item->get_description()) |
|
314 | 314 | ); |
315 | 315 | |
316 | 316 | break; |
317 | 317 | case 'price': |
318 | 318 | printf( |
319 | 319 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
320 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
320 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
321 | 321 | (int) $item->get_id() |
322 | 322 | ); |
323 | 323 | |
@@ -325,26 +325,26 @@ discard block |
||
325 | 325 | case 'qty': |
326 | 326 | printf( |
327 | 327 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
328 | - floatval( $item->get_quantity() ), |
|
328 | + floatval($item->get_quantity()), |
|
329 | 329 | (int) $item->get_id() |
330 | 330 | ); |
331 | 331 | |
332 | 332 | break; |
333 | 333 | case 'total': |
334 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
334 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
335 | 335 | |
336 | 336 | break; |
337 | 337 | case 'tax': |
338 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
338 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
339 | 339 | |
340 | 340 | break; |
341 | 341 | case 'action': |
342 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
342 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
343 | 343 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
344 | 344 | } |
345 | 345 | break; |
346 | 346 | } |
347 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
347 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
348 | 348 | ?> |
349 | 349 | </td> |
350 | 350 | <?php endforeach; ?> |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @param WP_Post $post |
359 | 359 | */ |
360 | - public static function output2( $post ) { |
|
360 | + public static function output2($post) { |
|
361 | 361 | |
362 | 362 | // Prepare the invoice. |
363 | - $invoice = new WPInv_Invoice( $post ); |
|
363 | + $invoice = new WPInv_Invoice($post); |
|
364 | 364 | |
365 | 365 | // Invoice items. |
366 | 366 | $items = $invoice->get_items(); |
@@ -368,28 +368,28 @@ discard block |
||
368 | 368 | $totals = array( |
369 | 369 | |
370 | 370 | 'subtotal' => array( |
371 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
372 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
371 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
372 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
373 | 373 | ), |
374 | 374 | |
375 | 375 | 'discount' => array( |
376 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
377 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
376 | + 'label' => __('Total Discount', 'invoicing'), |
|
377 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
378 | 378 | ), |
379 | 379 | |
380 | 380 | 'tax' => array( |
381 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
382 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
381 | + 'label' => __('Total Tax', 'invoicing'), |
|
382 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
383 | 383 | ), |
384 | 384 | |
385 | 385 | 'total' => array( |
386 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
387 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
386 | + 'label' => __('Invoice Total', 'invoicing'), |
|
387 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
388 | 388 | ) |
389 | 389 | ); |
390 | 390 | |
391 | - if ( ! wpinv_use_taxes() ) { |
|
392 | - unset( $totals['tax'] ); |
|
391 | + if (!wpinv_use_taxes()) { |
|
392 | + unset($totals['tax']); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | $item_args = array( |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | 'orderby' => 'title', |
398 | 398 | 'order' => 'ASC', |
399 | 399 | 'posts_per_page' => -1, |
400 | - 'post_status' => array( 'publish' ), |
|
400 | + 'post_status' => array('publish'), |
|
401 | 401 | 'meta_query' => array( |
402 | 402 | array( |
403 | 403 | 'key' => '_wpinv_type', |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | } |
422 | 422 | </style> |
423 | 423 | |
424 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
424 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
425 | 425 | |
426 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
427 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
426 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
427 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
428 | 428 | |
429 | 429 | <div class="row"> |
430 | 430 | <div class="col-12 col-sm-6"> |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | array( |
434 | 434 | 'id' => 'wpinv_template', |
435 | 435 | 'name' => 'wpinv_template', |
436 | - 'label' => __( 'Template', 'invoicing' ), |
|
436 | + 'label' => __('Template', 'invoicing'), |
|
437 | 437 | 'label_type' => 'vertical', |
438 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
438 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
439 | 439 | 'class' => 'form-control-sm', |
440 | - 'value' => $invoice->get_template( 'edit' ), |
|
440 | + 'value' => $invoice->get_template('edit'), |
|
441 | 441 | 'options' => array( |
442 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
443 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
444 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
442 | + 'quantity' => __('Quantity', 'invoicing'), |
|
443 | + 'hours' => __('Hours', 'invoicing'), |
|
444 | + 'amount' => __('Amount Only', 'invoicing'), |
|
445 | 445 | ), |
446 | 446 | 'data-allow-clear' => 'false', |
447 | 447 | 'select2' => true, |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | array( |
459 | 459 | 'id' => 'wpinv_currency', |
460 | 460 | 'name' => 'wpinv_currency', |
461 | - 'label' => __( 'Currency', 'invoicing' ), |
|
461 | + 'label' => __('Currency', 'invoicing'), |
|
462 | 462 | 'label_type' => 'vertical', |
463 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
463 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
464 | 464 | 'class' => 'form-control-sm', |
465 | - 'value' => $invoice->get_currency( 'edit' ), |
|
465 | + 'value' => $invoice->get_currency('edit'), |
|
466 | 466 | 'required' => false, |
467 | 467 | 'data-allow-clear' => 'false', |
468 | 468 | 'select2' => true, |
@@ -475,24 +475,24 @@ discard block |
||
475 | 475 | </div> |
476 | 476 | </div> |
477 | 477 | |
478 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
478 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
479 | 479 | <?php endif; ?> |
480 | 480 | |
481 | 481 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
482 | 482 | <thead> |
483 | 483 | <tr> |
484 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
484 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
485 | 485 | <th class="getpaid-quantity hide-if-amount text-right"> |
486 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
487 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
486 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
487 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
488 | 488 | </th> |
489 | 489 | <th class="getpaid-price hide-if-amount text-right"> |
490 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span> |
|
491 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span> |
|
490 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span> |
|
491 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span> |
|
492 | 492 | </th> |
493 | 493 | <th class="getpaid-item-subtotal text-right"> |
494 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span> |
|
495 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span> |
|
494 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span> |
|
495 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span> |
|
496 | 496 | </th> |
497 | 497 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
498 | 498 | </tr> |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | <tbody class="getpaid_invoice_line_items"> |
501 | 501 | <tr class="hide-if-has-items hide-if-not-editable"> |
502 | 502 | <td colspan="2" class="pt-4 pb-4"> |
503 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
504 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
503 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button> |
|
504 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
505 | 505 | </td> |
506 | 506 | <td class="hide-if-amount"> </th> |
507 | 507 | <td class="hide-if-amount"> </th> |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | <div class="col-12 col-sm-6 offset-sm-6"> |
534 | 534 | <table class="getpaid-invoice-totals text-right w-100"> |
535 | 535 | <tbody> |
536 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
537 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
538 | - <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td> |
|
536 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
537 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
538 | + <td class="label"><?php echo esc_html($data['label']) ?>:</td> |
|
539 | 539 | <td width="1%"></td> |
540 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
540 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
541 | 541 | </tr> |
542 | 542 | <?php endforeach; ?> |
543 | 543 | </tbody> |
@@ -550,18 +550,18 @@ discard block |
||
550 | 550 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
551 | 551 | <div class="row"> |
552 | 552 | <div class="text-left col-12 col-sm-8"> |
553 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
554 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
555 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
553 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button> |
|
554 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
555 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
556 | 556 | </div> |
557 | 557 | <div class="text-right col-12 col-sm-4"> |
558 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
558 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button> |
|
559 | 559 | </div> |
560 | 560 | </div> |
561 | 561 | </div> |
562 | 562 | |
563 | 563 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
564 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
564 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
565 | 565 | </div> |
566 | 566 | |
567 | 567 | <!-- Add items to an invoice --> |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | <div class="modal-dialog modal-dialog-centered" role="document"> |
570 | 570 | <div class="modal-content"> |
571 | 571 | <div class="modal-header"> |
572 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
573 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
574 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
572 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5> |
|
573 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
574 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
575 | 575 | <span aria-hidden="true">×</span> |
576 | 576 | <?php endif; ?> |
577 | 577 | </button> |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | <table class="widefat"> |
581 | 581 | <thead> |
582 | 582 | <tr> |
583 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
583 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
584 | 584 | <th class="pr-0 text-right hide-if-amount"> |
585 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
586 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
585 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
586 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
587 | 587 | </th> |
588 | 588 | </tr> |
589 | 589 | </thead> |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | <tr> |
592 | 592 | <td class="pl-0 text-left"> |
593 | 593 | <select class="regular-text getpaid-add-invoice-item-select"> |
594 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
595 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
596 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
594 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
595 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
596 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
597 | 597 | <?php endforeach; ?> |
598 | 598 | </select> |
599 | 599 | </td> |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | </table> |
606 | 606 | </div> |
607 | 607 | <div class="modal-footer"> |
608 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
609 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
608 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
609 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
610 | 610 | </div> |
611 | 611 | </div> |
612 | 612 | </div> |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | <div class="modal-dialog modal-dialog-centered" role="document"> |
618 | 618 | <div class="modal-content"> |
619 | 619 | <div class="modal-header"> |
620 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5> |
|
621 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
622 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
620 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5> |
|
621 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
622 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
623 | 623 | <span aria-hidden="true">×</span> |
624 | 624 | <?php endif; ?> |
625 | 625 | </button> |
@@ -628,27 +628,27 @@ discard block |
||
628 | 628 | <div class="getpaid-create-item-div"> |
629 | 629 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
630 | 630 | <label class="form-group mb-3 w-100"> |
631 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
632 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
631 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
632 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
633 | 633 | </label> |
634 | 634 | <label class="form-group mb-3 w-100"> |
635 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
636 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
637 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
635 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
636 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
637 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
638 | 638 | </label> |
639 | 639 | <label class="form-group mb-3 w-100 hide-if-amount"> |
640 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
640 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
641 | 641 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
642 | 642 | </label> |
643 | 643 | <label class="form-group mb-3 w-100"> |
644 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
645 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
644 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
645 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
646 | 646 | </label> |
647 | 647 | </div> |
648 | 648 | </div> |
649 | 649 | <div class="modal-footer"> |
650 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
651 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
650 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
651 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
652 | 652 | </div> |
653 | 653 | </div> |
654 | 654 | </div> |
@@ -659,9 +659,9 @@ discard block |
||
659 | 659 | <div class="modal-dialog modal-dialog-centered" role="document"> |
660 | 660 | <div class="modal-content"> |
661 | 661 | <div class="modal-header"> |
662 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5> |
|
663 | - <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
664 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
662 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5> |
|
663 | + <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
664 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
665 | 665 | <span aria-hidden="true">×</span> |
666 | 666 | <?php endif; ?> |
667 | 667 | </button> |
@@ -670,27 +670,27 @@ discard block |
||
670 | 670 | <div class="getpaid-edit-item-div"> |
671 | 671 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
672 | 672 | <label class="form-group mb-3 w-100"> |
673 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
674 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
673 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
674 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
675 | 675 | </label> |
676 | 676 | <label class="form-group mb-3 w-100"> |
677 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
678 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
679 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
677 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
678 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
679 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
680 | 680 | </label> |
681 | 681 | <label class="form-group mb-3 w-100 hide-if-amount"> |
682 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
682 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
683 | 683 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
684 | 684 | </label> |
685 | 685 | <label class="form-group mb-3 w-100"> |
686 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
687 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
686 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
687 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
688 | 688 | </label> |
689 | 689 | </div> |
690 | 690 | </div> |
691 | 691 | <div class="modal-footer"> |
692 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
693 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
692 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
693 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
694 | 694 | </div> |
695 | 695 | </div> |
696 | 696 | </div> |