@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | 6 | global $wpinv_euvat, $ajax_cart_details; |
@@ -11,158 +11,158 @@ discard block |
||
11 | 11 | $quantities_enabled = wpinv_item_quantities_enabled(); |
12 | 12 | $use_taxes = wpinv_use_taxes(); |
13 | 13 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
14 | -$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
15 | -$tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
14 | +$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
15 | +$tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
16 | 16 | |
17 | -do_action( 'wpinv_before_email_items', $invoice ); ?> |
|
17 | +do_action('wpinv_before_email_items', $invoice); ?> |
|
18 | 18 | <div id="wpinv-email-items"> |
19 | - <h3 class="wpinv-items-t"><?php echo apply_filters( 'wpinv_email_items_title', __( 'Items', 'invoicing' ) ); ?></h3> |
|
19 | + <h3 class="wpinv-items-t"><?php echo apply_filters('wpinv_email_items_title', __('Items', 'invoicing')); ?></h3> |
|
20 | 20 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
21 | 21 | <thead> |
22 | 22 | <tr class="wpinv_cart_header_row"> |
23 | - <?php do_action( 'wpinv_email_items_table_header_first' ); ?> |
|
24 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
25 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
26 | - <?php if ( $quantities_enabled ) { ?> |
|
27 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
23 | + <?php do_action('wpinv_email_items_table_header_first'); ?> |
|
24 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
25 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
26 | + <?php if ($quantities_enabled) { ?> |
|
27 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
28 | 28 | <?php } ?> |
29 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
29 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
30 | 30 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
31 | 31 | <?php } ?> |
32 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
33 | - <?php do_action( 'wpinv_email_items_table_header_last' ); ?> |
|
32 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
33 | + <?php do_action('wpinv_email_items_table_header_last'); ?> |
|
34 | 34 | </tr> |
35 | 35 | </thead> |
36 | 36 | <tbody> |
37 | 37 | <?php |
38 | - do_action( 'wpinv_email_items_before' ); |
|
39 | - if ( $cart_items ) { |
|
40 | - foreach ( $cart_items as $key => $item ) { |
|
41 | - $wpi_item = $item['id'] ? new WPInv_Item( $item['id'] ) : NULL; |
|
38 | + do_action('wpinv_email_items_before'); |
|
39 | + if ($cart_items) { |
|
40 | + foreach ($cart_items as $key => $item) { |
|
41 | + $wpi_item = $item['id'] ? new WPInv_Item($item['id']) : NULL; |
|
42 | 42 | ?> |
43 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
44 | - <?php do_action( 'wpinv_email_items_table_body_first', $item ); ?> |
|
43 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
44 | + <?php do_action('wpinv_email_items_table_body_first', $item); ?> |
|
45 | 45 | <td class="wpinv_cart_item_name text-left"> |
46 | 46 | <?php |
47 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
47 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
48 | 48 | echo '<div class="wpinv_cart_item_image">'; |
49 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
49 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
50 | 50 | echo '</div>'; |
51 | 51 | } |
52 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
52 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
53 | 53 | echo '<span class="wpinv_email_cart_item_title">' . $item_title . '</span>'; |
54 | 54 | |
55 | 55 | $summary = ''; |
56 | - if ( !empty( $wpi_item ) && $wpi_item->is_package() && !empty( $item['meta']['post_id'] ) ) { |
|
57 | - $post_link = '<a href="' . get_permalink( $item['meta']['post_id'] ) .'" target="_blank">' . (!empty($item['meta']['invoice_title']) ? $item['meta']['invoice_title'] : get_the_title( $item['meta']['post_id']) ) . '</a>'; |
|
58 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_custom_singular_name(), $post_link ); |
|
56 | + if (!empty($wpi_item) && $wpi_item->is_package() && !empty($item['meta']['post_id'])) { |
|
57 | + $post_link = '<a href="' . get_permalink($item['meta']['post_id']) . '" target="_blank">' . (!empty($item['meta']['invoice_title']) ? $item['meta']['invoice_title'] : get_the_title($item['meta']['post_id'])) . '</a>'; |
|
58 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_custom_singular_name(), $post_link); |
|
59 | 59 | } |
60 | 60 | |
61 | - $summary = apply_filters( 'wpinv_email_invoice_line_item_summary', $summary, $item, $wpi_item, $invoice ); |
|
62 | - if ( !empty( $summary ) ) { |
|
61 | + $summary = apply_filters('wpinv_email_invoice_line_item_summary', $summary, $item, $wpi_item, $invoice); |
|
62 | + if (!empty($summary)) { |
|
63 | 63 | echo '<p class="small">' . $summary . '</p>'; |
64 | 64 | } |
65 | 65 | |
66 | - do_action( 'wpinv_email_cart_item_title_after', $item, $key ); |
|
66 | + do_action('wpinv_email_cart_item_title_after', $item, $key); |
|
67 | 67 | ?> |
68 | 68 | </td> |
69 | 69 | <td class="wpinv_cart_item_price text-right"> |
70 | 70 | <?php |
71 | - echo wpinv_cart_item_price( $item ); |
|
72 | - do_action( 'wpinv_email_cart_item_price_after', $item, $key ); |
|
71 | + echo wpinv_cart_item_price($item); |
|
72 | + do_action('wpinv_email_cart_item_price_after', $item, $key); |
|
73 | 73 | ?> |
74 | 74 | </td> |
75 | - <?php if ( $quantities_enabled ) { ?> |
|
75 | + <?php if ($quantities_enabled) { ?> |
|
76 | 76 | <td class="wpinv_cart_item_qty text-right"> |
77 | 77 | <?php |
78 | - echo wpinv_get_cart_item_quantity( $item ); |
|
79 | - do_action( 'wpinv_email_item_quantitiy', $item, $key ); |
|
78 | + echo wpinv_get_cart_item_quantity($item); |
|
79 | + do_action('wpinv_email_item_quantitiy', $item, $key); |
|
80 | 80 | ?> |
81 | 81 | </td> |
82 | 82 | <?php } ?> |
83 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
83 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
84 | 84 | <td class="wpinv_cart_item_tax text-right"> |
85 | 85 | <?php |
86 | - echo wpinv_cart_item_tax( $item ); |
|
87 | - do_action( 'wpinv_email_item_tax', $item, $key ); |
|
86 | + echo wpinv_cart_item_tax($item); |
|
87 | + do_action('wpinv_email_item_tax', $item, $key); |
|
88 | 88 | ?> |
89 | 89 | </td> |
90 | 90 | <?php } ?> |
91 | 91 | <td class="wpinv_cart_item_subtotal text-right"> |
92 | 92 | <?php |
93 | - echo wpinv_cart_item_subtotal( $item ); |
|
94 | - do_action( 'wpinv_email_item_subtotal', $item, $key ); |
|
93 | + echo wpinv_cart_item_subtotal($item); |
|
94 | + do_action('wpinv_email_item_subtotal', $item, $key); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | - <?php do_action( 'wpinv_email_items_table_body_last', $item, $key ); ?> |
|
97 | + <?php do_action('wpinv_email_items_table_body_last', $item, $key); ?> |
|
98 | 98 | </tr> |
99 | 99 | <?php } ?> |
100 | 100 | <?php } ?> |
101 | - <?php do_action( 'wpinv_email_items_middle' ); ?> |
|
102 | - <?php do_action( 'wpinv_email_items_after' ); ?> |
|
101 | + <?php do_action('wpinv_email_items_middle'); ?> |
|
102 | + <?php do_action('wpinv_email_items_after'); ?> |
|
103 | 103 | </tbody> |
104 | 104 | <tfoot> |
105 | - <?php $cart_columns = wpinv_checkout_cart_columns(); if ( $zero_tax && $use_taxes ) { $cart_columns--; } ?> |
|
106 | - <?php if ( has_action( 'wpinv_email_footer_buttons' ) ) { ?> |
|
105 | + <?php $cart_columns = wpinv_checkout_cart_columns(); if ($zero_tax && $use_taxes) { $cart_columns--; } ?> |
|
106 | + <?php if (has_action('wpinv_email_footer_buttons')) { ?> |
|
107 | 107 | <tr class="wpinv_cart_footer_row"> |
108 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
109 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
110 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
108 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
109 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
110 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
111 | 111 | </td> |
112 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
112 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
113 | 113 | </tr> |
114 | 114 | <?php } ?> |
115 | 115 | |
116 | - <?php if ( !$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed() ) { ?> |
|
116 | + <?php if (!$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed()) { ?> |
|
117 | 117 | <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"> |
118 | - <?php do_action( 'wpinv_email_items_table_subtotal_first', $cart_items ); ?> |
|
119 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
120 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
118 | + <?php do_action('wpinv_email_items_table_subtotal_first', $cart_items); ?> |
|
119 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
120 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
121 | 121 | </td> |
122 | 122 | <td class="wpinv_cart_subtotal text-right"> |
123 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal( true ); ?></span> |
|
123 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal(true); ?></span> |
|
124 | 124 | </td> |
125 | - <?php do_action( 'wpinv_email_items_table_subtotal_last', $cart_items, $invoice ); ?> |
|
125 | + <?php do_action('wpinv_email_items_table_subtotal_last', $cart_items, $invoice); ?> |
|
126 | 126 | </tr> |
127 | 127 | <?php } ?> |
128 | 128 | |
129 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
129 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
130 | 130 | <tr class="wpinv_cart_footer_row wpinv_cart_discount_row"> |
131 | - <?php do_action( 'wpinv_receipt_items_table_discount_first', $cart_items, $invoice ); ?> |
|
132 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_discount_label text-right"> |
|
133 | - <strong><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</strong> |
|
131 | + <?php do_action('wpinv_receipt_items_table_discount_first', $cart_items, $invoice); ?> |
|
132 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_discount_label text-right"> |
|
133 | + <strong><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</strong> |
|
134 | 134 | </td> |
135 | 135 | <td class="wpinv_cart_discount text-right"> |
136 | - <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount( $invoice_id, true, true ); ?></span> |
|
136 | + <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount($invoice_id, true, true); ?></span> |
|
137 | 137 | </td> |
138 | - <?php do_action( 'wpinv_receipt_items_table_discount_last', $cart_items, $invoice ); ?> |
|
138 | + <?php do_action('wpinv_receipt_items_table_discount_last', $cart_items, $invoice); ?> |
|
139 | 139 | </tr> |
140 | 140 | <?php } ?> |
141 | 141 | |
142 | - <?php if ( !$zero_tax && $use_taxes && wpinv_is_cart_taxed() ) { ?> |
|
142 | + <?php if (!$zero_tax && $use_taxes && wpinv_is_cart_taxed()) { ?> |
|
143 | 143 | <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"> |
144 | - <?php do_action( 'wpinv_email_items_table_tax_first', $cart_items, $invoice ); ?> |
|
145 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
144 | + <?php do_action('wpinv_email_items_table_tax_first', $cart_items, $invoice); ?> |
|
145 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
146 | 146 | <strong><?php echo $tax_label; ?>:</strong> |
147 | 147 | </td> |
148 | 148 | <td class="wpinv_cart_tax text-right"> |
149 | - <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax( true ); ?></span> |
|
149 | + <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax(true); ?></span> |
|
150 | 150 | </td> |
151 | - <?php do_action( 'wpinv_email_items_table_tax_last', $cart_items, $invoice ); ?> |
|
151 | + <?php do_action('wpinv_email_items_table_tax_last', $cart_items, $invoice); ?> |
|
152 | 152 | </tr> |
153 | 153 | <?php } ?> |
154 | 154 | |
155 | 155 | <tr class="wpinv_cart_footer_row"> |
156 | - <?php do_action( 'wpinv_email_items_table_footer_first', $cart_items, $invoice ); ?> |
|
157 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
158 | - <?php echo apply_filters( 'wpinv_email_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
156 | + <?php do_action('wpinv_email_items_table_footer_first', $cart_items, $invoice); ?> |
|
157 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
158 | + <?php echo apply_filters('wpinv_email_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
159 | 159 | </td> |
160 | 160 | <td class="wpinv_cart_total text-right"> |
161 | - <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total( true ); ?></span> |
|
161 | + <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total(true); ?></span> |
|
162 | 162 | </td> |
163 | - <?php do_action( 'wpinv_email_items_table_footer_last', $cart_items, $invoice ); ?> |
|
163 | + <?php do_action('wpinv_email_items_table_footer_last', $cart_items, $invoice); ?> |
|
164 | 164 | </tr> |
165 | 165 | </tfoot> |
166 | 166 | </table> |
167 | 167 | </div> |
168 | -<?php do_action( 'wpinv_after_email_items', $invoice ); ?> |
|
169 | 168 | \ No newline at end of file |
169 | +<?php do_action('wpinv_after_email_items', $invoice); ?> |
|
170 | 170 | \ No newline at end of file |
@@ -5,140 +5,140 @@ |
||
5 | 5 | |
6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns, $wpi_session; |
7 | 7 | $invoice = wpinv_get_invoice_cart(); |
8 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
8 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
9 | 9 | $quantities_enabled = wpinv_item_quantities_enabled(); |
10 | 10 | $use_taxes = wpinv_use_taxes(); |
11 | 11 | $tax_label = $wpinv_euvat->tax_label(); |
12 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
12 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
13 | 13 | ?> |
14 | 14 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
15 | 15 | <thead> |
16 | 16 | <tr class="wpinv_cart_header_row"> |
17 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
18 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
19 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
20 | - <?php if ( $quantities_enabled ) { ?> |
|
21 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
17 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
18 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
19 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
20 | + <?php if ($quantities_enabled) { ?> |
|
21 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
22 | 22 | <?php } ?> |
23 | - <?php if ( $use_taxes ) { ?> |
|
23 | + <?php if ($use_taxes) { ?> |
|
24 | 24 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
25 | 25 | <?php } ?> |
26 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
27 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
26 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
27 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | <tbody> |
31 | 31 | <?php |
32 | - do_action( 'wpinv_cart_items_before' ); |
|
32 | + do_action('wpinv_cart_items_before'); |
|
33 | 33 | |
34 | - if ( $cart_items ) { |
|
35 | - foreach ( $cart_items as $key => $item ) { |
|
36 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
34 | + if ($cart_items) { |
|
35 | + foreach ($cart_items as $key => $item) { |
|
36 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
37 | 37 | ?> |
38 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
39 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
38 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
39 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
40 | 40 | <td class="wpinv_cart_item_name text-left"> |
41 | 41 | <?php |
42 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
42 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
43 | 43 | echo '<div class="wpinv_cart_item_image">'; |
44 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
44 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
45 | 45 | echo '</div>'; |
46 | 46 | } |
47 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
47 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
48 | 48 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
49 | - if ( !empty( $wpi_item ) && $wpi_item->is_package() && !empty( $item['meta']['post_id'] ) ) { |
|
50 | - $post_link = !empty( $item['meta']['invoice_title'] ) ? $item['meta']['invoice_title'] : get_the_title( $item['meta']['post_id'] ); |
|
51 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_custom_singular_name(), $post_link ); |
|
52 | - echo '<small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
49 | + if (!empty($wpi_item) && $wpi_item->is_package() && !empty($item['meta']['post_id'])) { |
|
50 | + $post_link = !empty($item['meta']['invoice_title']) ? $item['meta']['invoice_title'] : get_the_title($item['meta']['post_id']); |
|
51 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_custom_singular_name(), $post_link); |
|
52 | + echo '<small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
53 | 53 | } |
54 | - do_action( 'wpinv_checkout_cart_item_title_after', $item, $key ); |
|
54 | + do_action('wpinv_checkout_cart_item_title_after', $item, $key); |
|
55 | 55 | ?> |
56 | 56 | </td> |
57 | 57 | <td class="wpinv_cart_item_price text-right"> |
58 | 58 | <?php |
59 | - echo wpinv_cart_item_price( $item ); |
|
60 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
59 | + echo wpinv_cart_item_price($item); |
|
60 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
61 | 61 | ?> |
62 | 62 | </td> |
63 | - <?php if ( $quantities_enabled ) { ?> |
|
63 | + <?php if ($quantities_enabled) { ?> |
|
64 | 64 | <td class="wpinv_cart_item_qty text-right"> |
65 | 65 | <?php |
66 | - echo wpinv_get_cart_item_quantity( $item ); |
|
67 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
66 | + echo wpinv_get_cart_item_quantity($item); |
|
67 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
68 | 68 | ?> |
69 | 69 | </td> |
70 | 70 | <?php } ?> |
71 | - <?php if ( $use_taxes ) { ?> |
|
71 | + <?php if ($use_taxes) { ?> |
|
72 | 72 | <td class="wpinv_cart_item_tax text-right"> |
73 | 73 | <?php |
74 | - echo wpinv_cart_item_tax( $item ); |
|
74 | + echo wpinv_cart_item_tax($item); |
|
75 | 75 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
76 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
76 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
77 | 77 | ?> |
78 | 78 | </td> |
79 | 79 | <?php } ?> |
80 | 80 | <td class="wpinv_cart_item_subtotal text-right"> |
81 | 81 | <?php |
82 | - echo wpinv_cart_item_subtotal( $item ); |
|
83 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
82 | + echo wpinv_cart_item_subtotal($item); |
|
83 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
84 | 84 | ?> |
85 | 85 | </td> |
86 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
86 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
87 | 87 | </tr> |
88 | 88 | <?php } ?> |
89 | 89 | <?php } ?> |
90 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
91 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
90 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
91 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
92 | 92 | </tbody> |
93 | 93 | <tfoot> |
94 | 94 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
95 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
95 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
96 | 96 | <tr class="wpinv_cart_footer_row"> |
97 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
98 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
99 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
97 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
98 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
99 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
100 | 100 | </td> |
101 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
101 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
102 | 102 | </tr> |
103 | 103 | <?php } ?> |
104 | 104 | |
105 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
107 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
108 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
109 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
105 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
107 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
108 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
109 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
110 | 110 | </td> |
111 | 111 | <td class="wpinv_cart_subtotal text-right"> |
112 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span> |
|
112 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span> |
|
113 | 113 | </td> |
114 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
114 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
115 | 115 | </tr> |
116 | 116 | <?php } ?> |
117 | 117 | |
118 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
118 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
119 | 119 | |
120 | - <?php if ( $use_taxes ) { ?> |
|
121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
122 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
123 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
120 | + <?php if ($use_taxes) { ?> |
|
121 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
122 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
123 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
124 | 124 | <strong><?php echo $tax_label; ?>:</strong> |
125 | 125 | </td> |
126 | 126 | <td class="wpinv_cart_tax text-right"> |
127 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span> |
|
127 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span> |
|
128 | 128 | </td> |
129 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
129 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
130 | 130 | </tr> |
131 | 131 | <?php } ?> |
132 | 132 | |
133 | 133 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
134 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
135 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
136 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
134 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
135 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
136 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
137 | 137 | </td> |
138 | 138 | <td class="wpinv_cart_total text-right"> |
139 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
139 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
140 | 140 | </td> |
141 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
141 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
142 | 142 | </tr> |
143 | 143 | </tfoot> |
144 | 144 | </table> |
@@ -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,56 +36,56 @@ 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 | 41 | <div class="gdmbx-td"> |
42 | - <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> |
|
43 | - <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> |
|
44 | - <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> |
|
42 | + <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> |
|
43 | + <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> |
|
44 | + <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> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
48 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
48 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
49 | 49 | <div class="gdmbx-td"> |
50 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
50 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
51 | 51 | </div> |
52 | 52 | </div> |
53 | 53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
54 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
54 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
55 | 55 | <div class="gdmbx-td"> |
56 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
56 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
60 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
60 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
61 | 61 | <div class="gdmbx-td"> |
62 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
62 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
63 | 63 | </div> |
64 | 64 | </div> |
65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
66 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
66 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
67 | 67 | <div class="gdmbx-td"> |
68 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
68 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
69 | 69 | </div> |
70 | 70 | </div> |
71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
72 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
72 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
73 | 73 | <div class="gdmbx-td"> |
74 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
74 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
75 | 75 | </div> |
76 | 76 | </div> |
77 | 77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
78 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
78 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
79 | 79 | <div class="gdmbx-td"> |
80 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
80 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
81 | 81 | </div> |
82 | 82 | </div> |
83 | 83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
84 | - <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> |
|
84 | + <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> |
|
85 | 85 | <div class="gdmbx-td"> |
86 | 86 | <?php |
87 | - echo wpinv_html_select( array( |
|
88 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
87 | + echo wpinv_html_select(array( |
|
88 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
89 | 89 | 'name' => 'wpinv_country', |
90 | 90 | 'id' => 'wpinv_country', |
91 | 91 | 'selected' => $invoice->country, |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'show_option_none' => false, |
94 | 94 | 'class' => 'gdmbx2-text-large', |
95 | 95 | 'chosen' => false, |
96 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
96 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
97 | 97 | 'required' => false, |
98 | - ) ); |
|
98 | + )); |
|
99 | 99 | ?> |
100 | 100 | </div> |
101 | 101 | </div> |
102 | 102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
103 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
103 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
104 | 104 | <div class="gdmbx-td"> |
105 | 105 | <?php |
106 | - $states = wpinv_get_country_states( $invoice->country ); |
|
107 | - if( !empty( $states ) ) { |
|
108 | - echo wpinv_html_select( array( |
|
109 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
106 | + $states = wpinv_get_country_states($invoice->country); |
|
107 | + if (!empty($states)) { |
|
108 | + echo wpinv_html_select(array( |
|
109 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
110 | 110 | 'name' => 'wpinv_state', |
111 | 111 | 'id' => 'wpinv_state', |
112 | 112 | 'selected' => $invoice->state, |
@@ -114,44 +114,44 @@ discard block |
||
114 | 114 | 'show_option_none' => false, |
115 | 115 | 'class' => 'gdmbx2-text-large', |
116 | 116 | 'chosen' => false, |
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 | } |
@@ -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 | |
@@ -21,68 +21,68 @@ discard block |
||
21 | 21 | public function init() { |
22 | 22 | global $wp_filesystem; |
23 | 23 | |
24 | - if ( empty( $wp_filesystem ) ) { |
|
25 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
24 | + if (empty($wp_filesystem)) { |
|
25 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
26 | 26 | WP_Filesystem(); |
27 | 27 | global $wp_filesystem; |
28 | 28 | } |
29 | 29 | $this->wp_filesystem = $wp_filesystem; |
30 | 30 | |
31 | 31 | $this->export_dir = $this->export_location(); |
32 | - $this->export_url = $this->export_location( true ); |
|
32 | + $this->export_url = $this->export_location(true); |
|
33 | 33 | $this->export = 'invoicing'; |
34 | 34 | $this->filetype = 'csv'; |
35 | 35 | $this->per_page = 20; |
36 | 36 | |
37 | - do_action( 'wpinv_class_reports_init', $this ); |
|
37 | + do_action('wpinv_class_reports_init', $this); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function includes() { |
41 | - do_action( 'wpinv_class_reports_includes', $this ); |
|
41 | + do_action('wpinv_class_reports_includes', $this); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function actions() { |
45 | - if ( is_admin() ) { |
|
46 | - add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 ); |
|
47 | - add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) ); |
|
48 | - add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) ); |
|
45 | + if (is_admin()) { |
|
46 | + add_action('admin_menu', array($this, 'add_submenu'), 10); |
|
47 | + add_action('wpinv_reports_tab_export', array($this, 'export')); |
|
48 | + add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export')); |
|
49 | 49 | |
50 | 50 | // Export Invoices. |
51 | - add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) ); |
|
52 | - add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) ); |
|
53 | - add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) ); |
|
54 | - add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) ); |
|
51 | + add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export')); |
|
52 | + add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns')); |
|
53 | + add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data')); |
|
54 | + add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status')); |
|
55 | 55 | } |
56 | - do_action( 'wpinv_class_reports_actions', $this ); |
|
56 | + do_action('wpinv_class_reports_actions', $this); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public function add_submenu() { |
60 | 60 | global $wpi_reports_page; |
61 | - $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), 'manage_options', 'wpinv-reports', array( $this, 'reports_page' ) ); |
|
61 | + $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), 'manage_options', 'wpinv-reports', array($this, 'reports_page')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function reports_page() { |
65 | - if ( !wp_script_is( 'postbox', 'enqueued' ) ) { |
|
66 | - wp_enqueue_script( 'postbox' ); |
|
65 | + if (!wp_script_is('postbox', 'enqueued')) { |
|
66 | + wp_enqueue_script('postbox'); |
|
67 | 67 | } |
68 | - if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
|
69 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
68 | + if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) { |
|
69 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
70 | 70 | } |
71 | 71 | |
72 | - $current_page = admin_url( 'admin.php?page=wpinv-reports' ); |
|
73 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export'; |
|
72 | + $current_page = admin_url('admin.php?page=wpinv-reports'); |
|
73 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export'; |
|
74 | 74 | ?> |
75 | 75 | <div class="wrap wpi-reports-wrap"> |
76 | - <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1> |
|
76 | + <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1> |
|
77 | 77 | <h2 class="nav-tab-wrapper wp-clearfix"> |
78 | - <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a> |
|
79 | - <?php do_action( 'wpinv_reports_page_tabs' ); ;?> |
|
78 | + <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a> |
|
79 | + <?php do_action('wpinv_reports_page_tabs'); ;?> |
|
80 | 80 | </h2> |
81 | 81 | <div class="wpi-reports-content wpi-reports-<?php echo $active_tab; ?>"> |
82 | 82 | <?php |
83 | - do_action( 'wpinv_reports_page_top' ); |
|
84 | - do_action( 'wpinv_reports_tab_' . $active_tab ); |
|
85 | - do_action( 'wpinv_reports_page_bottom' ); |
|
83 | + do_action('wpinv_reports_page_top'); |
|
84 | + do_action('wpinv_reports_tab_' . $active_tab); |
|
85 | + do_action('wpinv_reports_page_bottom'); |
|
86 | 86 | ?> |
87 | 87 | </div> |
88 | 88 | <?php |
@@ -90,97 +90,97 @@ discard block |
||
90 | 90 | |
91 | 91 | public function export() { |
92 | 92 | $statuses = wpinv_get_invoice_statuses(); |
93 | - $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses ); |
|
93 | + $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses); |
|
94 | 94 | ?> |
95 | 95 | <div class="metabox-holder"> |
96 | 96 | <div id="post-body"> |
97 | 97 | <div id="post-body-content"> |
98 | - <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?> |
|
98 | + <?php do_action('wpinv_reports_tab_export_content_top'); ?> |
|
99 | 99 | |
100 | 100 | <div class="postbox wpi-export-invoices"> |
101 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2> |
|
101 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2> |
|
102 | 102 | <div class="inside"> |
103 | - <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p> |
|
103 | + <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p> |
|
104 | 104 | <form id="wpi-export-invoices" class="wpi-export-form" method="post"> |
105 | - <?php echo wpinv_html_date_field( array( |
|
105 | + <?php echo wpinv_html_date_field(array( |
|
106 | 106 | 'id' => 'wpi_export_from_date', |
107 | 107 | 'name' => 'from_date', |
108 | 108 | 'data' => array( |
109 | 109 | 'dateFormat' => 'yy-mm-dd' |
110 | 110 | ), |
111 | - 'placeholder' => __( 'From date', 'invoicing' ) ) |
|
111 | + 'placeholder' => __('From date', 'invoicing') ) |
|
112 | 112 | ); ?> |
113 | - <?php echo wpinv_html_date_field( array( |
|
113 | + <?php echo wpinv_html_date_field(array( |
|
114 | 114 | 'id' => 'wpi_export_to_date', |
115 | 115 | 'name' => 'to_date', |
116 | 116 | 'data' => array( |
117 | 117 | 'dateFormat' => 'yy-mm-dd' |
118 | 118 | ), |
119 | - 'placeholder' => __( 'To date', 'invoicing' ) ) |
|
119 | + 'placeholder' => __('To date', 'invoicing') ) |
|
120 | 120 | ); ?> |
121 | 121 | <span id="wpinv-status-wrap"> |
122 | - <?php echo wpinv_html_select( array( |
|
122 | + <?php echo wpinv_html_select(array( |
|
123 | 123 | 'options' => $statuses, |
124 | 124 | 'name' => 'status', |
125 | 125 | 'id' => 'wpi_export_status', |
126 | 126 | 'show_option_all' => false, |
127 | 127 | 'show_option_none' => false, |
128 | 128 | 'class' => '', |
129 | - ) ); ?> |
|
130 | - <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?> |
|
129 | + )); ?> |
|
130 | + <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?> |
|
131 | 131 | </span> |
132 | 132 | <span id="wpinv-submit-wrap"> |
133 | 133 | <input type="hidden" value="invoices" name="export" /> |
134 | - <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" /> |
|
134 | + <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" /> |
|
135 | 135 | </span> |
136 | 136 | </form> |
137 | 137 | </div> |
138 | 138 | </div> |
139 | 139 | |
140 | - <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?> |
|
140 | + <?php do_action('wpinv_reports_tab_export_content_bottom'); ?> |
|
141 | 141 | </div> |
142 | 142 | </div> |
143 | 143 | </div> |
144 | 144 | <?php |
145 | 145 | } |
146 | 146 | |
147 | - public function export_location( $relative = false ) { |
|
147 | + public function export_location($relative = false) { |
|
148 | 148 | $upload_dir = wp_upload_dir(); |
149 | - $export_location = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache'; |
|
150 | - $export_location = apply_filters( 'wpinv_export_location', $export_location, $relative ); |
|
149 | + $export_location = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache'; |
|
150 | + $export_location = apply_filters('wpinv_export_location', $export_location, $relative); |
|
151 | 151 | |
152 | - return trailingslashit( $export_location ); |
|
152 | + return trailingslashit($export_location); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function check_export_location() { |
156 | 156 | try { |
157 | - if ( empty( $this->wp_filesystem ) ) { |
|
158 | - return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' ); |
|
157 | + if (empty($this->wp_filesystem)) { |
|
158 | + return __('Filesystem ERROR: Could not access filesystem.', 'invoicing'); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( is_wp_error( $this->wp_filesystem ) ) { |
|
162 | - return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' ); |
|
161 | + if (is_wp_error($this->wp_filesystem)) { |
|
162 | + return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing'); |
|
163 | 163 | } |
164 | 164 | |
165 | - $is_dir = $this->wp_filesystem->is_dir( $this->export_dir ); |
|
166 | - $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
|
165 | + $is_dir = $this->wp_filesystem->is_dir($this->export_dir); |
|
166 | + $is_writeable = $is_dir && is_writeable($this->export_dir); |
|
167 | 167 | |
168 | - if ( $is_dir && $is_writeable ) { |
|
168 | + if ($is_dir && $is_writeable) { |
|
169 | 169 | return true; |
170 | - } else if ( $is_dir && !$is_writeable ) { |
|
171 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
172 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
170 | + } else if ($is_dir && !$is_writeable) { |
|
171 | + if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) { |
|
172 | + return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return true; |
176 | 176 | } else { |
177 | - if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
178 | - return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
|
177 | + if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) { |
|
178 | + return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return true; |
182 | 182 | } |
183 | - } catch ( Exception $e ) { |
|
183 | + } catch (Exception $e) { |
|
184 | 184 | return $e->getMessage(); |
185 | 185 | } |
186 | 186 | } |
@@ -188,130 +188,130 @@ discard block |
||
188 | 188 | public function ajax_export() { |
189 | 189 | $response = array(); |
190 | 190 | $response['success'] = false; |
191 | - $response['msg'] = __( 'Invalid export request found.', 'invoicing' ); |
|
191 | + $response['msg'] = __('Invalid export request found.', 'invoicing'); |
|
192 | 192 | |
193 | - if ( empty( $_POST['data'] ) || !current_user_can( 'manage_options' ) ) { |
|
194 | - wp_send_json( $response ); |
|
193 | + if (empty($_POST['data']) || !current_user_can('manage_options')) { |
|
194 | + wp_send_json($response); |
|
195 | 195 | } |
196 | 196 | |
197 | - parse_str( $_POST['data'], $data ); |
|
197 | + parse_str($_POST['data'], $data); |
|
198 | 198 | |
199 | - $data['step'] = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; |
|
199 | + $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1; |
|
200 | 200 | |
201 | 201 | $_REQUEST = (array)$data; |
202 | - if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) { |
|
203 | - $response['msg'] = __( 'Security check failed.', 'invoicing' ); |
|
204 | - wp_send_json( $response ); |
|
202 | + if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) { |
|
203 | + $response['msg'] = __('Security check failed.', 'invoicing'); |
|
204 | + wp_send_json($response); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( ( $error = $this->check_export_location( true ) ) !== true ) { |
|
208 | - $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' ); |
|
209 | - wp_send_json( $response ); |
|
207 | + if (($error = $this->check_export_location(true)) !== true) { |
|
208 | + $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing'); |
|
209 | + wp_send_json($response); |
|
210 | 210 | } |
211 | 211 | |
212 | - $this->set_export_params( $_REQUEST ); |
|
212 | + $this->set_export_params($_REQUEST); |
|
213 | 213 | |
214 | 214 | $return = $this->process_export_step(); |
215 | 215 | $done = $this->get_export_status(); |
216 | 216 | |
217 | - if ( $return ) { |
|
217 | + if ($return) { |
|
218 | 218 | $this->step += 1; |
219 | 219 | |
220 | 220 | $response['success'] = true; |
221 | 221 | $response['msg'] = ''; |
222 | 222 | |
223 | - if ( $done >= 100 ) { |
|
223 | + if ($done >= 100) { |
|
224 | 224 | $this->step = 'done'; |
225 | - $new_filename = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype; |
|
225 | + $new_filename = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype; |
|
226 | 226 | $new_file = $this->export_dir . $new_filename; |
227 | 227 | |
228 | - if ( file_exists( $this->file ) ) { |
|
229 | - $this->wp_filesystem->move( $this->file, $new_file, true ); |
|
228 | + if (file_exists($this->file)) { |
|
229 | + $this->wp_filesystem->move($this->file, $new_file, true); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( file_exists( $new_file ) ) { |
|
233 | - $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) ); |
|
232 | + if (file_exists($new_file)) { |
|
233 | + $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2)); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | 237 | $response['data']['step'] = $this->step; |
238 | 238 | $response['data']['done'] = $done; |
239 | 239 | } else { |
240 | - $response['msg'] = __( 'No data found for export.', 'invoicing' ); |
|
240 | + $response['msg'] = __('No data found for export.', 'invoicing'); |
|
241 | 241 | } |
242 | 242 | |
243 | - wp_send_json( $response ); |
|
243 | + wp_send_json($response); |
|
244 | 244 | } |
245 | 245 | |
246 | - public function set_export_params( $request ) { |
|
246 | + public function set_export_params($request) { |
|
247 | 247 | $this->empty = false; |
248 | - $this->step = !empty( $request['step'] ) ? absint( $request['step'] ) : 1; |
|
249 | - $this->export = !empty( $request['export'] ) ? $request['export'] : $this->export; |
|
248 | + $this->step = !empty($request['step']) ? absint($request['step']) : 1; |
|
249 | + $this->export = !empty($request['export']) ? $request['export'] : $this->export; |
|
250 | 250 | $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype; |
251 | 251 | $this->file = $this->export_dir . $this->filename; |
252 | 252 | |
253 | - do_action( 'wpinv_export_set_params_' . $this->export, $request ); |
|
253 | + do_action('wpinv_export_set_params_' . $this->export, $request); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | public function get_columns() { |
257 | 257 | $columns = array( |
258 | - 'id' => __( 'ID', 'invoicing' ), |
|
259 | - 'date' => __( 'Date', 'invoicing' ) |
|
258 | + 'id' => __('ID', 'invoicing'), |
|
259 | + 'date' => __('Date', 'invoicing') |
|
260 | 260 | ); |
261 | 261 | |
262 | - return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns ); |
|
262 | + return apply_filters('wpinv_export_get_columns_' . $this->export, $columns); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | protected function get_export_file() { |
266 | 266 | $file = ''; |
267 | 267 | |
268 | - if ( $this->wp_filesystem->exists( $this->file ) ) { |
|
269 | - $file = $this->wp_filesystem->get_contents( $this->file ); |
|
268 | + if ($this->wp_filesystem->exists($this->file)) { |
|
269 | + $file = $this->wp_filesystem->get_contents($this->file); |
|
270 | 270 | } else { |
271 | - $this->wp_filesystem->put_contents( $this->file, '' ); |
|
271 | + $this->wp_filesystem->put_contents($this->file, ''); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $file; |
275 | 275 | } |
276 | 276 | |
277 | - protected function attach_export_data( $data = '' ) { |
|
278 | - $filedata = $this->get_export_file(); |
|
279 | - $filedata .= $data; |
|
277 | + protected function attach_export_data($data = '') { |
|
278 | + $filedata = $this->get_export_file(); |
|
279 | + $filedata .= $data; |
|
280 | 280 | |
281 | - $this->wp_filesystem->put_contents( $this->file, $filedata ); |
|
281 | + $this->wp_filesystem->put_contents($this->file, $filedata); |
|
282 | 282 | |
283 | - $rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
283 | + $rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
284 | 284 | $columns = $this->get_columns(); |
285 | - $columns = empty( $columns ) ? 0 : 1; |
|
285 | + $columns = empty($columns) ? 0 : 1; |
|
286 | 286 | |
287 | - $this->empty = count( $rows ) == $columns ? true : false; |
|
287 | + $this->empty = count($rows) == $columns ? true : false; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | public function print_columns() { |
291 | 291 | $column_data = ''; |
292 | 292 | $columns = $this->get_columns(); |
293 | 293 | $i = 1; |
294 | - foreach( $columns as $key => $column ) { |
|
295 | - $column_data .= '"' . addslashes( $column ) . '"'; |
|
296 | - $column_data .= $i == count( $columns ) ? '' : ','; |
|
294 | + foreach ($columns as $key => $column) { |
|
295 | + $column_data .= '"' . addslashes($column) . '"'; |
|
296 | + $column_data .= $i == count($columns) ? '' : ','; |
|
297 | 297 | $i++; |
298 | 298 | } |
299 | 299 | $column_data .= "\r\n"; |
300 | 300 | |
301 | - $this->attach_export_data( $column_data ); |
|
301 | + $this->attach_export_data($column_data); |
|
302 | 302 | |
303 | 303 | return $column_data; |
304 | 304 | } |
305 | 305 | |
306 | 306 | public function process_export_step() { |
307 | - if ( $this->step < 2 ) { |
|
308 | - @unlink( $this->file ); |
|
307 | + if ($this->step < 2) { |
|
308 | + @unlink($this->file); |
|
309 | 309 | $this->print_columns(); |
310 | 310 | } |
311 | 311 | |
312 | 312 | $return = $this->print_rows(); |
313 | 313 | |
314 | - if ( $return ) { |
|
314 | + if ($return) { |
|
315 | 315 | return true; |
316 | 316 | } else { |
317 | 317 | return false; |
@@ -320,23 +320,23 @@ discard block |
||
320 | 320 | |
321 | 321 | public function get_export_status() { |
322 | 322 | $status = 100; |
323 | - return apply_filters( 'wpinv_get_export_status_' . $this->export, $status ); |
|
323 | + return apply_filters('wpinv_get_export_status_' . $this->export, $status); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | public function get_export_data() { |
327 | 327 | $data = array( |
328 | 328 | 0 => array( |
329 | 329 | 'id' => '', |
330 | - 'data' => date( 'F j, Y' ) |
|
330 | + 'data' => date('F j, Y') |
|
331 | 331 | ), |
332 | 332 | 1 => array( |
333 | 333 | 'id' => '', |
334 | - 'data' => date( 'F j, Y' ) |
|
334 | + 'data' => date('F j, Y') |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | - $data = apply_filters( 'wpinv_export_get_data', $data ); |
|
339 | - $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data ); |
|
338 | + $data = apply_filters('wpinv_export_get_data', $data); |
|
339 | + $data = apply_filters('wpinv_export_get_data_' . $this->export, $data); |
|
340 | 340 | |
341 | 341 | return $data; |
342 | 342 | } |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | $data = $this->get_export_data(); |
347 | 347 | $columns = $this->get_columns(); |
348 | 348 | |
349 | - if ( $data ) { |
|
350 | - foreach ( $data as $row ) { |
|
349 | + if ($data) { |
|
350 | + foreach ($data as $row) { |
|
351 | 351 | $i = 1; |
352 | - foreach ( $row as $key => $column ) { |
|
353 | - if ( array_key_exists( $key, $columns ) ) { |
|
354 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
355 | - $row_data .= $i == count( $columns ) ? '' : ','; |
|
352 | + foreach ($row as $key => $column) { |
|
353 | + if (array_key_exists($key, $columns)) { |
|
354 | + $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"'; |
|
355 | + $row_data .= $i == count($columns) ? '' : ','; |
|
356 | 356 | $i++; |
357 | 357 | } |
358 | 358 | } |
359 | 359 | $row_data .= "\r\n"; |
360 | 360 | } |
361 | 361 | |
362 | - $this->attach_export_data( $row_data ); |
|
362 | + $this->attach_export_data($row_data); |
|
363 | 363 | |
364 | 364 | return $row_data; |
365 | 365 | } |
@@ -368,46 +368,46 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | // Export Invoices. |
371 | - public function set_invoices_export( $request ) { |
|
372 | - $this->from_date = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : ''; |
|
373 | - $this->to_date = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : ''; |
|
374 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish'; |
|
371 | + public function set_invoices_export($request) { |
|
372 | + $this->from_date = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : ''; |
|
373 | + $this->to_date = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : ''; |
|
374 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish'; |
|
375 | 375 | } |
376 | 376 | |
377 | - public function get_invoices_columns( $columns = array() ) { |
|
377 | + public function get_invoices_columns($columns = array()) { |
|
378 | 378 | $columns = array( |
379 | - 'id' => __( 'ID', 'invoicing' ), |
|
380 | - 'number' => __( 'Number', 'invoicing' ), |
|
381 | - 'date' => __( 'Date', 'invoicing' ), |
|
382 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
383 | - 'status_nicename' => __( 'Status Nicename', 'invoicing' ), |
|
384 | - 'status' => __( 'Status', 'invoicing' ), |
|
385 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
386 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
387 | - 'user_id' => __( 'User ID', 'invoicing' ), |
|
388 | - 'email' => __( 'Email', 'invoicing' ), |
|
389 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
390 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
391 | - 'address' => __( 'Address', 'invoicing' ), |
|
392 | - 'city' => __( 'City', 'invoicing' ), |
|
393 | - 'state' => __( 'State', 'invoicing' ), |
|
394 | - 'country' => __( 'Country', 'invoicing' ), |
|
395 | - 'zip' => __( 'Zipcode', 'invoicing' ), |
|
396 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
397 | - 'company' => __( 'Company', 'invoicing' ), |
|
398 | - 'vat_number' => __( 'Vat Number', 'invoicing' ), |
|
399 | - 'ip' => __( 'IP', 'invoicing' ), |
|
400 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
401 | - 'gateway_nicename' => __( 'Gateway Nicename', 'invoicing' ), |
|
402 | - 'transaction_id'=> __( 'Transaction ID', 'invoicing' ), |
|
403 | - 'currency' => __( 'Currency', 'invoicing' ), |
|
404 | - 'due_date' => __( 'Due Date', 'invoicing' ), |
|
379 | + 'id' => __('ID', 'invoicing'), |
|
380 | + 'number' => __('Number', 'invoicing'), |
|
381 | + 'date' => __('Date', 'invoicing'), |
|
382 | + 'amount' => __('Amount', 'invoicing'), |
|
383 | + 'status_nicename' => __('Status Nicename', 'invoicing'), |
|
384 | + 'status' => __('Status', 'invoicing'), |
|
385 | + 'tax' => __('Tax', 'invoicing'), |
|
386 | + 'discount' => __('Discount', 'invoicing'), |
|
387 | + 'user_id' => __('User ID', 'invoicing'), |
|
388 | + 'email' => __('Email', 'invoicing'), |
|
389 | + 'first_name' => __('First Name', 'invoicing'), |
|
390 | + 'last_name' => __('Last Name', 'invoicing'), |
|
391 | + 'address' => __('Address', 'invoicing'), |
|
392 | + 'city' => __('City', 'invoicing'), |
|
393 | + 'state' => __('State', 'invoicing'), |
|
394 | + 'country' => __('Country', 'invoicing'), |
|
395 | + 'zip' => __('Zipcode', 'invoicing'), |
|
396 | + 'phone' => __('Phone', 'invoicing'), |
|
397 | + 'company' => __('Company', 'invoicing'), |
|
398 | + 'vat_number' => __('Vat Number', 'invoicing'), |
|
399 | + 'ip' => __('IP', 'invoicing'), |
|
400 | + 'gateway' => __('Gateway', 'invoicing'), |
|
401 | + 'gateway_nicename' => __('Gateway Nicename', 'invoicing'), |
|
402 | + 'transaction_id'=> __('Transaction ID', 'invoicing'), |
|
403 | + 'currency' => __('Currency', 'invoicing'), |
|
404 | + 'due_date' => __('Due Date', 'invoicing'), |
|
405 | 405 | ); |
406 | 406 | |
407 | 407 | return $columns; |
408 | 408 | } |
409 | 409 | |
410 | - public function get_invoices_data( $response = array() ) { |
|
410 | + public function get_invoices_data($response = array()) { |
|
411 | 411 | $args = array( |
412 | 412 | 'limit' => $this->per_page, |
413 | 413 | 'page' => $this->step, |
@@ -415,35 +415,35 @@ discard block |
||
415 | 415 | 'orderby' => 'date', |
416 | 416 | ); |
417 | 417 | |
418 | - if ( $this->status != 'any' ) { |
|
418 | + if ($this->status != 'any') { |
|
419 | 419 | $args['status'] = $this->status; |
420 | 420 | } |
421 | 421 | |
422 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
422 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
423 | 423 | $args['date_query'] = array( |
424 | 424 | array( |
425 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
426 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
425 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
426 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
427 | 427 | 'inclusive' => true |
428 | 428 | ) |
429 | 429 | ); |
430 | 430 | } |
431 | 431 | |
432 | - $invoices = wpinv_get_invoices( $args ); |
|
432 | + $invoices = wpinv_get_invoices($args); |
|
433 | 433 | |
434 | 434 | $data = array(); |
435 | 435 | |
436 | - if ( !empty( $invoices ) ) { |
|
437 | - foreach ( $invoices as $invoice ) { |
|
436 | + if (!empty($invoices)) { |
|
437 | + foreach ($invoices as $invoice) { |
|
438 | 438 | $row = array( |
439 | 439 | 'id' => $invoice->ID, |
440 | 440 | 'number' => $invoice->get_number(), |
441 | - 'date' => $invoice->get_invoice_date( false ), |
|
442 | - 'amount' => wpinv_round_amount( $invoice->get_total() ), |
|
443 | - 'status_nicename' => $invoice->get_status( true ), |
|
441 | + 'date' => $invoice->get_invoice_date(false), |
|
442 | + 'amount' => wpinv_round_amount($invoice->get_total()), |
|
443 | + 'status_nicename' => $invoice->get_status(true), |
|
444 | 444 | 'status' => $invoice->get_status(), |
445 | - 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '', |
|
446 | - 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '', |
|
445 | + 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '', |
|
446 | + 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '', |
|
447 | 447 | 'user_id' => $invoice->get_user_id(), |
448 | 448 | 'email' => $invoice->get_email(), |
449 | 449 | 'first_name' => $invoice->get_first_name(), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | 'due_date' => $invoice->needs_payment() ? $invoice->get_due_date() : '', |
465 | 465 | ); |
466 | 466 | |
467 | - $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice ); |
|
467 | + $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | return $data; |
@@ -480,29 +480,29 @@ discard block |
||
480 | 480 | 'return' => 'ids', |
481 | 481 | ); |
482 | 482 | |
483 | - if ( $this->status != 'any' ) { |
|
483 | + if ($this->status != 'any') { |
|
484 | 484 | $args['status'] = $this->status; |
485 | 485 | } |
486 | 486 | |
487 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
487 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
488 | 488 | $args['date_query'] = array( |
489 | 489 | array( |
490 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
491 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
490 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
491 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
492 | 492 | 'inclusive' => true |
493 | 493 | ) |
494 | 494 | ); |
495 | 495 | } |
496 | 496 | |
497 | - $invoices = wpinv_get_invoices( $args ); |
|
498 | - $total = !empty( $invoices ) ? count( $invoices ) : 0; |
|
497 | + $invoices = wpinv_get_invoices($args); |
|
498 | + $total = !empty($invoices) ? count($invoices) : 0; |
|
499 | 499 | $status = 100; |
500 | 500 | |
501 | - if ( $total > 0 ) { |
|
502 | - $status = ( ( $this->per_page * $this->step ) / $total ) * 100; |
|
501 | + if ($total > 0) { |
|
502 | + $status = (($this->per_page * $this->step) / $total) * 100; |
|
503 | 503 | } |
504 | 504 | |
505 | - if ( $status > 100 ) { |
|
505 | + if ($status > 100) { |
|
506 | 506 | $status = 100; |
507 | 507 | } |
508 | 508 |
@@ -7,89 +7,89 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_item_quantities_enabled() { |
15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
15 | + $ret = wpinv_get_option('item_quantities', true); |
|
16 | 16 | |
17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
17 | + return (bool)apply_filters('wpinv_item_quantities_enabled', $ret); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function wpinv_get_ip() { |
21 | 21 | $ip = '127.0.0.1'; |
22 | 22 | |
23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
29 | 29 | } |
30 | 30 | |
31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
31 | + return apply_filters('wpinv_get_ip', $ip); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | function wpinv_get_user_agent() { |
35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
37 | 37 | } else { |
38 | 38 | $user_agent = ''; |
39 | 39 | } |
40 | 40 | |
41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
42 | 42 | } |
43 | 43 | |
44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
45 | 45 | $is_negative = false; |
46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
48 | - if ( $decimals === NULL ) { |
|
48 | + if ($decimals === NULL) { |
|
49 | 49 | $decimals = wpinv_decimals(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Sanitize the amount |
53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
57 | - $amount = str_replace( '.', '', $amount ); |
|
53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
57 | + $amount = str_replace('.', '', $amount); |
|
58 | 58 | } |
59 | 59 | |
60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
63 | 63 | } |
64 | 64 | |
65 | - if( $amount < 0 ) { |
|
65 | + if ($amount < 0) { |
|
66 | 66 | $is_negative = true; |
67 | 67 | } |
68 | 68 | |
69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
70 | 70 | |
71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
72 | + $amount = number_format((double)$amount, absint($decimals), '.', ''); |
|
73 | 73 | |
74 | - if( $is_negative ) { |
|
74 | + if ($is_negative) { |
|
75 | 75 | $amount *= -1; |
76 | 76 | } |
77 | 77 | |
78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
79 | 79 | } |
80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
81 | 81 | |
82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
83 | - if ( $decimals === NULL ) { |
|
82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
83 | + if ($decimals === NULL) { |
|
84 | 84 | $decimals = wpinv_decimals(); |
85 | 85 | } |
86 | 86 | |
87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
87 | + $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_get_invoice_statuses( $trashed = false ) { |
|
92 | +function wpinv_get_invoice_statuses($trashed = false) { |
|
93 | 93 | global $post; |
94 | 94 | $invoice_statuses = array(); |
95 | 95 | $invoice_statuses = array( |
@@ -103,32 +103,32 @@ discard block |
||
103 | 103 | 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
104 | 104 | ); |
105 | 105 | |
106 | - if ( $trashed ) { |
|
107 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
106 | + if ($trashed) { |
|
107 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'wpinv_statuses', $invoice_statuses ); |
|
110 | + return apply_filters('wpinv_statuses', $invoice_statuses); |
|
111 | 111 | } |
112 | 112 | |
113 | -function wpinv_status_nicename( $status ) { |
|
113 | +function wpinv_status_nicename($status) { |
|
114 | 114 | $statuses = wpinv_get_invoice_statuses(); |
115 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
115 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
116 | 116 | |
117 | 117 | return $status; |
118 | 118 | } |
119 | 119 | |
120 | 120 | function wpinv_get_currency() { |
121 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
121 | + $currency = wpinv_get_option('currency', 'USD'); |
|
122 | 122 | |
123 | - return apply_filters( 'wpinv_currency', $currency ); |
|
123 | + return apply_filters('wpinv_currency', $currency); |
|
124 | 124 | } |
125 | 125 | |
126 | -function wpinv_currency_symbol( $currency = '' ) { |
|
127 | - if ( empty( $currency ) ) { |
|
126 | +function wpinv_currency_symbol($currency = '') { |
|
127 | + if (empty($currency)) { |
|
128 | 128 | $currency = wpinv_get_currency(); |
129 | 129 | } |
130 | 130 | |
131 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
131 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
132 | 132 | 'AED' => 'د.إ', |
133 | 133 | 'ARS' => '$', |
134 | 134 | 'AUD' => '$', |
@@ -180,78 +180,78 @@ discard block |
||
180 | 180 | 'USD' => '$', |
181 | 181 | 'VND' => '₫', |
182 | 182 | 'ZAR' => 'R', |
183 | - ) ); |
|
183 | + )); |
|
184 | 184 | |
185 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : '$'; |
|
185 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : '$'; |
|
186 | 186 | |
187 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
187 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | function wpinv_currency_position() { |
191 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
191 | + $position = wpinv_get_option('currency_position', 'left'); |
|
192 | 192 | |
193 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
193 | + return apply_filters('wpinv_currency_position', $position); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | function wpinv_thousands_separator() { |
197 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
197 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
198 | 198 | |
199 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
199 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | function wpinv_decimal_separator() { |
203 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
203 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
204 | 204 | |
205 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
205 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | function wpinv_decimals() { |
209 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
209 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
210 | 210 | |
211 | - return absint( $decimals ); |
|
211 | + return absint($decimals); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | function wpinv_get_currencies() { |
215 | 215 | $currencies = array( |
216 | - 'USD' => __( 'US Dollars ($)', 'invoicing' ), |
|
217 | - 'EUR' => __( 'Euros (€)', 'invoicing' ), |
|
218 | - 'GBP' => __( 'Pounds Sterling (£)', 'invoicing' ), |
|
219 | - 'AUD' => __( 'Australian Dollars ($)', 'invoicing' ), |
|
220 | - 'BRL' => __( 'Brazilian Real (R$)', 'invoicing' ), |
|
221 | - 'CAD' => __( 'Canadian Dollars ($)', 'invoicing' ), |
|
222 | - 'CLP' => __( 'Chilean Peso ($)', 'invoicing' ), |
|
223 | - 'CNY' => __( 'Chinese Yuan (¥)', 'invoicing' ), |
|
224 | - 'CZK' => __( 'Czech Koruna (Kč)', 'invoicing' ), |
|
225 | - 'DKK' => __( 'Danish Krone (DKK)', 'invoicing' ), |
|
226 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'invoicing' ), |
|
227 | - 'HUF' => __( 'Hungarian Forint (Ft)', 'invoicing' ), |
|
228 | - 'INR' => __( 'Indian Rupee (₹)', 'invoicing' ), |
|
229 | - 'ILS' => __( 'Israeli Shekel (₪)', 'invoicing' ), |
|
230 | - 'JPY' => __( 'Japanese Yen (¥)', 'invoicing' ), |
|
231 | - 'MYR' => __( 'Malaysian Ringgit (RM)', 'invoicing' ), |
|
232 | - 'MXN' => __( 'Mexican Peso ($)', 'invoicing' ), |
|
233 | - 'NZD' => __( 'New Zealand Dollar ($)', 'invoicing' ), |
|
234 | - 'NOK' => __( 'Norwegian Krone (kr)', 'invoicing' ), |
|
235 | - 'PHP' => __( 'Philippine Peso (₱)', 'invoicing' ), |
|
236 | - 'PLN' => __( 'Polish Zloty (zł)', 'invoicing' ), |
|
237 | - 'SGD' => __( 'Singapore Dollar ($)', 'invoicing' ), |
|
238 | - 'SEK' => __( 'Swedish Krona (kr)', 'invoicing' ), |
|
239 | - 'CHF' => __( 'Swiss Franc (CHF)', 'invoicing' ), |
|
240 | - 'TWD' => __( 'Taiwan New Dollar (NT$)', 'invoicing' ), |
|
241 | - 'THB' => __( 'Thai Baht (฿)', 'invoicing' ), |
|
242 | - 'TRY' => __( 'Turkish Lira (₺)', 'invoicing' ), |
|
243 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'invoicing' ), |
|
244 | - 'RUB' => __( 'Russian Ruble (₽)', 'invoicing' ), |
|
245 | - 'ZAR' => __( 'South African Rand (R)', 'invoicing' ) |
|
216 | + 'USD' => __('US Dollars ($)', 'invoicing'), |
|
217 | + 'EUR' => __('Euros (€)', 'invoicing'), |
|
218 | + 'GBP' => __('Pounds Sterling (£)', 'invoicing'), |
|
219 | + 'AUD' => __('Australian Dollars ($)', 'invoicing'), |
|
220 | + 'BRL' => __('Brazilian Real (R$)', 'invoicing'), |
|
221 | + 'CAD' => __('Canadian Dollars ($)', 'invoicing'), |
|
222 | + 'CLP' => __('Chilean Peso ($)', 'invoicing'), |
|
223 | + 'CNY' => __('Chinese Yuan (¥)', 'invoicing'), |
|
224 | + 'CZK' => __('Czech Koruna (Kč)', 'invoicing'), |
|
225 | + 'DKK' => __('Danish Krone (DKK)', 'invoicing'), |
|
226 | + 'HKD' => __('Hong Kong Dollar ($)', 'invoicing'), |
|
227 | + 'HUF' => __('Hungarian Forint (Ft)', 'invoicing'), |
|
228 | + 'INR' => __('Indian Rupee (₹)', 'invoicing'), |
|
229 | + 'ILS' => __('Israeli Shekel (₪)', 'invoicing'), |
|
230 | + 'JPY' => __('Japanese Yen (¥)', 'invoicing'), |
|
231 | + 'MYR' => __('Malaysian Ringgit (RM)', 'invoicing'), |
|
232 | + 'MXN' => __('Mexican Peso ($)', 'invoicing'), |
|
233 | + 'NZD' => __('New Zealand Dollar ($)', 'invoicing'), |
|
234 | + 'NOK' => __('Norwegian Krone (kr)', 'invoicing'), |
|
235 | + 'PHP' => __('Philippine Peso (₱)', 'invoicing'), |
|
236 | + 'PLN' => __('Polish Zloty (zł)', 'invoicing'), |
|
237 | + 'SGD' => __('Singapore Dollar ($)', 'invoicing'), |
|
238 | + 'SEK' => __('Swedish Krona (kr)', 'invoicing'), |
|
239 | + 'CHF' => __('Swiss Franc (CHF)', 'invoicing'), |
|
240 | + 'TWD' => __('Taiwan New Dollar (NT$)', 'invoicing'), |
|
241 | + 'THB' => __('Thai Baht (฿)', 'invoicing'), |
|
242 | + 'TRY' => __('Turkish Lira (₺)', 'invoicing'), |
|
243 | + 'RIAL' => __('Iranian Rial (﷼)', 'invoicing'), |
|
244 | + 'RUB' => __('Russian Ruble (₽)', 'invoicing'), |
|
245 | + 'ZAR' => __('South African Rand (R)', 'invoicing') |
|
246 | 246 | ); |
247 | 247 | |
248 | - asort( $currencies ); |
|
248 | + asort($currencies); |
|
249 | 249 | |
250 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
250 | + return apply_filters('wpinv_currencies', $currencies); |
|
251 | 251 | } |
252 | 252 | |
253 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
254 | - if( empty( $currency ) ) { |
|
253 | +function wpinv_price($amount = '', $currency = '') { |
|
254 | + if (empty($currency)) { |
|
255 | 255 | $currency = wpinv_get_currency(); |
256 | 256 | } |
257 | 257 | |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | |
260 | 260 | $negative = $amount < 0; |
261 | 261 | |
262 | - if ( $negative ) { |
|
263 | - $amount = substr( $amount, 1 ); |
|
262 | + if ($negative) { |
|
263 | + $amount = substr($amount, 1); |
|
264 | 264 | } |
265 | 265 | |
266 | - $symbol = wpinv_currency_symbol( $currency ); |
|
266 | + $symbol = wpinv_currency_symbol($currency); |
|
267 | 267 | |
268 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
269 | - switch ( $currency ) { |
|
268 | + if ($position == 'left' || $position == 'left_space') { |
|
269 | + switch ($currency) { |
|
270 | 270 | case "GBP" : |
271 | 271 | case "BRL" : |
272 | 272 | case "EUR" : |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | case "NZD" : |
279 | 279 | case "SGD" : |
280 | 280 | case "JPY" : |
281 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
281 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
282 | 282 | break; |
283 | 283 | default : |
284 | 284 | //$price = $currency . ' ' . $amount; |
285 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
285 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
286 | 286 | break; |
287 | 287 | } |
288 | 288 | } else { |
289 | - switch ( $currency ) { |
|
289 | + switch ($currency) { |
|
290 | 290 | case "GBP" : |
291 | 291 | case "BRL" : |
292 | 292 | case "EUR" : |
@@ -297,83 +297,83 @@ discard block |
||
297 | 297 | case "MXN" : |
298 | 298 | case "SGD" : |
299 | 299 | case "JPY" : |
300 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
300 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
301 | 301 | break; |
302 | 302 | default : |
303 | 303 | //$price = $amount . ' ' . $currency; |
304 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
304 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
305 | 305 | break; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - if ( $negative ) { |
|
309 | + if ($negative) { |
|
310 | 310 | $price = '-' . $price; |
311 | 311 | } |
312 | 312 | |
313 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
313 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
314 | 314 | |
315 | 315 | return $price; |
316 | 316 | } |
317 | 317 | |
318 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
318 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
319 | 319 | $thousands_sep = wpinv_thousands_separator(); |
320 | 320 | $decimal_sep = wpinv_decimal_separator(); |
321 | 321 | |
322 | - if ( $decimals === NULL ) { |
|
322 | + if ($decimals === NULL) { |
|
323 | 323 | $decimals = wpinv_decimals(); |
324 | 324 | } |
325 | 325 | |
326 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
327 | - $whole = substr( $amount, 0, $sep_found ); |
|
328 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
326 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
327 | + $whole = substr($amount, 0, $sep_found); |
|
328 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
329 | 329 | $amount = $whole . '.' . $part; |
330 | 330 | } |
331 | 331 | |
332 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
333 | - $amount = str_replace( ',', '', $amount ); |
|
332 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
333 | + $amount = str_replace(',', '', $amount); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
337 | - $amount = str_replace( ' ', '', $amount ); |
|
336 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
337 | + $amount = str_replace(' ', '', $amount); |
|
338 | 338 | } |
339 | 339 | |
340 | - if ( empty( $amount ) ) { |
|
340 | + if (empty($amount)) { |
|
341 | 341 | $amount = 0; |
342 | 342 | } |
343 | 343 | |
344 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
345 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
344 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
345 | + $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep); |
|
346 | 346 | |
347 | - if ( $calculate ) { |
|
348 | - if ( $thousands_sep === "," ) { |
|
349 | - $formatted = str_replace( ",", "", $formatted ); |
|
347 | + if ($calculate) { |
|
348 | + if ($thousands_sep === ",") { |
|
349 | + $formatted = str_replace(",", "", $formatted); |
|
350 | 350 | } |
351 | 351 | |
352 | - if ( $decimal_sep === "," ) { |
|
353 | - $formatted = str_replace( ",", ".", $formatted ); |
|
352 | + if ($decimal_sep === ",") { |
|
353 | + $formatted = str_replace(",", ".", $formatted); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
357 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
358 | 358 | } |
359 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
359 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
360 | 360 | |
361 | -function wpinv_sanitize_key( $key ) { |
|
361 | +function wpinv_sanitize_key($key) { |
|
362 | 362 | $raw_key = $key; |
363 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
363 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
364 | 364 | |
365 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
365 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
366 | 366 | } |
367 | 367 | |
368 | -function wpinv_get_file_extension( $str ) { |
|
369 | - $parts = explode( '.', $str ); |
|
370 | - return end( $parts ); |
|
368 | +function wpinv_get_file_extension($str) { |
|
369 | + $parts = explode('.', $str); |
|
370 | + return end($parts); |
|
371 | 371 | } |
372 | 372 | |
373 | -function wpinv_string_is_image_url( $str ) { |
|
374 | - $ext = wpinv_get_file_extension( $str ); |
|
373 | +function wpinv_string_is_image_url($str) { |
|
374 | + $ext = wpinv_get_file_extension($str); |
|
375 | 375 | |
376 | - switch ( strtolower( $ext ) ) { |
|
376 | + switch (strtolower($ext)) { |
|
377 | 377 | case 'jpeg'; |
378 | 378 | case 'jpg'; |
379 | 379 | $return = true; |
@@ -389,32 +389,32 @@ discard block |
||
389 | 389 | break; |
390 | 390 | } |
391 | 391 | |
392 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
392 | + return (bool)apply_filters('wpinv_string_is_image', $return, $str); |
|
393 | 393 | } |
394 | 394 | |
395 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
396 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
395 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
396 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
397 | 397 | |
398 | - if ( true === $should_log ) { |
|
398 | + if (true === $should_log) { |
|
399 | 399 | $label = ''; |
400 | - if ( $file && $file !== '' ) { |
|
401 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
400 | + if ($file && $file !== '') { |
|
401 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
402 | 402 | } |
403 | 403 | |
404 | - if ( $title && $title !== '' ) { |
|
404 | + if ($title && $title !== '') { |
|
405 | 405 | $label = $label !== '' ? $label . ' ' : ''; |
406 | 406 | $label .= $title . ' '; |
407 | 407 | } |
408 | 408 | |
409 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
409 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
410 | 410 | |
411 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
412 | - error_log( $label . print_r( $log, true ) ); |
|
411 | + if (is_array($log) || is_object($log)) { |
|
412 | + error_log($label . print_r($log, true)); |
|
413 | 413 | } else { |
414 | - error_log( $label . $log ); |
|
414 | + error_log($label . $log); |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( $exit ) { |
|
417 | + if ($exit) { |
|
418 | 418 | exit; |
419 | 419 | } |
420 | 420 | } |
@@ -422,65 +422,65 @@ discard block |
||
422 | 422 | |
423 | 423 | function wpinv_is_ajax_disabled() { |
424 | 424 | $retval = false; |
425 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
425 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
426 | 426 | } |
427 | 427 | |
428 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
428 | +function wpinv_get_current_page_url($nocache = false) { |
|
429 | 429 | global $wp; |
430 | 430 | |
431 | - if ( get_option( 'permalink_structure' ) ) { |
|
432 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
431 | + if (get_option('permalink_structure')) { |
|
432 | + $base = trailingslashit(home_url($wp->request)); |
|
433 | 433 | } else { |
434 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
435 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
434 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
435 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | $scheme = is_ssl() ? 'https' : 'http'; |
439 | - $uri = set_url_scheme( $base, $scheme ); |
|
439 | + $uri = set_url_scheme($base, $scheme); |
|
440 | 440 | |
441 | - if ( is_front_page() ) { |
|
442 | - $uri = home_url( '/' ); |
|
443 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
441 | + if (is_front_page()) { |
|
442 | + $uri = home_url('/'); |
|
443 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
444 | 444 | $uri = wpinv_get_checkout_uri(); |
445 | 445 | } |
446 | 446 | |
447 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
447 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
448 | 448 | |
449 | - if ( $nocache ) { |
|
450 | - $uri = wpinv_add_cache_busting( $uri ); |
|
449 | + if ($nocache) { |
|
450 | + $uri = wpinv_add_cache_busting($uri); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | return $uri; |
454 | 454 | } |
455 | 455 | |
456 | 456 | function wpinv_get_php_arg_separator_output() { |
457 | - return ini_get( 'arg_separator.output' ); |
|
457 | + return ini_get('arg_separator.output'); |
|
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_rgb_from_hex( $color ) { |
|
461 | - $color = str_replace( '#', '', $color ); |
|
460 | +function wpinv_rgb_from_hex($color) { |
|
461 | + $color = str_replace('#', '', $color); |
|
462 | 462 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
463 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
463 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
464 | 464 | |
465 | 465 | $rgb = array(); |
466 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
467 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
468 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
466 | + $rgb['R'] = hexdec($color{0} . $color{1} ); |
|
467 | + $rgb['G'] = hexdec($color{2} . $color{3} ); |
|
468 | + $rgb['B'] = hexdec($color{4} . $color{5} ); |
|
469 | 469 | |
470 | 470 | return $rgb; |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
474 | - $base = wpinv_rgb_from_hex( $color ); |
|
473 | +function wpinv_hex_darker($color, $factor = 30) { |
|
474 | + $base = wpinv_rgb_from_hex($color); |
|
475 | 475 | $color = '#'; |
476 | 476 | |
477 | - foreach ( $base as $k => $v ) { |
|
477 | + foreach ($base as $k => $v) { |
|
478 | 478 | $amount = $v / 100; |
479 | - $amount = round( $amount * $factor ); |
|
479 | + $amount = round($amount * $factor); |
|
480 | 480 | $new_decimal = $v - $amount; |
481 | 481 | |
482 | - $new_hex_component = dechex( $new_decimal ); |
|
483 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
482 | + $new_hex_component = dechex($new_decimal); |
|
483 | + if (strlen($new_hex_component) < 2) { |
|
484 | 484 | $new_hex_component = "0" . $new_hex_component; |
485 | 485 | } |
486 | 486 | $color .= $new_hex_component; |
@@ -489,18 +489,18 @@ discard block |
||
489 | 489 | return $color; |
490 | 490 | } |
491 | 491 | |
492 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
493 | - $base = wpinv_rgb_from_hex( $color ); |
|
492 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
493 | + $base = wpinv_rgb_from_hex($color); |
|
494 | 494 | $color = '#'; |
495 | 495 | |
496 | - foreach ( $base as $k => $v ) { |
|
496 | + foreach ($base as $k => $v) { |
|
497 | 497 | $amount = 255 - $v; |
498 | 498 | $amount = $amount / 100; |
499 | - $amount = round( $amount * $factor ); |
|
499 | + $amount = round($amount * $factor); |
|
500 | 500 | $new_decimal = $v + $amount; |
501 | 501 | |
502 | - $new_hex_component = dechex( $new_decimal ); |
|
503 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
502 | + $new_hex_component = dechex($new_decimal); |
|
503 | + if (strlen($new_hex_component) < 2) { |
|
504 | 504 | $new_hex_component = "0" . $new_hex_component; |
505 | 505 | } |
506 | 506 | $color .= $new_hex_component; |
@@ -509,22 +509,22 @@ discard block |
||
509 | 509 | return $color; |
510 | 510 | } |
511 | 511 | |
512 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
513 | - $hex = str_replace( '#', '', $color ); |
|
512 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
513 | + $hex = str_replace('#', '', $color); |
|
514 | 514 | |
515 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
516 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
517 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
515 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
516 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
517 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
518 | 518 | |
519 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
519 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
520 | 520 | |
521 | 521 | return $brightness > 155 ? $dark : $light; |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_format_hex( $hex ) { |
|
525 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
524 | +function wpinv_format_hex($hex) { |
|
525 | + $hex = trim(str_replace('#', '', $hex)); |
|
526 | 526 | |
527 | - if ( strlen( $hex ) == 3 ) { |
|
527 | + if (strlen($hex) == 3) { |
|
528 | 528 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
529 | 529 | } |
530 | 530 | |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
545 | 545 | * @return string |
546 | 546 | */ |
547 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
548 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
549 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
547 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
548 | + if (function_exists('mb_strimwidth')) { |
|
549 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
550 | 550 | } |
551 | 551 | |
552 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
552 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -561,28 +561,28 @@ discard block |
||
561 | 561 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
562 | 562 | * @return int Returns the number of characters in string. |
563 | 563 | */ |
564 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
565 | - if ( function_exists( 'mb_strlen' ) ) { |
|
566 | - return mb_strlen( $str, $encoding ); |
|
564 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
565 | + if (function_exists('mb_strlen')) { |
|
566 | + return mb_strlen($str, $encoding); |
|
567 | 567 | } |
568 | 568 | |
569 | - return strlen( $str ); |
|
569 | + return strlen($str); |
|
570 | 570 | } |
571 | 571 | |
572 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
573 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
574 | - return mb_strtolower( $str, $encoding ); |
|
572 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
573 | + if (function_exists('mb_strtolower')) { |
|
574 | + return mb_strtolower($str, $encoding); |
|
575 | 575 | } |
576 | 576 | |
577 | - return strtolower( $str ); |
|
577 | + return strtolower($str); |
|
578 | 578 | } |
579 | 579 | |
580 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
581 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
582 | - return mb_strtoupper( $str, $encoding ); |
|
580 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
581 | + if (function_exists('mb_strtoupper')) { |
|
582 | + return mb_strtoupper($str, $encoding); |
|
583 | 583 | } |
584 | 584 | |
585 | - return strtoupper( $str ); |
|
585 | + return strtoupper($str); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -596,12 +596,12 @@ discard block |
||
596 | 596 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
597 | 597 | * @return int Returns the position of the first occurrence of search in the string. |
598 | 598 | */ |
599 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
600 | - if ( function_exists( 'mb_strpos' ) ) { |
|
601 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
599 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
600 | + if (function_exists('mb_strpos')) { |
|
601 | + return mb_strpos($str, $find, $offset, $encoding); |
|
602 | 602 | } |
603 | 603 | |
604 | - return strpos( $str, $find, $offset ); |
|
604 | + return strpos($str, $find, $offset); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
616 | 616 | * @return int Returns the position of the last occurrence of search. |
617 | 617 | */ |
618 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
619 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
620 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
618 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
619 | + if (function_exists('mb_strrpos')) { |
|
620 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
621 | 621 | } |
622 | 622 | |
623 | - return strrpos( $str, $find, $offset ); |
|
623 | + return strrpos($str, $find, $offset); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
636 | 636 | * @return string |
637 | 637 | */ |
638 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
639 | - if ( function_exists( 'mb_substr' ) ) { |
|
640 | - if ( $length === null ) { |
|
641 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
638 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
639 | + if (function_exists('mb_substr')) { |
|
640 | + if ($length === null) { |
|
641 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
642 | 642 | } else { |
643 | - return mb_substr( $str, $start, $length, $encoding ); |
|
643 | + return mb_substr($str, $start, $length, $encoding); |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | - return substr( $str, $start, $length ); |
|
647 | + return substr($str, $start, $length); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
@@ -656,48 +656,48 @@ discard block |
||
656 | 656 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
657 | 657 | * @return string The width of string. |
658 | 658 | */ |
659 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
660 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
661 | - return mb_strwidth( $str, $encoding ); |
|
659 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
660 | + if (function_exists('mb_strwidth')) { |
|
661 | + return mb_strwidth($str, $encoding); |
|
662 | 662 | } |
663 | 663 | |
664 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
664 | + return wpinv_utf8_strlen($str, $encoding); |
|
665 | 665 | } |
666 | 666 | |
667 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
668 | - if ( function_exists( 'mb_strlen' ) ) { |
|
669 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
667 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
668 | + if (function_exists('mb_strlen')) { |
|
669 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
670 | 670 | $str_end = ""; |
671 | 671 | |
672 | - if ( $lower_str_end ) { |
|
673 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
672 | + if ($lower_str_end) { |
|
673 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
674 | 674 | } else { |
675 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
675 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | return $first_letter . $str_end; |
679 | 679 | } |
680 | 680 | |
681 | - return ucfirst( $str ); |
|
681 | + return ucfirst($str); |
|
682 | 682 | } |
683 | 683 | |
684 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
685 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
686 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
684 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
685 | + if (function_exists('mb_convert_case')) { |
|
686 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
687 | 687 | } |
688 | 688 | |
689 | - return ucwords( $str ); |
|
689 | + return ucwords($str); |
|
690 | 690 | } |
691 | 691 | |
692 | -function wpinv_period_in_days( $period, $unit ) { |
|
693 | - $period = absint( $period ); |
|
692 | +function wpinv_period_in_days($period, $unit) { |
|
693 | + $period = absint($period); |
|
694 | 694 | |
695 | - if ( $period > 0 ) { |
|
696 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
695 | + if ($period > 0) { |
|
696 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
697 | 697 | $period = $period * 7; |
698 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
698 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
699 | 699 | $period = $period * 30; |
700 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
700 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
701 | 701 | $period = $period * 365; |
702 | 702 | } |
703 | 703 | } |
@@ -7,28 +7,28 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Ajax { |
15 | 15 | public static function init() { |
16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
18 | 18 | self::add_ajax_events(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function define_ajax() { |
22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
24 | - define( 'DOING_AJAX', true ); |
|
22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
23 | + if (!defined('DOING_AJAX')) { |
|
24 | + define('DOING_AJAX', true); |
|
25 | 25 | } |
26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
27 | - define( 'WC_DOING_AJAX', true ); |
|
26 | + if (!defined('WC_DOING_AJAX')) { |
|
27 | + define('WC_DOING_AJAX', true); |
|
28 | 28 | } |
29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
31 | - @ini_set( 'display_errors', 0 ); |
|
30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
31 | + @ini_set('display_errors', 0); |
|
32 | 32 | } |
33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | public static function do_wpinv_ajax() { |
38 | 38 | global $wp_query; |
39 | 39 | |
40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
45 | 45 | self::wpinv_ajax_headers(); |
46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function wpinv_ajax_headers() { |
52 | 52 | send_origin_headers(); |
53 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
54 | - @header( 'X-Robots-Tag: noindex' ); |
|
53 | + @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
54 | + @header('X-Robots-Tag: noindex'); |
|
55 | 55 | send_nosniff_header(); |
56 | 56 | nocache_headers(); |
57 | - status_header( 200 ); |
|
57 | + status_header(200); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function add_ajax_events() { |
@@ -76,39 +76,39 @@ discard block |
||
76 | 76 | 'remove_discount' => false, |
77 | 77 | ); |
78 | 78 | |
79 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
80 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
79 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
80 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
81 | 81 | |
82 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
83 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
82 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
83 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
84 | 84 | } |
85 | 85 | |
86 | - if ( $nopriv ) { |
|
87 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
86 | + if ($nopriv) { |
|
87 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
88 | 88 | |
89 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
89 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function add_note() { |
95 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
95 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
96 | 96 | |
97 | - if ( !current_user_can( 'manage_options' ) ) { |
|
97 | + if (!current_user_can('manage_options')) { |
|
98 | 98 | die(-1); |
99 | 99 | } |
100 | 100 | |
101 | - $post_id = absint( $_POST['post_id'] ); |
|
102 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
103 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
101 | + $post_id = absint($_POST['post_id']); |
|
102 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
103 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
104 | 104 | |
105 | 105 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
106 | 106 | |
107 | - if ( $post_id > 0 ) { |
|
108 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
107 | + if ($post_id > 0) { |
|
108 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
109 | 109 | |
110 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
111 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
110 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
111 | + wpinv_get_invoice_note_line_item($note_id); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function delete_note() { |
119 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
119 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
120 | 120 | |
121 | - if ( !current_user_can( 'manage_options' ) ) { |
|
121 | + if (!current_user_can('manage_options')) { |
|
122 | 122 | die(-1); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $note_id = (int)$_POST['note_id']; |
126 | 126 | |
127 | - if ( $note_id > 0 ) { |
|
128 | - wp_delete_comment( $note_id, true ); |
|
127 | + if ($note_id > 0) { |
|
128 | + wp_delete_comment($note_id, true); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | die(); |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | public static function checkout() { |
141 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
142 | - define( 'WPINV_CHECKOUT', true ); |
|
141 | + if (!defined('WPINV_CHECKOUT')) { |
|
142 | + define('WPINV_CHECKOUT', true); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | wpinv_process_checkout(); |
@@ -148,53 +148,53 @@ discard block |
||
148 | 148 | |
149 | 149 | public static function add_invoice_item() { |
150 | 150 | global $wpi_userID, $wpinv_ip_address_country; |
151 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
152 | - if ( !current_user_can( 'manage_options' ) ) { |
|
151 | + check_ajax_referer('invoice-item', '_nonce'); |
|
152 | + if (!current_user_can('manage_options')) { |
|
153 | 153 | die(-1); |
154 | 154 | } |
155 | 155 | |
156 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
157 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
156 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
157 | + $invoice_id = absint($_POST['invoice_id']); |
|
158 | 158 | |
159 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
159 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
160 | 160 | die(); |
161 | 161 | } |
162 | 162 | |
163 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
164 | - if ( empty( $invoice ) ) { |
|
163 | + $invoice = wpinv_get_invoice($invoice_id); |
|
164 | + if (empty($invoice)) { |
|
165 | 165 | die(); |
166 | 166 | } |
167 | 167 | |
168 | - if ( $invoice->is_paid() ) { |
|
168 | + if ($invoice->is_paid()) { |
|
169 | 169 | die(); // Don't allow modify items for paid invoice. |
170 | 170 | } |
171 | 171 | |
172 | - if ( !empty( $_POST['user_id'] ) ) { |
|
173 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
172 | + if (!empty($_POST['user_id'])) { |
|
173 | + $wpi_userID = absint($_POST['user_id']); |
|
174 | 174 | } |
175 | 175 | |
176 | - $item = new WPInv_Item( $item_id ); |
|
177 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
176 | + $item = new WPInv_Item($item_id); |
|
177 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
178 | 178 | die(); |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Validate item before adding to invoice because recurring item must be paid individually. |
182 | - if ( !empty( $invoice->cart_details ) ) { |
|
182 | + if (!empty($invoice->cart_details)) { |
|
183 | 183 | $valid = true; |
184 | 184 | |
185 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
186 | - if ( $recurring_item != $item_id ) { |
|
185 | + if ($recurring_item = $invoice->get_recurring()) { |
|
186 | + if ($recurring_item != $item_id) { |
|
187 | 187 | $valid = false; |
188 | 188 | } |
189 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
189 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
190 | 190 | $valid = false; |
191 | 191 | } |
192 | 192 | |
193 | - if ( !$valid ) { |
|
193 | + if (!$valid) { |
|
194 | 194 | $response = array(); |
195 | 195 | $response['success'] = false; |
196 | - $response['msg'] = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' ); |
|
197 | - wp_send_json( $response ); |
|
196 | + $response['msg'] = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing'); |
|
197 | + wp_send_json($response); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | |
203 | 203 | $data = array(); |
204 | 204 | $data['invoice_id'] = $invoice_id; |
205 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
205 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
206 | 206 | |
207 | - wpinv_set_checkout_session( $data ); |
|
207 | + wpinv_set_checkout_session($data); |
|
208 | 208 | |
209 | 209 | $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
210 | 210 | |
@@ -219,21 +219,21 @@ discard block |
||
219 | 219 | 'fees' => array() |
220 | 220 | ); |
221 | 221 | |
222 | - $invoice->add_item( $item_id, $args ); |
|
222 | + $invoice->add_item($item_id, $args); |
|
223 | 223 | $invoice->save(); |
224 | 224 | |
225 | - if ( empty( $_POST['country'] ) ) { |
|
225 | + if (empty($_POST['country'])) { |
|
226 | 226 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
227 | 227 | } |
228 | - if ( empty( $_POST['state'] ) ) { |
|
228 | + if (empty($_POST['state'])) { |
|
229 | 229 | $_POST['state'] = $invoice->state; |
230 | 230 | } |
231 | 231 | |
232 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
233 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
232 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
233 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
234 | 234 | |
235 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
236 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
235 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
236 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
237 | 237 | |
238 | 238 | $wpinv_ip_address_country = $invoice->country; |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $response = array(); |
243 | 243 | $response['success'] = true; |
244 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
244 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
245 | 245 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
246 | 246 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
247 | 247 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -253,40 +253,40 @@ discard block |
||
253 | 253 | |
254 | 254 | wpinv_set_checkout_session($checkout_session); |
255 | 255 | |
256 | - wp_send_json( $response ); |
|
256 | + wp_send_json($response); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | public static function remove_invoice_item() { |
260 | 260 | global $wpi_userID, $wpinv_ip_address_country; |
261 | 261 | |
262 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
263 | - if ( !current_user_can( 'manage_options' ) ) { |
|
262 | + check_ajax_referer('invoice-item', '_nonce'); |
|
263 | + if (!current_user_can('manage_options')) { |
|
264 | 264 | die(-1); |
265 | 265 | } |
266 | 266 | |
267 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
268 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
269 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
267 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
268 | + $invoice_id = absint($_POST['invoice_id']); |
|
269 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
270 | 270 | |
271 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
271 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
272 | 272 | die(); |
273 | 273 | } |
274 | 274 | |
275 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
276 | - if ( empty( $invoice ) ) { |
|
275 | + $invoice = wpinv_get_invoice($invoice_id); |
|
276 | + if (empty($invoice)) { |
|
277 | 277 | die(); |
278 | 278 | } |
279 | 279 | |
280 | - if ( $invoice->is_paid() ) { |
|
280 | + if ($invoice->is_paid()) { |
|
281 | 281 | die(); // Don't allow modify items for paid invoice. |
282 | 282 | } |
283 | 283 | |
284 | - if ( !empty( $_POST['user_id'] ) ) { |
|
285 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
284 | + if (!empty($_POST['user_id'])) { |
|
285 | + $wpi_userID = absint($_POST['user_id']); |
|
286 | 286 | } |
287 | 287 | |
288 | - $item = new WPInv_Item( $item_id ); |
|
289 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
288 | + $item = new WPInv_Item($item_id); |
|
289 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
290 | 290 | die(); |
291 | 291 | } |
292 | 292 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | $data = array(); |
296 | 296 | $data['invoice_id'] = $invoice_id; |
297 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
297 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
298 | 298 | |
299 | - wpinv_set_checkout_session( $data ); |
|
299 | + wpinv_set_checkout_session($data); |
|
300 | 300 | |
301 | 301 | $args = array( |
302 | 302 | 'id' => $item_id, |
@@ -304,21 +304,21 @@ discard block |
||
304 | 304 | 'cart_index' => $cart_index |
305 | 305 | ); |
306 | 306 | |
307 | - $invoice->remove_item( $item_id, $args ); |
|
307 | + $invoice->remove_item($item_id, $args); |
|
308 | 308 | $invoice->save(); |
309 | 309 | |
310 | - if ( empty( $_POST['country'] ) ) { |
|
310 | + if (empty($_POST['country'])) { |
|
311 | 311 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
312 | 312 | } |
313 | - if ( empty( $_POST['state'] ) ) { |
|
313 | + if (empty($_POST['state'])) { |
|
314 | 314 | $_POST['state'] = $invoice->state; |
315 | 315 | } |
316 | 316 | |
317 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
318 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
317 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
318 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
319 | 319 | |
320 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
321 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
320 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
321 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
322 | 322 | |
323 | 323 | $wpinv_ip_address_country = $invoice->country; |
324 | 324 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | $response = array(); |
328 | 328 | $response['success'] = true; |
329 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
329 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
330 | 330 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
331 | 331 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
332 | 332 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -338,40 +338,40 @@ discard block |
||
338 | 338 | |
339 | 339 | wpinv_set_checkout_session($checkout_session); |
340 | 340 | |
341 | - wp_send_json( $response ); |
|
341 | + wp_send_json($response); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | public static function create_invoice_item() { |
345 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
346 | - if ( !current_user_can( 'manage_options' ) ) { |
|
345 | + check_ajax_referer('invoice-item', '_nonce'); |
|
346 | + if (!current_user_can('manage_options')) { |
|
347 | 347 | die(-1); |
348 | 348 | } |
349 | 349 | |
350 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
350 | + $invoice_id = absint($_POST['invoice_id']); |
|
351 | 351 | |
352 | 352 | // Find the item |
353 | - if ( !is_numeric( $invoice_id ) ) { |
|
353 | + if (!is_numeric($invoice_id)) { |
|
354 | 354 | die(); |
355 | 355 | } |
356 | 356 | |
357 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
358 | - if ( empty( $invoice ) ) { |
|
357 | + $invoice = wpinv_get_invoice($invoice_id); |
|
358 | + if (empty($invoice)) { |
|
359 | 359 | die(); |
360 | 360 | } |
361 | 361 | |
362 | 362 | // Validate item before adding to invoice because recurring item must be paid individually. |
363 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
363 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
364 | 364 | $response = array(); |
365 | 365 | $response['success'] = false; |
366 | - $response['msg'] = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' ); |
|
367 | - wp_send_json( $response ); |
|
366 | + $response['msg'] = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing'); |
|
367 | + wp_send_json($response); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | $save_item = $_POST['_wpinv_quick']; |
371 | 371 | |
372 | 372 | $meta = array(); |
373 | 373 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
374 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
374 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
375 | 375 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
376 | 376 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
377 | 377 | |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | $data['meta'] = $meta; |
382 | 382 | |
383 | 383 | $item = new WPInv_Item(); |
384 | - $item->create( $data ); |
|
384 | + $item->create($data); |
|
385 | 385 | |
386 | - if ( !empty( $item ) ) { |
|
386 | + if (!empty($item)) { |
|
387 | 387 | $_POST['item_id'] = $item->ID; |
388 | 388 | $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
389 | 389 | |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | public static function get_billing_details() { |
396 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
396 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
397 | 397 | |
398 | - if ( !current_user_can( 'manage_options' ) ) { |
|
398 | + if (!current_user_can('manage_options')) { |
|
399 | 399 | die(-1); |
400 | 400 | } |
401 | 401 | |
402 | 402 | $user_id = (int)$_POST['user_id']; |
403 | 403 | $billing_details = wpinv_get_user_address($user_id); |
404 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
404 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
405 | 405 | |
406 | 406 | if (isset($billing_details['user_id'])) { |
407 | 407 | unset($billing_details['user_id']); |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | $response['success'] = true; |
416 | 416 | $response['data']['billing_details'] = $billing_details; |
417 | 417 | |
418 | - wp_send_json( $response ); |
|
418 | + wp_send_json($response); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | public static function admin_recalculate_totals() { |
422 | 422 | global $wpi_userID, $wpinv_ip_address_country; |
423 | 423 | |
424 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
425 | - if ( !current_user_can( 'manage_options' ) ) { |
|
424 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
425 | + if (!current_user_can('manage_options')) { |
|
426 | 426 | die(-1); |
427 | 427 | } |
428 | 428 | |
429 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
430 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
431 | - if ( empty( $invoice ) ) { |
|
429 | + $invoice_id = absint($_POST['invoice_id']); |
|
430 | + $invoice = wpinv_get_invoice($invoice_id); |
|
431 | + if (empty($invoice)) { |
|
432 | 432 | die(); |
433 | 433 | } |
434 | 434 | |
@@ -436,23 +436,23 @@ discard block |
||
436 | 436 | |
437 | 437 | $data = array(); |
438 | 438 | $data['invoice_id'] = $invoice_id; |
439 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
439 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
440 | 440 | |
441 | - wpinv_set_checkout_session( $data ); |
|
441 | + wpinv_set_checkout_session($data); |
|
442 | 442 | |
443 | - if ( !empty( $_POST['user_id'] ) ) { |
|
444 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
443 | + if (!empty($_POST['user_id'])) { |
|
444 | + $wpi_userID = absint($_POST['user_id']); |
|
445 | 445 | } |
446 | 446 | |
447 | - if ( empty( $_POST['country'] ) ) { |
|
447 | + if (empty($_POST['country'])) { |
|
448 | 448 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
449 | 449 | } |
450 | 450 | |
451 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
452 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
453 | - if ( isset( $_POST['state'] ) ) { |
|
454 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
455 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
451 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
452 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
453 | + if (isset($_POST['state'])) { |
|
454 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
455 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $wpinv_ip_address_country = $invoice->country; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | $response = array(); |
463 | 463 | $response['success'] = true; |
464 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
464 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
465 | 465 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
466 | 466 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
467 | 467 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -473,25 +473,25 @@ discard block |
||
473 | 473 | |
474 | 474 | wpinv_set_checkout_session($checkout_session); |
475 | 475 | |
476 | - wp_send_json( $response ); |
|
476 | + wp_send_json($response); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | public static function admin_apply_discount() { |
480 | 480 | global $wpi_userID; |
481 | 481 | |
482 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
483 | - if ( !current_user_can( 'manage_options' ) ) { |
|
482 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
483 | + if (!current_user_can('manage_options')) { |
|
484 | 484 | die(-1); |
485 | 485 | } |
486 | 486 | |
487 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
488 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
489 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
487 | + $invoice_id = absint($_POST['invoice_id']); |
|
488 | + $discount_code = sanitize_text_field($_POST['code']); |
|
489 | + if (empty($invoice_id) || empty($discount_code)) { |
|
490 | 490 | die(); |
491 | 491 | } |
492 | 492 | |
493 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
494 | - if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) { |
|
493 | + $invoice = wpinv_get_invoice($invoice_id); |
|
494 | + if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) { |
|
495 | 495 | die(); |
496 | 496 | } |
497 | 497 | |
@@ -499,49 +499,49 @@ discard block |
||
499 | 499 | |
500 | 500 | $data = array(); |
501 | 501 | $data['invoice_id'] = $invoice_id; |
502 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
502 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
503 | 503 | |
504 | - wpinv_set_checkout_session( $data ); |
|
504 | + wpinv_set_checkout_session($data); |
|
505 | 505 | |
506 | 506 | $response = array(); |
507 | 507 | $response['success'] = false; |
508 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
508 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
509 | 509 | $response['data']['code'] = $discount_code; |
510 | 510 | |
511 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
512 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
511 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
512 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
513 | 513 | |
514 | 514 | $response['success'] = true; |
515 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
516 | - } else { |
|
515 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
516 | + } else { |
|
517 | 517 | $errors = wpinv_get_errors(); |
518 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
518 | + if (!empty($errors['wpinv-discount-error'])) { |
|
519 | 519 | $response['msg'] = $errors['wpinv-discount-error']; |
520 | 520 | } |
521 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
521 | + wpinv_unset_error('wpinv-discount-error'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | wpinv_set_checkout_session($checkout_session); |
525 | 525 | |
526 | - wp_send_json( $response ); |
|
526 | + wp_send_json($response); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | public static function admin_remove_discount() { |
530 | 530 | global $wpi_userID; |
531 | 531 | |
532 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
533 | - if ( !current_user_can( 'manage_options' ) ) { |
|
532 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
533 | + if (!current_user_can('manage_options')) { |
|
534 | 534 | die(-1); |
535 | 535 | } |
536 | 536 | |
537 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
538 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
539 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
537 | + $invoice_id = absint($_POST['invoice_id']); |
|
538 | + $discount_code = sanitize_text_field($_POST['code']); |
|
539 | + if (empty($invoice_id) || empty($discount_code)) { |
|
540 | 540 | die(); |
541 | 541 | } |
542 | 542 | |
543 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
544 | - if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) { |
|
543 | + $invoice = wpinv_get_invoice($invoice_id); |
|
544 | + if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) { |
|
545 | 545 | die(); |
546 | 546 | } |
547 | 547 | |
@@ -549,38 +549,38 @@ discard block |
||
549 | 549 | |
550 | 550 | $data = array(); |
551 | 551 | $data['invoice_id'] = $invoice_id; |
552 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
552 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
553 | 553 | |
554 | - wpinv_set_checkout_session( $data ); |
|
554 | + wpinv_set_checkout_session($data); |
|
555 | 555 | |
556 | 556 | $response = array(); |
557 | 557 | $response['success'] = false; |
558 | 558 | $response['msg'] = NULL; |
559 | 559 | |
560 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
560 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
561 | 561 | $response['success'] = true; |
562 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
562 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
563 | 563 | |
564 | 564 | wpinv_set_checkout_session($checkout_session); |
565 | 565 | |
566 | - wp_send_json( $response ); |
|
566 | + wp_send_json($response); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | public static function check_email() { |
570 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
571 | - if ( !current_user_can( 'manage_options' ) ) { |
|
570 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
571 | + if (!current_user_can('manage_options')) { |
|
572 | 572 | die(-1); |
573 | 573 | } |
574 | 574 | |
575 | - $email = sanitize_text_field( $_POST['email'] ); |
|
575 | + $email = sanitize_text_field($_POST['email']); |
|
576 | 576 | |
577 | 577 | $response = array(); |
578 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
578 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
579 | 579 | $user_id = $user_data->ID; |
580 | 580 | $user_login = $user_data->user_login; |
581 | 581 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
582 | 582 | $billing_details = wpinv_get_user_address($user_id); |
583 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
583 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
584 | 584 | |
585 | 585 | if (isset($billing_details['user_id'])) { |
586 | 586 | unset($billing_details['user_id']); |
@@ -596,31 +596,31 @@ discard block |
||
596 | 596 | $response['data']['billing_details'] = $billing_details; |
597 | 597 | } |
598 | 598 | |
599 | - wp_send_json( $response ); |
|
599 | + wp_send_json($response); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | public static function run_tool() { |
603 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
604 | - if ( !current_user_can( 'manage_options' ) ) { |
|
603 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
604 | + if (!current_user_can('manage_options')) { |
|
605 | 605 | die(-1); |
606 | 606 | } |
607 | 607 | |
608 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
608 | + $tool = sanitize_text_field($_POST['tool']); |
|
609 | 609 | |
610 | - do_action( 'wpinv_run_tool' ); |
|
610 | + do_action('wpinv_run_tool'); |
|
611 | 611 | |
612 | - if ( !empty( $tool ) ) { |
|
613 | - do_action( 'wpinv_tool_' . $tool ); |
|
612 | + if (!empty($tool)) { |
|
613 | + do_action('wpinv_tool_' . $tool); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | public static function apply_discount() { |
618 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
618 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
619 | 619 | |
620 | 620 | $response = array(); |
621 | 621 | |
622 | - if ( isset( $_POST['code'] ) ) { |
|
623 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
622 | + if (isset($_POST['code'])) { |
|
623 | + $discount_code = sanitize_text_field($_POST['code']); |
|
624 | 624 | |
625 | 625 | $response['success'] = false; |
626 | 626 | $response['msg'] = ''; |
@@ -628,14 +628,14 @@ discard block |
||
628 | 628 | |
629 | 629 | $user = is_user_logged_in() ? get_current_user_id() : ''; |
630 | 630 | |
631 | - if ( wpinv_is_discount_valid( $discount_code, $user ) ) { |
|
632 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
633 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
634 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
635 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
636 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
631 | + if (wpinv_is_discount_valid($discount_code, $user)) { |
|
632 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
633 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
634 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
635 | + $total = wpinv_get_cart_total(null, $discounts); |
|
636 | + $cart_totals = wpinv_recalculate_tax(true); |
|
637 | 637 | |
638 | - if ( !empty( $cart_totals ) ) { |
|
638 | + if (!empty($cart_totals)) { |
|
639 | 639 | $response['success'] = true; |
640 | 640 | $response['data'] = $cart_totals; |
641 | 641 | $response['data']['code'] = $discount_code; |
@@ -644,29 +644,29 @@ discard block |
||
644 | 644 | } |
645 | 645 | } else { |
646 | 646 | $errors = wpinv_get_errors(); |
647 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
648 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
647 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
648 | + wpinv_unset_error('wpinv-discount-error'); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | // Allow for custom discount code handling |
652 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
652 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
653 | 653 | } |
654 | 654 | |
655 | - wp_send_json( $response ); |
|
655 | + wp_send_json($response); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | public static function remove_discount() { |
659 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
659 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
660 | 660 | |
661 | 661 | $response = array(); |
662 | 662 | |
663 | - if ( isset( $_POST['code'] ) ) { |
|
664 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
665 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
666 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
667 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
663 | + if (isset($_POST['code'])) { |
|
664 | + $discount_code = sanitize_text_field($_POST['code']); |
|
665 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
666 | + $total = wpinv_get_cart_total(null, $discounts); |
|
667 | + $cart_totals = wpinv_recalculate_tax(true); |
|
668 | 668 | |
669 | - if ( !empty( $cart_totals ) ) { |
|
669 | + if (!empty($cart_totals)) { |
|
670 | 670 | $response['success'] = true; |
671 | 671 | $response['data'] = $cart_totals; |
672 | 672 | $response['data']['code'] = $discount_code; |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | } |
676 | 676 | |
677 | 677 | // Allow for custom discount code handling |
678 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
678 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
679 | 679 | } |
680 | 680 | |
681 | - wp_send_json( $response ); |
|
681 | + wp_send_json($response); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 |
@@ -1,80 +1,80 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | -if ( !( $user_id = get_current_user_id() ) ) { |
|
6 | +if (!($user_id = get_current_user_id())) { |
|
7 | 7 | ?> |
8 | - <div class="wpinv-empty alert alert-error"><?php _e( 'You are not allowed to access this section', 'invoicing' ) ;?></div> |
|
8 | + <div class="wpinv-empty alert alert-error"><?php _e('You are not allowed to access this section', 'invoicing'); ?></div> |
|
9 | 9 | <?php |
10 | 10 | return; |
11 | 11 | } |
12 | 12 | |
13 | 13 | global $current_page; |
14 | -$current_page = empty( $current_page ) ? 1 : absint( $current_page ); |
|
15 | -$query = apply_filters( 'wpinv_user_invoices_query', array( 'user' => $user_id, 'page' => $current_page, 'paginate' => true ) ); |
|
16 | -$user_invoices = wpinv_get_invoices( $query ); |
|
14 | +$current_page = empty($current_page) ? 1 : absint($current_page); |
|
15 | +$query = apply_filters('wpinv_user_invoices_query', array('user' => $user_id, 'page' => $current_page, 'paginate' => true)); |
|
16 | +$user_invoices = wpinv_get_invoices($query); |
|
17 | 17 | $has_invoices = 0 < $user_invoices->total; |
18 | 18 | |
19 | -do_action( 'wpinv_before_user_invoices', $has_invoices ); ?> |
|
19 | +do_action('wpinv_before_user_invoices', $has_invoices); ?> |
|
20 | 20 | |
21 | -<?php if ( $has_invoices ) { ?> |
|
21 | +<?php if ($has_invoices) { ?> |
|
22 | 22 | <table class="table table-bordered table-hover wpi-user-invoices"> |
23 | 23 | <thead> |
24 | 24 | <tr> |
25 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
26 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
25 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
26 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
27 | 27 | <?php endforeach; ?> |
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | |
31 | 31 | <tbody> |
32 | - <?php foreach ( $user_invoices->invoices as $invoice ) { |
|
32 | + <?php foreach ($user_invoices->invoices as $invoice) { |
|
33 | 33 | ?> |
34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
35 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
36 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
37 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
38 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
39 | - |
|
40 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
41 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
42 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
35 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
36 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
37 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
38 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
39 | + |
|
40 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
41 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
42 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
43 | 43 | </a> |
44 | 44 | |
45 | - <?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
46 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
45 | + <?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
46 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
47 | 47 | |
48 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
49 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
48 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
49 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
50 | 50 | |
51 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
52 | - <?php echo $invoice->get_total( true ); ?> |
|
51 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
52 | + <?php echo $invoice->get_total(true); ?> |
|
53 | 53 | |
54 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
54 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
55 | 55 | <?php |
56 | 56 | $actions = array( |
57 | 57 | 'pay' => array( |
58 | 58 | 'url' => $invoice->get_checkout_payment_url(), |
59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
59 | + 'name' => __('Pay Now', 'invoicing'), |
|
60 | 60 | 'class' => 'btn-success' |
61 | 61 | ), |
62 | 62 | 'print' => array( |
63 | 63 | 'url' => $invoice->get_view_url(), |
64 | - 'name' => __( 'Print', 'invoicing' ), |
|
64 | + 'name' => __('Print', 'invoicing'), |
|
65 | 65 | 'class' => 'btn-primary', |
66 | 66 | 'attrs' => 'target="_blank"' |
67 | 67 | ) |
68 | 68 | ); |
69 | 69 | |
70 | - if ( ! $invoice->needs_payment() ) { |
|
71 | - unset( $actions['pay'] ); |
|
70 | + if (!$invoice->needs_payment()) { |
|
71 | + unset($actions['pay']); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | - foreach ( $actions as $key => $action ) { |
|
74 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
75 | + foreach ($actions as $key => $action) { |
|
76 | 76 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
77 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
77 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | ?> |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | </tbody> |
87 | 87 | </table> |
88 | 88 | |
89 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
89 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
90 | 90 | |
91 | - <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
|
91 | + <?php if (1 < $user_invoices->max_num_pages) : ?> |
|
92 | 92 | <div class="invoicing-Pagination"> |
93 | 93 | <?php |
94 | 94 | $big = 999999; |
@@ -101,23 +101,23 @@ discard block |
||
101 | 101 | else |
102 | 102 | $current_page = 1; |
103 | 103 | |
104 | - echo paginate_links( array( |
|
105 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
104 | + echo paginate_links(array( |
|
105 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
106 | 106 | 'format' => '?paged=%#%', |
107 | - 'current' => max( 1, $current_page ), |
|
107 | + 'current' => max(1, $current_page), |
|
108 | 108 | 'total' => $user_invoices->max_num_pages, |
109 | 109 | 'add_args' => array( |
110 | 110 | 'wpinv-cpt' => 'wpi_invoice', |
111 | 111 | ) |
112 | - ) ); |
|
112 | + )); |
|
113 | 113 | ?> |
114 | 114 | </div> |
115 | 115 | <?php endif; ?> |
116 | 116 | |
117 | 117 | <?php } else { ?> |
118 | 118 | <div class="wpinv-empty alert-info"> |
119 | - <?php _e( 'No invoice has been made yet.', 'invoicing' ); ?> |
|
119 | + <?php _e('No invoice has been made yet.', 'invoicing'); ?> |
|
120 | 120 | </div> |
121 | 121 | <?php } ?> |
122 | 122 | |
123 | -<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?> |
|
123 | +<?php do_action('wpinv_after_user_invoices', $has_invoices); ?> |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function wpinv_gd_active() { |
8 | - return (bool)defined( 'GEODIRECTORY_VERSION' ); |
|
8 | + return (bool)defined('GEODIRECTORY_VERSION'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | function wpinv_pm_active() { |
12 | - return (bool)wpinv_gd_active() && (bool)defined( 'GEODIRPAYMENT_VERSION' ); |
|
12 | + return (bool)wpinv_gd_active() && (bool)defined('GEODIRPAYMENT_VERSION'); |
|
13 | 13 | } |
14 | 14 | |
15 | -function wpinv_is_gd_post_type( $post_type ) { |
|
15 | +function wpinv_is_gd_post_type($post_type) { |
|
16 | 16 | global $gd_posttypes; |
17 | 17 | |
18 | - $gd_posttypes = !empty( $gd_posttypes ) && is_array( $gd_posttypes ) ? $gd_posttypes : geodir_get_posttypes(); |
|
18 | + $gd_posttypes = !empty($gd_posttypes) && is_array($gd_posttypes) ? $gd_posttypes : geodir_get_posttypes(); |
|
19 | 19 | |
20 | - if ( !empty( $post_type ) && !empty( $gd_posttypes ) && in_array( $post_type, $gd_posttypes ) ) { |
|
20 | + if (!empty($post_type) && !empty($gd_posttypes) && in_array($post_type, $gd_posttypes)) { |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
32 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
33 | 33 | // Add fields for force upgrade |
34 | - if ( defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column') ) { |
|
35 | - geodir_add_column_if_not_exist( INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0' ); |
|
34 | + if (defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column')) { |
|
35 | + geodir_add_column_if_not_exist(INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0'); |
|
36 | 36 | |
37 | 37 | update_option('wpinv_gdp_column', '1'); |
38 | 38 | } |
@@ -40,39 +40,39 @@ discard block |
||
40 | 40 | wpinv_merge_gd_packages_to_items(); |
41 | 41 | } |
42 | 42 | } |
43 | -add_action( 'admin_init', 'wpinv_geodir_integration' ); |
|
43 | +add_action('admin_init', 'wpinv_geodir_integration'); |
|
44 | 44 | |
45 | -function wpinv_get_gdp_package_type( $item_types ) { |
|
46 | - if ( wpinv_pm_active() ) { |
|
47 | - $item_types['package'] = __( 'Package', 'invoicing' ); |
|
45 | +function wpinv_get_gdp_package_type($item_types) { |
|
46 | + if (wpinv_pm_active()) { |
|
47 | + $item_types['package'] = __('Package', 'invoicing'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $item_types; |
51 | 51 | } |
52 | -add_filter( 'wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1 ); |
|
52 | +add_filter('wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1); |
|
53 | 53 | |
54 | 54 | function wpinv_update_package_item($package_id) { |
55 | 55 | return wpinv_merge_gd_package_to_item($package_id, true); |
56 | 56 | } |
57 | 57 | add_action('geodir_after_save_package', 'wpinv_update_package_item', 10, 1); |
58 | 58 | |
59 | -function wpinv_merge_gd_packages_to_items( $force = false ) { |
|
60 | - if ( $merged = get_option( 'wpinv_merge_gd_packages' ) && !$force ) { |
|
59 | +function wpinv_merge_gd_packages_to_items($force = false) { |
|
60 | + if ($merged = get_option('wpinv_merge_gd_packages') && !$force) { |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
64 | - if(!function_exists('geodir_package_list_info')){ |
|
64 | + if (!function_exists('geodir_package_list_info')) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $packages = geodir_package_list_info(); |
69 | 69 | |
70 | - foreach ( $packages as $key => $package ) { |
|
71 | - wpinv_merge_gd_package_to_item( $package->pid, $force, $package ); |
|
70 | + foreach ($packages as $key => $package) { |
|
71 | + wpinv_merge_gd_package_to_item($package->pid, $force, $package); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( !$merged ) { |
|
75 | - update_option( 'wpinv_merge_gd_packages', 1 ); |
|
74 | + if (!$merged) { |
|
75 | + update_option('wpinv_merge_gd_packages', 1); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return true; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $package = empty($package) ? geodir_get_package_info_by_id($package_id, '') : $package; |
103 | 103 | |
104 | - if ( empty($package) || !wpinv_is_gd_post_type( $package->post_type ) ) { |
|
104 | + if (empty($package) || !wpinv_is_gd_post_type($package->post_type)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | $meta['custom_id'] = $package_id; |
111 | 111 | $meta['custom_singular_name'] = get_post_type_singular_label($package->post_type); |
112 | 112 | $meta['custom_name'] = get_post_type_plural_label($package->post_type); |
113 | - $meta['price'] = wpinv_round_amount( $package->amount ); |
|
113 | + $meta['price'] = wpinv_round_amount($package->amount); |
|
114 | 114 | $meta['vat_rule'] = 'digital'; |
115 | 115 | $meta['vat_class'] = '_standard'; |
116 | 116 | |
117 | - if ( !empty( $package->sub_active ) ) { |
|
118 | - $sub_num_trial_days = absint( $package->sub_num_trial_days ); |
|
117 | + if (!empty($package->sub_active)) { |
|
118 | + $sub_num_trial_days = absint($package->sub_num_trial_days); |
|
119 | 119 | |
120 | 120 | $meta['is_recurring'] = 1; |
121 | 121 | $meta['recurring_period'] = $package->sub_units; |
122 | - $meta['recurring_interval'] = absint( $package->sub_units_num ); |
|
123 | - $meta['recurring_limit'] = absint( $package->sub_units_num_times ); |
|
122 | + $meta['recurring_interval'] = absint($package->sub_units_num); |
|
123 | + $meta['recurring_limit'] = absint($package->sub_units_num_times); |
|
124 | 124 | $meta['free_trial'] = $sub_num_trial_days > 0 ? 1 : 0; |
125 | 125 | $meta['trial_period'] = $package->sub_num_trial_units; |
126 | 126 | $meta['trial_interval'] = $sub_num_trial_days; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $meta['trial_interval'] = ''; |
135 | 135 | } |
136 | 136 | |
137 | - $data = array( |
|
137 | + $data = array( |
|
138 | 138 | 'post_title' => $package->title, |
139 | 139 | 'post_excerpt' => $package->title_desc, |
140 | 140 | 'post_status' => $package->status == 1 ? 'publish' : 'pending', |
@@ -151,48 +151,48 @@ discard block |
||
151 | 151 | return $item; |
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_gdp_to_wpi_gateway( $payment_method ) { |
|
155 | - switch( $payment_method ) { |
|
154 | +function wpinv_gdp_to_wpi_gateway($payment_method) { |
|
155 | + switch ($payment_method) { |
|
156 | 156 | case 'prebanktransfer': |
157 | 157 | $gateway = 'bank_transfer'; |
158 | 158 | break; |
159 | 159 | default: |
160 | - $gateway = empty( $payment_method ) ? 'manual' : $payment_method; |
|
160 | + $gateway = empty($payment_method) ? 'manual' : $payment_method; |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway', $gateway, $payment_method ); |
|
164 | + return apply_filters('wpinv_gdp_to_wpi_gateway', $gateway, $payment_method); |
|
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_gdp_to_wpi_gateway_title( $payment_method ) { |
|
168 | - $gateway = wpinv_gdp_to_wpi_gateway( $payment_method ); |
|
167 | +function wpinv_gdp_to_wpi_gateway_title($payment_method) { |
|
168 | + $gateway = wpinv_gdp_to_wpi_gateway($payment_method); |
|
169 | 169 | |
170 | - $gateway_title = wpinv_get_gateway_checkout_label( $gateway ); |
|
170 | + $gateway_title = wpinv_get_gateway_checkout_label($gateway); |
|
171 | 171 | |
172 | - if ( $gateway == $gateway_title ) { |
|
173 | - $gateway_title = geodir_payment_method_title( $gateway ); |
|
172 | + if ($gateway == $gateway_title) { |
|
173 | + $gateway_title = geodir_payment_method_title($gateway); |
|
174 | 174 | } |
175 | 175 | |
176 | - return apply_filters( 'wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method ); |
|
176 | + return apply_filters('wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function wpinv_print_checkout_errors() { |
180 | 180 | global $wpi_session; |
181 | 181 | wpinv_print_errors(); |
182 | 182 | } |
183 | -add_action( 'geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10 ); |
|
183 | +add_action('geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10); |
|
184 | 184 | |
185 | -function wpinv_cpt_save( $invoice_id, $update = false, $pre_status = NULL ) { |
|
185 | +function wpinv_cpt_save($invoice_id, $update = false, $pre_status = NULL) { |
|
186 | 186 | global $wpi_nosave, $wpi_zero_tax, $wpi_gdp_inv_merge; |
187 | 187 | |
188 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
188 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
189 | 189 | |
190 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : 0; |
|
190 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : 0; |
|
191 | 191 | |
192 | 192 | if (!empty($invoice_info)) { |
193 | - $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice( $wpi_invoice_id ) : NULL; |
|
193 | + $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice($wpi_invoice_id) : NULL; |
|
194 | 194 | |
195 | - if ( !empty( $wpi_invoice ) ) { // update invoice |
|
195 | + if (!empty($wpi_invoice)) { // update invoice |
|
196 | 196 | $save = false; |
197 | 197 | if ($invoice_info->coupon_code !== $wpi_invoice->discount_code || (float)$invoice_info->discount < (float)$wpi_invoice->discount || (float)$invoice_info->discount > (float)$wpi_invoice->discount) { |
198 | 198 | $save = true; |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | |
203 | 203 | if ($invoice_info->paymentmethod !== $wpi_invoice->gateway) { |
204 | 204 | $save = true; |
205 | - $gateway = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
206 | - $gateway = wpinv_gdp_to_wpi_gateway( $gateway ); |
|
207 | - $gateway_title = wpinv_gdp_to_wpi_gateway_title( $gateway ); |
|
208 | - $wpi_invoice->set('gateway', $gateway ); |
|
209 | - $wpi_invoice->set('gateway_title', $gateway_title ); |
|
205 | + $gateway = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
206 | + $gateway = wpinv_gdp_to_wpi_gateway($gateway); |
|
207 | + $gateway_title = wpinv_gdp_to_wpi_gateway_title($gateway); |
|
208 | + $wpi_invoice->set('gateway', $gateway); |
|
209 | + $wpi_invoice->set('gateway_title', $gateway_title); |
|
210 | 210 | } |
211 | 211 | |
212 | - if ( ( $status = wpinv_gdp_to_wpi_status( $invoice_info->status ) ) !== $wpi_invoice->status ) { |
|
212 | + if (($status = wpinv_gdp_to_wpi_status($invoice_info->status)) !== $wpi_invoice->status) { |
|
213 | 213 | $save = true; |
214 | - $wpi_invoice->set( 'status', $status ); |
|
214 | + $wpi_invoice->set('status', $status); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($save) { |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | |
223 | 223 | return $wpi_invoice; |
224 | 224 | } else { // create invoice |
225 | - $user_info = get_userdata( $invoice_info->user_id ); |
|
225 | + $user_info = get_userdata($invoice_info->user_id); |
|
226 | 226 | |
227 | - if ( !empty( $pre_status ) ) { |
|
227 | + if (!empty($pre_status)) { |
|
228 | 228 | $invoice_info->status = $pre_status; |
229 | 229 | } |
230 | - $status = wpinv_gdp_to_wpi_status( $invoice_info->status ); |
|
230 | + $status = wpinv_gdp_to_wpi_status($invoice_info->status); |
|
231 | 231 | |
232 | 232 | $wpi_zero_tax = false; |
233 | 233 | |
234 | - if ( $wpi_gdp_inv_merge && in_array( $status, array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
234 | + if ($wpi_gdp_inv_merge && in_array($status, array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
235 | 235 | $wpi_zero_tax = true; |
236 | 236 | } |
237 | 237 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $invoice_data['user_id'] = $invoice_info->user_id; |
242 | 242 | $invoice_data['created_via'] = 'API'; |
243 | 243 | |
244 | - if ( !empty( $invoice_info->date ) ) { |
|
245 | - $invoice_data['created_date'] = $invoice_info->date; |
|
244 | + if (!empty($invoice_info->date)) { |
|
245 | + $invoice_data['created_date'] = $invoice_info->date; |
|
246 | 246 | } |
247 | 247 | |
248 | - $paymentmethod = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : ''; |
|
249 | - $paymentmethod = wpinv_gdp_to_wpi_gateway( $paymentmethod ); |
|
250 | - $payment_method_title = wpinv_gdp_to_wpi_gateway_title( $paymentmethod ); |
|
248 | + $paymentmethod = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : ''; |
|
249 | + $paymentmethod = wpinv_gdp_to_wpi_gateway($paymentmethod); |
|
250 | + $payment_method_title = wpinv_gdp_to_wpi_gateway_title($paymentmethod); |
|
251 | 251 | |
252 | 252 | $invoice_data['payment_details'] = array( |
253 | 253 | 'gateway' => $paymentmethod, |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | 'currency' => geodir_get_currency_type(), |
256 | 256 | ); |
257 | 257 | |
258 | - $user_address = wpinv_get_user_address( $invoice_info->user_id, false ); |
|
258 | + $user_address = wpinv_get_user_address($invoice_info->user_id, false); |
|
259 | 259 | |
260 | 260 | $invoice_data['user_info'] = array( |
261 | 261 | 'user_id' => $invoice_info->user_id, |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | |
279 | 279 | $post_item = wpinv_get_gd_package_item($invoice_info->package_id); |
280 | 280 | |
281 | - if ( $invoice_info->invoice_type == 'add_franchise' ) { |
|
281 | + if ($invoice_info->invoice_type == 'add_franchise') { |
|
282 | 282 | $custom_price = $invoice_info->amount; |
283 | 283 | } else { |
284 | 284 | $custom_price = ''; |
285 | 285 | } |
286 | 286 | |
287 | - if ( !empty( $post_item ) ) { |
|
288 | - $cart_details = array(); |
|
287 | + if (!empty($post_item)) { |
|
288 | + $cart_details = array(); |
|
289 | 289 | $cart_details[] = array( |
290 | 290 | 'id' => $post_item->ID, |
291 | 291 | 'name' => $post_item->get_name(), |
@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | ), |
300 | 300 | ); |
301 | 301 | |
302 | - $invoice_data['cart_details'] = $cart_details; |
|
302 | + $invoice_data['cart_details'] = $cart_details; |
|
303 | 303 | } |
304 | 304 | |
305 | - $data = array( 'invoice' => $invoice_data ); |
|
305 | + $data = array('invoice' => $invoice_data); |
|
306 | 306 | |
307 | 307 | $wpinv_api = new WPInv_API(); |
308 | - $data = $wpinv_api->insert_invoice( $data ); |
|
308 | + $data = $wpinv_api->insert_invoice($data); |
|
309 | 309 | |
310 | - if ( is_wp_error( $data ) ) { |
|
311 | - wpinv_error_log( 'WPInv_Invoice: ' . $data->get_error_message() ); |
|
310 | + if (is_wp_error($data)) { |
|
311 | + wpinv_error_log('WPInv_Invoice: ' . $data->get_error_message()); |
|
312 | 312 | } else { |
313 | - if ( !empty( $data ) ) { |
|
314 | - update_post_meta( $data->ID, '_wpinv_gdp_id', $invoice_id ); |
|
313 | + if (!empty($data)) { |
|
314 | + update_post_meta($data->ID, '_wpinv_gdp_id', $invoice_id); |
|
315 | 315 | |
316 | 316 | $update_data = array(); |
317 | 317 | $update_data['tax_amount'] = $data->get_tax(); |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | $update_data['invoice_id'] = $data->ID; |
320 | 320 | |
321 | 321 | global $wpdb; |
322 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $invoice_id ) ); |
|
322 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $invoice_id)); |
|
323 | 323 | |
324 | 324 | return $data; |
325 | 325 | } else { |
326 | - if ( $update ) { |
|
327 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to update invoice.', 'invoicing' ) ); |
|
326 | + if ($update) { |
|
327 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to update invoice.', 'invoicing')); |
|
328 | 328 | } else { |
329 | - wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to create invoice.', 'invoicing' ) ); |
|
329 | + wpinv_error_log('WPInv_Invoice: ' . __('Fail to create invoice.', 'invoicing')); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | } |
@@ -337,59 +337,59 @@ discard block |
||
337 | 337 | } |
338 | 338 | add_action('geodir_payment_invoice_created', 'wpinv_cpt_save', 11, 3); |
339 | 339 | |
340 | -function wpinv_cpt_update( $invoice_id ) { |
|
341 | - return wpinv_cpt_save( $invoice_id, true ); |
|
340 | +function wpinv_cpt_update($invoice_id) { |
|
341 | + return wpinv_cpt_save($invoice_id, true); |
|
342 | 342 | } |
343 | 343 | add_action('geodir_payment_invoice_updated', 'wpinv_cpt_update', 11, 1); |
344 | 344 | |
345 | -function wpinv_payment_status_changed( $invoice_id, $new_status, $old_status = 'pending', $subscription = false ) { |
|
346 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
347 | - if ( empty( $invoice_info ) ) { |
|
345 | +function wpinv_payment_status_changed($invoice_id, $new_status, $old_status = 'pending', $subscription = false) { |
|
346 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
347 | + if (empty($invoice_info)) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | |
351 | - $invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
352 | - if ( !empty( $invoice ) ) { |
|
351 | + $invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
352 | + if (!empty($invoice)) { |
|
353 | 353 | $new_status = wpinv_gdp_to_wpi_status($new_status); |
354 | - $invoice = wpinv_update_payment_status( $invoice->ID, $new_status ); |
|
354 | + $invoice = wpinv_update_payment_status($invoice->ID, $new_status); |
|
355 | 355 | } else { |
356 | - $invoice = wpinv_cpt_save( $invoice_id ); |
|
356 | + $invoice = wpinv_cpt_save($invoice_id); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return $invoice; |
360 | 360 | } |
361 | -add_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
361 | +add_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
362 | 362 | |
363 | -function wpinv_transaction_details_note( $invoice_id, $html ) { |
|
364 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
365 | - if ( empty( $invoice_info ) ) { |
|
363 | +function wpinv_transaction_details_note($invoice_id, $html) { |
|
364 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
365 | + if (empty($invoice_info)) { |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | - $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : NULL; |
|
369 | + $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : NULL; |
|
370 | 370 | |
371 | - if ( !$wpi_invoice_id ) { |
|
372 | - $invoice = wpinv_cpt_save( $invoice_id, false, $old_status ); |
|
371 | + if (!$wpi_invoice_id) { |
|
372 | + $invoice = wpinv_cpt_save($invoice_id, false, $old_status); |
|
373 | 373 | |
374 | - if ( !empty( $invoice ) ) { |
|
374 | + if (!empty($invoice)) { |
|
375 | 375 | $wpi_invoice_id = $invoice->ID; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | - $invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
379 | + $invoice = wpinv_get_invoice($wpi_invoice_id); |
|
380 | 380 | |
381 | - if ( empty( $invoice ) ) { |
|
381 | + if (empty($invoice)) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - return $invoice->add_note( $html, true ); |
|
385 | + return $invoice->add_note($html, true); |
|
386 | 386 | } |
387 | -add_action( 'geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2 ); |
|
387 | +add_action('geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2); |
|
388 | 388 | |
389 | -function wpinv_gdp_to_wpi_status( $status ) { |
|
389 | +function wpinv_gdp_to_wpi_status($status) { |
|
390 | 390 | $inv_status = $status ? $status : 'pending'; |
391 | 391 | |
392 | - switch ( $status ) { |
|
392 | + switch ($status) { |
|
393 | 393 | case 'confirmed': |
394 | 394 | $inv_status = 'publish'; |
395 | 395 | break; |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | return $inv_status; |
410 | 410 | } |
411 | 411 | |
412 | -function wpinv_wpi_to_gdp_status( $status ) { |
|
412 | +function wpinv_wpi_to_gdp_status($status) { |
|
413 | 413 | $inv_status = $status ? $status : 'pending'; |
414 | 414 | |
415 | - switch ( $status ) { |
|
415 | + switch ($status) { |
|
416 | 416 | case 'publish': |
417 | 417 | case 'wpi-processing': |
418 | 418 | case 'wpi-renewal': |
@@ -435,72 +435,72 @@ discard block |
||
435 | 435 | return $inv_status; |
436 | 436 | } |
437 | 437 | |
438 | -function wpinv_wpi_to_gdp_id( $invoice_id ) { |
|
438 | +function wpinv_wpi_to_gdp_id($invoice_id) { |
|
439 | 439 | global $wpdb; |
440 | 440 | |
441 | - return $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array( (int)$invoice_id ) ) ); |
|
441 | + return $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array((int)$invoice_id))); |
|
442 | 442 | } |
443 | 443 | |
444 | -function wpinv_gdp_to_wpi_id( $invoice_id ) { |
|
445 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
446 | - return ( empty( $invoice->invoice_id ) ? $invoice->invoice_id : false); |
|
444 | +function wpinv_gdp_to_wpi_id($invoice_id) { |
|
445 | + $invoice = geodir_get_invoice($invoice_id); |
|
446 | + return (empty($invoice->invoice_id) ? $invoice->invoice_id : false); |
|
447 | 447 | } |
448 | 448 | |
449 | -function wpinv_to_gdp_recalculate_total( $invoice, $wpi_nosave ) { |
|
449 | +function wpinv_to_gdp_recalculate_total($invoice, $wpi_nosave) { |
|
450 | 450 | global $wpdb; |
451 | 451 | |
452 | - if ( !empty( $wpi_nosave ) ) { |
|
452 | + if (!empty($wpi_nosave)) { |
|
453 | 453 | return; |
454 | 454 | } |
455 | 455 | |
456 | - $gdp_invoice_id = wpinv_wpi_to_gdp_id( $invoice->ID ); |
|
456 | + $gdp_invoice_id = wpinv_wpi_to_gdp_id($invoice->ID); |
|
457 | 457 | |
458 | - if ( $gdp_invoice_id > 0 ) { |
|
458 | + if ($gdp_invoice_id > 0) { |
|
459 | 459 | $update_data = array(); |
460 | 460 | $update_data['tax_amount'] = $invoice->tax; |
461 | 461 | $update_data['paied_amount'] = $invoice->total; |
462 | 462 | $update_data['discount'] = $invoice->discount; |
463 | 463 | $update_data['coupon_code'] = $invoice->discount_code; |
464 | 464 | |
465 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $gdp_invoice_id ) ); |
|
465 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $gdp_invoice_id)); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | return; |
469 | 469 | } |
470 | 470 | //add_action( 'wpinv_invoice_recalculate_total', 'wpinv_to_gdp_recalculate_total', 10, 2 ); |
471 | 471 | |
472 | -function wpinv_gdp_to_wpi_invoice( $invoice_id ) { |
|
473 | - $invoice = geodir_get_invoice( $invoice_id ); |
|
474 | - if ( empty( $invoice->invoice_id ) ) { |
|
472 | +function wpinv_gdp_to_wpi_invoice($invoice_id) { |
|
473 | + $invoice = geodir_get_invoice($invoice_id); |
|
474 | + if (empty($invoice->invoice_id)) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | - return wpinv_get_invoice( $invoice->invoice_id ); |
|
478 | + return wpinv_get_invoice($invoice->invoice_id); |
|
479 | 479 | } |
480 | 480 | |
481 | -function wpinv_payment_set_coupon_code( $status, $invoice_id, $coupon_code ) { |
|
482 | - $invoice = wpinv_gdp_to_wpi_invoice( $invoice_id ); |
|
483 | - if ( empty( $invoice ) ) { |
|
481 | +function wpinv_payment_set_coupon_code($status, $invoice_id, $coupon_code) { |
|
482 | + $invoice = wpinv_gdp_to_wpi_invoice($invoice_id); |
|
483 | + if (empty($invoice)) { |
|
484 | 484 | return $status; |
485 | 485 | } |
486 | 486 | |
487 | - if ( $status === 1 || $status === 0 ) { |
|
488 | - if ( $status === 1 ) { |
|
489 | - $discount = geodir_get_discount_amount( $coupon_code, $invoice->get_subtotal() ); |
|
487 | + if ($status === 1 || $status === 0) { |
|
488 | + if ($status === 1) { |
|
489 | + $discount = geodir_get_discount_amount($coupon_code, $invoice->get_subtotal()); |
|
490 | 490 | } else { |
491 | 491 | $discount = ''; |
492 | 492 | $coupon_code = ''; |
493 | 493 | } |
494 | 494 | |
495 | - $invoice->set( 'discount', $discount ); |
|
496 | - $invoice->set( 'discount_code', $coupon_code ); |
|
495 | + $invoice->set('discount', $discount); |
|
496 | + $invoice->set('discount_code', $coupon_code); |
|
497 | 497 | $invoice->save(); |
498 | 498 | $invoice->recalculate_total(); |
499 | 499 | } |
500 | 500 | |
501 | 501 | return $status; |
502 | 502 | } |
503 | -add_filter( 'geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3 ); |
|
503 | +add_filter('geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3); |
|
504 | 504 | |
505 | 505 | function wpinv_merge_gd_invoices() { |
506 | 506 | if (!defined('GEODIRPAYMENT_VERSION')) { |
@@ -508,157 +508,157 @@ discard block |
||
508 | 508 | } |
509 | 509 | ?> |
510 | 510 | <tr> |
511 | - <td><?php _e( 'Merge Price Packages', 'invoicing' ); ?></td> |
|
512 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing' ); ?></p></td> |
|
513 | - <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
511 | + <td><?php _e('Merge Price Packages', 'invoicing'); ?></td> |
|
512 | + <td><p><?php _e('Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing'); ?></p></td> |
|
513 | + <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
514 | 514 | </tr> |
515 | 515 | <tr> |
516 | - <td><?php _e( 'Merge Invoices', 'invoicing' ); ?></td> |
|
517 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing' ); ?></p></td> |
|
518 | - <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
516 | + <td><?php _e('Merge Invoices', 'invoicing'); ?></td> |
|
517 | + <td><p><?php _e('Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing'); ?></p></td> |
|
518 | + <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
519 | 519 | </tr> |
520 | 520 | <tr> |
521 | - <td><?php _e( 'Fix Taxes for Merged Invoices', 'invoicing' ); ?></td> |
|
522 | - <td><p><?php _e( 'Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing' ); ?></p></td> |
|
523 | - <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
521 | + <td><?php _e('Fix Taxes for Merged Invoices', 'invoicing'); ?></td> |
|
522 | + <td><p><?php _e('Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing'); ?></p></td> |
|
523 | + <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
524 | 524 | </tr> |
525 | 525 | <tr> |
526 | - <td><?php _e( 'Merge Coupons', 'invoicing' ); ?></td> |
|
527 | - <td><p><?php _e( 'Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing' ); ?></p></td> |
|
528 | - <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td> |
|
526 | + <td><?php _e('Merge Coupons', 'invoicing'); ?></td> |
|
527 | + <td><p><?php _e('Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing'); ?></p></td> |
|
528 | + <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td> |
|
529 | 529 | </tr> |
530 | 530 | <?php |
531 | 531 | } |
532 | -add_action( 'wpinv_tools_row', 'wpinv_merge_gd_invoices', 10 ); |
|
532 | +add_action('wpinv_tools_row', 'wpinv_merge_gd_invoices', 10); |
|
533 | 533 | |
534 | 534 | function wpinv_tool_merge_packages() { |
535 | 535 | $packages = geodir_package_list_info(); |
536 | 536 | |
537 | 537 | $count = 0; |
538 | 538 | |
539 | - if ( !empty( $packages ) ) { |
|
539 | + if (!empty($packages)) { |
|
540 | 540 | $success = true; |
541 | 541 | |
542 | - foreach ( $packages as $key => $package ) { |
|
542 | + foreach ($packages as $key => $package) { |
|
543 | 543 | $item = wpinv_get_item_by('custom_id', $package->pid, 'package'); |
544 | - if ( !empty( $item ) ) { |
|
544 | + if (!empty($item)) { |
|
545 | 545 | continue; |
546 | 546 | } |
547 | 547 | |
548 | - $merged = wpinv_merge_gd_package_to_item( $package->pid, false, $package ); |
|
548 | + $merged = wpinv_merge_gd_package_to_item($package->pid, false, $package); |
|
549 | 549 | |
550 | - if ( !empty( $merged ) ) { |
|
551 | - wpinv_error_log( 'Package merge S : ' . $package->pid ); |
|
550 | + if (!empty($merged)) { |
|
551 | + wpinv_error_log('Package merge S : ' . $package->pid); |
|
552 | 552 | $count++; |
553 | 553 | } else { |
554 | - wpinv_error_log( 'Package merge F : ' . $package->pid ); |
|
554 | + wpinv_error_log('Package merge F : ' . $package->pid); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | - if ( $count > 0 ) { |
|
559 | - $message = sprintf( _n( 'Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing' ), $count ); |
|
558 | + if ($count > 0) { |
|
559 | + $message = sprintf(_n('Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing'), $count); |
|
560 | 560 | } else { |
561 | - $message = __( 'No price packages merged.', 'invoicing' ); |
|
561 | + $message = __('No price packages merged.', 'invoicing'); |
|
562 | 562 | } |
563 | 563 | } else { |
564 | 564 | $success = false; |
565 | - $message = __( 'No price packages found to merge!', 'invoicing' ); |
|
565 | + $message = __('No price packages found to merge!', 'invoicing'); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | $response = array(); |
569 | 569 | $response['success'] = $success; |
570 | 570 | $response['data']['message'] = $message; |
571 | - wp_send_json( $response ); |
|
571 | + wp_send_json($response); |
|
572 | 572 | } |
573 | -add_action( 'wpinv_tool_merge_packages', 'wpinv_tool_merge_packages' ); |
|
573 | +add_action('wpinv_tool_merge_packages', 'wpinv_tool_merge_packages'); |
|
574 | 574 | |
575 | 575 | function wpinv_tool_merge_invoices() { |
576 | 576 | global $wpdb, $wpi_gdp_inv_merge, $wpi_tax_rates; |
577 | 577 | |
578 | 578 | $sql = "SELECT `gdi`.`id`, `gdi`.`date`, `gdi`.`date_updated` FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NULL ORDER BY `gdi`.`id` ASC"; |
579 | 579 | |
580 | - $items = $wpdb->get_results( $sql ); |
|
580 | + $items = $wpdb->get_results($sql); |
|
581 | 581 | |
582 | 582 | $count = 0; |
583 | 583 | |
584 | - if ( !empty( $items ) ) { |
|
584 | + if (!empty($items)) { |
|
585 | 585 | $success = true; |
586 | 586 | $wpi_gdp_inv_merge = true; |
587 | 587 | |
588 | - foreach ( $items as $item ) { |
|
588 | + foreach ($items as $item) { |
|
589 | 589 | $wpi_tax_rates = NULL; |
590 | 590 | |
591 | - $wpdb->query( "UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'" ); |
|
591 | + $wpdb->query("UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'"); |
|
592 | 592 | |
593 | - $merged = wpinv_cpt_save( $item->id ); |
|
593 | + $merged = wpinv_cpt_save($item->id); |
|
594 | 594 | |
595 | - if ( !empty( $merged ) && !empty( $merged->ID ) ) { |
|
595 | + if (!empty($merged) && !empty($merged->ID)) { |
|
596 | 596 | $count++; |
597 | 597 | |
598 | - $post_date = !empty( $item->date ) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time( 'mysql' ); |
|
599 | - $post_date_gmt = get_gmt_from_date( $post_date ); |
|
600 | - $post_modified = !empty( $item->date_updated ) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
601 | - $post_modified_gmt = get_gmt_from_date( $post_modified ); |
|
598 | + $post_date = !empty($item->date) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time('mysql'); |
|
599 | + $post_date_gmt = get_gmt_from_date($post_date); |
|
600 | + $post_modified = !empty($item->date_updated) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date; |
|
601 | + $post_modified_gmt = get_gmt_from_date($post_modified); |
|
602 | 602 | |
603 | - $wpdb->update( $wpdb->posts, array( 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt ), array( 'ID' => $merged->ID ) ); |
|
603 | + $wpdb->update($wpdb->posts, array('post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt), array('ID' => $merged->ID)); |
|
604 | 604 | |
605 | - if ( $merged->is_paid() ) { |
|
606 | - update_post_meta( $merged->ID, '_wpinv_completed_date', $post_modified ); |
|
605 | + if ($merged->is_paid()) { |
|
606 | + update_post_meta($merged->ID, '_wpinv_completed_date', $post_modified); |
|
607 | 607 | } |
608 | 608 | |
609 | - clean_post_cache( $merged->ID ); |
|
609 | + clean_post_cache($merged->ID); |
|
610 | 610 | |
611 | - wpinv_error_log( 'Invoice merge S : ' . $item->id . ' => ' . $merged->ID ); |
|
611 | + wpinv_error_log('Invoice merge S : ' . $item->id . ' => ' . $merged->ID); |
|
612 | 612 | } else { |
613 | - wpinv_error_log( 'Invoice merge F : ' . $item->id ); |
|
613 | + wpinv_error_log('Invoice merge F : ' . $item->id); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | $wpi_gdp_inv_merge = false; |
618 | 618 | |
619 | - if ( $count > 0 ) { |
|
620 | - $message = sprintf( _n( 'Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing' ), $count ); |
|
619 | + if ($count > 0) { |
|
620 | + $message = sprintf(_n('Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing'), $count); |
|
621 | 621 | } else { |
622 | - $message = __( 'No invoices merged.', 'invoicing' ); |
|
622 | + $message = __('No invoices merged.', 'invoicing'); |
|
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | $success = false; |
626 | - $message = __( 'No invoices found to merge!', 'invoicing' ); |
|
626 | + $message = __('No invoices found to merge!', 'invoicing'); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | $response = array(); |
630 | 630 | $response['success'] = $success; |
631 | 631 | $response['data']['message'] = $message; |
632 | - wp_send_json( $response ); |
|
632 | + wp_send_json($response); |
|
633 | 633 | } |
634 | -add_action( 'wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices' ); |
|
634 | +add_action('wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices'); |
|
635 | 635 | |
636 | 636 | function wpinv_tool_merge_coupons() { |
637 | 637 | global $wpdb; |
638 | 638 | |
639 | 639 | $sql = "SELECT * FROM `" . COUPON_TABLE . "` WHERE `coupon_code` IS NOT NULL AND `coupon_code` != '' ORDER BY `cid` ASC"; |
640 | - $items = $wpdb->get_results( $sql ); |
|
640 | + $items = $wpdb->get_results($sql); |
|
641 | 641 | $count = 0; |
642 | 642 | |
643 | - if ( !empty( $items ) ) { |
|
643 | + if (!empty($items)) { |
|
644 | 644 | $success = true; |
645 | 645 | |
646 | - foreach ( $items as $item ) { |
|
647 | - if ( wpinv_get_discount_by_code( $item->coupon_code ) ) { |
|
646 | + foreach ($items as $item) { |
|
647 | + if (wpinv_get_discount_by_code($item->coupon_code)) { |
|
648 | 648 | continue; |
649 | 649 | } |
650 | 650 | |
651 | 651 | $args = array( |
652 | 652 | 'post_type' => 'wpi_discount', |
653 | 653 | 'post_title' => $item->coupon_code, |
654 | - 'post_status' => !empty( $item->status ) ? 'publish' : 'pending' |
|
654 | + 'post_status' => !empty($item->status) ? 'publish' : 'pending' |
|
655 | 655 | ); |
656 | 656 | |
657 | - $merged = wp_insert_post( $args ); |
|
657 | + $merged = wp_insert_post($args); |
|
658 | 658 | |
659 | 659 | $item_id = $item->cid; |
660 | 660 | |
661 | - if ( $merged ) { |
|
661 | + if ($merged) { |
|
662 | 662 | $meta = array( |
663 | 663 | 'code' => $item->coupon_code, |
664 | 664 | 'type' => $item->discount_type != 'per' ? 'flat' : 'percent', |
@@ -666,65 +666,65 @@ discard block |
||
666 | 666 | 'max_uses' => (int)$item->usage_limit, |
667 | 667 | 'uses' => (int)$item->usage_count, |
668 | 668 | ); |
669 | - wpinv_store_discount( $merged, $meta, get_post( $merged ) ); |
|
669 | + wpinv_store_discount($merged, $meta, get_post($merged)); |
|
670 | 670 | |
671 | 671 | $count++; |
672 | 672 | |
673 | - wpinv_error_log( 'Coupon merge S : ' . $item_id . ' => ' . $merged ); |
|
673 | + wpinv_error_log('Coupon merge S : ' . $item_id . ' => ' . $merged); |
|
674 | 674 | } else { |
675 | - wpinv_error_log( 'Coupon merge F : ' . $item_id ); |
|
675 | + wpinv_error_log('Coupon merge F : ' . $item_id); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | - if ( $count > 0 ) { |
|
680 | - $message = sprintf( _n( 'Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing' ), $count ); |
|
679 | + if ($count > 0) { |
|
680 | + $message = sprintf(_n('Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing'), $count); |
|
681 | 681 | } else { |
682 | - $message = __( 'No coupons merged.', 'invoicing' ); |
|
682 | + $message = __('No coupons merged.', 'invoicing'); |
|
683 | 683 | } |
684 | 684 | } else { |
685 | 685 | $success = false; |
686 | - $message = __( 'No coupons found to merge!', 'invoicing' ); |
|
686 | + $message = __('No coupons found to merge!', 'invoicing'); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | $response = array(); |
690 | 690 | $response['success'] = $success; |
691 | 691 | $response['data']['message'] = $message; |
692 | - wp_send_json( $response ); |
|
692 | + wp_send_json($response); |
|
693 | 693 | } |
694 | -add_action( 'wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons' ); |
|
694 | +add_action('wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons'); |
|
695 | 695 | |
696 | -function wpinv_gdp_to_wpi_currency( $value, $option = '' ) { |
|
696 | +function wpinv_gdp_to_wpi_currency($value, $option = '') { |
|
697 | 697 | return wpinv_get_currency(); |
698 | 698 | } |
699 | -add_filter( 'pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2 ); |
|
699 | +add_filter('pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2); |
|
700 | 700 | |
701 | -function wpinv_gdp_to_wpi_currency_sign( $value, $option = '' ) { |
|
701 | +function wpinv_gdp_to_wpi_currency_sign($value, $option = '') { |
|
702 | 702 | return wpinv_currency_symbol(); |
703 | 703 | } |
704 | -add_filter( 'pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2 ); |
|
704 | +add_filter('pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2); |
|
705 | 705 | |
706 | -function wpinv_gdp_to_wpi_display_price( $price, $amount, $display = true , $decimal_sep, $thousand_sep ) { |
|
707 | - if ( !$display ) { |
|
708 | - $price = wpinv_round_amount( $amount ); |
|
706 | +function wpinv_gdp_to_wpi_display_price($price, $amount, $display = true, $decimal_sep, $thousand_sep) { |
|
707 | + if (!$display) { |
|
708 | + $price = wpinv_round_amount($amount); |
|
709 | 709 | } else { |
710 | - $price = wpinv_price( wpinv_format_amount( $amount ) ); |
|
710 | + $price = wpinv_price(wpinv_format_amount($amount)); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | return $price; |
714 | 714 | } |
715 | -add_filter( 'geodir_payment_price' , 'wpinv_gdp_to_wpi_display_price', 10000, 5 ); |
|
715 | +add_filter('geodir_payment_price', 'wpinv_gdp_to_wpi_display_price', 10000, 5); |
|
716 | 716 | |
717 | -function wpinv_gdp_to_inv_checkout_redirect( $redirect_url ) { |
|
717 | +function wpinv_gdp_to_inv_checkout_redirect($redirect_url) { |
|
718 | 718 | $invoice_id = geodir_payment_cart_id(); |
719 | - $invoice_info = geodir_get_invoice( $invoice_id ); |
|
720 | - $wpi_invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL; |
|
719 | + $invoice_info = geodir_get_invoice($invoice_id); |
|
720 | + $wpi_invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL; |
|
721 | 721 | |
722 | - if ( !( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) ) { |
|
723 | - $wpi_invoice_id = wpinv_cpt_save( $invoice_id ); |
|
724 | - $wpi_invoice = wpinv_get_invoice( $wpi_invoice_id ); |
|
722 | + if (!(!empty($wpi_invoice) && !empty($wpi_invoice->ID))) { |
|
723 | + $wpi_invoice_id = wpinv_cpt_save($invoice_id); |
|
724 | + $wpi_invoice = wpinv_get_invoice($wpi_invoice_id); |
|
725 | 725 | } |
726 | 726 | |
727 | - if ( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) { |
|
727 | + if (!empty($wpi_invoice) && !empty($wpi_invoice->ID)) { |
|
728 | 728 | |
729 | 729 | // Clear cart |
730 | 730 | geodir_payment_clear_cart(); |
@@ -734,121 +734,121 @@ discard block |
||
734 | 734 | |
735 | 735 | return $redirect_url; |
736 | 736 | } |
737 | -add_filter( 'geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1 ); |
|
737 | +add_filter('geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1); |
|
738 | 738 | |
739 | -function wpinv_gdp_dashboard_invoice_history_link( $dashboard_links ) { |
|
740 | - if ( get_current_user_id() ) { |
|
741 | - $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url( wpinv_get_history_page_uri() ) . '">' . __( 'My Invoice History', 'invoicing' ) . '</a></li>'; |
|
739 | +function wpinv_gdp_dashboard_invoice_history_link($dashboard_links) { |
|
740 | + if (get_current_user_id()) { |
|
741 | + $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url(wpinv_get_history_page_uri()) . '">' . __('My Invoice History', 'invoicing') . '</a></li>'; |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | return $dashboard_links; |
745 | 745 | } |
746 | -add_action( 'geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link' ); |
|
747 | -remove_action( 'geodir_dashboard_links', 'geodir_payment_invoices_list_page_link' ); |
|
746 | +add_action('geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link'); |
|
747 | +remove_action('geodir_dashboard_links', 'geodir_payment_invoices_list_page_link'); |
|
748 | 748 | |
749 | -function wpinv_wpi_to_gdp_update_status( $invoice_id, $new_status, $old_status ) { |
|
749 | +function wpinv_wpi_to_gdp_update_status($invoice_id, $new_status, $old_status) { |
|
750 | 750 | if (!defined('GEODIRPAYMENT_VERSION')) { |
751 | 751 | return false; |
752 | 752 | } |
753 | 753 | |
754 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
755 | - if ( empty( $invoice ) ) { |
|
754 | + $invoice = wpinv_get_invoice($invoice_id); |
|
755 | + if (empty($invoice)) { |
|
756 | 756 | return false; |
757 | 757 | } |
758 | 758 | |
759 | - remove_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 ); |
|
759 | + remove_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4); |
|
760 | 760 | |
761 | - $invoice_id = wpinv_wpi_to_gdp_id( $invoice_id ); |
|
762 | - $new_status = wpinv_wpi_to_gdp_status( $new_status ); |
|
761 | + $invoice_id = wpinv_wpi_to_gdp_id($invoice_id); |
|
762 | + $new_status = wpinv_wpi_to_gdp_status($new_status); |
|
763 | 763 | |
764 | - geodir_update_invoice_status( $invoice_id, $new_status, $invoice->is_recurring() ); |
|
764 | + geodir_update_invoice_status($invoice_id, $new_status, $invoice->is_recurring()); |
|
765 | 765 | } |
766 | -add_action( 'wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3 ); |
|
766 | +add_action('wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3); |
|
767 | 767 | |
768 | -function wpinv_gdp_to_wpi_delete_package( $gd_package_id ) { |
|
769 | - $item = wpinv_get_item_by( 'custom_id', $gd_package_id, 'package' ); |
|
768 | +function wpinv_gdp_to_wpi_delete_package($gd_package_id) { |
|
769 | + $item = wpinv_get_item_by('custom_id', $gd_package_id, 'package'); |
|
770 | 770 | |
771 | - if ( !empty( $item ) ) { |
|
772 | - wpinv_remove_item( $item, true ); |
|
771 | + if (!empty($item)) { |
|
772 | + wpinv_remove_item($item, true); |
|
773 | 773 | } |
774 | 774 | } |
775 | -add_action( 'geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1 ) ; |
|
775 | +add_action('geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1); |
|
776 | 776 | |
777 | -function wpinv_can_delete_package_item( $return, $post_id ) { |
|
778 | - if ( $return && function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && $package_id = get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
779 | - $gd_package = geodir_get_package_info_by_id( $package_id, '' ); |
|
777 | +function wpinv_can_delete_package_item($return, $post_id) { |
|
778 | + if ($return && function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && $package_id = get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
779 | + $gd_package = geodir_get_package_info_by_id($package_id, ''); |
|
780 | 780 | |
781 | - if ( !empty( $gd_package ) ) { |
|
781 | + if (!empty($gd_package)) { |
|
782 | 782 | $return = false; |
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
786 | 786 | return $return; |
787 | 787 | } |
788 | -add_filter( 'wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2 ); |
|
788 | +add_filter('wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2); |
|
789 | 789 | |
790 | -function wpinv_package_item_classes( $classes, $class, $post_id ) { |
|
790 | +function wpinv_package_item_classes($classes, $class, $post_id) { |
|
791 | 791 | global $typenow; |
792 | 792 | |
793 | - if ( $typenow == 'wpi_item' && in_array( 'wpi-gd-package', $classes ) ) { |
|
794 | - if ( wpinv_item_in_use( $post_id ) ) { |
|
793 | + if ($typenow == 'wpi_item' && in_array('wpi-gd-package', $classes)) { |
|
794 | + if (wpinv_item_in_use($post_id)) { |
|
795 | 795 | $classes[] = 'wpi-inuse-pkg'; |
796 | - } else if ( !( function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && geodir_get_package_info_by_id( (int)get_post_meta( $post_id, '_wpinv_custom_id', true ), '' ) ) ) { |
|
796 | + } else if (!(function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && geodir_get_package_info_by_id((int)get_post_meta($post_id, '_wpinv_custom_id', true), ''))) { |
|
797 | 797 | $classes[] = 'wpi-delete-pkg'; |
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
801 | 801 | return $classes; |
802 | 802 | } |
803 | -add_filter( 'post_class', 'wpinv_package_item_classes', 10, 3 ); |
|
803 | +add_filter('post_class', 'wpinv_package_item_classes', 10, 3); |
|
804 | 804 | |
805 | -function wpinv_gdp_package_type_info( $post ) { |
|
806 | - if ( wpinv_pm_active() ) { |
|
807 | - ?><p class="wpi-m0"><?php _e( 'Package: GeoDirectory price packages items.', 'invoicing' );?></p> |
|
805 | +function wpinv_gdp_package_type_info($post) { |
|
806 | + if (wpinv_pm_active()) { |
|
807 | + ?><p class="wpi-m0"><?php _e('Package: GeoDirectory price packages items.', 'invoicing'); ?></p> |
|
808 | 808 | <?php |
809 | 809 | } |
810 | 810 | } |
811 | -add_action( 'wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1 ) ; |
|
811 | +add_action('wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1); |
|
812 | 812 | |
813 | -function wpinv_gdp_to_gdi_set_zero_tax( $is_taxable, $item_id, $country , $state ) { |
|
813 | +function wpinv_gdp_to_gdi_set_zero_tax($is_taxable, $item_id, $country, $state) { |
|
814 | 814 | global $wpi_zero_tax; |
815 | 815 | |
816 | - if ( $wpi_zero_tax ) { |
|
816 | + if ($wpi_zero_tax) { |
|
817 | 817 | $is_taxable = false; |
818 | 818 | } |
819 | 819 | |
820 | 820 | return $is_taxable; |
821 | 821 | } |
822 | -add_action( 'wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4 ) ; |
|
822 | +add_action('wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4); |
|
823 | 823 | |
824 | 824 | function wpinv_tool_merge_fix_taxes() { |
825 | 825 | global $wpdb; |
826 | 826 | |
827 | 827 | $sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'"; |
828 | - $items = $wpdb->get_results( $sql ); |
|
828 | + $items = $wpdb->get_results($sql); |
|
829 | 829 | |
830 | - if ( !empty( $items ) ) { |
|
831 | - foreach ( $items as $item ) { |
|
832 | - if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) { |
|
833 | - update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' ); |
|
830 | + if (!empty($items)) { |
|
831 | + foreach ($items as $item) { |
|
832 | + if (get_post_meta($item->ID, '_wpinv_vat_class', true) == '_exempt') { |
|
833 | + update_post_meta($item->ID, '_wpinv_vat_class', '_standard'); |
|
834 | 834 | } |
835 | 835 | } |
836 | 836 | } |
837 | 837 | |
838 | 838 | $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'wpi-processing', 'wpi-renewal' ) ORDER BY `gdi`.`id` ASC"; |
839 | - $items = $wpdb->get_results( $sql ); |
|
839 | + $items = $wpdb->get_results($sql); |
|
840 | 840 | |
841 | - if ( !empty( $items ) ) { |
|
841 | + if (!empty($items)) { |
|
842 | 842 | $success = false; |
843 | - $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' ); |
|
843 | + $message = __('Taxes fixed for non-paid merged GD invoices.', 'invoicing'); |
|
844 | 844 | |
845 | 845 | global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates; |
846 | 846 | |
847 | - foreach ( $items as $item ) { |
|
847 | + foreach ($items as $item) { |
|
848 | 848 | $wpi_tax_rates = NULL; |
849 | 849 | $data = wpinv_get_invoice($item->ID); |
850 | 850 | |
851 | - if ( empty( $data ) ) { |
|
851 | + if (empty($data)) { |
|
852 | 852 | continue; |
853 | 853 | } |
854 | 854 | |
@@ -856,51 +856,51 @@ discard block |
||
856 | 856 | |
857 | 857 | $data_session = array(); |
858 | 858 | $data_session['invoice_id'] = $data->ID; |
859 | - $data_session['cart_discounts'] = $data->get_discounts( true ); |
|
859 | + $data_session['cart_discounts'] = $data->get_discounts(true); |
|
860 | 860 | |
861 | - wpinv_set_checkout_session( $data_session ); |
|
861 | + wpinv_set_checkout_session($data_session); |
|
862 | 862 | |
863 | 863 | $wpi_userID = (int)$data->get_user_id(); |
864 | 864 | $_POST['country'] = !empty($data->country) ? $data->country : wpinv_get_default_country(); |
865 | 865 | |
866 | - $data->country = sanitize_text_field( $_POST['country'] ); |
|
867 | - $data->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
866 | + $data->country = sanitize_text_field($_POST['country']); |
|
867 | + $data->set('country', sanitize_text_field($_POST['country'])); |
|
868 | 868 | |
869 | 869 | $wpinv_ip_address_country = $data->country; |
870 | 870 | |
871 | 871 | $data->recalculate_totals(true); |
872 | 872 | |
873 | - wpinv_set_checkout_session( $checkout_session ); |
|
873 | + wpinv_set_checkout_session($checkout_session); |
|
874 | 874 | |
875 | 875 | $update_data = array(); |
876 | 876 | $update_data['tax_amount'] = $data->get_tax(); |
877 | 877 | $update_data['paied_amount'] = $data->get_total(); |
878 | 878 | $update_data['invoice_id'] = $data->ID; |
879 | 879 | |
880 | - $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) ); |
|
880 | + $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $item->gdp_id)); |
|
881 | 881 | } |
882 | 882 | } else { |
883 | 883 | $success = false; |
884 | - $message = __( 'No invoices found to fix taxes!', 'invoicing' ); |
|
884 | + $message = __('No invoices found to fix taxes!', 'invoicing'); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | $response = array(); |
888 | 888 | $response['success'] = $success; |
889 | 889 | $response['data']['message'] = $message; |
890 | - wp_send_json( $response ); |
|
890 | + wp_send_json($response); |
|
891 | 891 | } |
892 | -add_action( 'wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes' ); |
|
893 | -remove_action( 'geodir_before_detail_fields' , 'geodir_build_coupon', 2 ); |
|
892 | +add_action('wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes'); |
|
893 | +remove_action('geodir_before_detail_fields', 'geodir_build_coupon', 2); |
|
894 | 894 | |
895 | -function wpinv_wpi_to_gdp_handle_subscription_cancel( $invoice_id, $invoice ) { |
|
896 | - if ( wpinv_pm_active() && !empty( $invoice ) && $invoice->is_recurring() ) { |
|
897 | - if ( $invoice->is_renewal() ) { |
|
895 | +function wpinv_wpi_to_gdp_handle_subscription_cancel($invoice_id, $invoice) { |
|
896 | + if (wpinv_pm_active() && !empty($invoice) && $invoice->is_recurring()) { |
|
897 | + if ($invoice->is_renewal()) { |
|
898 | 898 | $invoice = $invoice->get_parent_payment(); |
899 | 899 | } |
900 | 900 | |
901 | - if ( !empty( $invoice ) ) { |
|
902 | - wpinv_wpi_to_gdp_update_status( $invoice->ID, 'wpi-cancelled', $invoice->get_status() ); |
|
901 | + if (!empty($invoice)) { |
|
902 | + wpinv_wpi_to_gdp_update_status($invoice->ID, 'wpi-cancelled', $invoice->get_status()); |
|
903 | 903 | } |
904 | 904 | } |
905 | 905 | } |
906 | -add_action( 'wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2 ); |
|
907 | 906 | \ No newline at end of file |
907 | +add_action('wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2); |
|
908 | 908 | \ No newline at end of file |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
8 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
9 | 9 | |
10 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
10 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
11 | 11 | |
12 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
16 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
19 | 18 | \ No newline at end of file |
19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | \ No newline at end of file |