@@ -29,16 +29,16 @@ |
||
29 | 29 | <table class="table table-bordered table-hover table-responsive wpi-user-subscriptions"> |
30 | 30 | <thead> |
31 | 31 | <tr> |
32 | - <th class="sub-no"><span class="nobr"><?php _e( 'No.', 'invoicing' ); ?></span></th> |
|
33 | - <th class="sub-amount"><span class="nobr"><?php _e( 'Initial Amount', 'invoicing' ); ?></span></th> |
|
34 | - <th class="sub-cycle"><span class="nobr"><?php _e( 'Billing Cycle', 'invoicing' ); ?></span></th> |
|
35 | - <th class="sub-billed"><span class="nobr"><?php _e( 'Times Billed', 'invoicing' ); ?></span></th> |
|
36 | - <th class="sub-status"><span class="nobr"><?php _e( 'Status', 'invoicing' ); ?></span></th> |
|
37 | - <th class="sub-invoice"><span class="nobr"><?php _e( 'Invoice', 'invoicing' ); ?></span></th> |
|
38 | - <th class="sub-item"><span class="nobr"><?php _e( 'Item', 'invoicing' ); ?></span></th> |
|
39 | - <th class="sub-gateway"><span class="nobr"><?php _e( 'Gateway', 'invoicing' ); ?></span></th> |
|
40 | - <th class="sub-expiry"><span class="nobr"><?php _e( 'Expires On', 'invoicing' ); ?></span></th> |
|
41 | - <th class="sub-actions"><span class="nobr"><?php _e( 'Actions', 'invoicing' ); ?></span></th> |
|
32 | + <th class="sub-no"><span class="nobr"><?php _e('No.', 'invoicing'); ?></span></th> |
|
33 | + <th class="sub-amount"><span class="nobr"><?php _e('Initial Amount', 'invoicing'); ?></span></th> |
|
34 | + <th class="sub-cycle"><span class="nobr"><?php _e('Billing Cycle', 'invoicing'); ?></span></th> |
|
35 | + <th class="sub-billed"><span class="nobr"><?php _e('Times Billed', 'invoicing'); ?></span></th> |
|
36 | + <th class="sub-status"><span class="nobr"><?php _e('Status', 'invoicing'); ?></span></th> |
|
37 | + <th class="sub-invoice"><span class="nobr"><?php _e('Invoice', 'invoicing'); ?></span></th> |
|
38 | + <th class="sub-item"><span class="nobr"><?php _e('Item', 'invoicing'); ?></span></th> |
|
39 | + <th class="sub-gateway"><span class="nobr"><?php _e('Gateway', 'invoicing'); ?></span></th> |
|
40 | + <th class="sub-expiry"><span class="nobr"><?php _e('Expires On', 'invoicing'); ?></span></th> |
|
41 | + <th class="sub-actions"><span class="nobr"><?php _e('Actions', 'invoicing'); ?></span></th> |
|
42 | 42 | </tr> |
43 | 43 | </thead> |
44 | 44 |
@@ -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,18 +14,18 @@ discard block |
||
14 | 14 | * Hook in methods. |
15 | 15 | */ |
16 | 16 | public static function init() { |
17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function init_hooks() { |
22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
24 | + $success_page = wpinv_get_option('success_page', ''); |
|
25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
40 | 40 | |
41 | 41 | // Exclude permalinks |
42 | - $checkout_page = get_post( $checkout_page ); |
|
43 | - $success_page = get_post( $success_page ); |
|
44 | - $failure_page = get_post( $failure_page ); |
|
45 | - $history_page = get_post( $history_page ); |
|
46 | - $subscr_page = get_post( $subscr_page ); |
|
42 | + $checkout_page = get_post($checkout_page); |
|
43 | + $success_page = get_post($success_page); |
|
44 | + $failure_page = get_post($failure_page); |
|
45 | + $history_page = get_post($history_page); |
|
46 | + $subscr_page = get_post($subscr_page); |
|
47 | 47 | |
48 | - if ( ! is_null( $checkout_page ) ) { |
|
48 | + if (!is_null($checkout_page)) { |
|
49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
50 | 50 | } |
51 | - if ( ! is_null( $success_page ) ) { |
|
51 | + if (!is_null($success_page)) { |
|
52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
53 | 53 | } |
54 | - if ( ! is_null( $failure_page ) ) { |
|
54 | + if (!is_null($failure_page)) { |
|
55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
56 | 56 | } |
57 | - if ( ! is_null( $history_page ) ) { |
|
57 | + if (!is_null($history_page)) { |
|
58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
59 | 59 | } |
60 | - if ( ! is_null( $subscr_page ) ) { |
|
60 | + if (!is_null($subscr_page)) { |
|
61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
62 | 62 | } |
63 | 63 | |
64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( is_array( $page_uris ) ) { |
|
68 | - foreach( $page_uris as $uri ) { |
|
69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
67 | + if (is_array($page_uris)) { |
|
68 | + foreach ($page_uris as $uri) { |
|
69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
70 | 70 | self::nocache(); |
71 | 71 | break; |
72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | */ |
81 | 81 | private static function nocache() { |
82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
83 | - define( "DONOTCACHEPAGE", true ); |
|
82 | + if (!defined('DONOTCACHEPAGE')) { |
|
83 | + define("DONOTCACHEPAGE", true); |
|
84 | 84 | } |
85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
86 | - define( "DONOTCACHEOBJECT", true ); |
|
85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
86 | + define("DONOTCACHEOBJECT", true); |
|
87 | 87 | } |
88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
89 | - define( "DONOTCACHEDB", true ); |
|
88 | + if (!defined('DONOTCACHEDB')) { |
|
89 | + define("DONOTCACHEDB", true); |
|
90 | 90 | } |
91 | 91 | nocache_headers(); |
92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | * notices function. |
96 | 96 | */ |
97 | 97 | public static function notices() { |
98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $config = w3_instance( 'W3_Config' ); |
|
103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
102 | + $config = w3_instance('W3_Config'); |
|
103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
105 | 105 | |
106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
107 | 107 | ?> |
108 | 108 | <div class="error"> |
109 | - <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p> |
|
109 | + <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p> |
|
110 | 110 | </div> |
111 | 111 | <?php |
112 | 112 | } |
@@ -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', |
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"> |
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); |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,92 +72,92 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
226 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
281 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
314 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
351 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |
@@ -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', |
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', |
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"> |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | - $statuses = wpinv_get_invoice_statuses( true ); |
|
10 | + $statuses = wpinv_get_invoice_statuses(true); |
|
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
28 | 28 | |
29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,36 +34,36 @@ discard block |
||
34 | 34 | <div class="gdmbx2-wrap form-table"> |
35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
39 | 39 | </div> |
40 | - <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?> |
|
40 | + <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
45 | - <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p> |
|
44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
45 | + <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p> |
|
46 | 46 | </div> |
47 | 47 | </div> |
48 | 48 | <?php } ?> |
49 | - <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
50 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
49 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
50 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
51 | 51 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
52 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
53 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
52 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
53 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
54 | 54 | </div> |
55 | 55 | <?php } ?> |
56 | - <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?> |
|
56 | + <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?> |
|
57 | 57 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed"> |
58 | - <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div> |
|
59 | - <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div> |
|
58 | + <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div> |
|
59 | + <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div> |
|
60 | 60 | </div> |
61 | 61 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
62 | 62 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
63 | 63 | <div class="gdmbx-td"> |
64 | 64 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
65 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
66 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
65 | + <?php foreach ($statuses as $value => $label) { ?> |
|
66 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
67 | 67 | <?php } ?> |
68 | 68 | </select> |
69 | 69 | </div> |
@@ -71,117 +71,117 @@ discard block |
||
71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
72 | 72 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
73 | 73 | <div class="gdmbx-td"> |
74 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
74 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
75 | 75 | </div> |
76 | 76 | </div> |
77 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); |
|
77 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); |
|
78 | 78 | $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id); |
79 | 79 | ?> |
80 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?> |
|
80 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?> |
|
81 | 81 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
82 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
82 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
83 | 83 | <div class="gdmbx-td"> |
84 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
84 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
85 | 85 | </div> |
86 | 86 | </div> |
87 | 87 | <?php } ?> |
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
91 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
91 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
92 | 92 | <select id="wpi_save_send" name="wpi_save_send"> |
93 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
94 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
93 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
94 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
95 | 95 | </select> |
96 | 96 | </p> |
97 | 97 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
98 | 98 | </div> |
99 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
99 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
100 | 100 | <?php |
101 | 101 | } |
102 | 102 | |
103 | - public static function resend_invoice( $post ) { |
|
103 | + public static function resend_invoice($post) { |
|
104 | 104 | global $wpi_mb_invoice; |
105 | 105 | |
106 | - if ( empty( $wpi_mb_invoice ) ) { |
|
106 | + if (empty($wpi_mb_invoice)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $text = array( |
111 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
112 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
111 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
112 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
116 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
116 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
117 | 117 | |
118 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
118 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
119 | 119 | $email_actions = array(); |
120 | - $email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
121 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
120 | + $email_actions['email_url'] = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))); |
|
121 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
122 | 122 | |
123 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
123 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
124 | 124 | ?> |
125 | 125 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
126 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
127 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
128 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
126 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
127 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
128 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
129 | 129 | <?php } ?> |
130 | 130 | <?php |
131 | 131 | } |
132 | 132 | |
133 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
133 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
134 | 134 | } |
135 | 135 | |
136 | - public static function subscriptions( $post ) { |
|
137 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
136 | + public static function subscriptions($post) { |
|
137 | + $invoice = wpinv_get_invoice($post->ID); |
|
138 | 138 | |
139 | - if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
140 | - $subscription = wpinv_get_subscription( $invoice ); |
|
139 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
140 | + $subscription = wpinv_get_subscription($invoice); |
|
141 | 141 | |
142 | - if ( empty( $subscription ) ) { |
|
142 | + if (empty($subscription)) { |
|
143 | 143 | ?> |
144 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
144 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p> |
|
145 | 145 | <?php |
146 | 146 | return; |
147 | 147 | } |
148 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
149 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
150 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
148 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
149 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
150 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
151 | 151 | $payments = $subscription->get_child_payments(); |
152 | 152 | ?> |
153 | 153 | <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
154 | - <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
154 | + <?php if (!empty($subscription) && !empty($subscription->id)) { ?> |
|
155 | 155 | <p class="wpi-meta-row wpi-sub-id"> |
156 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
156 | + <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
157 | 157 | <?php } ?> |
158 | 158 | <p class="wpi-meta-row wpi-bill-cycle"> |
159 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
159 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?> |
|
160 | 160 | </p> |
161 | 161 | <p class="wpi-meta-row wpi-billed-times"> |
162 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
162 | + <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
163 | 163 | </p> |
164 | 164 | <p class="wpi-meta-row wpi-start-date"> |
165 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
165 | + <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
166 | 166 | </p> |
167 | 167 | <p class="wpi-meta-row wpi-end-date"> |
168 | - <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
168 | + <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
169 | 169 | </p> |
170 | - <?php if ( $subscription->status ) { ?> |
|
170 | + <?php if ($subscription->status) { ?> |
|
171 | 171 | <p class="wpi-meta-row wpi-sub-status"> |
172 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
172 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
173 | 173 | </p> |
174 | 174 | <?php } ?> |
175 | - <?php if ( !empty( $payments ) ) { ?> |
|
176 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
175 | + <?php if (!empty($payments)) { ?> |
|
176 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
177 | 177 | <ul id="wpi-sub-payments"> |
178 | - <?php foreach ( $payments as $payment ) { |
|
178 | + <?php foreach ($payments as $payment) { |
|
179 | 179 | $invoice_id = $payment->ID; |
180 | 180 | ?> |
181 | 181 | <li> |
182 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
183 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
184 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
182 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
183 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
184 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
185 | 185 | </li> |
186 | 186 | <?php } ?> |
187 | 187 | </ul> |
@@ -189,50 +189,50 @@ discard block |
||
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | - public static function renewals( $post ) { |
|
193 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
192 | + public static function renewals($post) { |
|
193 | + $invoice = wpinv_get_invoice($post->ID); |
|
194 | 194 | |
195 | - if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
196 | - $parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
197 | - $parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
198 | - $subscription = wpinv_get_subscription( $invoice ); |
|
195 | + if (wpinv_is_subscription_payment($invoice)) { |
|
196 | + $parent_url = get_edit_post_link($invoice->parent_invoice); |
|
197 | + $parent_id = wpinv_get_invoice_number($invoice->parent_invoice); |
|
198 | + $subscription = wpinv_get_subscription($invoice); |
|
199 | 199 | ?> |
200 | - <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
201 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
200 | + <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
201 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
202 | 202 | <?php |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - public static function payment_meta( $post ) { |
|
206 | + public static function payment_meta($post) { |
|
207 | 207 | global $wpi_mb_invoice; |
208 | 208 | |
209 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
210 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
209 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
210 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
211 | 211 | $set_dateway = true; |
212 | 212 | } |
213 | 213 | |
214 | 214 | ?> |
215 | 215 | <p class="wpi-meta-row"> |
216 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
217 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
216 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
217 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
218 | 218 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
219 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
220 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
219 | + <?php foreach ($gateways as $name => $gateway) { |
|
220 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | ?> |
224 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
224 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
225 | 225 | <?php } ?> |
226 | 226 | </select> |
227 | 227 | <?php } else { |
228 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) ); |
|
228 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway)); |
|
229 | 229 | } ?> |
230 | 230 | </p> |
231 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
232 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
231 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
232 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
233 | 233 | <?php } ?> |
234 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
235 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
234 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
235 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
236 | 236 | <?php } ?> |
237 | 237 | <?php |
238 | 238 | } |
@@ -1,34 +1,34 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Billing_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $user_ID; |
10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
11 | + $invoice = new WPInv_Invoice($post_id); |
|
12 | 12 | ?> |
13 | 13 | <div class="gdmbx2-wrap form-table"> |
14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
16 | 16 | <div class="gdmbx-th"> |
17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
18 | 18 | </div> |
19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
20 | - <?php wpinv_dropdown_users( array( |
|
20 | + <?php wpinv_dropdown_users(array( |
|
21 | 21 | 'name' => 'post_author_override', |
22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
23 | 23 | 'include_selected' => true, |
24 | 24 | 'show' => 'user_email', |
25 | 25 | 'orderby' => 'user_email', |
26 | 26 | 'class' => 'gdmbx2-text-large' |
27 | - ) ); ?> |
|
27 | + )); ?> |
|
28 | 28 | </div> |
29 | 29 | </div> |
30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
32 | 32 | </div> |
33 | 33 | <div class="gdmbx-td"> |
34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,122 +36,122 @@ discard block |
||
36 | 36 | </div> |
37 | 37 | </div> |
38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
40 | 40 | </div> |
41 | - <?php if ( $invoice->has_status( array( 'auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending' ) ) ) { ?> |
|
41 | + <?php if ($invoice->has_status(array('auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending'))) { ?> |
|
42 | 42 | <div class="gdmbx-td"> |
43 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
44 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
45 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
43 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
44 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
45 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
46 | 46 | </div> |
47 | 47 | <?php } ?> |
48 | 48 | </div> |
49 | 49 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
50 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
50 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
51 | 51 | <div class="gdmbx-td"> |
52 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
52 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
53 | 53 | </div> |
54 | 54 | </div> |
55 | 55 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
56 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
56 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
57 | 57 | <div class="gdmbx-td"> |
58 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
58 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
62 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
62 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
63 | 63 | <div class="gdmbx-td"> |
64 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
64 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
65 | 65 | </div> |
66 | 66 | </div> |
67 | 67 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
68 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
68 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
69 | 69 | <div class="gdmbx-td"> |
70 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
70 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
74 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
74 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
75 | 75 | <div class="gdmbx-td"> |
76 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
76 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | 79 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
80 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
80 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
81 | 81 | <div class="gdmbx-td"> |
82 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
82 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
83 | 83 | </div> |
84 | 84 | </div> |
85 | 85 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
86 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
86 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
87 | 87 | <div class="gdmbx-td"> |
88 | 88 | <?php |
89 | - echo wpinv_html_select( array( |
|
90 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
89 | + echo wpinv_html_select(array( |
|
90 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
91 | 91 | 'name' => 'wpinv_country', |
92 | 92 | 'id' => 'wpinv_country', |
93 | 93 | 'selected' => $invoice->country, |
94 | 94 | 'show_option_all' => false, |
95 | 95 | 'show_option_none' => false, |
96 | 96 | 'class' => 'gdmbx2-text-large', |
97 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
97 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
98 | 98 | 'required' => false, |
99 | - ) ); |
|
99 | + )); |
|
100 | 100 | ?> |
101 | 101 | </div> |
102 | 102 | </div> |
103 | 103 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
104 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
104 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
105 | 105 | <div class="gdmbx-td"> |
106 | 106 | <?php |
107 | - $states = wpinv_get_country_states( $invoice->country ); |
|
108 | - if( !empty( $states ) ) { |
|
109 | - echo wpinv_html_select( array( |
|
110 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
107 | + $states = wpinv_get_country_states($invoice->country); |
|
108 | + if (!empty($states)) { |
|
109 | + echo wpinv_html_select(array( |
|
110 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
111 | 111 | 'name' => 'wpinv_state', |
112 | 112 | 'id' => 'wpinv_state', |
113 | 113 | 'selected' => $invoice->state, |
114 | 114 | 'show_option_all' => false, |
115 | 115 | 'show_option_none' => false, |
116 | 116 | 'class' => 'gdmbx2-text-large', |
117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
118 | 118 | 'required' => false, |
119 | - ) ); |
|
119 | + )); |
|
120 | 120 | } else { |
121 | - echo wpinv_html_text( array( |
|
121 | + echo wpinv_html_text(array( |
|
122 | 122 | 'name' => 'wpinv_state', |
123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
124 | 124 | 'id' => 'wpinv_state', |
125 | 125 | 'class' => 'gdmbx2-text-large', |
126 | 126 | 'required' => false, |
127 | - ) ); |
|
127 | + )); |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </div> |
131 | 131 | </div> |
132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
134 | 134 | <div class="gdmbx-td"> |
135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
136 | 136 | </div> |
137 | 137 | </div> |
138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
140 | 140 | <div class="gdmbx-td"> |
141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
142 | 142 | </div> |
143 | 143 | </div> |
144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
147 | 147 | <?php } ?></label></div> |
148 | 148 | <div class="gdmbx-td"> |
149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
150 | 150 | </div> |
151 | 151 | </div> |
152 | 152 | </div> |
153 | 153 | </div> |
154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
155 | 155 | <?php |
156 | 156 | } |
157 | 157 | } |
@@ -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 | ); |