@@ -180,8 +180,11 @@ discard block |
||
180 | 180 | <label for="tablecell"> |
181 | 181 | <?php if( 'trialling' == $sub->status ) : ?> |
182 | 182 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
183 | - <?php else: ?> |
|
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
183 | + <?php else { |
|
184 | + : ?> |
|
185 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
186 | +} |
|
187 | +?> |
|
185 | 188 | <?php endif; ?> |
186 | 189 | </label> |
187 | 190 | </td> |
@@ -251,7 +254,10 @@ discard block |
||
251 | 254 | </thead> |
252 | 255 | <tbody> |
253 | 256 | <?php if ( ! empty( $payments ) ) : ?> |
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
257 | + <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) { |
|
258 | + continue; |
|
259 | +} |
|
260 | +?> |
|
255 | 261 | <tr> |
256 | 262 | <td><?php echo $payment->ID; ?></td> |
257 | 263 | <td><?php echo $invoice->get_total( true ); ?></td> |
@@ -268,9 +274,12 @@ discard block |
||
268 | 274 | </td> |
269 | 275 | </tr> |
270 | 276 | <?php endforeach; ?> |
271 | - <?php else: ?> |
|
277 | + <?php else { |
|
278 | + : ?> |
|
272 | 279 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
280 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
281 | +} |
|
282 | +?></td> |
|
274 | 283 | </tr> |
275 | 284 | <?php endif; ?> |
276 | 285 | </tbody> |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,56 +299,56 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | - 'profile_id' => $profile_id, |
|
325 | - 'product_id' => $product_id, |
|
326 | - 'transaction_id' => $transaction_id, |
|
327 | - ) ); |
|
318 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | + $product_id = absint( $_POST['product_id'] ); |
|
321 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | + $subscription->update( array( |
|
323 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
324 | + 'profile_id' => $profile_id, |
|
325 | + 'product_id' => $product_id, |
|
326 | + 'transaction_id' => $transaction_id, |
|
327 | + ) ); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field( $_POST['status'] ); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch( $status ) { |
|
332 | 332 | |
333 | - case 'cancelled' : |
|
333 | + case 'cancelled' : |
|
334 | 334 | |
335 | - $subscription->cancel(); |
|
336 | - break; |
|
335 | + $subscription->cancel(); |
|
336 | + break; |
|
337 | 337 | |
338 | - case 'expired' : |
|
338 | + case 'expired' : |
|
339 | 339 | |
340 | - $subscription->expire(); |
|
341 | - break; |
|
340 | + $subscription->expire(); |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'completed' : |
|
343 | + case 'completed' : |
|
344 | 344 | |
345 | - $subscription->complete(); |
|
346 | - break; |
|
345 | + $subscription->complete(); |
|
346 | + break; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | - exit; |
|
350 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
351 | + exit; |
|
352 | 352 | |
353 | 353 | } |
354 | 354 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
366 | - return; |
|
367 | - } |
|
365 | + if( empty( $_POST['sub_id'] ) ) { |
|
366 | + return; |
|
367 | + } |
|
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | - return; |
|
371 | - } |
|
369 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | - return; |
|
375 | - } |
|
373 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
374 | + return; |
|
375 | + } |
|
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | - } |
|
377 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + } |
|
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
384 | 384 | |
385 | - $subscription->delete(); |
|
385 | + $subscription->delete(); |
|
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | - exit; |
|
387 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
388 | + exit; |
|
389 | 389 | |
390 | 390 | } |
391 | 391 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if (!empty($_GET['id'])) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
23 | 23 | </h1> |
24 | 24 | <?php |
25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <input type="hidden" name="post_type" value="download" /> |
32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
33 | 33 | <?php $subscribers_table->views(); ?> |
34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
35 | 35 | <?php $subscribers_table->display(); ?> |
36 | 36 | |
37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | $render = true; |
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
52 | + if (!current_user_can('manage_invoicing')) { |
|
53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
58 | 58 | } |
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int)$_GET['id']; |
|
61 | + $sub = new WPInv_Subscription($sub_id); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
63 | + if (empty($sub)) { |
|
64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | ?> |
68 | 68 | <div class="wrap"> |
69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
70 | 70 | |
71 | - <?php if ( $sub ) : ?> |
|
71 | + <?php if ($sub) : ?> |
|
72 | 72 | |
73 | 73 | <div id="wpinv-item-card-wrapper"> |
74 | 74 | |
75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
76 | 76 | |
77 | 77 | <div class="info-wrapper item-section"> |
78 | 78 | |
79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
80 | 80 | |
81 | 81 | <div class="item-info"> |
82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td class="row-title"> |
87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
99 | 99 | <td class="row-title"> |
100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
101 | 101 | </td> |
102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
103 | 103 | </tr> |
104 | 104 | <tr> |
105 | 105 | <td class="row-title"> |
106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
107 | 107 | </td> |
108 | 108 | <td> |
109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
110 | - <a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
110 | + <a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
111 | 111 | </td> |
112 | 112 | </tr> |
113 | 113 | <tr> |
114 | 114 | <td class="row-title"> |
115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
116 | 116 | </td> |
117 | 117 | <td> |
118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
119 | 119 | </tr> |
120 | 120 | <tr> |
121 | 121 | <td class="row-title"> |
122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
123 | 123 | </td> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - echo wpinv_item_dropdown( array( |
|
126 | + echo wpinv_item_dropdown(array( |
|
127 | 127 | 'name' => 'product_id', |
128 | 128 | 'id' => 'wpinv_invoice_item', |
129 | 129 | 'with_packages' => false, |
130 | 130 | 'show_recurring' => true, |
131 | 131 | 'selected' => $sub->product_id, |
132 | 132 | 'class' => 'wpinv-sub-product-id wpi_select2', |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | ?> |
136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
137 | 137 | 'post' => $sub->product_id, |
138 | 138 | 'action' => 'edit' |
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
143 | 143 | <td class="row-title"> |
144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
145 | 145 | </td> |
146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
147 | 147 | </tr> |
148 | 148 | <tr> |
149 | 149 | <td class="row-title"> |
150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
151 | 151 | </td> |
152 | 152 | <td> |
153 | 153 | <span class="wpinv-sub-profile-id"> |
154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
155 | 155 | </span> |
156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
157 | 157 | <span> – </span> |
158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | <tr> |
162 | 162 | <td class="row-title"> |
163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
164 | 164 | </td> |
165 | 165 | <td> |
166 | - <span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span> |
|
167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
166 | + <span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span> |
|
167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
168 | 168 | <span> – </span> |
169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
170 | 170 | </td> |
171 | 171 | </tr> |
172 | 172 | <tr> |
173 | 173 | <td class="row-title"> |
174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
175 | 175 | </td> |
176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
177 | 177 | </tr> |
178 | 178 | <tr> |
179 | 179 | <td class="row-title"> |
180 | 180 | <label for="tablecell"> |
181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
181 | + <?php if ('trialling' == $sub->status) : ?> |
|
182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
183 | 183 | <?php else: ?> |
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
185 | 185 | <?php endif; ?> |
186 | 186 | </label> |
187 | 187 | </td> |
188 | 188 | <td> |
189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <td class="row-title"> |
194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
195 | 195 | </td> |
196 | 196 | <td> |
197 | 197 | <select name="status" class="wpi_select2"> |
198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </td> |
207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
209 | 209 | </table> |
210 | 210 | </div> |
211 | 211 | <div id="wpinv-sub-notices"> |
212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
214 | 214 | </div> |
215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
219 | - <?php if( $sub->can_cancel() ) : ?> |
|
220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
219 | + <?php if ($sub->can_cancel()) : ?> |
|
220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
221 | 221 | <?php endif; ?> |
222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | </form> |
226 | 226 | </div> |
227 | 227 | |
228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
229 | 229 | |
230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
231 | 231 | |
232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
233 | 233 | |
234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
235 | 235 | |
236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
240 | 240 | <?php endif; ?> |
241 | 241 | <table class="wp-list-table widefat striped payments"> |
242 | 242 | <thead> |
243 | 243 | <tr> |
244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
250 | 250 | </tr> |
251 | 251 | </thead> |
252 | 252 | <tbody> |
253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
253 | + <?php if (!empty($payments)) : ?> |
|
254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
255 | 255 | <tr> |
256 | 256 | <td><?php echo $payment->ID; ?></td> |
257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
260 | 260 | <td> |
261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
263 | 263 | </td> |
264 | 264 | <td class="column-wpi_actions"> |
265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
266 | 266 | </a> |
267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <?php endforeach; ?> |
271 | 271 | <?php else: ?> |
272 | 272 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
274 | 274 | </tr> |
275 | 275 | <?php endif; ?> |
276 | 276 | </tbody> |
277 | 277 | <tfoot></tfoot> |
278 | 278 | </table> |
279 | 279 | |
280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -299,36 +299,36 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
302 | + if (empty($_POST['sub_id'])) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
310 | + if (!current_user_can('manage_invoicing')) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
316 | 316 | } |
317 | 317 | |
318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
320 | - $product_id = absint( $_POST['product_id'] ); |
|
321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
322 | - $subscription->update( array( |
|
323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
318 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
319 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
320 | + $product_id = absint($_POST['product_id']); |
|
321 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
322 | + $subscription->update(array( |
|
323 | + 'status' => sanitize_text_field($_POST['status']), |
|
324 | 324 | 'profile_id' => $profile_id, |
325 | 325 | 'product_id' => $product_id, |
326 | 326 | 'transaction_id' => $transaction_id, |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
329 | + $status = sanitize_text_field($_POST['status']); |
|
330 | 330 | |
331 | - switch( $status ) { |
|
331 | + switch ($status) { |
|
332 | 332 | |
333 | 333 | case 'cancelled' : |
334 | 334 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
350 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
351 | 351 | exit; |
352 | 352 | |
353 | 353 | } |
354 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
354 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Handles subscription deletion |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
364 | 364 | |
365 | - if( empty( $_POST['sub_id'] ) ) { |
|
365 | + if (empty($_POST['sub_id'])) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
369 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
373 | + if (!current_user_can('manage_invoicing')) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
377 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
378 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
379 | 379 | } |
380 | 380 | |
381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
381 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
382 | 382 | |
383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
383 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
384 | 384 | |
385 | 385 | $subscription->delete(); |
386 | 386 | |
387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
387 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
388 | 388 | exit; |
389 | 389 | |
390 | 390 | } |
391 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
391 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -176,69 +176,69 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | - global $wpinv_options, $pagenow, $post; |
|
179 | + global $wpinv_options, $pagenow, $post; |
|
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | - } |
|
181 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | + } |
|
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | - } |
|
185 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | + } |
|
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | - } |
|
189 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | + } |
|
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | - } |
|
193 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | + } |
|
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | - } |
|
197 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | + } |
|
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | - } |
|
201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | + } |
|
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | - } |
|
205 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | + } |
|
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
214 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
218 | 218 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | - } |
|
221 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | - } |
|
225 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | + } |
|
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | - } |
|
229 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | + } |
|
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | - } |
|
239 | - } |
|
236 | + if ( !empty( $message ) ) { |
|
237 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors( 'wpinv-notices' ); |
|
242 | 242 | } |
243 | 243 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
244 | 244 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
304 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
305 | 305 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
306 | 306 | if ( $wpinv_euvat->allow_vat_rules() ) { |
307 | 307 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,245 +7,245 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
83 | - $time_format = get_option( 'time_format' ); |
|
84 | - $date_time_format = $date_format . ' '. $time_format; |
|
82 | + $date_format = get_option('date_format'); |
|
83 | + $time_format = get_option('time_format'); |
|
84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
85 | 85 | |
86 | 86 | $m_time = $post->post_date; |
87 | - $h_time = mysql2date( $date_format, $m_time ); |
|
87 | + $h_time = mysql2date($date_format, $m_time); |
|
88 | 88 | |
89 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
89 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
90 | 90 | break; |
91 | 91 | case 'payment_date' : |
92 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
93 | - $date_format = get_option( 'date_format' ); |
|
94 | - $time_format = get_option( 'time_format' ); |
|
95 | - $date_time_format = $date_format . ' '. $time_format; |
|
92 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
93 | + $date_format = get_option('date_format'); |
|
94 | + $time_format = get_option('time_format'); |
|
95 | + $date_time_format = $date_format . ' ' . $time_format; |
|
96 | 96 | |
97 | 97 | $m_time = $date_completed; |
98 | - $h_time = mysql2date( $date_format, $m_time ); |
|
98 | + $h_time = mysql2date($date_format, $m_time); |
|
99 | 99 | |
100 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
100 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
101 | 101 | } else { |
102 | 102 | $value = '-'; |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | case 'status' : |
106 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
107 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
108 | - if ( 1 == $is_viewed ) { |
|
109 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
106 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
107 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
108 | + if (1 == $is_viewed) { |
|
109 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
110 | 110 | } |
111 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
112 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
111 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
112 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
113 | 113 | } |
114 | 114 | break; |
115 | 115 | case 'number' : |
116 | - $edit_link = get_edit_post_link( $post->ID ); |
|
117 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
116 | + $edit_link = get_edit_post_link($post->ID); |
|
117 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | 118 | break; |
119 | 119 | case 'wpi_actions' : |
120 | 120 | $value = ''; |
121 | - if ( !empty( $post->post_name ) ) { |
|
122 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
121 | + if (!empty($post->post_name)) { |
|
122 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( $email = $wpi_invoice->get_email() ) { |
|
126 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
125 | + if ($email = $wpi_invoice->get_email()) { |
|
126 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | break; |
130 | 130 | default: |
131 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
131 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
132 | 132 | break; |
133 | 133 | |
134 | 134 | } |
135 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
135 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
136 | 136 | |
137 | - if ( $value !== NULL ) { |
|
137 | + if ($value !== NULL) { |
|
138 | 138 | echo $value; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -function wpinv_admin_post_id( $id = 0 ) { |
|
142 | +function wpinv_admin_post_id($id = 0) { |
|
143 | 143 | global $post; |
144 | 144 | |
145 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
145 | + if (isset($id) && !empty($id)) { |
|
146 | 146 | return (int)$id; |
147 | - } else if ( get_the_ID() ) { |
|
148 | - return (int) get_the_ID(); |
|
149 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
150 | - return (int) $post->ID; |
|
151 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
152 | - return (int) $_GET['post']; |
|
153 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
154 | - return (int) $_GET['id']; |
|
155 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
156 | - return (int) $_POST['id']; |
|
147 | + } else if (get_the_ID()) { |
|
148 | + return (int)get_the_ID(); |
|
149 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
150 | + return (int)$post->ID; |
|
151 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
152 | + return (int)$_GET['post']; |
|
153 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
154 | + return (int)$_GET['id']; |
|
155 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
156 | + return (int)$_POST['id']; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return null; |
160 | 160 | } |
161 | 161 | |
162 | -function wpinv_admin_post_type( $id = 0 ) { |
|
163 | - if ( !$id ) { |
|
162 | +function wpinv_admin_post_type($id = 0) { |
|
163 | + if (!$id) { |
|
164 | 164 | $id = wpinv_admin_post_id(); |
165 | 165 | } |
166 | 166 | |
167 | - $type = get_post_type( $id ); |
|
167 | + $type = get_post_type($id); |
|
168 | 168 | |
169 | - if ( !$type ) { |
|
170 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
169 | + if (!$type) { |
|
170 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
173 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_admin_messages() { |
177 | 177 | global $wpinv_options, $pagenow, $post; |
178 | 178 | |
179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
179 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
180 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
183 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
184 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
187 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
188 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
191 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
192 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
195 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
196 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
197 | 197 | } |
198 | 198 | |
199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
199 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
200 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
203 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
204 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
207 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
208 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
209 | 209 | } |
210 | 210 | |
211 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
211 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
212 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
216 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
215 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
216 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
219 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
220 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
223 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
224 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
225 | 225 | } |
226 | 226 | |
227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
227 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
228 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
231 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
232 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
233 | 233 | |
234 | - if ( !empty( $message ) ) { |
|
235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
234 | + if (!empty($message)) { |
|
235 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - settings_errors( 'wpinv-notices' ); |
|
239 | + settings_errors('wpinv-notices'); |
|
240 | 240 | } |
241 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
241 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
242 | 242 | |
243 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
244 | -function wpinv_show_test_payment_gateway_notice(){ |
|
245 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
243 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
244 | +function wpinv_show_test_payment_gateway_notice() { |
|
245 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
246 | 246 | } |
247 | 247 | |
248 | -function wpinv_test_payment_gateway_messages(){ |
|
248 | +function wpinv_test_payment_gateway_messages() { |
|
249 | 249 | $gateways = wpinv_get_enabled_payment_gateways(); |
250 | 250 | $name = array(); $test_gateways = ''; |
251 | 251 | if ($gateways) { |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | $test_gateways = implode(', ', $name); |
258 | 258 | } |
259 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
259 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
260 | 260 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
261 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
261 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
262 | 262 | ?> |
263 | 263 | <div class="notice notice-warning is-dismissible"> |
264 | 264 | <p><?php echo $notice; ?></p> |
@@ -267,29 +267,29 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | -function wpinv_items_columns( $existing_columns ) { |
|
270 | +function wpinv_items_columns($existing_columns) { |
|
271 | 271 | global $wpinv_euvat; |
272 | 272 | |
273 | 273 | $columns = array(); |
274 | 274 | $columns['cb'] = $existing_columns['cb']; |
275 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
276 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
277 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
278 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
275 | + $columns['title'] = __('Title', 'invoicing'); |
|
276 | + $columns['price'] = __('Price', 'invoicing'); |
|
277 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
278 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
279 | 279 | } |
280 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
281 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
280 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
281 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
282 | 282 | } |
283 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
284 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
285 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
286 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
283 | + $columns['type'] = __('Type', 'invoicing'); |
|
284 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
285 | + $columns['date'] = __('Date', 'invoicing'); |
|
286 | + $columns['id'] = __('ID', 'invoicing'); |
|
287 | 287 | |
288 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
288 | + return apply_filters('wpinv_items_columns', $columns); |
|
289 | 289 | } |
290 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
290 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
291 | 291 | |
292 | -function wpinv_items_sortable_columns( $columns ) { |
|
292 | +function wpinv_items_sortable_columns($columns) { |
|
293 | 293 | $columns['price'] = 'price'; |
294 | 294 | $columns['vat_rule'] = 'vat_rule'; |
295 | 295 | $columns['vat_class'] = 'vat_class'; |
@@ -299,151 +299,151 @@ discard block |
||
299 | 299 | |
300 | 300 | return $columns; |
301 | 301 | } |
302 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
302 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
303 | 303 | |
304 | -function wpinv_items_table_custom_column( $column ) { |
|
304 | +function wpinv_items_table_custom_column($column) { |
|
305 | 305 | global $wpinv_euvat, $post, $wpi_item; |
306 | 306 | |
307 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
308 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
307 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
308 | + $wpi_item = new WPInv_Item($post->ID); |
|
309 | 309 | } |
310 | 310 | |
311 | - switch ( $column ) { |
|
311 | + switch ($column) { |
|
312 | 312 | case 'price' : |
313 | - echo wpinv_item_price( $post->ID ); |
|
313 | + echo wpinv_item_price($post->ID); |
|
314 | 314 | break; |
315 | 315 | case 'vat_rule' : |
316 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
316 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
317 | 317 | break; |
318 | 318 | case 'vat_class' : |
319 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
319 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
320 | 320 | break; |
321 | 321 | case 'type' : |
322 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
322 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
323 | 323 | break; |
324 | 324 | case 'recurring' : |
325 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
325 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
326 | 326 | break; |
327 | 327 | case 'id' : |
328 | 328 | echo $post->ID; |
329 | 329 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
330 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
331 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
332 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
330 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
331 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
332 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
333 | 333 | } |
334 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
335 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
334 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
335 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
336 | 336 | } |
337 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
337 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
338 | 338 | </div>'; |
339 | 339 | break; |
340 | 340 | } |
341 | 341 | |
342 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
342 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
343 | 343 | } |
344 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
344 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
345 | 345 | |
346 | 346 | function wpinv_add_items_filters() { |
347 | 347 | global $wpinv_euvat, $typenow; |
348 | 348 | |
349 | 349 | // Checks if the current post type is 'item' |
350 | - if ( $typenow == 'wpi_item') { |
|
351 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
352 | - echo wpinv_html_select( array( |
|
353 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
350 | + if ($typenow == 'wpi_item') { |
|
351 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
352 | + echo wpinv_html_select(array( |
|
353 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
354 | 354 | 'name' => 'vat_rule', |
355 | 355 | 'id' => 'vat_rule', |
356 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
356 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
357 | 357 | 'show_option_all' => false, |
358 | 358 | 'show_option_none' => false, |
359 | 359 | 'class' => 'gdmbx2-text-medium wpi_select2', |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
364 | - echo wpinv_html_select( array( |
|
365 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
363 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
364 | + echo wpinv_html_select(array( |
|
365 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
366 | 366 | 'name' => 'vat_class', |
367 | 367 | 'id' => 'vat_class', |
368 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
368 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
369 | 369 | 'show_option_all' => false, |
370 | 370 | 'show_option_none' => false, |
371 | 371 | 'class' => 'gdmbx2-text-medium wpi_select2', |
372 | - ) ); |
|
372 | + )); |
|
373 | 373 | } |
374 | 374 | |
375 | - echo wpinv_html_select( array( |
|
376 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
375 | + echo wpinv_html_select(array( |
|
376 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
377 | 377 | 'name' => 'type', |
378 | 378 | 'id' => 'type', |
379 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
379 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
380 | 380 | 'show_option_all' => false, |
381 | 381 | 'show_option_none' => false, |
382 | 382 | 'class' => 'gdmbx2-text-medium', |
383 | - ) ); |
|
383 | + )); |
|
384 | 384 | |
385 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
385 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
386 | 386 | echo '<input type="hidden" name="all_posts" value="1" />'; |
387 | 387 | } |
388 | 388 | } |
389 | 389 | } |
390 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
390 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
391 | 391 | |
392 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
393 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
392 | +function wpinv_send_invoice_after_save($invoice) { |
|
393 | + if (empty($_POST['wpi_save_send'])) { |
|
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
398 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
397 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
398 | + wpinv_user_invoice_notification($invoice->ID); |
|
399 | 399 | } |
400 | 400 | } |
401 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
401 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
402 | 402 | |
403 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
404 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
405 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
406 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
403 | +function wpinv_send_register_new_user($data, $postarr) { |
|
404 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
405 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
406 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
407 | 407 | |
408 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
409 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
410 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
411 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
412 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
413 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
408 | + if ($is_new_user && $email && !email_exists($email)) { |
|
409 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
410 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
411 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
412 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
413 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
414 | 414 | |
415 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
416 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
415 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
416 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
417 | 417 | $new_user_login = strstr($email, '@', true); |
418 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
419 | - $user_login = sanitize_user($new_user_login, true ); |
|
418 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
419 | + $user_login = sanitize_user($new_user_login, true); |
|
420 | 420 | } |
421 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
422 | - $user_append_text = rand(10,1000); |
|
423 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
421 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
422 | + $user_append_text = rand(10, 1000); |
|
423 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
424 | 424 | } |
425 | 425 | |
426 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
426 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
427 | 427 | $user_login = $email; |
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | 431 | $userdata = array( |
432 | 432 | 'user_login' => $user_login, |
433 | - 'user_pass' => wp_generate_password( 12, false ), |
|
434 | - 'user_email' => sanitize_text_field( $email ), |
|
433 | + 'user_pass' => wp_generate_password(12, false), |
|
434 | + 'user_email' => sanitize_text_field($email), |
|
435 | 435 | 'first_name' => $first_name, |
436 | 436 | 'last_name' => $last_name, |
437 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
437 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
438 | 438 | 'nickname' => $display_name, |
439 | 439 | 'display_name' => $display_name, |
440 | 440 | ); |
441 | 441 | |
442 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
442 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
443 | 443 | |
444 | - $new_user_id = wp_insert_user( $userdata ); |
|
444 | + $new_user_id = wp_insert_user($userdata); |
|
445 | 445 | |
446 | - if ( !is_wp_error( $new_user_id ) ) { |
|
446 | + if (!is_wp_error($new_user_id)) { |
|
447 | 447 | $data['post_author'] = $new_user_id; |
448 | 448 | $_POST['post_author'] = $new_user_id; |
449 | 449 | $_POST['post_author_override'] = $new_user_id; |
@@ -464,72 +464,72 @@ discard block |
||
464 | 464 | |
465 | 465 | $meta = array(); |
466 | 466 | ///$meta['_wpinv_user_id'] = $new_user_id; |
467 | - foreach ( $meta_fields as $field ) { |
|
468 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
467 | + foreach ($meta_fields as $field) { |
|
468 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
469 | 469 | } |
470 | 470 | |
471 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
471 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
472 | 472 | |
473 | 473 | // Update user meta. |
474 | - foreach ( $meta as $key => $value ) { |
|
475 | - update_user_meta( $new_user_id, $key, $value ); |
|
474 | + foreach ($meta as $key => $value) { |
|
475 | + update_user_meta($new_user_id, $key, $value); |
|
476 | 476 | } |
477 | 477 | |
478 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
478 | + if (function_exists('wp_send_new_user_notifications')) { |
|
479 | 479 | // Send email notifications related to the creation of new user. |
480 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
480 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
481 | 481 | } |
482 | 482 | } else { |
483 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
483 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | 488 | return $data; |
489 | 489 | } |
490 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
490 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
491 | 491 | |
492 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
492 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
493 | 493 | $all_gateways = wpinv_get_payment_gateways(); |
494 | 494 | |
495 | - if ( !empty( $all_gateways ) ) { |
|
495 | + if (!empty($all_gateways)) { |
|
496 | 496 | $gateways = array(); |
497 | 497 | |
498 | - foreach ( $all_gateways as $key => $gateway ) { |
|
499 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
498 | + foreach ($all_gateways as $key => $gateway) { |
|
499 | + if (wpinv_gateway_support_subscription($key)) { |
|
500 | 500 | $gateways[] = $gateway['admin_label']; |
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | - if ( !empty( $gateways ) ) { |
|
504 | + if (!empty($gateways)) { |
|
505 | 505 | ?> |
506 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
506 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
507 | 507 | <?php |
508 | 508 | } |
509 | 509 | } |
510 | 510 | } |
511 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
511 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
512 | 512 | |
513 | -function wpinv_post_updated_messages( $messages ) { |
|
513 | +function wpinv_post_updated_messages($messages) { |
|
514 | 514 | global $post, $post_ID; |
515 | 515 | |
516 | 516 | $messages['wpi_discount'] = array( |
517 | 517 | 0 => '', |
518 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
519 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
520 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
521 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
522 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
523 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
524 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
525 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
526 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
527 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
518 | + 1 => __('Discount updated.', 'invoicing'), |
|
519 | + 2 => __('Custom field updated.', 'invoicing'), |
|
520 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
521 | + 4 => __('Discount updated.', 'invoicing'), |
|
522 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
523 | + 6 => __('Discount updated.', 'invoicing'), |
|
524 | + 7 => __('Discount saved.', 'invoicing'), |
|
525 | + 8 => __('Discount submitted.', 'invoicing'), |
|
526 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
527 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
528 | 528 | ); |
529 | 529 | |
530 | 530 | return $messages; |
531 | 531 | } |
532 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
532 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
533 | 533 | |
534 | 534 | add_action('admin_init', 'admin_init_example_type'); |
535 | 535 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | function admin_init_example_type() { |
540 | 540 | global $typenow; |
541 | 541 | |
542 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
542 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
543 | 543 | add_filter('posts_search', 'posts_search_example_type', 10, 2); |
544 | 544 | } |
545 | 545 | } |
@@ -554,9 +554,9 @@ discard block |
||
554 | 554 | global $wpdb; |
555 | 555 | |
556 | 556 | if ($query->is_main_query() && !empty($query->query['s'])) { |
557 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
558 | - if ( ! empty( $search ) ) { |
|
559 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
557 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
558 | + if (!empty($search)) { |
|
559 | + $search = preg_replace('/^ AND /', '', $search); |
|
560 | 560 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
561 | 561 | } else { |
562 | 562 | $search = " AND ( {$conditions_str} )"; |
@@ -566,9 +566,9 @@ discard block |
||
566 | 566 | return $search; |
567 | 567 | } |
568 | 568 | |
569 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
570 | -function wpinv_reset_invoice_count(){ |
|
571 | - if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
569 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
570 | +function wpinv_reset_invoice_count() { |
|
571 | + if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
572 | 572 | wpinv_update_option('invoice_sequence_start', 1); |
573 | 573 | delete_option('wpinv_last_invoice_number'); |
574 | 574 | $url = add_query_arg(array('reset_invoice_done' => 1)); |
@@ -579,8 +579,8 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | add_action('admin_notices', 'wpinv_invoice_count_reset_message'); |
582 | -function wpinv_invoice_count_reset_message(){ |
|
583 | - if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
582 | +function wpinv_invoice_count_reset_message() { |
|
583 | + if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
584 | 584 | $notice = __('Invoice number sequence reset successfully.', 'invoicing'); |
585 | 585 | ?> |
586 | 586 | <div class="notice notice-success is-dismissible"> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Personal data exporters. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy_Exporters Class. |
@@ -17,37 +17,37 @@ discard block |
||
17 | 17 | * @param int $page Page. |
18 | 18 | * @return array An array of invoice data in name value pairs |
19 | 19 | */ |
20 | - public static function customer_invoice_data_exporter( $email_address, $page ) { |
|
20 | + public static function customer_invoice_data_exporter($email_address, $page) { |
|
21 | 21 | $done = false; |
22 | - $page = (int) $page; |
|
22 | + $page = (int)$page; |
|
23 | 23 | $data_to_export = array(); |
24 | 24 | |
25 | - $user = get_user_by( 'email', $email_address ); |
|
26 | - if ( ! $user instanceof WP_User ) { |
|
25 | + $user = get_user_by('email', $email_address); |
|
26 | + if (!$user instanceof WP_User) { |
|
27 | 27 | return array( |
28 | 28 | 'data' => $data_to_export, |
29 | 29 | 'done' => true, |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - $args = array( |
|
33 | + $args = array( |
|
34 | 34 | 'limit' => 30, |
35 | 35 | 'page' => $page, |
36 | 36 | 'user' => $user->ID, |
37 | 37 | ); |
38 | 38 | |
39 | - $invoices = wpinv_get_invoices( $args ); |
|
39 | + $invoices = wpinv_get_invoices($args); |
|
40 | 40 | |
41 | - if ( 0 < count( $invoices ) ) { |
|
42 | - foreach ( $invoices as $invoice ) { |
|
41 | + if (0 < count($invoices)) { |
|
42 | + foreach ($invoices as $invoice) { |
|
43 | 43 | $data_to_export[] = array( |
44 | 44 | 'group_id' => 'customer_invoices', |
45 | - 'group_label' => __( 'Invoicing Data', 'invoicing' ), |
|
45 | + 'group_label' => __('Invoicing Data', 'invoicing'), |
|
46 | 46 | 'item_id' => "wpinv-{$invoice->ID}", |
47 | - 'data' => self::get_customer_invoice_data( $invoice ), |
|
47 | + 'data' => self::get_customer_invoice_data($invoice), |
|
48 | 48 | ); |
49 | 49 | } |
50 | - $done = 30 > count( $invoices ); |
|
50 | + $done = 30 > count($invoices); |
|
51 | 51 | } else { |
52 | 52 | $done = true; |
53 | 53 | } |
@@ -65,59 +65,59 @@ discard block |
||
65 | 65 | * @param WPInv_Invoice $invoice invoice object. |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - public static function get_customer_invoice_data( $invoice ) { |
|
68 | + public static function get_customer_invoice_data($invoice) { |
|
69 | 69 | $personal_data = array(); |
70 | 70 | |
71 | 71 | $props_to_export = array( |
72 | - 'number' => __( 'Invoice Number', 'invoicing' ), |
|
73 | - 'created_date' => __( 'Invoice Date', 'invoicing' ), |
|
74 | - 'status' => __( 'Invoice Status', 'invoicing' ), |
|
75 | - 'total' => __( 'Invoice Total', 'invoicing' ), |
|
76 | - 'items' => __( 'Invoice Items', 'invoicing' ), |
|
77 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
78 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
79 | - 'email' => __( 'Email Address', 'invoicing' ), |
|
80 | - '_wpinv_company' => __( 'Company', 'invoicing' ), |
|
81 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
82 | - 'address' => __( 'Address', 'invoicing' ), |
|
83 | - '_wpinv_city' => __( 'City', 'invoicing' ), |
|
84 | - '_wpinv_country' => __( 'Country', 'invoicing' ), |
|
85 | - '_wpinv_state' => __( 'State', 'invoicing' ), |
|
86 | - '_wpinv_zip' => __( 'Zip Code', 'invoicing' ), |
|
72 | + 'number' => __('Invoice Number', 'invoicing'), |
|
73 | + 'created_date' => __('Invoice Date', 'invoicing'), |
|
74 | + 'status' => __('Invoice Status', 'invoicing'), |
|
75 | + 'total' => __('Invoice Total', 'invoicing'), |
|
76 | + 'items' => __('Invoice Items', 'invoicing'), |
|
77 | + 'first_name' => __('First Name', 'invoicing'), |
|
78 | + 'last_name' => __('Last Name', 'invoicing'), |
|
79 | + 'email' => __('Email Address', 'invoicing'), |
|
80 | + '_wpinv_company' => __('Company', 'invoicing'), |
|
81 | + 'phone' => __('Phone Number', 'invoicing'), |
|
82 | + 'address' => __('Address', 'invoicing'), |
|
83 | + '_wpinv_city' => __('City', 'invoicing'), |
|
84 | + '_wpinv_country' => __('Country', 'invoicing'), |
|
85 | + '_wpinv_state' => __('State', 'invoicing'), |
|
86 | + '_wpinv_zip' => __('Zip Code', 'invoicing'), |
|
87 | 87 | ); |
88 | 88 | |
89 | - $subscription = wpinv_get_subscription( $invoice ); |
|
89 | + $subscription = wpinv_get_subscription($invoice); |
|
90 | 90 | $period = $initial_amt = $bill_times = $billed = $renewal_date = ''; |
91 | 91 | |
92 | - if ( $invoice->is_recurring() && !empty( $subscription ) ) { |
|
93 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period,$subscription->frequency ); |
|
94 | - $period = wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
95 | - $initial_amt = wpinv_price( wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
96 | - $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); |
|
97 | - $renewal_date = ! empty( $subscription->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
98 | - |
|
99 | - $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' ); |
|
100 | - $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' ); |
|
101 | - $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' ); |
|
102 | - $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' ); |
|
92 | + if ($invoice->is_recurring() && !empty($subscription)) { |
|
93 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
94 | + $period = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
95 | + $initial_amt = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
96 | + $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); |
|
97 | + $renewal_date = !empty($subscription->expiration) ? date_i18n(get_option('date_format'), strtotime($subscription->expiration)) : __('N/A', 'invoicing'); |
|
98 | + |
|
99 | + $props_to_export['period'] = __('Billing Cycle', 'invoicing'); |
|
100 | + $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing'); |
|
101 | + $props_to_export['bill_times'] = __('Times Billed', 'invoicing'); |
|
102 | + $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing'); |
|
103 | 103 | } |
104 | 104 | |
105 | - $props_to_export['ip'] = __( 'IP Address', 'invoicing' ); |
|
106 | - $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' ); |
|
105 | + $props_to_export['ip'] = __('IP Address', 'invoicing'); |
|
106 | + $props_to_export['view_url'] = __('Invoice Link', 'invoicing'); |
|
107 | 107 | |
108 | - $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
108 | + $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
109 | 109 | |
110 | - foreach ( $props_to_export as $prop => $name ) { |
|
110 | + foreach ($props_to_export as $prop => $name) { |
|
111 | 111 | $value = ''; |
112 | 112 | |
113 | - switch ( $prop ) { |
|
113 | + switch ($prop) { |
|
114 | 114 | case 'items': |
115 | 115 | $item_names = array(); |
116 | - foreach ( $invoice->get_cart_details() as $key => $cart_item ) { |
|
117 | - $item_quantity = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
116 | + foreach ($invoice->get_cart_details() as $key => $cart_item) { |
|
117 | + $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
118 | 118 | $item_names[] = $cart_item['name'] . ' x ' . $item_quantity; |
119 | 119 | } |
120 | - $value = implode( ', ', $item_names ); |
|
120 | + $value = implode(', ', $item_names); |
|
121 | 121 | break; |
122 | 122 | case 'status': |
123 | 123 | $value = $invoice->get_status(true); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $value = $renewal_date; |
139 | 139 | break; |
140 | 140 | default: |
141 | - if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) { |
|
141 | + if (is_callable(array($invoice, 'get_' . $prop))) { |
|
142 | 142 | $value = $invoice->{"get_$prop"}(); |
143 | 143 | } else { |
144 | 144 | $value = $invoice->get_meta($prop); |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | break; |
147 | 147 | } |
148 | 148 | |
149 | - $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice ); |
|
149 | + $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice); |
|
150 | 150 | |
151 | - if ( $value ) { |
|
151 | + if ($value) { |
|
152 | 152 | $personal_data[] = array( |
153 | 153 | 'name' => $name, |
154 | 154 | 'value' => $value, |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | } |
159 | 159 | |
160 | - $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice ); |
|
160 | + $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice); |
|
161 | 161 | |
162 | 162 | return $personal_data; |
163 | 163 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Abstract privacy class. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Abstract class that is intended to be extended by |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $name Plugin identifier. |
40 | 40 | */ |
41 | - public function __construct( $name = '' ) { |
|
41 | + public function __construct($name = '') { |
|
42 | 42 | $this->name = $name; |
43 | 43 | $this->init(); |
44 | 44 | } |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | * Hook in events. |
48 | 48 | */ |
49 | 49 | protected function init() { |
50 | - add_action( 'admin_init', array( $this, 'add_privacy_message' ) ); |
|
50 | + add_action('admin_init', array($this, 'add_privacy_message')); |
|
51 | 51 | // Register data exporters |
52 | - add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 ); |
|
52 | + add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10); |
|
53 | 53 | // Register data erasers |
54 | - add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) ); |
|
54 | + add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Adds the privacy message on invoicing privacy page. |
59 | 59 | */ |
60 | 60 | public function add_privacy_message() { |
61 | - if ( function_exists( 'wp_add_privacy_policy_content' ) ) { |
|
61 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
62 | 62 | $content = $this->get_privacy_message(); |
63 | 63 | |
64 | - if ( $content ) { |
|
65 | - wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() ); |
|
64 | + if ($content) { |
|
65 | + wp_add_privacy_policy_content($this->name, $this->get_privacy_message()); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param array $exporters List of exporter callbacks. |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public function register_exporters( $exporters = array() ) { |
|
87 | - foreach ( $this->exporters as $id => $exporter ) { |
|
88 | - $exporters[ $id ] = $exporter; |
|
86 | + public function register_exporters($exporters = array()) { |
|
87 | + foreach ($this->exporters as $id => $exporter) { |
|
88 | + $exporters[$id] = $exporter; |
|
89 | 89 | } |
90 | 90 | return $exporters; |
91 | 91 | } |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * @param array $erasers List of eraser callbacks. |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function register_erasers( $erasers = array() ) { |
|
100 | - foreach ( $this->erasers as $id => $eraser ) { |
|
101 | - $erasers[ $id ] = $eraser; |
|
99 | + public function register_erasers($erasers = array()) { |
|
100 | + foreach ($this->erasers as $id => $eraser) { |
|
101 | + $erasers[$id] = $eraser; |
|
102 | 102 | } |
103 | 103 | return $erasers; |
104 | 104 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function add_exporter( $id, $name, $callback ) { |
|
116 | - $this->exporters[ $id ] = array( |
|
115 | + public function add_exporter($id, $name, $callback) { |
|
116 | + $this->exporters[$id] = array( |
|
117 | 117 | 'exporter_friendly_name' => $name, |
118 | 118 | 'callback' => $callback, |
119 | 119 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function add_eraser( $id, $name, $callback ) { |
|
133 | - $this->erasers[ $id ] = array( |
|
132 | + public function add_eraser($id, $name, $callback) { |
|
133 | + $this->erasers[$id] = array( |
|
134 | 134 | 'eraser_friendly_name' => $name, |
135 | 135 | 'callback' => $callback, |
136 | 136 | ); |
@@ -31,27 +31,27 @@ |
||
31 | 31 | public function get_privacy_message() { |
32 | 32 | |
33 | 33 | $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' . |
34 | - '<div contenteditable="false">' . |
|
35 | - '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
36 | - '</div>' . |
|
37 | - '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
38 | - '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
39 | - '<ul>' . |
|
40 | - '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' . |
|
41 | - '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
42 | - '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
43 | - '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
44 | - '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
45 | - '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
46 | - '</ul>' . |
|
47 | - '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
48 | - '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
49 | - '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
50 | - '<div contenteditable="false">' . |
|
51 | - '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
52 | - '</div>' . |
|
53 | - '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
54 | - '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>'; |
|
34 | + '<div contenteditable="false">' . |
|
35 | + '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
36 | + '</div>' . |
|
37 | + '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
38 | + '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
39 | + '<ul>' . |
|
40 | + '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' . |
|
41 | + '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
42 | + '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
43 | + '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
44 | + '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
45 | + '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
46 | + '</ul>' . |
|
47 | + '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
48 | + '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
49 | + '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
50 | + '<div contenteditable="false">' . |
|
51 | + '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
52 | + '</div>' . |
|
53 | + '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
54 | + '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Privacy/GDPR related functionality which ties into WordPress functionality. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy Class. |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | * Init - hook into events. |
15 | 15 | */ |
16 | 16 | public function __construct() { |
17 | - parent::__construct( __( 'Invoicing', 'invoicing' ) ); |
|
17 | + parent::__construct(__('Invoicing', 'invoicing')); |
|
18 | 18 | |
19 | 19 | // Include supporting classes. |
20 | 20 | include_once 'class-wpinv-privacy-exporters.php'; |
21 | 21 | |
22 | 22 | // This hook registers Invoicing data exporters. |
23 | - $this->add_exporter( 'wpinv-customer-invoices', __( 'Customer Invoices', 'invoicing' ), array( 'WPInv_Privacy_Exporters', 'customer_invoice_data_exporter' ) ); |
|
23 | + $this->add_exporter('wpinv-customer-invoices', __('Customer Invoices', 'invoicing'), array('WPInv_Privacy_Exporters', 'customer_invoice_data_exporter')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function get_privacy_message() { |
32 | 32 | |
33 | - $content = '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' . |
|
33 | + $content = '<h2>' . __('Invoices and checkout', 'invoicing') . '</h2>' . |
|
34 | 34 | '<div contenteditable="false">' . |
35 | - '<p class="wp-policy-help">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
35 | + '<p class="wp-policy-help">' . __('Example privacy texts.', 'invoicing') . '</p>' . |
|
36 | 36 | '</div>' . |
37 | - '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
38 | - '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
37 | + '<p>' . __('We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing') . '</p>' . |
|
38 | + '<p>' . __('Handling this data also allows us to:', 'invoicing') . '</p>' . |
|
39 | 39 | '<ul>' . |
40 | - '<li>' . __( '- Send you important account/order/service information.', 'invoicing' ) . '</li>' . |
|
41 | - '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
42 | - '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
43 | - '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
44 | - '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
45 | - '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
40 | + '<li>' . __('- Send you important account/order/service information.', 'invoicing') . '</li>' . |
|
41 | + '<li>' . __('- Estimate taxes based on your location.', 'invoicing') . '</li>' . |
|
42 | + '<li>' . __('- Respond to your queries or complaints.', 'invoicing') . '</li>' . |
|
43 | + '<li>' . __('- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' . |
|
44 | + '<li>' . __('- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing') . '</li>' . |
|
45 | + '<li>' . __('- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' . |
|
46 | 46 | '</ul>' . |
47 | - '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
48 | - '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
49 | - '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
47 | + '<p>' . __('In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing') . '</p>' . |
|
48 | + '<h2>' . __('What we share with others', 'invoicing') . '</h2>' . |
|
49 | + '<p>' . __('We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing') . '</p>' . |
|
50 | 50 | '<div contenteditable="false">' . |
51 | - '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
51 | + '<p class="wp-policy-help">' . __('In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing') . '</p>' . |
|
52 | 52 | '</div>' . |
53 | - '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
54 | - '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>'; |
|
53 | + '<p>' . __('We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing') . '</p>' . |
|
54 | + '<p>' . __('Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing') . '</p>'; |
|
55 | 55 | |
56 | 56 | |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // '</p>' . |
63 | 63 | // '</div>'; |
64 | 64 | |
65 | - return apply_filters( 'wpinv_privacy_policy_content', $content ); |
|
65 | + return apply_filters('wpinv_privacy_policy_content', $content); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,74 +14,74 @@ discard block |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | public function init() { |
17 | - do_action( 'wpinv_class_notes_init', $this ); |
|
17 | + do_action('wpinv_class_notes_init', $this); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function includes() { |
21 | - do_action( 'wpinv_class_notes_includes', $this ); |
|
21 | + do_action('wpinv_class_notes_includes', $this); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function actions() { |
25 | 25 | // Secure inovice notes |
26 | - add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
27 | - add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
26 | + add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1); |
|
27 | + add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1); |
|
28 | 28 | |
29 | 29 | // Count comments |
30 | - add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 ); |
|
30 | + add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2); |
|
31 | 31 | |
32 | 32 | // Delete comments count cache whenever there is a new comment or a comment status changes |
33 | - add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
34 | - add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
33 | + add_action('wp_insert_comment', array($this, 'delete_comments_count_cache')); |
|
34 | + add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache')); |
|
35 | 35 | |
36 | - do_action( 'wpinv_class_notes_actions', $this ); |
|
36 | + do_action('wpinv_class_notes_actions', $this); |
|
37 | 37 | } |
38 | 38 | |
39 | - public function set_invoice_note_type( $query ) { |
|
40 | - $post_ID = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
39 | + public function set_invoice_note_type($query) { |
|
40 | + $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
41 | 41 | |
42 | - if ( $post_ID && in_array(get_post_type( $post_ID ), array($this->invoice_post_type, 'wpi_quote' )) ) { |
|
42 | + if ($post_ID && in_array(get_post_type($post_ID), array($this->invoice_post_type, 'wpi_quote'))) { |
|
43 | 43 | $query->query_vars['type__in'] = $this->comment_type; |
44 | 44 | $query->query_vars['type__not_in'] = ''; |
45 | 45 | } else { |
46 | - if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) { |
|
47 | - if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) { |
|
48 | - $key = array_search( $this->comment_type, $type_in ); |
|
49 | - unset( $query->query_vars['type__in'][$key] ); |
|
50 | - } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) { |
|
46 | + if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) { |
|
47 | + if (is_array($type_in) && in_array($this->comment_type, $type_in)) { |
|
48 | + $key = array_search($this->comment_type, $type_in); |
|
49 | + unset($query->query_vars['type__in'][$key]); |
|
50 | + } else if (!is_array($type_in) && $type_in == $this->comment_type) { |
|
51 | 51 | $query->query_vars['type__in'] = ''; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) { |
|
56 | - if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) { |
|
55 | + if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) { |
|
56 | + if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) { |
|
57 | 57 | $query->query_vars['type__not_in'][] = $this->comment_type; |
58 | - } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) { |
|
58 | + } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) { |
|
59 | 59 | $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in']; |
60 | 60 | $query->query_vars['type__not_in'][] = $this->comment_type; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $query->query_vars['type__not_in'] = $this->comment_type; |
|
63 | + $query->query_vars['type__not_in'] = $this->comment_type; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | return $query; |
68 | 68 | } |
69 | 69 | |
70 | - public function get_invoice_notes( $invoice_id = 0, $type = '' ) { |
|
70 | + public function get_invoice_notes($invoice_id = 0, $type = '') { |
|
71 | 71 | $args = array( |
72 | 72 | 'post_id' => $invoice_id, |
73 | 73 | 'orderby' => 'comment_ID', |
74 | 74 | 'order' => 'ASC', |
75 | 75 | ); |
76 | 76 | |
77 | - if ( $type == 'customer' ) { |
|
77 | + if ($type == 'customer') { |
|
78 | 78 | $args['meta_key'] = '_wpi_customer_note'; |
79 | 79 | $args['meta_value'] = 1; |
80 | 80 | } |
81 | 81 | |
82 | - $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
82 | + $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type); |
|
83 | 83 | |
84 | - return get_comments( $args ); |
|
84 | + return get_comments($args); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return void |
93 | 93 | */ |
94 | 94 | public function delete_comments_count_cache() { |
95 | - delete_transient( 'wpinv_count_comments' ); |
|
95 | + delete_transient('wpinv_count_comments'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | * @param int $post_id Post ID. |
104 | 104 | * @return object |
105 | 105 | */ |
106 | - public function wp_count_comments( $stats, $post_id ) { |
|
106 | + public function wp_count_comments($stats, $post_id) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - if ( 0 === $post_id ) { |
|
110 | - $stats = get_transient( 'wpinv_count_comments' ); |
|
109 | + if (0 === $post_id) { |
|
110 | + $stats = get_transient('wpinv_count_comments'); |
|
111 | 111 | |
112 | - if ( ! $stats ) { |
|
112 | + if (!$stats) { |
|
113 | 113 | $stats = array(); |
114 | 114 | |
115 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A ); |
|
115 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A); |
|
116 | 116 | |
117 | 117 | $total = 0; |
118 | 118 | $approved = array( |
@@ -123,33 +123,33 @@ discard block |
||
123 | 123 | 'post-trashed' => 'post-trashed', |
124 | 124 | ); |
125 | 125 | |
126 | - foreach ( (array) $count as $row ) { |
|
126 | + foreach ((array)$count as $row) { |
|
127 | 127 | // Do not count post-trashed toward totals. |
128 | - if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) { |
|
128 | + if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) { |
|
129 | 129 | $total += $row['num_comments']; |
130 | 130 | } |
131 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
132 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
131 | + if (isset($approved[$row['comment_approved']])) { |
|
132 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | $stats['total_comments'] = $total; |
137 | 137 | $stats['all'] = $total; |
138 | - foreach ( $approved as $key ) { |
|
139 | - if ( empty( $stats[ $key ] ) ) { |
|
140 | - $stats[ $key ] = 0; |
|
138 | + foreach ($approved as $key) { |
|
139 | + if (empty($stats[$key])) { |
|
140 | + $stats[$key] = 0; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - $stats = (object) $stats; |
|
145 | - set_transient( 'wpinv_count_comments', $stats ); |
|
144 | + $stats = (object)$stats; |
|
145 | + set_transient('wpinv_count_comments', $stats); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | return $stats; |
150 | 150 | } |
151 | 151 | |
152 | - function wpinv_comment_feed_where($where){ |
|
153 | - return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
152 | + function wpinv_comment_feed_where($where) { |
|
153 | + return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' "; |
|
154 | 154 | } |
155 | 155 | } |
@@ -11,49 +11,49 @@ discard block |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | - if ( $wpi_version == WPINV_VERSION ) { |
|
16 | + if ($wpi_version == WPINV_VERSION) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
20 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
21 | 21 | wpinv_v005_upgrades(); |
22 | 22 | } |
23 | 23 | |
24 | - if ( version_compare( $wpi_version, '1.0.3', '<' ) ) { |
|
24 | + if (version_compare($wpi_version, '1.0.3', '<')) { |
|
25 | 25 | wpinv_v110_upgrades(); |
26 | 26 | } |
27 | 27 | |
28 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
28 | + update_option('wpinv_version', WPINV_VERSION); |
|
29 | 29 | } |
30 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
30 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
31 | 31 | |
32 | 32 | function wpinv_v005_upgrades() { |
33 | 33 | global $wpdb; |
34 | 34 | |
35 | 35 | // Invoices status |
36 | - $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
37 | - if ( !empty( $results ) ) { |
|
38 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
36 | + $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
37 | + if (!empty($results)) { |
|
38 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
39 | 39 | |
40 | 40 | // Clean post cache |
41 | - foreach ( $results as $row ) { |
|
42 | - clean_post_cache( $row->ID ); |
|
41 | + foreach ($results as $row) { |
|
42 | + clean_post_cache($row->ID); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item meta key changes |
47 | 47 | $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
48 | - $results = $wpdb->get_results( $query ); |
|
48 | + $results = $wpdb->get_results($query); |
|
49 | 49 | |
50 | - if ( !empty( $results ) ) { |
|
51 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
52 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
53 | - $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
50 | + if (!empty($results)) { |
|
51 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
52 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
53 | + $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
54 | 54 | |
55 | - foreach ( $results as $row ) { |
|
56 | - clean_post_cache( $row->post_id ); |
|
55 | + foreach ($results as $row) { |
|
56 | + clean_post_cache($row->post_id); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
@@ -74,79 +74,79 @@ discard block |
||
74 | 74 | function wpinv_convert_old_subscriptions() { |
75 | 75 | global $wpdb; |
76 | 76 | |
77 | - $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1 AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC"; |
|
77 | + $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1 AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC"; |
|
78 | 78 | |
79 | - $results = $wpdb->get_results( $query ); |
|
79 | + $results = $wpdb->get_results($query); |
|
80 | 80 | |
81 | - if ( empty( $results ) ) { |
|
81 | + if (empty($results)) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - foreach ( $results as $row ) { |
|
86 | - $invoice = new WPInv_Invoice( $row->ID ); |
|
85 | + foreach ($results as $row) { |
|
86 | + $invoice = new WPInv_Invoice($row->ID); |
|
87 | 87 | |
88 | - if ( empty( $invoice->ID ) ) { |
|
88 | + if (empty($invoice->ID)) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - if ( $invoice->has_status( 'wpi-renewal' ) ) { |
|
92 | + if ($invoice->has_status('wpi-renewal')) { |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
96 | - $item = $invoice->get_recurring( true ); |
|
96 | + $item = $invoice->get_recurring(true); |
|
97 | 97 | |
98 | - if ( empty( $item ) ) { |
|
98 | + if (empty($item)) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $is_free_trial = $invoice->is_free_trial(); |
103 | - $profile_id = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true ); |
|
104 | - $subscription_status = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true ); |
|
103 | + $profile_id = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true); |
|
104 | + $subscription_status = get_post_meta($invoice->ID, '_wpinv_subscr_status', true); |
|
105 | 105 | $transaction_id = $invoice->get_transaction_id(); |
106 | 106 | |
107 | 107 | // Last invoice |
108 | - $query = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | - $last_payment = $wpdb->get_row( $query ); |
|
108 | + $query = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1"; |
|
109 | + $last_payment = $wpdb->get_row($query); |
|
110 | 110 | |
111 | - if ( !empty( $last_payment ) ) { |
|
112 | - $invoice_date = $last_payment->post_date; |
|
111 | + if (!empty($last_payment)) { |
|
112 | + $invoice_date = $last_payment->post_date; |
|
113 | 113 | |
114 | - $meta_profile_id = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true ); |
|
115 | - $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true ); |
|
114 | + $meta_profile_id = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true); |
|
115 | + $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true); |
|
116 | 116 | |
117 | - if ( !empty( $meta_profile_id ) ) { |
|
118 | - $profile_id = $meta_profile_id; |
|
117 | + if (!empty($meta_profile_id)) { |
|
118 | + $profile_id = $meta_profile_id; |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( !empty( $meta_transaction_id ) ) { |
|
122 | - $transaction_id = $meta_transaction_id; |
|
121 | + if (!empty($meta_transaction_id)) { |
|
122 | + $transaction_id = $meta_transaction_id; |
|
123 | 123 | } |
124 | 124 | } else { |
125 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
125 | + $invoice_date = $invoice->get_invoice_date(false); |
|
126 | 126 | } |
127 | 127 | |
128 | - $profile_id = empty( $profile_id ) ? $invoice->ID : $profile_id; |
|
129 | - $status = empty( $subscription_status ) ? 'pending' : $subscription_status; |
|
128 | + $profile_id = empty($profile_id) ? $invoice->ID : $profile_id; |
|
129 | + $status = empty($subscription_status) ? 'pending' : $subscription_status; |
|
130 | 130 | |
131 | - $period = $item->get_recurring_period( true ); |
|
131 | + $period = $item->get_recurring_period(true); |
|
132 | 132 | $interval = $item->get_recurring_interval(); |
133 | 133 | $bill_times = (int)$item->get_recurring_limit(); |
134 | 134 | $add_period = $interval . ' ' . $period; |
135 | 135 | $trial_period = ''; |
136 | 136 | |
137 | - if ( $invoice->is_free_trial() ) { |
|
138 | - $trial_period = $item->get_trial_period( true ); |
|
137 | + if ($invoice->is_free_trial()) { |
|
138 | + $trial_period = $item->get_trial_period(true); |
|
139 | 139 | $free_interval = $item->get_trial_interval(); |
140 | 140 | $trial_period = $free_interval . ' ' . $trial_period; |
141 | 141 | |
142 | - if ( empty( $last_payment ) ) { |
|
142 | + if (empty($last_payment)) { |
|
143 | 143 | $add_period = $trial_period; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
148 | - if ( strtotime( $expiration ) < strtotime( date_i18n( 'Y-m-d' ) ) ) { |
|
149 | - if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) { |
|
147 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
148 | + if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) { |
|
149 | + if ($status == 'active' || $status == 'trialling' || $status == 'pending') { |
|
150 | 150 | $status = 'expired'; |
151 | 151 | } |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'frequency' => $interval, |
160 | 160 | 'period' => $period, |
161 | 161 | 'initial_amount' => $invoice->get_total(), |
162 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
162 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
163 | 163 | 'bill_times' => $bill_times, |
164 | 164 | 'created' => $invoice_date, |
165 | 165 | 'expiration' => $expiration, |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | $subs_db = new WPInv_Subscriptions_DB; |
172 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) ); |
|
173 | - $subscription = reset( $subs ); |
|
172 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1)); |
|
173 | + $subscription = reset($subs); |
|
174 | 174 | |
175 | - if ( empty( $subscription ) || $subscription->id <= 0 ) { |
|
175 | + if (empty($subscription) || $subscription->id <= 0) { |
|
176 | 176 | $subscription = new WPInv_Subscription(); |
177 | - $new_sub = $subscription->create( $args ); |
|
177 | + $new_sub = $subscription->create($args); |
|
178 | 178 | |
179 | - if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) { |
|
179 | + if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) { |
|
180 | 180 | $new_sub->complete(); // Mark completed if all times billed |
181 | 181 | } |
182 | 182 | } |
@@ -186,20 +186,20 @@ discard block |
||
186 | 186 | function wpinv_update_new_email_settings() { |
187 | 187 | global $wpinv_options; |
188 | 188 | |
189 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
189 | + $current_options = get_option('wpinv_settings', array()); |
|
190 | 190 | $options = array( |
191 | - 'email_new_invoice_body' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ), |
|
192 | - 'email_cancelled_invoice_body' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ), |
|
193 | - 'email_failed_invoice_body' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ), |
|
194 | - 'email_onhold_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ), |
|
195 | - 'email_processing_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ), |
|
196 | - 'email_refunded_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
197 | - 'email_user_invoice_body' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
198 | - 'email_user_note_body' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
199 | - 'email_overdue_body' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
191 | + 'email_new_invoice_body' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'), |
|
192 | + 'email_cancelled_invoice_body' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'), |
|
193 | + 'email_failed_invoice_body' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'), |
|
194 | + 'email_onhold_invoice_body' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'), |
|
195 | + 'email_processing_invoice_body' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'), |
|
196 | + 'email_refunded_invoice_body' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
197 | + 'email_user_invoice_body' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
198 | + 'email_user_note_body' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
199 | + 'email_overdue_body' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
200 | 200 | ); |
201 | 201 | |
202 | - foreach ($options as $option => $value){ |
|
202 | + foreach ($options as $option => $value) { |
|
203 | 203 | if (!isset($current_options[$option])) { |
204 | 204 | $current_options[$option] = $value; |
205 | 205 | } |
@@ -207,5 +207,5 @@ discard block |
||
207 | 207 | |
208 | 208 | $wpinv_options = $current_options; |
209 | 209 | |
210 | - update_option( 'wpinv_settings', $current_options ); |
|
210 | + update_option('wpinv_settings', $current_options); |
|
211 | 211 | } |
212 | 212 | \ No newline at end of file |
@@ -79,7 +79,7 @@ |
||
79 | 79 | |
80 | 80 | if(empty($count)){ |
81 | 81 | $output .= __('No Invoice(s)','invoicing'); |
82 | - }else{ |
|
82 | + } else{ |
|
83 | 83 | $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
84 | 84 | $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
85 | 85 | $output .= "<a href='$link_url' >$link_text</a>"; |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Admin_Users { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
19 | 19 | self::$instance = new WPInv_Admin_Users; |
20 | 20 | } |
21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function __construct() { |
26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column') ); |
|
27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content') , 10, 3 ); |
|
26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | - public function wpinv_add_user_column( $column ) { |
|
38 | - $column['wpinvoicing'] = __('Invoicing','invoicing'); |
|
37 | + public function wpinv_add_user_column($column) { |
|
38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
39 | 39 | return $column; |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
51 | + function wpinv_user_column_content($val, $column_name, $user_id) { |
|
52 | 52 | switch ($column_name) { |
53 | 53 | case 'wpinvoicing' : |
54 | - return $this->get_user_invoices( $user_id ); |
|
54 | + return $this->get_user_invoices($user_id); |
|
55 | 55 | break; |
56 | 56 | default: |
57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function get_user_invoices($user_id){ |
|
68 | + public function get_user_invoices($user_id) { |
|
69 | 69 | $output = ''; |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_invoice', |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | |
78 | 78 | $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
79 | 79 | |
80 | - $invoices = new WP_Query( $wp_query_args ); |
|
81 | - $count = absint( $invoices->found_posts ); |
|
80 | + $invoices = new WP_Query($wp_query_args); |
|
81 | + $count = absint($invoices->found_posts); |
|
82 | 82 | |
83 | - if(empty($count)){ |
|
84 | - $output .= __('No Invoice(s)','invoicing'); |
|
85 | - }else{ |
|
86 | - $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
|
87 | - $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
|
83 | + if (empty($count)) { |
|
84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
85 | + } else { |
|
86 | + $link_url = admin_url("edit.php?post_type=wpi_invoice&author=" . absint($user_id)); |
|
87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
89 | 89 | } |
90 | 90 |
@@ -28,6 +28,9 @@ |
||
28 | 28 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
29 | 29 | ); |
30 | 30 | |
31 | + /** |
|
32 | + * @return callable |
|
33 | + */ |
|
31 | 34 | public static function getInitializer(ClassLoader $loader) |
32 | 35 | { |
33 | 36 | return \Closure::bind(function () use ($loader) { |
@@ -6,31 +6,31 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
11 | 11 | ); |
12 | 12 | |
13 | - public static $prefixLengthsPsr4 = array ( |
|
13 | + public static $prefixLengthsPsr4 = array( |
|
14 | 14 | 'C' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'Composer\\Installers\\' => 20, |
17 | 17 | ), |
18 | 18 | ); |
19 | 19 | |
20 | - public static $prefixDirsPsr4 = array ( |
|
20 | + public static $prefixDirsPsr4 = array( |
|
21 | 21 | 'Composer\\Installers\\' => |
22 | - array ( |
|
22 | + array( |
|
23 | 23 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
24 | 24 | ), |
25 | 25 | ); |
26 | 26 | |
27 | - public static $classMap = array ( |
|
27 | + public static $classMap = array( |
|
28 | 28 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
29 | 29 | ); |
30 | 30 | |
31 | 31 | public static function getInitializer(ClassLoader $loader) |
32 | 32 | { |
33 | - return \Closure::bind(function () use ($loader) { |
|
33 | + return \Closure::bind(function() use ($loader) { |
|
34 | 34 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
35 | 35 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
36 | 36 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |