@@ -121,29 +121,29 @@ discard block |
||
121 | 121 | |
122 | 122 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
123 | 123 | if ( ! empty( $args ) && is_array( $args ) ) { |
124 | - extract( $args ); |
|
125 | - } |
|
124 | + extract( $args ); |
|
125 | + } |
|
126 | 126 | |
127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
128 | - // Allow 3rd party plugin filter template file from their plugin. |
|
129 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
127 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
128 | + // Allow 3rd party plugin filter template file from their plugin. |
|
129 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
130 | 130 | |
131 | - if ( ! file_exists( $located ) ) { |
|
131 | + if ( ! file_exists( $located ) ) { |
|
132 | 132 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
133 | - return; |
|
134 | - } |
|
133 | + return; |
|
134 | + } |
|
135 | 135 | |
136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
137 | 137 | |
138 | - include( $located ); |
|
138 | + include( $located ); |
|
139 | 139 | |
140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
140 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | - ob_start(); |
|
145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
146 | - return ob_get_clean(); |
|
144 | + ob_start(); |
|
145 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
146 | + return ob_get_clean(); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -173,120 +173,120 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
176 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | 177 | |
178 | - // Setup possible parts |
|
179 | - $templates = array(); |
|
180 | - if ( isset( $name ) ) |
|
181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
182 | - $templates[] = $slug . '.php'; |
|
178 | + // Setup possible parts |
|
179 | + $templates = array(); |
|
180 | + if ( isset( $name ) ) |
|
181 | + $templates[] = $slug . '-' . $name . '.php'; |
|
182 | + $templates[] = $slug . '.php'; |
|
183 | 183 | |
184 | - // Allow template parts to be filtered |
|
185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
184 | + // Allow template parts to be filtered |
|
185 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
186 | 186 | |
187 | - // Return the part that is found |
|
188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
187 | + // Return the part that is found |
|
188 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
192 | - // No file found yet |
|
193 | - $located = false; |
|
192 | + // No file found yet |
|
193 | + $located = false; |
|
194 | 194 | |
195 | - // Try to find a template file |
|
196 | - foreach ( (array)$template_names as $template_name ) { |
|
195 | + // Try to find a template file |
|
196 | + foreach ( (array)$template_names as $template_name ) { |
|
197 | 197 | |
198 | - // Continue if template is empty |
|
199 | - if ( empty( $template_name ) ) |
|
200 | - continue; |
|
198 | + // Continue if template is empty |
|
199 | + if ( empty( $template_name ) ) |
|
200 | + continue; |
|
201 | 201 | |
202 | - // Trim off any slashes from the template name |
|
203 | - $template_name = ltrim( $template_name, '/' ); |
|
202 | + // Trim off any slashes from the template name |
|
203 | + $template_name = ltrim( $template_name, '/' ); |
|
204 | 204 | |
205 | - // try locating this template file by looping through the template paths |
|
206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
205 | + // try locating this template file by looping through the template paths |
|
206 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
207 | 207 | |
208 | - if( file_exists( $template_path . $template_name ) ) { |
|
209 | - $located = $template_path . $template_name; |
|
210 | - break; |
|
211 | - } |
|
212 | - } |
|
208 | + if( file_exists( $template_path . $template_name ) ) { |
|
209 | + $located = $template_path . $template_name; |
|
210 | + break; |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - if( !empty( $located ) ) { |
|
215 | - break; |
|
216 | - } |
|
217 | - } |
|
214 | + if( !empty( $located ) ) { |
|
215 | + break; |
|
216 | + } |
|
217 | + } |
|
218 | 218 | |
219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
220 | - load_template( $located, $require_once ); |
|
219 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
220 | + load_template( $located, $require_once ); |
|
221 | 221 | |
222 | - return $located; |
|
222 | + return $located; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | function wpinv_get_theme_template_paths() { |
226 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
226 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
227 | 227 | |
228 | - $file_paths = array( |
|
229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | - 100 => wpinv_get_templates_dir() |
|
232 | - ); |
|
228 | + $file_paths = array( |
|
229 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
230 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 100 => wpinv_get_templates_dir() |
|
232 | + ); |
|
233 | 233 | |
234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
234 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
235 | 235 | |
236 | - // sort the file paths based on priority |
|
237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
236 | + // sort the file paths based on priority |
|
237 | + ksort( $file_paths, SORT_NUMERIC ); |
|
238 | 238 | |
239 | - return array_map( 'trailingslashit', $file_paths ); |
|
239 | + return array_map( 'trailingslashit', $file_paths ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_get_theme_template_dir_name() { |
243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
243 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | function wpinv_checkout_meta_tags() { |
247 | 247 | |
248 | - $pages = array(); |
|
249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
248 | + $pages = array(); |
|
249 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
250 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
251 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
252 | 252 | |
253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
254 | - return; |
|
255 | - } |
|
253 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
254 | + return; |
|
255 | + } |
|
256 | 256 | |
257 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
257 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
258 | 258 | } |
259 | 259 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
260 | 260 | |
261 | 261 | function wpinv_add_body_classes( $class ) { |
262 | - $classes = (array)$class; |
|
262 | + $classes = (array)$class; |
|
263 | 263 | |
264 | - if( wpinv_is_checkout() ) { |
|
265 | - $classes[] = 'wpinv-checkout'; |
|
266 | - $classes[] = 'wpinv-page'; |
|
267 | - } |
|
264 | + if( wpinv_is_checkout() ) { |
|
265 | + $classes[] = 'wpinv-checkout'; |
|
266 | + $classes[] = 'wpinv-page'; |
|
267 | + } |
|
268 | 268 | |
269 | - if( wpinv_is_success_page() ) { |
|
270 | - $classes[] = 'wpinv-success'; |
|
271 | - $classes[] = 'wpinv-page'; |
|
272 | - } |
|
269 | + if( wpinv_is_success_page() ) { |
|
270 | + $classes[] = 'wpinv-success'; |
|
271 | + $classes[] = 'wpinv-page'; |
|
272 | + } |
|
273 | 273 | |
274 | - if( wpinv_is_failed_transaction_page() ) { |
|
275 | - $classes[] = 'wpinv-failed-transaction'; |
|
276 | - $classes[] = 'wpinv-page'; |
|
277 | - } |
|
274 | + if( wpinv_is_failed_transaction_page() ) { |
|
275 | + $classes[] = 'wpinv-failed-transaction'; |
|
276 | + $classes[] = 'wpinv-page'; |
|
277 | + } |
|
278 | 278 | |
279 | - if( wpinv_is_invoice_history_page() ) { |
|
280 | - $classes[] = 'wpinv-history'; |
|
281 | - $classes[] = 'wpinv-page'; |
|
282 | - } |
|
279 | + if( wpinv_is_invoice_history_page() ) { |
|
280 | + $classes[] = 'wpinv-history'; |
|
281 | + $classes[] = 'wpinv-page'; |
|
282 | + } |
|
283 | 283 | |
284 | - if( wpinv_is_test_mode() ) { |
|
285 | - $classes[] = 'wpinv-test-mode'; |
|
286 | - $classes[] = 'wpinv-page'; |
|
287 | - } |
|
284 | + if( wpinv_is_test_mode() ) { |
|
285 | + $classes[] = 'wpinv-test-mode'; |
|
286 | + $classes[] = 'wpinv-page'; |
|
287 | + } |
|
288 | 288 | |
289 | - return array_unique( $classes ); |
|
289 | + return array_unique( $classes ); |
|
290 | 290 | } |
291 | 291 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
292 | 292 | |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1452 | 1452 | |
1453 | 1453 | function wpinv_empty_cart_message() { |
1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1454 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | /** |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | * @return void |
1462 | 1462 | */ |
1463 | 1463 | function wpinv_empty_checkout_cart() { |
1464 | - echo wpinv_empty_cart_message(); |
|
1464 | + echo wpinv_empty_cart_message(); |
|
1465 | 1465 | } |
1466 | 1466 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1467 | 1467 | |
@@ -1598,11 +1598,11 @@ discard block |
||
1598 | 1598 | do_action( 'wpinv_payment_mode_before_gateways' ); |
1599 | 1599 | |
1600 | 1600 | if(!empty($gateways)){ |
1601 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1602 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1603 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1604 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1605 | - ?> |
|
1601 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
1602 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1603 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1604 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
1605 | + ?> |
|
1606 | 1606 | <div class="list-group-item"> |
1607 | 1607 | <div class="radio"> |
1608 | 1608 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1615,9 +1615,9 @@ discard block |
||
1615 | 1615 | </div> |
1616 | 1616 | </div> |
1617 | 1617 | <?php |
1618 | - } |
|
1618 | + } |
|
1619 | 1619 | }else{ |
1620 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1620 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -140,6 +140,9 @@ discard block |
||
140 | 140 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
141 | 141 | } |
142 | 142 | |
143 | +/** |
|
144 | + * @param string $template_name |
|
145 | + */ |
|
143 | 146 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | 147 | ob_start(); |
145 | 148 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -172,6 +175,9 @@ discard block |
||
172 | 175 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
173 | 176 | } |
174 | 177 | |
178 | +/** |
|
179 | + * @param string $slug |
|
180 | + */ |
|
175 | 181 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | 182 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
177 | 183 | |
@@ -871,6 +877,9 @@ discard block |
||
871 | 877 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
872 | 878 | } |
873 | 879 | |
880 | +/** |
|
881 | + * @param integer $id |
|
882 | + */ |
|
874 | 883 | function wpinv_get_watermark( $id ) { |
875 | 884 | if ( !$id > 0 ) { |
876 | 885 | return NULL; |
@@ -7,101 +7,101 @@ 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 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', 'invoicing/' ); |
|
22 | + return apply_filters('wpinv_template_path', 'invoicing/'); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_post_class( $classes, $class, $post_id ) { |
|
25 | +function wpinv_post_class($classes, $class, $post_id) { |
|
26 | 26 | global $pagenow, $typenow; |
27 | 27 | |
28 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' ) { |
|
28 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && get_post_meta($post_id, '_wpinv_type', true) == 'package') { |
|
29 | 29 | $classes[] = 'wpi-gd-package'; |
30 | 30 | } |
31 | 31 | return $classes; |
32 | 32 | } |
33 | -add_filter( 'post_class', 'wpinv_post_class', 10, 3 ); |
|
33 | +add_filter('post_class', 'wpinv_post_class', 10, 3); |
|
34 | 34 | |
35 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
36 | - if ( empty( $invoice ) ) { |
|
35 | +function wpinv_display_invoice_top_bar($invoice) { |
|
36 | + if (empty($invoice)) { |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | <div class="row wpinv-top-bar no-print"> |
41 | 41 | <div class="container"> |
42 | 42 | <div class="col-xs-6"> |
43 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
43 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
44 | 44 | </div> |
45 | 45 | <div class="col-xs-6 text-right"> |
46 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
46 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | <?php |
51 | 51 | } |
52 | 52 | |
53 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
54 | - if ( empty( $invoice ) ) { |
|
53 | +function wpinv_invoice_display_left_actions($invoice) { |
|
54 | + if (empty($invoice)) { |
|
55 | 55 | return; // Exit if invoice is not set. |
56 | 56 | } |
57 | 57 | |
58 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
59 | - if ( $invoice->needs_payment() ) { |
|
60 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
58 | + if ($invoice->post_type == 'wpi_invoice') { |
|
59 | + if ($invoice->needs_payment()) { |
|
60 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | do_action('wpinv_invoice_display_left_actions', $invoice); |
64 | 64 | } |
65 | 65 | |
66 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
67 | - if ( empty( $invoice ) ) { |
|
66 | +function wpinv_invoice_display_right_actions($invoice) { |
|
67 | + if (empty($invoice)) { |
|
68 | 68 | return; // Exit if invoice is not set. |
69 | 69 | } |
70 | 70 | |
71 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
72 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
73 | - <?php if ( is_user_logged_in() ) { ?> |
|
74 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
71 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
72 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
73 | + <?php if (is_user_logged_in()) { ?> |
|
74 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
75 | 75 | <?php } |
76 | 76 | } |
77 | 77 | do_action('wpinv_invoice_display_right_actions', $invoice); |
78 | 78 | } |
79 | 79 | |
80 | -function wpinv_before_invoice_content( $content ) { |
|
80 | +function wpinv_before_invoice_content($content) { |
|
81 | 81 | global $post; |
82 | 82 | |
83 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
83 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
84 | 84 | ob_start(); |
85 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
85 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
86 | 86 | $content = ob_get_clean() . $content; |
87 | 87 | } |
88 | 88 | |
89 | 89 | return $content; |
90 | 90 | } |
91 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
91 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
92 | 92 | |
93 | -function wpinv_after_invoice_content( $content ) { |
|
93 | +function wpinv_after_invoice_content($content) { |
|
94 | 94 | global $post; |
95 | 95 | |
96 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
96 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
97 | 97 | ob_start(); |
98 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
98 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
99 | 99 | $content .= ob_get_clean(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | return $content; |
103 | 103 | } |
104 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
104 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
105 | 105 | |
106 | 106 | function wpinv_get_templates_dir() { |
107 | 107 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -111,105 +111,105 @@ discard block |
||
111 | 111 | return WPINV_PLUGIN_URL . 'templates'; |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
115 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
116 | - extract( $args ); |
|
114 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
115 | + if (!empty($args) && is_array($args)) { |
|
116 | + extract($args); |
|
117 | 117 | } |
118 | 118 | |
119 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
119 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
120 | 120 | // Allow 3rd party plugin filter template file from their plugin. |
121 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
121 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
122 | 122 | |
123 | - if ( ! file_exists( $located ) ) { |
|
124 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
123 | + if (!file_exists($located)) { |
|
124 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
128 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
129 | 129 | |
130 | - include( $located ); |
|
130 | + include($located); |
|
131 | 131 | |
132 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
132 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
135 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
136 | 136 | ob_start(); |
137 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
137 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
138 | 138 | return ob_get_clean(); |
139 | 139 | } |
140 | 140 | |
141 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
142 | - if ( ! $template_path ) { |
|
141 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
142 | + if (!$template_path) { |
|
143 | 143 | $template_path = wpinv_template_path(); |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! $default_path ) { |
|
146 | + if (!$default_path) { |
|
147 | 147 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Look within passed path within the theme - this is priority. |
151 | 151 | $template = locate_template( |
152 | 152 | array( |
153 | - trailingslashit( $template_path ) . $template_name, |
|
153 | + trailingslashit($template_path) . $template_name, |
|
154 | 154 | $template_name |
155 | 155 | ) |
156 | 156 | ); |
157 | 157 | |
158 | 158 | // Get default templates/ |
159 | - if ( !$template && $default_path ) { |
|
160 | - $template = trailingslashit( $default_path ) . $template_name; |
|
159 | + if (!$template && $default_path) { |
|
160 | + $template = trailingslashit($default_path) . $template_name; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Return what we found. |
164 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
164 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
168 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
167 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
168 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
169 | 169 | |
170 | 170 | // Setup possible parts |
171 | 171 | $templates = array(); |
172 | - if ( isset( $name ) ) |
|
172 | + if (isset($name)) |
|
173 | 173 | $templates[] = $slug . '-' . $name . '.php'; |
174 | 174 | $templates[] = $slug . '.php'; |
175 | 175 | |
176 | 176 | // Allow template parts to be filtered |
177 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
177 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
178 | 178 | |
179 | 179 | // Return the part that is found |
180 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
180 | + return wpinv_locate_tmpl($templates, $load, false); |
|
181 | 181 | } |
182 | 182 | |
183 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
183 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
184 | 184 | // No file found yet |
185 | 185 | $located = false; |
186 | 186 | |
187 | 187 | // Try to find a template file |
188 | - foreach ( (array)$template_names as $template_name ) { |
|
188 | + foreach ((array)$template_names as $template_name) { |
|
189 | 189 | |
190 | 190 | // Continue if template is empty |
191 | - if ( empty( $template_name ) ) |
|
191 | + if (empty($template_name)) |
|
192 | 192 | continue; |
193 | 193 | |
194 | 194 | // Trim off any slashes from the template name |
195 | - $template_name = ltrim( $template_name, '/' ); |
|
195 | + $template_name = ltrim($template_name, '/'); |
|
196 | 196 | |
197 | 197 | // try locating this template file by looping through the template paths |
198 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
198 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
199 | 199 | |
200 | - if( file_exists( $template_path . $template_name ) ) { |
|
200 | + if (file_exists($template_path . $template_name)) { |
|
201 | 201 | $located = $template_path . $template_name; |
202 | 202 | break; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - if( !empty( $located ) ) { |
|
206 | + if (!empty($located)) { |
|
207 | 207 | break; |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
212 | - load_template( $located, $require_once ); |
|
211 | + if ((true == $load) && !empty($located)) |
|
212 | + load_template($located, $require_once); |
|
213 | 213 | |
214 | 214 | return $located; |
215 | 215 | } |
@@ -218,143 +218,143 @@ discard block |
||
218 | 218 | $template_dir = wpinv_get_theme_template_dir_name(); |
219 | 219 | |
220 | 220 | $file_paths = array( |
221 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
222 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
221 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
222 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
223 | 223 | 100 => wpinv_get_templates_dir() |
224 | 224 | ); |
225 | 225 | |
226 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
226 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
227 | 227 | |
228 | 228 | // sort the file paths based on priority |
229 | - ksort( $file_paths, SORT_NUMERIC ); |
|
229 | + ksort($file_paths, SORT_NUMERIC); |
|
230 | 230 | |
231 | - return array_map( 'trailingslashit', $file_paths ); |
|
231 | + return array_map('trailingslashit', $file_paths); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | function wpinv_get_theme_template_dir_name() { |
235 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
235 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | function wpinv_checkout_meta_tags() { |
239 | 239 | |
240 | 240 | $pages = array(); |
241 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
242 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
243 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
241 | + $pages[] = wpinv_get_option('success_page'); |
|
242 | + $pages[] = wpinv_get_option('failure_page'); |
|
243 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
244 | 244 | |
245 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
245 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
250 | 250 | } |
251 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
251 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
252 | 252 | |
253 | -function wpinv_add_body_classes( $class ) { |
|
253 | +function wpinv_add_body_classes($class) { |
|
254 | 254 | $classes = (array)$class; |
255 | 255 | |
256 | - if( wpinv_is_checkout() ) { |
|
256 | + if (wpinv_is_checkout()) { |
|
257 | 257 | $classes[] = 'wpinv-checkout'; |
258 | 258 | $classes[] = 'wpinv-page'; |
259 | 259 | } |
260 | 260 | |
261 | - if( wpinv_is_success_page() ) { |
|
261 | + if (wpinv_is_success_page()) { |
|
262 | 262 | $classes[] = 'wpinv-success'; |
263 | 263 | $classes[] = 'wpinv-page'; |
264 | 264 | } |
265 | 265 | |
266 | - if( wpinv_is_failed_transaction_page() ) { |
|
266 | + if (wpinv_is_failed_transaction_page()) { |
|
267 | 267 | $classes[] = 'wpinv-failed-transaction'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if( wpinv_is_invoice_history_page() ) { |
|
271 | + if (wpinv_is_invoice_history_page()) { |
|
272 | 272 | $classes[] = 'wpinv-history'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if( wpinv_is_test_mode() ) { |
|
276 | + if (wpinv_is_test_mode()) { |
|
277 | 277 | $classes[] = 'wpinv-test-mode'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - return array_unique( $classes ); |
|
281 | + return array_unique($classes); |
|
282 | 282 | } |
283 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
283 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
284 | 284 | |
285 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
286 | - $args = array( 'nopaging' => true ); |
|
285 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
286 | + $args = array('nopaging' => true); |
|
287 | 287 | |
288 | - if ( ! empty( $status ) ) |
|
288 | + if (!empty($status)) |
|
289 | 289 | $args['post_status'] = $status; |
290 | 290 | |
291 | - $discounts = wpinv_get_discounts( $args ); |
|
291 | + $discounts = wpinv_get_discounts($args); |
|
292 | 292 | $options = array(); |
293 | 293 | |
294 | - if ( $discounts ) { |
|
295 | - foreach ( $discounts as $discount ) { |
|
296 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
294 | + if ($discounts) { |
|
295 | + foreach ($discounts as $discount) { |
|
296 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
297 | 297 | } |
298 | 298 | } else { |
299 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
299 | + $options[0] = __('No discounts found', 'invoicing'); |
|
300 | 300 | } |
301 | 301 | |
302 | - $output = wpinv_html_select( array( |
|
302 | + $output = wpinv_html_select(array( |
|
303 | 303 | 'name' => $name, |
304 | 304 | 'selected' => $selected, |
305 | 305 | 'options' => $options, |
306 | 306 | 'show_option_all' => false, |
307 | 307 | 'show_option_none' => false, |
308 | - ) ); |
|
308 | + )); |
|
309 | 309 | |
310 | 310 | return $output; |
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
314 | - $current = date( 'Y' ); |
|
315 | - $start_year = $current - absint( $years_before ); |
|
316 | - $end_year = $current + absint( $years_after ); |
|
317 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
313 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
314 | + $current = date('Y'); |
|
315 | + $start_year = $current - absint($years_before); |
|
316 | + $end_year = $current + absint($years_after); |
|
317 | + $selected = empty($selected) ? date('Y') : $selected; |
|
318 | 318 | $options = array(); |
319 | 319 | |
320 | - while ( $start_year <= $end_year ) { |
|
321 | - $options[ absint( $start_year ) ] = $start_year; |
|
320 | + while ($start_year <= $end_year) { |
|
321 | + $options[absint($start_year)] = $start_year; |
|
322 | 322 | $start_year++; |
323 | 323 | } |
324 | 324 | |
325 | - $output = wpinv_html_select( array( |
|
325 | + $output = wpinv_html_select(array( |
|
326 | 326 | 'name' => $name, |
327 | 327 | 'selected' => $selected, |
328 | 328 | 'options' => $options, |
329 | 329 | 'show_option_all' => false, |
330 | 330 | 'show_option_none' => false |
331 | - ) ); |
|
331 | + )); |
|
332 | 332 | |
333 | 333 | return $output; |
334 | 334 | } |
335 | 335 | |
336 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
336 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
337 | 337 | $month = 1; |
338 | 338 | $options = array(); |
339 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
339 | + $selected = empty($selected) ? date('n') : $selected; |
|
340 | 340 | |
341 | - while ( $month <= 12 ) { |
|
342 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
341 | + while ($month <= 12) { |
|
342 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
343 | 343 | $month++; |
344 | 344 | } |
345 | 345 | |
346 | - $output = wpinv_html_select( array( |
|
346 | + $output = wpinv_html_select(array( |
|
347 | 347 | 'name' => $name, |
348 | 348 | 'selected' => $selected, |
349 | 349 | 'options' => $options, |
350 | 350 | 'show_option_all' => false, |
351 | 351 | 'show_option_none' => false |
352 | - ) ); |
|
352 | + )); |
|
353 | 353 | |
354 | 354 | return $output; |
355 | 355 | } |
356 | 356 | |
357 | -function wpinv_html_select( $args = array() ) { |
|
357 | +function wpinv_html_select($args = array()) { |
|
358 | 358 | $defaults = array( |
359 | 359 | 'options' => array(), |
360 | 360 | 'name' => null, |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | 'chosen' => false, |
365 | 365 | 'placeholder' => null, |
366 | 366 | 'multiple' => false, |
367 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
368 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
367 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
368 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
369 | 369 | 'data' => array(), |
370 | 370 | 'onchange' => null, |
371 | 371 | 'required' => false, |
@@ -373,78 +373,78 @@ discard block |
||
373 | 373 | 'readonly' => false, |
374 | 374 | ); |
375 | 375 | |
376 | - $args = wp_parse_args( $args, $defaults ); |
|
376 | + $args = wp_parse_args($args, $defaults); |
|
377 | 377 | |
378 | 378 | $data_elements = ''; |
379 | - foreach ( $args['data'] as $key => $value ) { |
|
380 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
379 | + foreach ($args['data'] as $key => $value) { |
|
380 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
381 | 381 | } |
382 | 382 | |
383 | - if( $args['multiple'] ) { |
|
383 | + if ($args['multiple']) { |
|
384 | 384 | $multiple = ' MULTIPLE'; |
385 | 385 | } else { |
386 | 386 | $multiple = ''; |
387 | 387 | } |
388 | 388 | |
389 | - if( $args['chosen'] ) { |
|
389 | + if ($args['chosen']) { |
|
390 | 390 | $args['class'] .= ' wpinv-select-chosen'; |
391 | 391 | } |
392 | 392 | |
393 | - if( $args['placeholder'] ) { |
|
393 | + if ($args['placeholder']) { |
|
394 | 394 | $placeholder = $args['placeholder']; |
395 | 395 | } else { |
396 | 396 | $placeholder = ''; |
397 | 397 | } |
398 | 398 | |
399 | 399 | $options = ''; |
400 | - if( !empty( $args['onchange'] ) ) { |
|
401 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
400 | + if (!empty($args['onchange'])) { |
|
401 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
402 | 402 | } |
403 | 403 | |
404 | - if( !empty( $args['required'] ) ) { |
|
404 | + if (!empty($args['required'])) { |
|
405 | 405 | $options .= ' required="required"'; |
406 | 406 | } |
407 | 407 | |
408 | - if( !empty( $args['disabled'] ) ) { |
|
408 | + if (!empty($args['disabled'])) { |
|
409 | 409 | $options .= ' disabled'; |
410 | 410 | } |
411 | 411 | |
412 | - if( !empty( $args['readonly'] ) ) { |
|
412 | + if (!empty($args['readonly'])) { |
|
413 | 413 | $options .= ' readonly'; |
414 | 414 | } |
415 | 415 | |
416 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
417 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
416 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
417 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
418 | 418 | |
419 | - if ( $args['show_option_all'] ) { |
|
420 | - if( $args['multiple'] ) { |
|
421 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
419 | + if ($args['show_option_all']) { |
|
420 | + if ($args['multiple']) { |
|
421 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
422 | 422 | } else { |
423 | - $selected = selected( $args['selected'], 0, false ); |
|
423 | + $selected = selected($args['selected'], 0, false); |
|
424 | 424 | } |
425 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
425 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | - if ( !empty( $args['options'] ) ) { |
|
428 | + if (!empty($args['options'])) { |
|
429 | 429 | |
430 | - if ( $args['show_option_none'] ) { |
|
431 | - if( $args['multiple'] ) { |
|
432 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
430 | + if ($args['show_option_none']) { |
|
431 | + if ($args['multiple']) { |
|
432 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
433 | 433 | } else { |
434 | - $selected = selected( $args['selected'] === "", true, false ); |
|
434 | + $selected = selected($args['selected'] === "", true, false); |
|
435 | 435 | } |
436 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
436 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - foreach( $args['options'] as $key => $option ) { |
|
439 | + foreach ($args['options'] as $key => $option) { |
|
440 | 440 | |
441 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
442 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
441 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
442 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
443 | 443 | } else { |
444 | - $selected = selected( $args['selected'], $key, false ); |
|
444 | + $selected = selected($args['selected'], $key, false); |
|
445 | 445 | } |
446 | 446 | |
447 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
447 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | return $output; |
454 | 454 | } |
455 | 455 | |
456 | -function wpinv_item_dropdown( $args = array() ) { |
|
456 | +function wpinv_item_dropdown($args = array()) { |
|
457 | 457 | $defaults = array( |
458 | 458 | 'name' => 'wpi_item', |
459 | 459 | 'id' => 'wpi_item', |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | 'selected' => 0, |
463 | 463 | 'chosen' => false, |
464 | 464 | 'number' => 100, |
465 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
466 | - 'data' => array( 'search-type' => 'item' ), |
|
465 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
466 | + 'data' => array('search-type' => 'item'), |
|
467 | 467 | 'show_option_all' => false, |
468 | 468 | 'show_option_none' => false, |
469 | 469 | 'with_packages' => true, |
470 | 470 | 'show_recurring' => false, |
471 | 471 | ); |
472 | 472 | |
473 | - $args = wp_parse_args( $args, $defaults ); |
|
473 | + $args = wp_parse_args($args, $defaults); |
|
474 | 474 | |
475 | 475 | $item_args = array( |
476 | 476 | 'post_type' => 'wpi_item', |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | 'posts_per_page' => $args['number'] |
480 | 480 | ); |
481 | 481 | |
482 | - if ( !$args['with_packages'] ) { |
|
482 | + if (!$args['with_packages']) { |
|
483 | 483 | $item_args['meta_query'] = array( |
484 | 484 | array( |
485 | 485 | 'key' => '_wpinv_type', |
@@ -489,42 +489,42 @@ discard block |
||
489 | 489 | ); |
490 | 490 | } |
491 | 491 | |
492 | - $items = get_posts( $item_args ); |
|
492 | + $items = get_posts($item_args); |
|
493 | 493 | $options = array(); |
494 | - if ( $items ) { |
|
495 | - foreach ( $items as $item ) { |
|
496 | - $title = esc_html( $item->post_title ); |
|
494 | + if ($items) { |
|
495 | + foreach ($items as $item) { |
|
496 | + $title = esc_html($item->post_title); |
|
497 | 497 | |
498 | - if ( !empty( $args['show_recurring'] ) ) { |
|
499 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
498 | + if (!empty($args['show_recurring'])) { |
|
499 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
500 | 500 | } |
501 | 501 | |
502 | - $options[ absint( $item->ID ) ] = $title; |
|
502 | + $options[absint($item->ID)] = $title; |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | // This ensures that any selected items are included in the drop down |
507 | - if( is_array( $args['selected'] ) ) { |
|
508 | - foreach( $args['selected'] as $item ) { |
|
509 | - if( ! in_array( $item, $options ) ) { |
|
510 | - $title = get_the_title( $item ); |
|
511 | - if ( !empty( $args['show_recurring'] ) ) { |
|
512 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
507 | + if (is_array($args['selected'])) { |
|
508 | + foreach ($args['selected'] as $item) { |
|
509 | + if (!in_array($item, $options)) { |
|
510 | + $title = get_the_title($item); |
|
511 | + if (!empty($args['show_recurring'])) { |
|
512 | + $title .= wpinv_get_item_suffix($item, false); |
|
513 | 513 | } |
514 | 514 | $options[$item] = $title; |
515 | 515 | } |
516 | 516 | } |
517 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
518 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
519 | - $title = get_the_title( $args['selected'] ); |
|
520 | - if ( !empty( $args['show_recurring'] ) ) { |
|
521 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
517 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
518 | + if (!in_array($args['selected'], $options)) { |
|
519 | + $title = get_the_title($args['selected']); |
|
520 | + if (!empty($args['show_recurring'])) { |
|
521 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
522 | 522 | } |
523 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
523 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
527 | - $output = wpinv_html_select( array( |
|
527 | + $output = wpinv_html_select(array( |
|
528 | 528 | 'name' => $args['name'], |
529 | 529 | 'selected' => $args['selected'], |
530 | 530 | 'id' => $args['id'], |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | 'show_option_all' => $args['show_option_all'], |
537 | 537 | 'show_option_none' => $args['show_option_none'], |
538 | 538 | 'data' => $args['data'], |
539 | - ) ); |
|
539 | + )); |
|
540 | 540 | |
541 | 541 | return $output; |
542 | 542 | } |
543 | 543 | |
544 | -function wpinv_html_checkbox( $args = array() ) { |
|
544 | +function wpinv_html_checkbox($args = array()) { |
|
545 | 545 | $defaults = array( |
546 | 546 | 'name' => null, |
547 | 547 | 'current' => null, |
@@ -552,38 +552,38 @@ discard block |
||
552 | 552 | ) |
553 | 553 | ); |
554 | 554 | |
555 | - $args = wp_parse_args( $args, $defaults ); |
|
555 | + $args = wp_parse_args($args, $defaults); |
|
556 | 556 | |
557 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
557 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
558 | 558 | $options = ''; |
559 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
559 | + if (!empty($args['options']['disabled'])) { |
|
560 | 560 | $options .= ' disabled="disabled"'; |
561 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
561 | + } elseif (!empty($args['options']['readonly'])) { |
|
562 | 562 | $options .= ' readonly'; |
563 | 563 | } |
564 | 564 | |
565 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
565 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
566 | 566 | |
567 | 567 | return $output; |
568 | 568 | } |
569 | 569 | |
570 | -function wpinv_html_text( $args = array() ) { |
|
570 | +function wpinv_html_text($args = array()) { |
|
571 | 571 | // Backwards compatibility |
572 | - if ( func_num_args() > 1 ) { |
|
572 | + if (func_num_args() > 1) { |
|
573 | 573 | $args = func_get_args(); |
574 | 574 | |
575 | 575 | $name = $args[0]; |
576 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
577 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
578 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
576 | + $value = isset($args[1]) ? $args[1] : ''; |
|
577 | + $label = isset($args[2]) ? $args[2] : ''; |
|
578 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | $defaults = array( |
582 | 582 | 'id' => '', |
583 | - 'name' => isset( $name ) ? $name : 'text', |
|
584 | - 'value' => isset( $value ) ? $value : null, |
|
585 | - 'label' => isset( $label ) ? $label : null, |
|
586 | - 'desc' => isset( $desc ) ? $desc : null, |
|
583 | + 'name' => isset($name) ? $name : 'text', |
|
584 | + 'value' => isset($value) ? $value : null, |
|
585 | + 'label' => isset($label) ? $label : null, |
|
586 | + 'desc' => isset($desc) ? $desc : null, |
|
587 | 587 | 'placeholder' => '', |
588 | 588 | 'class' => 'regular-text', |
589 | 589 | 'disabled' => false, |
@@ -593,51 +593,51 @@ discard block |
||
593 | 593 | 'data' => false |
594 | 594 | ); |
595 | 595 | |
596 | - $args = wp_parse_args( $args, $defaults ); |
|
596 | + $args = wp_parse_args($args, $defaults); |
|
597 | 597 | |
598 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
598 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
599 | 599 | $options = ''; |
600 | - if( $args['required'] ) { |
|
600 | + if ($args['required']) { |
|
601 | 601 | $options .= ' required="required"'; |
602 | 602 | } |
603 | - if( $args['readonly'] ) { |
|
603 | + if ($args['readonly']) { |
|
604 | 604 | $options .= ' readonly'; |
605 | 605 | } |
606 | - if( $args['readonly'] ) { |
|
606 | + if ($args['readonly']) { |
|
607 | 607 | $options .= ' readonly'; |
608 | 608 | } |
609 | 609 | |
610 | 610 | $data = ''; |
611 | - if ( !empty( $args['data'] ) ) { |
|
612 | - foreach ( $args['data'] as $key => $value ) { |
|
613 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
611 | + if (!empty($args['data'])) { |
|
612 | + foreach ($args['data'] as $key => $value) { |
|
613 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
618 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
619 | - if ( ! empty( $args['desc'] ) ) { |
|
620 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
617 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
618 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
619 | + if (!empty($args['desc'])) { |
|
620 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
621 | 621 | } |
622 | 622 | |
623 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
623 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
624 | 624 | |
625 | 625 | $output .= '</span>'; |
626 | 626 | |
627 | 627 | return $output; |
628 | 628 | } |
629 | 629 | |
630 | -function wpinv_html_date_field( $args = array() ) { |
|
631 | - if( empty( $args['class'] ) ) { |
|
630 | +function wpinv_html_date_field($args = array()) { |
|
631 | + if (empty($args['class'])) { |
|
632 | 632 | $args['class'] = 'wpiDatepicker'; |
633 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
633 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
634 | 634 | $args['class'] .= ' wpiDatepicker'; |
635 | 635 | } |
636 | 636 | |
637 | - return wpinv_html_text( $args ); |
|
637 | + return wpinv_html_text($args); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_html_textarea( $args = array() ) { |
|
640 | +function wpinv_html_textarea($args = array()) { |
|
641 | 641 | $defaults = array( |
642 | 642 | 'name' => 'textarea', |
643 | 643 | 'value' => null, |
@@ -647,31 +647,31 @@ discard block |
||
647 | 647 | 'disabled' => false |
648 | 648 | ); |
649 | 649 | |
650 | - $args = wp_parse_args( $args, $defaults ); |
|
650 | + $args = wp_parse_args($args, $defaults); |
|
651 | 651 | |
652 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
652 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
653 | 653 | $disabled = ''; |
654 | - if( $args['disabled'] ) { |
|
654 | + if ($args['disabled']) { |
|
655 | 655 | $disabled = ' disabled="disabled"'; |
656 | 656 | } |
657 | 657 | |
658 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
659 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
660 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
658 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
659 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
660 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
661 | 661 | |
662 | - if ( ! empty( $args['desc'] ) ) { |
|
663 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
662 | + if (!empty($args['desc'])) { |
|
663 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
664 | 664 | } |
665 | 665 | $output .= '</span>'; |
666 | 666 | |
667 | 667 | return $output; |
668 | 668 | } |
669 | 669 | |
670 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
670 | +function wpinv_html_ajax_user_search($args = array()) { |
|
671 | 671 | $defaults = array( |
672 | 672 | 'name' => 'user_id', |
673 | 673 | 'value' => null, |
674 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
674 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
675 | 675 | 'label' => null, |
676 | 676 | 'desc' => null, |
677 | 677 | 'class' => '', |
@@ -680,13 +680,13 @@ discard block |
||
680 | 680 | 'data' => false |
681 | 681 | ); |
682 | 682 | |
683 | - $args = wp_parse_args( $args, $defaults ); |
|
683 | + $args = wp_parse_args($args, $defaults); |
|
684 | 684 | |
685 | 685 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
686 | 686 | |
687 | 687 | $output = '<span class="wpinv_user_search_wrap">'; |
688 | - $output .= wpinv_html_text( $args ); |
|
689 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
688 | + $output .= wpinv_html_text($args); |
|
689 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
690 | 690 | $output .= '</span>'; |
691 | 691 | |
692 | 692 | return $output; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | function wpinv_ip_geolocation() { |
696 | 696 | global $wpinv_euvat; |
697 | 697 | |
698 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
698 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
699 | 699 | $content = ''; |
700 | 700 | $iso = ''; |
701 | 701 | $country = ''; |
@@ -706,69 +706,69 @@ discard block |
||
706 | 706 | $credit = ''; |
707 | 707 | $address = ''; |
708 | 708 | |
709 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
709 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
710 | 710 | try { |
711 | 711 | $iso = $geoip2_city->country->isoCode; |
712 | 712 | $country = $geoip2_city->country->name; |
713 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
713 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
714 | 714 | $city = $geoip2_city->city->name; |
715 | 715 | $longitude = $geoip2_city->location->longitude; |
716 | 716 | $latitude = $geoip2_city->location->latitude; |
717 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
718 | - } catch( Exception $e ) { } |
|
717 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
718 | + } catch (Exception $e) { } |
|
719 | 719 | } |
720 | 720 | |
721 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
721 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
722 | 722 | try { |
723 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
723 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
724 | 724 | |
725 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
725 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
726 | 726 | $iso = $load_xml->geoplugin_countryCode; |
727 | 727 | $country = $load_xml->geoplugin_countryName; |
728 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
729 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
728 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
729 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
730 | 730 | $longitude = $load_xml->geoplugin_longitude; |
731 | 731 | $latitude = $load_xml->geoplugin_latitude; |
732 | 732 | $credit = $load_xml->geoplugin_credit; |
733 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
733 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
734 | 734 | } |
735 | - } catch( Exception $e ) { } |
|
735 | + } catch (Exception $e) { } |
|
736 | 736 | } |
737 | 737 | |
738 | - if ( $iso && $longitude && $latitude ) { |
|
739 | - if ( $city ) { |
|
738 | + if ($iso && $longitude && $latitude) { |
|
739 | + if ($city) { |
|
740 | 740 | $address .= $city . ', '; |
741 | 741 | } |
742 | 742 | |
743 | - if ( $region ) { |
|
743 | + if ($region) { |
|
744 | 744 | $address .= $region . ', '; |
745 | 745 | } |
746 | 746 | |
747 | 747 | $address .= $country . ' (' . $iso . ')'; |
748 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
749 | - $content .= '<p>'. $credit . '</p>'; |
|
748 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
749 | + $content .= '<p>' . $credit . '</p>'; |
|
750 | 750 | } else { |
751 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
751 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
752 | 752 | } |
753 | 753 | ?> |
754 | 754 | <!DOCTYPE html> |
755 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
755 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
756 | 756 | <body> |
757 | - <?php if ( $latitude && $latitude ) { ?> |
|
757 | + <?php if ($latitude && $latitude) { ?> |
|
758 | 758 | <div id="map"></div> |
759 | 759 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
760 | 760 | <script type="text/javascript"> |
761 | 761 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
762 | 762 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
763 | 763 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
764 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
764 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
765 | 765 | |
766 | 766 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
767 | 767 | |
768 | 768 | var marker = new L.Marker(latlng); |
769 | 769 | map.addLayer(marker); |
770 | 770 | |
771 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
771 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
772 | 772 | </script> |
773 | 773 | <?php } ?> |
774 | 774 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -776,31 +776,31 @@ discard block |
||
776 | 776 | <?php |
777 | 777 | exit; |
778 | 778 | } |
779 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
780 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
779 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
780 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
781 | 781 | |
782 | 782 | // Set up the template for the invoice. |
783 | -function wpinv_template( $template ) { |
|
783 | +function wpinv_template($template) { |
|
784 | 784 | global $post, $wp_query; |
785 | 785 | |
786 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
787 | - if ( wpinv_user_can_print_invoice( $post->ID ) ) { |
|
788 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
786 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
787 | + if (wpinv_user_can_print_invoice($post->ID)) { |
|
788 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
789 | 789 | } else { |
790 | - if ( !is_user_logged_in() && !empty( $_REQUEST['_wpipay'] ) && $invoice = wpinv_get_invoice( $post->ID ) ) { |
|
790 | + if (!is_user_logged_in() && !empty($_REQUEST['_wpipay']) && $invoice = wpinv_get_invoice($post->ID)) { |
|
791 | 791 | $user_id = $invoice->get_user_id(); |
792 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
792 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
793 | 793 | |
794 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key() ) ) { // valid invoice link |
|
795 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
794 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key())) { // valid invoice link |
|
795 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
796 | 796 | |
797 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
797 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
798 | 798 | wpinv_die(); |
799 | 799 | } |
800 | 800 | } |
801 | - $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
801 | + $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
802 | 802 | |
803 | - wp_redirect( $redirect_to ); |
|
803 | + wp_redirect($redirect_to); |
|
804 | 804 | wpinv_die(); |
805 | 805 | } |
806 | 806 | } |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | |
811 | 811 | function wpinv_get_business_address() { |
812 | 812 | $business_address = wpinv_store_address(); |
813 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
813 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
814 | 814 | |
815 | 815 | /* |
816 | 816 | $default_country = wpinv_get_default_country(); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
836 | 836 | |
837 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
837 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | function wpinv_display_from_address() { |
@@ -844,188 +844,188 @@ discard block |
||
844 | 844 | if (empty($from_name)) { |
845 | 845 | $from_name = wpinv_get_business_name(); |
846 | 846 | } |
847 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
847 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
848 | 848 | <div class="wrapper col-xs-10"> |
849 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
850 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
851 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
849 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
850 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
851 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
852 | 852 | <?php } ?> |
853 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
854 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s' ), $email_from );?></div> |
|
853 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
854 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s'), $email_from); ?></div> |
|
855 | 855 | <?php } ?> |
856 | 856 | </div> |
857 | 857 | <?php |
858 | 858 | } |
859 | 859 | |
860 | -function wpinv_watermark( $id = 0 ) { |
|
861 | - $output = wpinv_get_watermark( $id ); |
|
860 | +function wpinv_watermark($id = 0) { |
|
861 | + $output = wpinv_get_watermark($id); |
|
862 | 862 | |
863 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
863 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
864 | 864 | } |
865 | 865 | |
866 | -function wpinv_get_watermark( $id ) { |
|
867 | - if ( !$id > 0 ) { |
|
866 | +function wpinv_get_watermark($id) { |
|
867 | + if (!$id > 0) { |
|
868 | 868 | return NULL; |
869 | 869 | } |
870 | - $invoice = wpinv_get_invoice( $id ); |
|
870 | + $invoice = wpinv_get_invoice($id); |
|
871 | 871 | |
872 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
873 | - if ( $invoice->is_paid() ) { |
|
874 | - return __( 'Paid', 'invoicing' ); |
|
872 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
873 | + if ($invoice->is_paid()) { |
|
874 | + return __('Paid', 'invoicing'); |
|
875 | 875 | } |
876 | - if ( $invoice->is_refunded() ) { |
|
877 | - return __( 'Refunded', 'invoicing' ); |
|
876 | + if ($invoice->is_refunded()) { |
|
877 | + return __('Refunded', 'invoicing'); |
|
878 | 878 | } |
879 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
880 | - return __( 'Cancelled', 'invoicing' ); |
|
879 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
880 | + return __('Cancelled', 'invoicing'); |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 | |
884 | 884 | return NULL; |
885 | 885 | } |
886 | 886 | |
887 | -function wpinv_display_invoice_details( $invoice ) { |
|
887 | +function wpinv_display_invoice_details($invoice) { |
|
888 | 888 | global $wpinv_euvat; |
889 | 889 | |
890 | 890 | $invoice_id = $invoice->ID; |
891 | 891 | $vat_name = $wpinv_euvat->get_vat_name(); |
892 | 892 | $use_taxes = wpinv_use_taxes(); |
893 | 893 | |
894 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
894 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
895 | 895 | |
896 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
897 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
896 | + if ($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
897 | + elseif ($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
898 | 898 | ?> |
899 | 899 | <table class="table table-bordered table-sm"> |
900 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
900 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
901 | 901 | <tr class="wpi-row-number"> |
902 | - <th><?php echo sprintf(__( '%s Number', 'invoicing' ), $type); ?></th> |
|
903 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
902 | + <th><?php echo sprintf(__('%s Number', 'invoicing'), $type); ?></th> |
|
903 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
904 | 904 | </tr> |
905 | 905 | <?php } ?> |
906 | 906 | <tr class="wpi-row-status"> |
907 | - <th><?php echo wp_sprintf(__( '%s Status', 'invoicing' ), $type); ?></th> |
|
908 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
907 | + <th><?php echo wp_sprintf(__('%s Status', 'invoicing'), $type); ?></th> |
|
908 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
909 | 909 | </tr> |
910 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
910 | + <?php if ($invoice->is_renewal()) { ?> |
|
911 | 911 | <tr class="wpi-row-parent"> |
912 | - <th><?php echo wp_sprintf(__( 'Parent %s', 'invoicing' ), $type); ?></th> |
|
913 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
912 | + <th><?php echo wp_sprintf(__('Parent %s', 'invoicing'), $type); ?></th> |
|
913 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
914 | 914 | </tr> |
915 | 915 | <?php } ?> |
916 | 916 | <tr class="wpi-row-gateway"> |
917 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
918 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
917 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
918 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
919 | 919 | </tr> |
920 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
920 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
921 | 921 | <tr class="wpi-row-date"> |
922 | - <th><?php echo wp_sprintf(__( '%s Date', 'invoicing' ), $type); ?></th> |
|
922 | + <th><?php echo wp_sprintf(__('%s Date', 'invoicing'), $type); ?></th> |
|
923 | 923 | <td><?php echo $invoice_date; ?></td> |
924 | 924 | </tr> |
925 | 925 | <?php } ?> |
926 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
926 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
927 | 927 | <tr class="wpi-row-date"> |
928 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
928 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
929 | 929 | <td><?php echo $due_date; ?></td> |
930 | 930 | </tr> |
931 | 931 | <?php } ?> |
932 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
932 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
933 | 933 | <tr class="wpi-row-ovatno"> |
934 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
934 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
935 | 935 | <td><?php echo $owner_vat_number; ?></td> |
936 | 936 | </tr> |
937 | 937 | <?php } ?> |
938 | - <?php if ( $use_taxes && $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
938 | + <?php if ($use_taxes && $user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
939 | 939 | <tr class="wpi-row-uvatno"> |
940 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
940 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
941 | 941 | <td><?php echo $user_vat_number; ?></td> |
942 | 942 | </tr> |
943 | 943 | <?php } ?> |
944 | 944 | <tr class="table-active tr-total wpi-row-total"> |
945 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
946 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
945 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
946 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
947 | 947 | </tr> |
948 | 948 | </table> |
949 | 949 | <?php |
950 | 950 | } |
951 | 951 | |
952 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
953 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
952 | +function wpinv_display_to_address($invoice_id = 0) { |
|
953 | + $invoice = wpinv_get_invoice($invoice_id); |
|
954 | 954 | |
955 | - if ( empty( $invoice ) ) { |
|
955 | + if (empty($invoice)) { |
|
956 | 956 | return NULL; |
957 | 957 | } |
958 | 958 | |
959 | 959 | $billing_details = $invoice->get_user_info(); |
960 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
960 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
961 | 961 | $output .= '<div class="wrapper col-xs-10">'; |
962 | 962 | |
963 | 963 | ob_start(); |
964 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
964 | + do_action('wpinv_display_to_address_top', $invoice); |
|
965 | 965 | $output .= ob_get_clean(); |
966 | 966 | |
967 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
968 | - if ( $company = $billing_details['company'] ) { |
|
969 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
967 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
968 | + if ($company = $billing_details['company']) { |
|
969 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
970 | 970 | } |
971 | 971 | $address_row = ''; |
972 | - if ( $address = $billing_details['address'] ) { |
|
973 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
972 | + if ($address = $billing_details['address']) { |
|
973 | + $address_row .= wpautop(wp_kses_post($address)); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | $address_fields = array(); |
977 | - if ( !empty( $billing_details['city'] ) ) { |
|
977 | + if (!empty($billing_details['city'])) { |
|
978 | 978 | $address_fields[] = $billing_details['city']; |
979 | 979 | } |
980 | 980 | |
981 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
982 | - if ( !empty( $billing_details['state'] ) ) { |
|
983 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
981 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
982 | + if (!empty($billing_details['state'])) { |
|
983 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
984 | 984 | } |
985 | 985 | |
986 | - if ( !empty( $billing_country ) ) { |
|
987 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
986 | + if (!empty($billing_country)) { |
|
987 | + $address_fields[] = wpinv_country_name($billing_country); |
|
988 | 988 | } |
989 | 989 | |
990 | - if ( !empty( $address_fields ) ) { |
|
991 | - $address_fields = implode( ", ", $address_fields ); |
|
990 | + if (!empty($address_fields)) { |
|
991 | + $address_fields = implode(", ", $address_fields); |
|
992 | 992 | |
993 | - if ( !empty( $billing_details['zip'] ) ) { |
|
993 | + if (!empty($billing_details['zip'])) { |
|
994 | 994 | $address_fields .= ' ' . $billing_details['zip']; |
995 | 995 | } |
996 | 996 | |
997 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
997 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
998 | 998 | } |
999 | 999 | |
1000 | - if ( $address_row ) { |
|
1000 | + if ($address_row) { |
|
1001 | 1001 | $output .= '<div class="address">' . $address_row . '</div>'; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - if ( $phone = $invoice->get_phone() ) { |
|
1005 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s' ), esc_html( $phone ) ) . '</div>'; |
|
1004 | + if ($phone = $invoice->get_phone()) { |
|
1005 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s'), esc_html($phone)) . '</div>'; |
|
1006 | 1006 | } |
1007 | - if ( $email = $invoice->get_email() ) { |
|
1008 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' ), esc_html( $email ) ) . '</div>'; |
|
1007 | + if ($email = $invoice->get_email()) { |
|
1008 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s'), esc_html($email)) . '</div>'; |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | ob_start(); |
1012 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
1012 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
1013 | 1013 | $output .= ob_get_clean(); |
1014 | 1014 | |
1015 | 1015 | $output .= '</div>'; |
1016 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1016 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1017 | 1017 | |
1018 | 1018 | echo $output; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1021 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1022 | 1022 | global $wpinv_euvat, $ajax_cart_details; |
1023 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1023 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1024 | 1024 | $quantities_enabled = wpinv_item_quantities_enabled(); |
1025 | 1025 | $use_taxes = wpinv_use_taxes(); |
1026 | 1026 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
1027 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
1028 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
1027 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
1028 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
1029 | 1029 | |
1030 | 1030 | $cart_details = $invoice->get_cart_details(); |
1031 | 1031 | $ajax_cart_details = $cart_details; |
@@ -1034,68 +1034,68 @@ discard block |
||
1034 | 1034 | <table class="table table-sm table-bordered table-responsive"> |
1035 | 1035 | <thead> |
1036 | 1036 | <tr> |
1037 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1038 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1037 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1038 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1039 | 1039 | <?php if ($quantities_enabled) { ?> |
1040 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1040 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1041 | 1041 | <?php } ?> |
1042 | 1042 | <?php if ($use_taxes && !$zero_tax) { ?> |
1043 | 1043 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1044 | 1044 | <?php } ?> |
1045 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1045 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1046 | 1046 | </tr> |
1047 | 1047 | </thead> |
1048 | 1048 | <tbody> |
1049 | 1049 | <?php |
1050 | - if ( !empty( $cart_details ) ) { |
|
1051 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1050 | + if (!empty($cart_details)) { |
|
1051 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1052 | 1052 | |
1053 | 1053 | $count = 0; |
1054 | 1054 | $cols = 3; |
1055 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1056 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1057 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1058 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1059 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1055 | + foreach ($cart_details as $key => $cart_item) { |
|
1056 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1057 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1058 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1059 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1060 | 1060 | |
1061 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1061 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1062 | 1062 | $summary = ''; |
1063 | 1063 | $cols = 3; |
1064 | - if ( !empty($item) ) { |
|
1064 | + if (!empty($item)) { |
|
1065 | 1065 | $item_name = $item->get_name(); |
1066 | 1066 | $summary = $item->get_summary(); |
1067 | 1067 | } |
1068 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1068 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1069 | 1069 | |
1070 | 1070 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1071 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1072 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_custom_singular_name(), $post_link ); |
|
1071 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1072 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_custom_singular_name(), $post_link); |
|
1073 | 1073 | } |
1074 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1074 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1075 | 1075 | |
1076 | 1076 | $item_tax = ''; |
1077 | 1077 | $tax_rate = ''; |
1078 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1079 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1080 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1081 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1078 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1079 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1080 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1081 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1082 | 1082 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | $line_item_tax = $item_tax . $tax_rate; |
1086 | 1086 | |
1087 | - if ( $line_item_tax === '' ) { |
|
1087 | + if ($line_item_tax === '') { |
|
1088 | 1088 | $line_item_tax = 0; // Zero tax |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1092 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1093 | - if ( $summary !== '' ) { |
|
1094 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1091 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1092 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1093 | + if ($summary !== '') { |
|
1094 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1095 | 1095 | } |
1096 | 1096 | $line_item .= '</td>'; |
1097 | 1097 | |
1098 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1098 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1099 | 1099 | if ($quantities_enabled) { |
1100 | 1100 | $cols++; |
1101 | 1101 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1104,55 +1104,55 @@ discard block |
||
1104 | 1104 | $cols++; |
1105 | 1105 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1106 | 1106 | } |
1107 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1107 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1108 | 1108 | $line_item .= '</tr>'; |
1109 | 1109 | |
1110 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1110 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1111 | 1111 | |
1112 | 1112 | $count++; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1115 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1116 | 1116 | ?> |
1117 | 1117 | <tr class="row-sub-total row_odd"> |
1118 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1119 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1118 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1119 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1120 | 1120 | </tr> |
1121 | 1121 | <?php |
1122 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1122 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1123 | 1123 | |
1124 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1125 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1124 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1125 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1126 | 1126 | ?> |
1127 | 1127 | <tr class="row-discount"> |
1128 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1129 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1128 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1129 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1130 | 1130 | </tr> |
1131 | 1131 | <?php |
1132 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1132 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | - if ( $use_taxes ) { |
|
1136 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1135 | + if ($use_taxes) { |
|
1136 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1137 | 1137 | ?> |
1138 | 1138 | <tr class="row-tax"> |
1139 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1140 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1139 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1140 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1141 | 1141 | </tr> |
1142 | 1142 | <?php |
1143 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1143 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1146 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1147 | 1147 | ?> |
1148 | 1148 | <tr class="table-active row-total"> |
1149 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1150 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1149 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1150 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1151 | 1151 | </tr> |
1152 | 1152 | <?php |
1153 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1153 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1154 | 1154 | |
1155 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1155 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1156 | 1156 | } |
1157 | 1157 | ?> |
1158 | 1158 | </tbody> |
@@ -1161,35 +1161,35 @@ discard block |
||
1161 | 1161 | echo ob_get_clean(); |
1162 | 1162 | } |
1163 | 1163 | |
1164 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1164 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1165 | 1165 | $use_taxes = wpinv_use_taxes(); |
1166 | 1166 | |
1167 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1167 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1168 | 1168 | ?> |
1169 | 1169 | <table class="table table-sm table-bordered table-responsive"> |
1170 | 1170 | <tbody> |
1171 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1171 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1172 | 1172 | <tr class="row-sub-total"> |
1173 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1174 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1173 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1174 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1175 | 1175 | </tr> |
1176 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1177 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1176 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1177 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1178 | 1178 | <tr class="row-discount"> |
1179 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1180 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1179 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1180 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1181 | 1181 | </tr> |
1182 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1182 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1183 | 1183 | <?php } ?> |
1184 | - <?php if ( $use_taxes ) { ?> |
|
1184 | + <?php if ($use_taxes) { ?> |
|
1185 | 1185 | <tr class="row-tax"> |
1186 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1187 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1186 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1187 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1188 | 1188 | </tr> |
1189 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1189 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1190 | 1190 | <?php } ?> |
1191 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1192 | - <?php foreach ( $fees as $fee ) { ?> |
|
1191 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1192 | + <?php foreach ($fees as $fee) { ?> |
|
1193 | 1193 | <tr class="row-fee"> |
1194 | 1194 | <td class="rate"><?php echo $fee['label']; ?></td> |
1195 | 1195 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1197,72 +1197,72 @@ discard block |
||
1197 | 1197 | <?php } ?> |
1198 | 1198 | <?php } ?> |
1199 | 1199 | <tr class="table-active row-total"> |
1200 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1201 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1200 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1201 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1202 | 1202 | </tr> |
1203 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1203 | + <?php do_action('wpinv_after_totals'); ?> |
|
1204 | 1204 | </tbody> |
1205 | 1205 | |
1206 | 1206 | </table> |
1207 | 1207 | |
1208 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1208 | + <?php do_action('wpinv_after_totals_table'); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1212 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1211 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1212 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1213 | 1213 | |
1214 | 1214 | ob_start(); |
1215 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1216 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1215 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1216 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1217 | 1217 | ?> |
1218 | 1218 | <div class="wpi-payment-info"> |
1219 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1220 | - <?php if ( $gateway_title ) { ?> |
|
1221 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1219 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1220 | + <?php if ($gateway_title) { ?> |
|
1221 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1222 | 1222 | <?php } ?> |
1223 | 1223 | </div> |
1224 | 1224 | <?php |
1225 | 1225 | } |
1226 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1226 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1227 | 1227 | $outout = ob_get_clean(); |
1228 | 1228 | |
1229 | - if ( $echo ) { |
|
1229 | + if ($echo) { |
|
1230 | 1230 | echo $outout; |
1231 | 1231 | } else { |
1232 | 1232 | return $outout; |
1233 | 1233 | } |
1234 | 1234 | } |
1235 | 1235 | |
1236 | -function wpinv_display_style( $invoice ) { |
|
1237 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1236 | +function wpinv_display_style($invoice) { |
|
1237 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1238 | 1238 | |
1239 | - wp_print_styles( 'open-sans' ); |
|
1240 | - wp_print_styles( 'wpinv-single-style' ); |
|
1239 | + wp_print_styles('open-sans'); |
|
1240 | + wp_print_styles('wpinv-single-style'); |
|
1241 | 1241 | } |
1242 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1242 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1243 | 1243 | |
1244 | 1244 | function wpinv_checkout_billing_details() { |
1245 | 1245 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1246 | 1246 | if (empty($invoice_id)) { |
1247 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1247 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1248 | 1248 | return null; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1251 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1252 | 1252 | if (empty($invoice)) { |
1253 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1253 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1254 | 1254 | return null; |
1255 | 1255 | } |
1256 | 1256 | $user_id = $invoice->get_user_id(); |
1257 | 1257 | $user_info = $invoice->get_user_info(); |
1258 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1258 | + $address_info = wpinv_get_user_address($user_id); |
|
1259 | 1259 | |
1260 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1260 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1261 | 1261 | $user_info['first_name'] = $user_info['first_name']; |
1262 | 1262 | $user_info['last_name'] = $user_info['last_name']; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1265 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1266 | 1266 | $user_info['country'] = $address_info['country']; |
1267 | 1267 | $user_info['state'] = $address_info['state']; |
1268 | 1268 | $user_info['city'] = $address_info['city']; |
@@ -1278,103 +1278,103 @@ discard block |
||
1278 | 1278 | 'address' |
1279 | 1279 | ); |
1280 | 1280 | |
1281 | - foreach ( $address_fields as $field ) { |
|
1282 | - if ( empty( $user_info[$field] ) ) { |
|
1281 | + foreach ($address_fields as $field) { |
|
1282 | + if (empty($user_info[$field])) { |
|
1283 | 1283 | $user_info[$field] = $address_info[$field]; |
1284 | 1284 | } |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1287 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | function wpinv_admin_get_line_items($invoice = array()) { |
1291 | 1291 | $item_quantities = wpinv_item_quantities_enabled(); |
1292 | 1292 | $use_taxes = wpinv_use_taxes(); |
1293 | 1293 | |
1294 | - if ( empty( $invoice ) ) { |
|
1294 | + if (empty($invoice)) { |
|
1295 | 1295 | return NULL; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | $cart_items = $invoice->get_cart_details(); |
1299 | - if ( empty( $cart_items ) ) { |
|
1299 | + if (empty($cart_items)) { |
|
1300 | 1300 | return NULL; |
1301 | 1301 | } |
1302 | 1302 | ob_start(); |
1303 | 1303 | |
1304 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1304 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1305 | 1305 | |
1306 | 1306 | $count = 0; |
1307 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1307 | + foreach ($cart_items as $key => $cart_item) { |
|
1308 | 1308 | $item_id = $cart_item['id']; |
1309 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1309 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1310 | 1310 | |
1311 | 1311 | if (empty($wpi_item)) { |
1312 | 1312 | continue; |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
1316 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1317 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
1315 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
1316 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1317 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
1318 | 1318 | $can_remove = true; |
1319 | 1319 | |
1320 | 1320 | $summary = ''; |
1321 | 1321 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1322 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1323 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_custom_singular_name(), $post_link ); |
|
1322 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1323 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_custom_singular_name(), $post_link); |
|
1324 | 1324 | } |
1325 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
1325 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
1326 | 1326 | |
1327 | 1327 | $item_tax = ''; |
1328 | 1328 | $tax_rate = ''; |
1329 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1330 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1331 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1332 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1329 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1330 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1331 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1332 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1333 | 1333 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1334 | 1334 | } |
1335 | 1335 | $line_item_tax = $item_tax . $tax_rate; |
1336 | 1336 | |
1337 | - if ( $line_item_tax === '' ) { |
|
1337 | + if ($line_item_tax === '') { |
|
1338 | 1338 | $line_item_tax = 0; // Zero tax |
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1341 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1342 | 1342 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1343 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1344 | - if ( $summary !== '' ) { |
|
1345 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1343 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1344 | + if ($summary !== '') { |
|
1345 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1346 | 1346 | } |
1347 | 1347 | $line_item .= '</td>'; |
1348 | 1348 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1349 | 1349 | |
1350 | - if ( $item_quantities ) { |
|
1351 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1350 | + if ($item_quantities) { |
|
1351 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1352 | 1352 | $can_remove = false; |
1353 | 1353 | } |
1354 | 1354 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1355 | 1355 | } else { |
1356 | - if ( count( $cart_items ) == 1 ) { |
|
1356 | + if (count($cart_items) == 1) { |
|
1357 | 1357 | $can_remove = false; |
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1361 | 1361 | |
1362 | - if ( $use_taxes ) { |
|
1362 | + if ($use_taxes) { |
|
1363 | 1363 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1364 | 1364 | } |
1365 | 1365 | $line_item .= '<td class="action">'; |
1366 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1366 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1367 | 1367 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1368 | 1368 | } |
1369 | 1369 | $line_item .= '</td>'; |
1370 | 1370 | $line_item .= '</tr>'; |
1371 | 1371 | |
1372 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1372 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1373 | 1373 | |
1374 | 1374 | $count++; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1377 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1378 | 1378 | |
1379 | 1379 | return ob_get_clean(); |
1380 | 1380 | } |
@@ -1385,35 +1385,35 @@ discard block |
||
1385 | 1385 | // Set current invoice id. |
1386 | 1386 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1387 | 1387 | |
1388 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1388 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1389 | 1389 | |
1390 | 1390 | ob_start(); |
1391 | 1391 | echo '<div id="wpinv_checkout_wrap">'; |
1392 | 1392 | |
1393 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1393 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1394 | 1394 | ?> |
1395 | 1395 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1396 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1396 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1397 | 1397 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1398 | 1398 | <?php |
1399 | - do_action( 'wpinv_checkout_form_top' ); |
|
1400 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1401 | - do_action( 'wpinv_checkout_cart' ); |
|
1402 | - do_action( 'wpinv_payment_mode_select' ); |
|
1403 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1399 | + do_action('wpinv_checkout_form_top'); |
|
1400 | + do_action('wpinv_checkout_billing_info'); |
|
1401 | + do_action('wpinv_checkout_cart'); |
|
1402 | + do_action('wpinv_payment_mode_select'); |
|
1403 | + do_action('wpinv_checkout_form_bottom') |
|
1404 | 1404 | ?> |
1405 | 1405 | </form> |
1406 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1406 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1407 | 1407 | </div><!--end #wpinv_checkout_form_wrap--> |
1408 | 1408 | <?php |
1409 | 1409 | } else { |
1410 | - do_action( 'wpinv_cart_empty' ); |
|
1410 | + do_action('wpinv_cart_empty'); |
|
1411 | 1411 | } |
1412 | 1412 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1413 | 1413 | return ob_get_clean(); |
1414 | 1414 | } |
1415 | 1415 | |
1416 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1416 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1417 | 1417 | global $ajax_cart_details; |
1418 | 1418 | $ajax_cart_details = $cart_details; |
1419 | 1419 | /* |
@@ -1428,25 +1428,25 @@ discard block |
||
1428 | 1428 | } |
1429 | 1429 | */ |
1430 | 1430 | ob_start(); |
1431 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1431 | + do_action('wpinv_before_checkout_cart'); |
|
1432 | 1432 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1433 | 1433 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1434 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1434 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1435 | 1435 | echo '</div>'; |
1436 | 1436 | echo '</div>'; |
1437 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1437 | + do_action('wpinv_after_checkout_cart'); |
|
1438 | 1438 | $content = ob_get_clean(); |
1439 | 1439 | |
1440 | - if ( $echo ) { |
|
1440 | + if ($echo) { |
|
1441 | 1441 | echo $content; |
1442 | 1442 | } else { |
1443 | 1443 | return $content; |
1444 | 1444 | } |
1445 | 1445 | } |
1446 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1446 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1447 | 1447 | |
1448 | 1448 | function wpinv_empty_cart_message() { |
1449 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1449 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | /** |
@@ -1458,91 +1458,91 @@ discard block |
||
1458 | 1458 | function wpinv_empty_checkout_cart() { |
1459 | 1459 | echo wpinv_empty_cart_message(); |
1460 | 1460 | } |
1461 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1461 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1462 | 1462 | |
1463 | 1463 | function wpinv_save_cart_button() { |
1464 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1464 | + if (wpinv_is_cart_saving_disabled()) |
|
1465 | 1465 | return; |
1466 | 1466 | ?> |
1467 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
1467 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
1468 | 1468 | <?php |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | function wpinv_update_cart_button() { |
1472 | - if ( !wpinv_item_quantities_enabled() ) |
|
1472 | + if (!wpinv_item_quantities_enabled()) |
|
1473 | 1473 | return; |
1474 | 1474 | ?> |
1475 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1475 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1476 | 1476 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1477 | 1477 | <?php |
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | function wpinv_checkout_cart_columns() { |
1481 | 1481 | $default = 3; |
1482 | - if ( wpinv_item_quantities_enabled() ) { |
|
1482 | + if (wpinv_item_quantities_enabled()) { |
|
1483 | 1483 | $default++; |
1484 | 1484 | } |
1485 | 1485 | |
1486 | - if ( wpinv_use_taxes() ) { |
|
1486 | + if (wpinv_use_taxes()) { |
|
1487 | 1487 | $default++; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1490 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | function wpinv_display_cart_messages() { |
1494 | 1494 | global $wpi_session; |
1495 | 1495 | |
1496 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1496 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1497 | 1497 | |
1498 | - if ( $messages ) { |
|
1499 | - foreach ( $messages as $message_id => $message ) { |
|
1498 | + if ($messages) { |
|
1499 | + foreach ($messages as $message_id => $message) { |
|
1500 | 1500 | // Try and detect what type of message this is |
1501 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1501 | + if (strpos(strtolower($message), 'error')) { |
|
1502 | 1502 | $type = 'error'; |
1503 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1503 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1504 | 1504 | $type = 'success'; |
1505 | 1505 | } else { |
1506 | 1506 | $type = 'info'; |
1507 | 1507 | } |
1508 | 1508 | |
1509 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1509 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1510 | 1510 | |
1511 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1511 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1512 | 1512 | // Loop message codes and display messages |
1513 | 1513 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1514 | 1514 | echo '</div>'; |
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | // Remove all of the cart saving messages |
1518 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1518 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1519 | 1519 | } |
1520 | 1520 | } |
1521 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1521 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1522 | 1522 | |
1523 | 1523 | function wpinv_discount_field() { |
1524 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1524 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1525 | 1525 | return; // Only show before a payment method has been selected if ajax is disabled |
1526 | 1526 | } |
1527 | 1527 | |
1528 | - if ( !wpinv_is_checkout() ) { |
|
1528 | + if (!wpinv_is_checkout()) { |
|
1529 | 1529 | return; |
1530 | 1530 | } |
1531 | 1531 | |
1532 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1532 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1533 | 1533 | ?> |
1534 | 1534 | <div id="wpinv-discount-field" class="panel panel-default"> |
1535 | 1535 | <div class="panel-body"> |
1536 | 1536 | <p> |
1537 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1538 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1537 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1538 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1539 | 1539 | </p> |
1540 | 1540 | <div class="form-group row"> |
1541 | 1541 | <div class="col-sm-4"> |
1542 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1542 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1543 | 1543 | </div> |
1544 | 1544 | <div class="col-sm-3"> |
1545 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1545 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1546 | 1546 | </div> |
1547 | 1547 | <div style="clear:both"></div> |
1548 | 1548 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1555,10 +1555,10 @@ discard block |
||
1555 | 1555 | <?php |
1556 | 1556 | } |
1557 | 1557 | } |
1558 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1558 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1559 | 1559 | |
1560 | 1560 | function wpinv_agree_to_terms_js() { |
1561 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1561 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1562 | 1562 | ?> |
1563 | 1563 | <script type="text/javascript"> |
1564 | 1564 | jQuery(document).ready(function($){ |
@@ -1573,126 +1573,126 @@ discard block |
||
1573 | 1573 | <?php |
1574 | 1574 | } |
1575 | 1575 | } |
1576 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1576 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1577 | 1577 | |
1578 | 1578 | function wpinv_payment_mode_select() { |
1579 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1580 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1579 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1580 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1581 | 1581 | $page_URL = wpinv_get_current_page_url(); |
1582 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1582 | + $invoice = wpinv_get_invoice(0, true); |
|
1583 | 1583 | |
1584 | 1584 | do_action('wpinv_payment_mode_top'); |
1585 | 1585 | $invoice_id = (int)$invoice->ID; |
1586 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1586 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1587 | 1587 | ?> |
1588 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;"' : '' ); ?>> |
|
1589 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1588 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;"' : ''); ?>> |
|
1589 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1590 | 1590 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1591 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1591 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1592 | 1592 | <div class="panel-body list-group wpi-payment_methods"> |
1593 | 1593 | <?php |
1594 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1594 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1595 | 1595 | |
1596 | - if(!empty($gateways)){ |
|
1597 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1598 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1599 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1600 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1596 | + if (!empty($gateways)) { |
|
1597 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1598 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1599 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1600 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1601 | 1601 | ?> |
1602 | 1602 | <div class="list-group-item"> |
1603 | 1603 | <div class="radio"> |
1604 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1604 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1605 | 1605 | </div> |
1606 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1607 | - <?php if ( !empty( $description ) ) { ?> |
|
1608 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1606 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1607 | + <?php if (!empty($description)) { ?> |
|
1608 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1609 | 1609 | <?php } ?> |
1610 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1610 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1611 | 1611 | </div> |
1612 | 1612 | </div> |
1613 | 1613 | <?php |
1614 | 1614 | } |
1615 | - }else{ |
|
1616 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1615 | + } else { |
|
1616 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1617 | 1617 | } |
1618 | 1618 | |
1619 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1619 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1620 | 1620 | ?> |
1621 | 1621 | </div> |
1622 | 1622 | </div> |
1623 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1623 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1624 | 1624 | </div> |
1625 | 1625 | <?php |
1626 | 1626 | do_action('wpinv_payment_mode_bottom'); |
1627 | 1627 | } |
1628 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1628 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1629 | 1629 | |
1630 | 1630 | function wpinv_checkout_billing_info() { |
1631 | - if ( wpinv_is_checkout() ) { |
|
1631 | + if (wpinv_is_checkout()) { |
|
1632 | 1632 | $logged_in = is_user_logged_in(); |
1633 | 1633 | $billing_details = wpinv_checkout_billing_details(); |
1634 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1634 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1635 | 1635 | ?> |
1636 | 1636 | <div id="wpinv-fields" class="clearfix"> |
1637 | 1637 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1638 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1638 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1639 | 1639 | <div id="wpinv-fields-box" class="panel-body"> |
1640 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1640 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1641 | 1641 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1642 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1642 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1643 | 1643 | <?php |
1644 | - echo wpinv_html_text( array( |
|
1644 | + echo wpinv_html_text(array( |
|
1645 | 1645 | 'id' => 'wpinv_first_name', |
1646 | 1646 | 'name' => 'wpinv_first_name', |
1647 | 1647 | 'value' => $billing_details['first_name'], |
1648 | 1648 | 'class' => 'wpi-input form-control', |
1649 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1650 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1651 | - ) ); |
|
1649 | + 'placeholder' => __('First name', 'invoicing'), |
|
1650 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1651 | + )); |
|
1652 | 1652 | ?> |
1653 | 1653 | </p> |
1654 | 1654 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1655 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1655 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1656 | 1656 | <?php |
1657 | - echo wpinv_html_text( array( |
|
1657 | + echo wpinv_html_text(array( |
|
1658 | 1658 | 'id' => 'wpinv_last_name', |
1659 | 1659 | 'name' => 'wpinv_last_name', |
1660 | 1660 | 'value' => $billing_details['last_name'], |
1661 | 1661 | 'class' => 'wpi-input form-control', |
1662 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1663 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1664 | - ) ); |
|
1662 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1663 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1664 | + )); |
|
1665 | 1665 | ?> |
1666 | 1666 | </p> |
1667 | 1667 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1668 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1668 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1669 | 1669 | <?php |
1670 | - echo wpinv_html_text( array( |
|
1670 | + echo wpinv_html_text(array( |
|
1671 | 1671 | 'id' => 'wpinv_address', |
1672 | 1672 | 'name' => 'wpinv_address', |
1673 | 1673 | 'value' => $billing_details['address'], |
1674 | 1674 | 'class' => 'wpi-input form-control', |
1675 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1676 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1677 | - ) ); |
|
1675 | + 'placeholder' => __('Address', 'invoicing'), |
|
1676 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1677 | + )); |
|
1678 | 1678 | ?> |
1679 | 1679 | </p> |
1680 | 1680 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1681 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1681 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1682 | 1682 | <?php |
1683 | - echo wpinv_html_text( array( |
|
1683 | + echo wpinv_html_text(array( |
|
1684 | 1684 | 'id' => 'wpinv_city', |
1685 | 1685 | 'name' => 'wpinv_city', |
1686 | 1686 | 'value' => $billing_details['city'], |
1687 | 1687 | 'class' => 'wpi-input form-control', |
1688 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1689 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1690 | - ) ); |
|
1688 | + 'placeholder' => __('City', 'invoicing'), |
|
1689 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1690 | + )); |
|
1691 | 1691 | ?> |
1692 | 1692 | </p> |
1693 | 1693 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1694 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1695 | - <?php echo wpinv_html_select( array( |
|
1694 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1695 | + <?php echo wpinv_html_select(array( |
|
1696 | 1696 | 'options' => wpinv_get_country_list(), |
1697 | 1697 | 'name' => 'wpinv_country', |
1698 | 1698 | 'id' => 'wpinv_country', |
@@ -1700,16 +1700,16 @@ discard block |
||
1700 | 1700 | 'show_option_all' => false, |
1701 | 1701 | 'show_option_none' => false, |
1702 | 1702 | 'class' => 'wpi-input form-control', |
1703 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1704 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1705 | - ) ); ?> |
|
1703 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1704 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1705 | + )); ?> |
|
1706 | 1706 | </p> |
1707 | 1707 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1708 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1708 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1709 | 1709 | <?php |
1710 | - $states = wpinv_get_country_states( $selected_country ); |
|
1711 | - if( !empty( $states ) ) { |
|
1712 | - echo wpinv_html_select( array( |
|
1710 | + $states = wpinv_get_country_states($selected_country); |
|
1711 | + if (!empty($states)) { |
|
1712 | + echo wpinv_html_select(array( |
|
1713 | 1713 | 'options' => $states, |
1714 | 1714 | 'name' => 'wpinv_state', |
1715 | 1715 | 'id' => 'wpinv_state', |
@@ -1717,61 +1717,61 @@ discard block |
||
1717 | 1717 | 'show_option_all' => false, |
1718 | 1718 | 'show_option_none' => false, |
1719 | 1719 | 'class' => 'wpi-input form-control', |
1720 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1721 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1722 | - ) ); |
|
1720 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1721 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1722 | + )); |
|
1723 | 1723 | } else { |
1724 | - echo wpinv_html_text( array( |
|
1724 | + echo wpinv_html_text(array( |
|
1725 | 1725 | 'name' => 'wpinv_state', |
1726 | 1726 | 'value' => $billing_details['state'], |
1727 | 1727 | 'id' => 'wpinv_state', |
1728 | 1728 | 'class' => 'wpi-input form-control', |
1729 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1730 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1731 | - ) ); |
|
1729 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1730 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1731 | + )); |
|
1732 | 1732 | } |
1733 | 1733 | ?> |
1734 | 1734 | </p> |
1735 | 1735 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1736 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1736 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1737 | 1737 | <?php |
1738 | - echo wpinv_html_text( array( |
|
1738 | + echo wpinv_html_text(array( |
|
1739 | 1739 | 'name' => 'wpinv_zip', |
1740 | 1740 | 'value' => $billing_details['zip'], |
1741 | 1741 | 'id' => 'wpinv_zip', |
1742 | 1742 | 'class' => 'wpi-input form-control', |
1743 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1744 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1745 | - ) ); |
|
1743 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1744 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1745 | + )); |
|
1746 | 1746 | ?> |
1747 | 1747 | </p> |
1748 | 1748 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1749 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1749 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1750 | 1750 | <?php |
1751 | - echo wpinv_html_text( array( |
|
1751 | + echo wpinv_html_text(array( |
|
1752 | 1752 | 'id' => 'wpinv_phone', |
1753 | 1753 | 'name' => 'wpinv_phone', |
1754 | 1754 | 'value' => $billing_details['phone'], |
1755 | 1755 | 'class' => 'wpi-input form-control', |
1756 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1757 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1758 | - ) ); |
|
1756 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1757 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1758 | + )); |
|
1759 | 1759 | ?> |
1760 | 1760 | </p> |
1761 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1761 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1762 | 1762 | <div class="clearfix"></div> |
1763 | 1763 | </div> |
1764 | 1764 | </div> |
1765 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1765 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1766 | 1766 | </div> |
1767 | 1767 | <?php |
1768 | 1768 | } |
1769 | 1769 | } |
1770 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1770 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1771 | 1771 | |
1772 | 1772 | function wpinv_checkout_hidden_fields() { |
1773 | 1773 | ?> |
1774 | - <?php if ( is_user_logged_in() ) { ?> |
|
1774 | + <?php if (is_user_logged_in()) { ?> |
|
1775 | 1775 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1776 | 1776 | <?php } ?> |
1777 | 1777 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1781,9 +1781,9 @@ discard block |
||
1781 | 1781 | function wpinv_checkout_button_purchase() { |
1782 | 1782 | ob_start(); |
1783 | 1783 | ?> |
1784 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1784 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1785 | 1785 | <?php |
1786 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1786 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | function wpinv_checkout_total() { |
@@ -1792,96 +1792,96 @@ discard block |
||
1792 | 1792 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1793 | 1793 | <div class="panel-body"> |
1794 | 1794 | <?php |
1795 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1795 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1796 | 1796 | ?> |
1797 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1797 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1798 | 1798 | <?php |
1799 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1799 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1800 | 1800 | ?> |
1801 | 1801 | </div> |
1802 | 1802 | </div> |
1803 | 1803 | <?php |
1804 | 1804 | } |
1805 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1805 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1806 | 1806 | |
1807 | 1807 | function wpinv_checkout_submit() { |
1808 | 1808 | ?> |
1809 | 1809 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1810 | 1810 | <div class="panel-body text-center"> |
1811 | 1811 | <?php |
1812 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1812 | + do_action('wpinv_purchase_form_before_submit'); |
|
1813 | 1813 | wpinv_checkout_hidden_fields(); |
1814 | 1814 | echo wpinv_checkout_button_purchase(); |
1815 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1815 | + do_action('wpinv_purchase_form_after_submit'); |
|
1816 | 1816 | ?> |
1817 | 1817 | </div> |
1818 | 1818 | </div> |
1819 | 1819 | <?php |
1820 | 1820 | } |
1821 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1821 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1822 | 1822 | |
1823 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1824 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1823 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1824 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1825 | 1825 | |
1826 | - if ( empty( $invoice ) ) { |
|
1826 | + if (empty($invoice)) { |
|
1827 | 1827 | return NULL; |
1828 | 1828 | } |
1829 | 1829 | |
1830 | 1830 | $billing_details = $invoice->get_user_info(); |
1831 | 1831 | $address_row = ''; |
1832 | - if ( $address = $billing_details['address'] ) { |
|
1833 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1832 | + if ($address = $billing_details['address']) { |
|
1833 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1834 | 1834 | } |
1835 | 1835 | |
1836 | 1836 | $address_fields = array(); |
1837 | - if ( !empty( $billing_details['city'] ) ) { |
|
1837 | + if (!empty($billing_details['city'])) { |
|
1838 | 1838 | $address_fields[] = $billing_details['city']; |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1842 | - if ( !empty( $billing_details['state'] ) ) { |
|
1843 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1841 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1842 | + if (!empty($billing_details['state'])) { |
|
1843 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1844 | 1844 | } |
1845 | 1845 | |
1846 | - if ( !empty( $billing_country ) ) { |
|
1847 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1846 | + if (!empty($billing_country)) { |
|
1847 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1848 | 1848 | } |
1849 | 1849 | |
1850 | - if ( !empty( $address_fields ) ) { |
|
1851 | - $address_fields = implode( ", ", $address_fields ); |
|
1850 | + if (!empty($address_fields)) { |
|
1851 | + $address_fields = implode(", ", $address_fields); |
|
1852 | 1852 | |
1853 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1853 | + if (!empty($billing_details['zip'])) { |
|
1854 | 1854 | $address_fields .= ' ' . $billing_details['zip']; |
1855 | 1855 | } |
1856 | 1856 | |
1857 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1857 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1858 | 1858 | } |
1859 | 1859 | ob_start(); |
1860 | 1860 | ?> |
1861 | 1861 | <table class="table table-bordered table-sm wpi-billing-details"> |
1862 | 1862 | <tbody> |
1863 | 1863 | <tr class="wpi-receipt-name"> |
1864 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1865 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1864 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1865 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1866 | 1866 | </tr> |
1867 | 1867 | <tr class="wpi-receipt-email"> |
1868 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1869 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1868 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1869 | + <td><?php echo $billing_details['email']; ?></td> |
|
1870 | 1870 | </tr> |
1871 | - <?php if ( $billing_details['company'] ) { ?> |
|
1871 | + <?php if ($billing_details['company']) { ?> |
|
1872 | 1872 | <tr class="wpi-receipt-company"> |
1873 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1874 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1873 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1874 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1875 | 1875 | </tr> |
1876 | 1876 | <?php } ?> |
1877 | 1877 | <tr class="wpi-receipt-address"> |
1878 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1879 | - <td><?php echo $address_row ;?></td> |
|
1878 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1879 | + <td><?php echo $address_row; ?></td> |
|
1880 | 1880 | </tr> |
1881 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1881 | + <?php if ($billing_details['phone']) { ?> |
|
1882 | 1882 | <tr class="wpi-receipt-phone"> |
1883 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1884 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1883 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1884 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1885 | 1885 | </tr> |
1886 | 1886 | <?php } ?> |
1887 | 1887 | </tbody> |
@@ -1889,103 +1889,103 @@ discard block |
||
1889 | 1889 | <?php |
1890 | 1890 | $output = ob_get_clean(); |
1891 | 1891 | |
1892 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1892 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1893 | 1893 | |
1894 | 1894 | echo $output; |
1895 | 1895 | } |
1896 | 1896 | |
1897 | -function wpinv_filter_success_page_content( $content ) { |
|
1898 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1899 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1900 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1897 | +function wpinv_filter_success_page_content($content) { |
|
1898 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1899 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1900 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1901 | 1901 | } |
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | return $content; |
1905 | 1905 | } |
1906 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1906 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1907 | 1907 | |
1908 | -function wpinv_receipt_actions( $invoice ) { |
|
1909 | - if ( !empty( $invoice ) ) { |
|
1908 | +function wpinv_receipt_actions($invoice) { |
|
1909 | + if (!empty($invoice)) { |
|
1910 | 1910 | $actions = array(); |
1911 | 1911 | |
1912 | - if ( wpinv_user_can_print_invoice( $invoice->ID ) ) { |
|
1913 | - $actions['print'] = array( |
|
1914 | - 'url' => $invoice->get_view_url( false, true ), |
|
1915 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1912 | + if (wpinv_user_can_print_invoice($invoice->ID)) { |
|
1913 | + $actions['print'] = array( |
|
1914 | + 'url' => $invoice->get_view_url(false, true), |
|
1915 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1916 | 1916 | 'class' => 'btn-primary', |
1917 | 1917 | ); |
1918 | 1918 | } |
1919 | 1919 | |
1920 | - if ( is_user_logged_in() ) { |
|
1920 | + if (is_user_logged_in()) { |
|
1921 | 1921 | $actions['history'] = array( |
1922 | 1922 | 'url' => wpinv_get_history_page_uri(), |
1923 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1923 | + 'name' => __('Invoice History', 'invoicing'), |
|
1924 | 1924 | 'class' => 'btn-warning', |
1925 | 1925 | ); |
1926 | 1926 | } |
1927 | 1927 | |
1928 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1928 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1929 | 1929 | |
1930 | - if ( !empty( $actions ) ) { |
|
1930 | + if (!empty($actions)) { |
|
1931 | 1931 | ?> |
1932 | 1932 | <div class="wpinv-receipt-actions text-right"> |
1933 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1934 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1933 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1934 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1935 | 1935 | <?php } ?> |
1936 | 1936 | </div> |
1937 | 1937 | <?php |
1938 | 1938 | } |
1939 | 1939 | } |
1940 | 1940 | } |
1941 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1941 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1942 | 1942 | |
1943 | -function wpinv_invoice_link( $invoice_id ) { |
|
1944 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1943 | +function wpinv_invoice_link($invoice_id) { |
|
1944 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1945 | 1945 | |
1946 | - if ( empty( $invoice ) ) { |
|
1946 | + if (empty($invoice)) { |
|
1947 | 1947 | return NULL; |
1948 | 1948 | } |
1949 | 1949 | |
1950 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1950 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1951 | 1951 | |
1952 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1952 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1956 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1955 | +function wpinv_invoice_subscription_details($invoice) { |
|
1956 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1957 | 1957 | $total_payments = (int)$invoice->get_total_payments(); |
1958 | 1958 | $payments = $invoice->get_child_payments(); |
1959 | 1959 | |
1960 | 1960 | $subscription = $invoice->get_subscription_data(); |
1961 | 1961 | |
1962 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
1962 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
1963 | 1963 | return; |
1964 | 1964 | } |
1965 | 1965 | |
1966 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
1967 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
1966 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
1967 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
1968 | 1968 | |
1969 | 1969 | $subscription_status = $invoice->get_subscription_status(); |
1970 | 1970 | |
1971 | 1971 | $status_desc = ''; |
1972 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
1973 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
1974 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
1975 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
1972 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
1973 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
1974 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
1975 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
1976 | 1976 | } |
1977 | 1977 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
1978 | 1978 | ?> |
1979 | 1979 | <div class="wpinv-subscriptions-details"> |
1980 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1980 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1981 | 1981 | <table class="table"> |
1982 | 1982 | <thead> |
1983 | 1983 | <tr> |
1984 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1985 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1986 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1987 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1988 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1984 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1985 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1986 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1987 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1988 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1989 | 1989 | </tr> |
1990 | 1990 | </thead> |
1991 | 1991 | <tbody> |
@@ -1994,32 +1994,32 @@ discard block |
||
1994 | 1994 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
1995 | 1995 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
1996 | 1996 | <td class="text-center"><?php echo $times_billed; ?></td> |
1997 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
1997 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
1998 | 1998 | <?php echo $status_desc; ?> |
1999 | 1999 | </td> |
2000 | 2000 | </tr> |
2001 | 2001 | </tbody> |
2002 | 2002 | </table> |
2003 | 2003 | </div> |
2004 | - <?php if ( !empty( $payments ) ) { ?> |
|
2004 | + <?php if (!empty($payments)) { ?> |
|
2005 | 2005 | <div class="wpinv-renewal-payments"> |
2006 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
2006 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
2007 | 2007 | <table class="table"> |
2008 | 2008 | <thead> |
2009 | 2009 | <tr> |
2010 | 2010 | <th>#</th> |
2011 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
2012 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2013 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
2011 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
2012 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2013 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2014 | 2014 | </tr> |
2015 | 2015 | </thead> |
2016 | 2016 | <tbody> |
2017 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
2017 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
2018 | 2018 | <tr> |
2019 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
2020 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2021 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2022 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2019 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
2020 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2021 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2022 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2023 | 2023 | </tr> |
2024 | 2024 | <?php } ?> |
2025 | 2025 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2031,52 +2031,52 @@ discard block |
||
2031 | 2031 | } |
2032 | 2032 | } |
2033 | 2033 | |
2034 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2035 | - if ( empty( $invoice ) ) { |
|
2034 | +function wpinv_cart_total_label($label, $invoice) { |
|
2035 | + if (empty($invoice)) { |
|
2036 | 2036 | return $label; |
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | $prefix_label = ''; |
2040 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2041 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2042 | - } else if ( $invoice->is_renewal() ) { |
|
2043 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2040 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2041 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2042 | + } else if ($invoice->is_renewal()) { |
|
2043 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2044 | 2044 | } |
2045 | 2045 | |
2046 | - if ( $prefix_label != '' ) { |
|
2047 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2046 | + if ($prefix_label != '') { |
|
2047 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | return $label; |
2051 | 2051 | } |
2052 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2053 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2054 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2052 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2053 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2054 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2055 | 2055 | |
2056 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2056 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2057 | 2057 | |
2058 | -function wpinv_invoice_print_description( $invoice ) { |
|
2059 | - if ( empty( $invoice ) ) { |
|
2058 | +function wpinv_invoice_print_description($invoice) { |
|
2059 | + if (empty($invoice)) { |
|
2060 | 2060 | return NULL; |
2061 | 2061 | } |
2062 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2062 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2063 | 2063 | ?> |
2064 | 2064 | <div class="row wpinv-lower"> |
2065 | 2065 | <div class="col-sm-12 wpinv-description"> |
2066 | - <?php echo wpautop( $description ); ?> |
|
2066 | + <?php echo wpautop($description); ?> |
|
2067 | 2067 | </div> |
2068 | 2068 | </div> |
2069 | 2069 | <?php |
2070 | 2070 | } |
2071 | 2071 | } |
2072 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2072 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2073 | 2073 | |
2074 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2075 | - if ( empty( $invoice ) ) { |
|
2074 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2075 | + if (empty($invoice)) { |
|
2076 | 2076 | return NULL; |
2077 | 2077 | } |
2078 | 2078 | |
2079 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2079 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2080 | 2080 | ?> |
2081 | 2081 | <div class="row wpinv-payments"> |
2082 | 2082 | <div class="col-sm-12"> |
@@ -2088,43 +2088,43 @@ discard block |
||
2088 | 2088 | } |
2089 | 2089 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2090 | 2090 | |
2091 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2092 | - if ( empty( $note ) ) { |
|
2091 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2092 | + if (empty($note)) { |
|
2093 | 2093 | return NULL; |
2094 | 2094 | } |
2095 | 2095 | |
2096 | - if ( is_int( $note ) ) { |
|
2097 | - $note = get_comment( $note ); |
|
2096 | + if (is_int($note)) { |
|
2097 | + $note = get_comment($note); |
|
2098 | 2098 | } |
2099 | 2099 | |
2100 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2100 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2101 | 2101 | return NULL; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | - $note_classes = array( 'note' ); |
|
2105 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2106 | - $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : ''; |
|
2107 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2108 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2104 | + $note_classes = array('note'); |
|
2105 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2106 | + $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : ''; |
|
2107 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2108 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2109 | 2109 | |
2110 | 2110 | ob_start(); |
2111 | 2111 | ?> |
2112 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2112 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2113 | 2113 | <div class="note_content"> |
2114 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2114 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2115 | 2115 | </div> |
2116 | 2116 | <p class="meta"> |
2117 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2118 | - <?php if($note->comment_author !== 'System') {?> |
|
2119 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2117 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2118 | + <?php if ($note->comment_author !== 'System') {?> |
|
2119 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2120 | 2120 | <?php } ?> |
2121 | 2121 | </p> |
2122 | 2122 | </li> |
2123 | 2123 | <?php |
2124 | 2124 | $note_content = ob_get_clean(); |
2125 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2125 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2126 | 2126 | |
2127 | - if ( $echo ) { |
|
2127 | + if ($echo) { |
|
2128 | 2128 | echo $note_content; |
2129 | 2129 | } else { |
2130 | 2130 | return $note_content; |
@@ -169,8 +169,9 @@ discard block |
||
169 | 169 | |
170 | 170 | // Setup possible parts |
171 | 171 | $templates = array(); |
172 | - if ( isset( $name ) ) |
|
173 | - $templates[] = $slug . '-' . $name . '.php'; |
|
172 | + if ( isset( $name ) ) { |
|
173 | + $templates[] = $slug . '-' . $name . '.php'; |
|
174 | + } |
|
174 | 175 | $templates[] = $slug . '.php'; |
175 | 176 | |
176 | 177 | // Allow template parts to be filtered |
@@ -188,8 +189,9 @@ discard block |
||
188 | 189 | foreach ( (array)$template_names as $template_name ) { |
189 | 190 | |
190 | 191 | // Continue if template is empty |
191 | - if ( empty( $template_name ) ) |
|
192 | - continue; |
|
192 | + if ( empty( $template_name ) ) { |
|
193 | + continue; |
|
194 | + } |
|
193 | 195 | |
194 | 196 | // Trim off any slashes from the template name |
195 | 197 | $template_name = ltrim( $template_name, '/' ); |
@@ -208,8 +210,9 @@ discard block |
||
208 | 210 | } |
209 | 211 | } |
210 | 212 | |
211 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
212 | - load_template( $located, $require_once ); |
|
213 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
214 | + load_template( $located, $require_once ); |
|
215 | + } |
|
213 | 216 | |
214 | 217 | return $located; |
215 | 218 | } |
@@ -285,8 +288,9 @@ discard block |
||
285 | 288 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
286 | 289 | $args = array( 'nopaging' => true ); |
287 | 290 | |
288 | - if ( ! empty( $status ) ) |
|
289 | - $args['post_status'] = $status; |
|
291 | + if ( ! empty( $status ) ) { |
|
292 | + $args['post_status'] = $status; |
|
293 | + } |
|
290 | 294 | |
291 | 295 | $discounts = wpinv_get_discounts( $args ); |
292 | 296 | $options = array(); |
@@ -893,8 +897,11 @@ discard block |
||
893 | 897 | |
894 | 898 | $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
895 | 899 | |
896 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
897 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
900 | + if($invoice->post_type == 'wpi_invoice') { |
|
901 | + $type = 'Invoice'; |
|
902 | + } elseif($invoice->post_type == 'wpi_quote') { |
|
903 | + $type = 'Quote'; |
|
904 | + } |
|
898 | 905 | ?> |
899 | 906 | <table class="table table-bordered table-sm"> |
900 | 907 | <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
@@ -1461,17 +1468,19 @@ discard block |
||
1461 | 1468 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1462 | 1469 | |
1463 | 1470 | function wpinv_save_cart_button() { |
1464 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1465 | - return; |
|
1466 | -?> |
|
1471 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
1472 | + return; |
|
1473 | + } |
|
1474 | + ?> |
|
1467 | 1475 | <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
1468 | 1476 | <?php |
1469 | 1477 | } |
1470 | 1478 | |
1471 | 1479 | function wpinv_update_cart_button() { |
1472 | - if ( !wpinv_item_quantities_enabled() ) |
|
1473 | - return; |
|
1474 | -?> |
|
1480 | + if ( !wpinv_item_quantities_enabled() ) { |
|
1481 | + return; |
|
1482 | + } |
|
1483 | + ?> |
|
1475 | 1484 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
1476 | 1485 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1477 | 1486 | <?php |
@@ -1612,7 +1621,7 @@ discard block |
||
1612 | 1621 | </div> |
1613 | 1622 | <?php |
1614 | 1623 | } |
1615 | - }else{ |
|
1624 | + } else{ |
|
1616 | 1625 | echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
1617 | 1626 | } |
1618 | 1627 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -function wpinv_get_subscriptions( $args = array() ) { |
|
3 | - if ( empty( $args['parent_invoice_id'] ) ) { |
|
2 | +function wpinv_get_subscriptions($args = array()) { |
|
3 | + if (empty($args['parent_invoice_id'])) { |
|
4 | 4 | return false; |
5 | 5 | } |
6 | 6 | |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | ); |
15 | 15 | |
16 | 16 | $args['post_parent'] = $args['parent_invoice_id']; |
17 | - $args = wp_parse_args( $args, $defaults ); |
|
17 | + $args = wp_parse_args($args, $defaults); |
|
18 | 18 | |
19 | - if( $args['numberposts'] < 1 ) { |
|
19 | + if ($args['numberposts'] < 1) { |
|
20 | 20 | $args['numberposts'] = 999999999999; |
21 | 21 | } |
22 | 22 | |
23 | - $posts = get_posts( $args ); |
|
23 | + $posts = get_posts($args); |
|
24 | 24 | $subscriptions = array(); |
25 | - if ( !empty( $posts ) ) { |
|
26 | - foreach ( $posts as $post ) { |
|
27 | - if ( !empty( $post->ID ) ) { |
|
28 | - $subscriptions[] = wpinv_get_invoice( $post->ID ); |
|
25 | + if (!empty($posts)) { |
|
26 | + foreach ($posts as $post) { |
|
27 | + if (!empty($post->ID)) { |
|
28 | + $subscriptions[] = wpinv_get_invoice($post->ID); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | |
34 | 34 | return $subscriptions; |
35 | 35 | } |
36 | -function wpinv_get_subscription( $id = 0, $by_profile_id = false ) { |
|
36 | +function wpinv_get_subscription($id = 0, $by_profile_id = false) { |
|
37 | 37 | global $wpdb; |
38 | 38 | |
39 | - if ( empty( $id ) ) { |
|
39 | + if (empty($id)) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - $id = esc_sql( $id ); |
|
43 | + $id = esc_sql($id); |
|
44 | 44 | |
45 | - $invoice_id = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1" ); |
|
45 | + $invoice_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1"); |
|
46 | 46 | |
47 | - if ( $invoice_id != null ) { |
|
48 | - return wpinv_get_invoice( $invoice_id ); |
|
47 | + if ($invoice_id != null) { |
|
48 | + return wpinv_get_invoice($invoice_id); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return false; |
@@ -55,49 +55,49 @@ discard block |
||
55 | 55 | * Records a new payment on the subscription |
56 | 56 | * |
57 | 57 | */ |
58 | -function wpinv_recurring_add_subscription_payment( $parent_invoice_id, $subscription_args = array() ) { |
|
59 | - $args = wp_parse_args( $subscription_args, array( |
|
58 | +function wpinv_recurring_add_subscription_payment($parent_invoice_id, $subscription_args = array()) { |
|
59 | + $args = wp_parse_args($subscription_args, array( |
|
60 | 60 | 'amount' => '', |
61 | 61 | 'transaction_id' => '', |
62 | 62 | 'gateway' => '' |
63 | - ) ); |
|
63 | + )); |
|
64 | 64 | |
65 | - if ( wpinv_payment_exists( $args['transaction_id'] ) ) { |
|
65 | + if (wpinv_payment_exists($args['transaction_id'])) { |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | - $parent_invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
70 | - if ( empty( $parent_invoice ) ) { |
|
69 | + $parent_invoice = wpinv_get_invoice($parent_invoice_id); |
|
70 | + if (empty($parent_invoice)) { |
|
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | 74 | $invoice = new WPInv_Invoice(); |
75 | - $invoice->set( 'parent_invoice', $parent_invoice_id ); |
|
76 | - $invoice->set( 'currency', $parent_invoice->get_currency() ); |
|
75 | + $invoice->set('parent_invoice', $parent_invoice_id); |
|
76 | + $invoice->set('currency', $parent_invoice->get_currency()); |
|
77 | 77 | //$invoice->set( 'status', 'publish' ); |
78 | - $invoice->set( 'transaction_id', $args['transaction_id'] ); |
|
79 | - $invoice->set( 'key', $parent_invoice->get_key() ); |
|
78 | + $invoice->set('transaction_id', $args['transaction_id']); |
|
79 | + $invoice->set('key', $parent_invoice->get_key()); |
|
80 | 80 | |
81 | - $invoice->set( 'ip', $parent_invoice->ip ); |
|
82 | - $invoice->set( 'user_id', $parent_invoice->get_user_id() ); |
|
83 | - $invoice->set( 'first_name', $parent_invoice->get_first_name() ); |
|
84 | - $invoice->set( 'last_name', $parent_invoice->get_last_name() ); |
|
81 | + $invoice->set('ip', $parent_invoice->ip); |
|
82 | + $invoice->set('user_id', $parent_invoice->get_user_id()); |
|
83 | + $invoice->set('first_name', $parent_invoice->get_first_name()); |
|
84 | + $invoice->set('last_name', $parent_invoice->get_last_name()); |
|
85 | 85 | ///$invoice->set( 'email', $parent_invoice->get_email() ); |
86 | - $invoice->set( 'phone', $parent_invoice->phone ); |
|
87 | - $invoice->set( 'address', $parent_invoice->address ); |
|
88 | - $invoice->set( 'city', $parent_invoice->city ); |
|
89 | - $invoice->set( 'country', $parent_invoice->country ); |
|
90 | - $invoice->set( 'state', $parent_invoice->state ); |
|
91 | - $invoice->set( 'zip', $parent_invoice->zip ); |
|
92 | - $invoice->set( 'company', $parent_invoice->company ); |
|
93 | - $invoice->set( 'vat_number', $parent_invoice->vat_number ); |
|
94 | - $invoice->set( 'vat_rate', $parent_invoice->vat_rate ); |
|
95 | - $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed ); |
|
96 | - |
|
97 | - if ( empty( $args['gateway'] ) ) { |
|
98 | - $invoice->set( 'gateway', $parent_invoice->get_gateway() ); |
|
86 | + $invoice->set('phone', $parent_invoice->phone); |
|
87 | + $invoice->set('address', $parent_invoice->address); |
|
88 | + $invoice->set('city', $parent_invoice->city); |
|
89 | + $invoice->set('country', $parent_invoice->country); |
|
90 | + $invoice->set('state', $parent_invoice->state); |
|
91 | + $invoice->set('zip', $parent_invoice->zip); |
|
92 | + $invoice->set('company', $parent_invoice->company); |
|
93 | + $invoice->set('vat_number', $parent_invoice->vat_number); |
|
94 | + $invoice->set('vat_rate', $parent_invoice->vat_rate); |
|
95 | + $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed); |
|
96 | + |
|
97 | + if (empty($args['gateway'])) { |
|
98 | + $invoice->set('gateway', $parent_invoice->get_gateway()); |
|
99 | 99 | } else { |
100 | - $invoice->set( 'gateway', $args['gateway'] ); |
|
100 | + $invoice->set('gateway', $args['gateway']); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $recurring_details = $parent_invoice->get_recurring_details(); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | // increase the earnings for each item in the subscription |
106 | 106 | $items = $recurring_details['cart_details']; |
107 | 107 | |
108 | - if ( $items ) { |
|
108 | + if ($items) { |
|
109 | 109 | $add_items = array(); |
110 | 110 | $cart_details = array(); |
111 | 111 | |
112 | - foreach ( $items as $item ) { |
|
112 | + foreach ($items as $item) { |
|
113 | 113 | $add_item = array(); |
114 | 114 | $add_item['id'] = $item['id']; |
115 | 115 | $add_item['quantity'] = $item['quantity']; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | break; |
120 | 120 | } |
121 | 121 | |
122 | - $invoice->set( 'items', $add_items ); |
|
122 | + $invoice->set('items', $add_items); |
|
123 | 123 | $invoice->cart_details = $cart_details; |
124 | 124 | } |
125 | 125 | |
@@ -129,277 +129,277 @@ discard block |
||
129 | 129 | $tax = $recurring_details['tax']; |
130 | 130 | $discount = $recurring_details['discount']; |
131 | 131 | |
132 | - if ( $discount > 0 ) { |
|
133 | - $invoice->set( 'discount_code', $parent_invoice->discount_code ); |
|
132 | + if ($discount > 0) { |
|
133 | + $invoice->set('discount_code', $parent_invoice->discount_code); |
|
134 | 134 | } |
135 | 135 | |
136 | - $invoice->subtotal = wpinv_round_amount( $subtotal ); |
|
137 | - $invoice->tax = wpinv_round_amount( $tax ); |
|
138 | - $invoice->discount = wpinv_round_amount( $discount ); |
|
139 | - $invoice->total = wpinv_round_amount( $total ); |
|
136 | + $invoice->subtotal = wpinv_round_amount($subtotal); |
|
137 | + $invoice->tax = wpinv_round_amount($tax); |
|
138 | + $invoice->discount = wpinv_round_amount($discount); |
|
139 | + $invoice->total = wpinv_round_amount($total); |
|
140 | 140 | $invoice->save(); |
141 | 141 | |
142 | - wpinv_update_payment_status( $invoice->ID, 'publish' ); |
|
142 | + wpinv_update_payment_status($invoice->ID, 'publish'); |
|
143 | 143 | sleep(1); |
144 | - wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' ); |
|
144 | + wpinv_update_payment_status($invoice->ID, 'wpi-renewal'); |
|
145 | 145 | |
146 | - $invoice = wpinv_get_invoice( $invoice->ID ); |
|
146 | + $invoice = wpinv_get_invoice($invoice->ID); |
|
147 | 147 | |
148 | - $subscription_data = wpinv_payment_subscription_data( $parent_invoice ); |
|
148 | + $subscription_data = wpinv_payment_subscription_data($parent_invoice); |
|
149 | 149 | $subscription_data['recurring_amount'] = $invoice->get_total(); |
150 | - $subscription_data['created'] = current_time( 'mysql', 0 ); |
|
151 | - $subscription_data['expiration'] = $invoice->get_new_expiration( $subscription_data['item_id'] ); |
|
150 | + $subscription_data['created'] = current_time('mysql', 0); |
|
151 | + $subscription_data['expiration'] = $invoice->get_new_expiration($subscription_data['item_id']); |
|
152 | 152 | |
153 | 153 | // Retrieve pending subscription from database and update it's status to active and set proper profile ID |
154 | - $invoice->update_subscription( $subscription_data ); |
|
154 | + $invoice->update_subscription($subscription_data); |
|
155 | 155 | |
156 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args ); |
|
157 | - do_action( 'wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args ); |
|
156 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args); |
|
157 | + do_action('wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args); |
|
158 | 158 | |
159 | 159 | return $invoice; |
160 | 160 | } |
161 | 161 | |
162 | -function wpinv_payment_exists( $txn_id = '' ) { |
|
162 | +function wpinv_payment_exists($txn_id = '') { |
|
163 | 163 | global $wpdb; |
164 | 164 | |
165 | - if ( empty( $txn_id ) ) { |
|
165 | + if (empty($txn_id)) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $txn_id = esc_sql( $txn_id ); |
|
169 | + $txn_id = esc_sql($txn_id); |
|
170 | 170 | |
171 | - $invoice = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" ); |
|
171 | + $invoice = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1"); |
|
172 | 172 | |
173 | - if ( $invoice != null ) { |
|
173 | + if ($invoice != null) { |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
181 | - if ( empty( $invoice ) ) { |
|
180 | +function wpinv_is_subscription_payment($invoice = '') { |
|
181 | + if (empty($invoice)) { |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
186 | - $invoice = wpinv_get_invoice( $invoice ); |
|
185 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
186 | + $invoice = wpinv_get_invoice($invoice); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( empty( $invoice ) ) { |
|
189 | + if (empty($invoice)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
193 | - if ( $invoice->is_renewal() ) { |
|
193 | + if ($invoice->is_renewal()) { |
|
194 | 194 | return true; |
195 | 195 | } |
196 | 196 | |
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
200 | -function wpinv_payment_subscription_data( $invoice = '' ) { |
|
201 | - if ( empty( $invoice ) ) { |
|
200 | +function wpinv_payment_subscription_data($invoice = '') { |
|
201 | + if (empty($invoice)) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
206 | - $invoice = wpinv_get_invoice( $invoice ); |
|
205 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
206 | + $invoice = wpinv_get_invoice($invoice); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( empty( $invoice ) ) { |
|
209 | + if (empty($invoice)) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | 213 | return $invoice->get_subscription_data(); |
214 | 214 | } |
215 | 215 | |
216 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
217 | - if ( empty( $invoice ) ) { |
|
216 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
217 | + if (empty($invoice)) { |
|
218 | 218 | return false; |
219 | 219 | } |
220 | 220 | |
221 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
222 | - $invoice = wpinv_get_invoice( $invoice ); |
|
221 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
222 | + $invoice = wpinv_get_invoice($invoice); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( empty( $invoice ) ) { |
|
225 | + if (empty($invoice)) { |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
229 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
230 | 230 | } |
231 | 231 | |
232 | -function wpinv_get_pretty_subscription_period( $period ) { |
|
232 | +function wpinv_get_pretty_subscription_period($period) { |
|
233 | 233 | $frequency = ''; |
234 | 234 | //Format period details |
235 | - switch ( $period ) { |
|
235 | + switch ($period) { |
|
236 | 236 | case 'D' : |
237 | 237 | case 'day' : |
238 | - $frequency = __( 'Daily', 'invoicing' ); |
|
238 | + $frequency = __('Daily', 'invoicing'); |
|
239 | 239 | break; |
240 | 240 | case 'W' : |
241 | 241 | case 'week' : |
242 | - $frequency = __( 'Weekly', 'invoicing' ); |
|
242 | + $frequency = __('Weekly', 'invoicing'); |
|
243 | 243 | break; |
244 | 244 | case 'M' : |
245 | 245 | case 'month' : |
246 | - $frequency = __( 'Monthly', 'invoicing' ); |
|
246 | + $frequency = __('Monthly', 'invoicing'); |
|
247 | 247 | break; |
248 | 248 | case 'Y' : |
249 | 249 | case 'year' : |
250 | - $frequency = __( 'Yearly', 'invoicing' ); |
|
250 | + $frequency = __('Yearly', 'invoicing'); |
|
251 | 251 | break; |
252 | 252 | default : |
253 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period', $frequency, $period ); |
|
253 | + $frequency = apply_filters('wpinv_pretty_subscription_period', $frequency, $period); |
|
254 | 254 | break; |
255 | 255 | } |
256 | 256 | |
257 | 257 | return $frequency; |
258 | 258 | } |
259 | 259 | |
260 | -function wpinv_get_pretty_subscription_period_name( $period ) { |
|
260 | +function wpinv_get_pretty_subscription_period_name($period) { |
|
261 | 261 | $frequency = ''; |
262 | 262 | //Format period details |
263 | - switch ( $period ) { |
|
263 | + switch ($period) { |
|
264 | 264 | case 'D' : |
265 | 265 | case 'day' : |
266 | - $frequency = __( 'Day', 'invoicing' ); |
|
266 | + $frequency = __('Day', 'invoicing'); |
|
267 | 267 | break; |
268 | 268 | case 'W' : |
269 | 269 | case 'week' : |
270 | - $frequency = __( 'Week', 'invoicing' ); |
|
270 | + $frequency = __('Week', 'invoicing'); |
|
271 | 271 | break; |
272 | 272 | case 'M' : |
273 | 273 | case 'month' : |
274 | - $frequency = __( 'Month', 'invoicing' ); |
|
274 | + $frequency = __('Month', 'invoicing'); |
|
275 | 275 | break; |
276 | 276 | case 'Y' : |
277 | 277 | case 'year' : |
278 | - $frequency = __( 'Year', 'invoicing' ); |
|
278 | + $frequency = __('Year', 'invoicing'); |
|
279 | 279 | break; |
280 | 280 | default : |
281 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period_name', $frequency, $period ); |
|
281 | + $frequency = apply_filters('wpinv_pretty_subscription_period_name', $frequency, $period); |
|
282 | 282 | break; |
283 | 283 | } |
284 | 284 | |
285 | 285 | return $frequency; |
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
288 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
289 | 289 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
290 | 290 | |
291 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
292 | - $amount = __( 'Free', 'invoicing' ); |
|
291 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
292 | + $amount = __('Free', 'invoicing'); |
|
293 | 293 | $interval = $trial_interval; |
294 | 294 | $period = $trial_period; |
295 | 295 | } |
296 | 296 | |
297 | 297 | $description = ''; |
298 | - switch ( $period ) { |
|
298 | + switch ($period) { |
|
299 | 299 | case 'D' : |
300 | 300 | case 'day' : |
301 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
301 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
302 | 302 | break; |
303 | 303 | case 'W' : |
304 | 304 | case 'week' : |
305 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
305 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
306 | 306 | break; |
307 | 307 | case 'M' : |
308 | 308 | case 'month' : |
309 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
309 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
310 | 310 | break; |
311 | 311 | case 'Y' : |
312 | 312 | case 'year' : |
313 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
313 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
314 | 314 | break; |
315 | 315 | } |
316 | 316 | |
317 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
317 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
320 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
321 | 321 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
322 | 322 | $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
323 | 323 | |
324 | 324 | $description = ''; |
325 | - switch ( $period ) { |
|
325 | + switch ($period) { |
|
326 | 326 | case 'D' : |
327 | 327 | case 'day' : |
328 | - if ( (int)$bill_times > 0 ) { |
|
329 | - if ( $interval > 1 ) { |
|
330 | - if ( $bill_times > 1 ) { |
|
331 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
328 | + if ((int)$bill_times > 0) { |
|
329 | + if ($interval > 1) { |
|
330 | + if ($bill_times > 1) { |
|
331 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
332 | 332 | } else { |
333 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
333 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
334 | 334 | } |
335 | 335 | } else { |
336 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
336 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
337 | 337 | } |
338 | 338 | } else { |
339 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
339 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
340 | 340 | } |
341 | 341 | break; |
342 | 342 | case 'W' : |
343 | 343 | case 'week' : |
344 | - if ( (int)$bill_times > 0 ) { |
|
345 | - if ( $interval > 1 ) { |
|
346 | - if ( $bill_times > 1 ) { |
|
347 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
344 | + if ((int)$bill_times > 0) { |
|
345 | + if ($interval > 1) { |
|
346 | + if ($bill_times > 1) { |
|
347 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
348 | 348 | } else { |
349 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
349 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
350 | 350 | } |
351 | 351 | } else { |
352 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
352 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
353 | 353 | } |
354 | 354 | } else { |
355 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
355 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
356 | 356 | } |
357 | 357 | break; |
358 | 358 | case 'M' : |
359 | 359 | case 'month' : |
360 | - if ( (int)$bill_times > 0 ) { |
|
361 | - if ( $interval > 1 ) { |
|
362 | - if ( $bill_times > 1 ) { |
|
363 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
360 | + if ((int)$bill_times > 0) { |
|
361 | + if ($interval > 1) { |
|
362 | + if ($bill_times > 1) { |
|
363 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
364 | 364 | } else { |
365 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
365 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
366 | 366 | } |
367 | 367 | } else { |
368 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
368 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
369 | 369 | } |
370 | 370 | } else { |
371 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
371 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
372 | 372 | } |
373 | 373 | break; |
374 | 374 | case 'Y' : |
375 | 375 | case 'year' : |
376 | - if ( (int)$bill_times > 0 ) { |
|
377 | - if ( $interval > 1 ) { |
|
378 | - if ( $bill_times > 1 ) { |
|
379 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
376 | + if ((int)$bill_times > 0) { |
|
377 | + if ($interval > 1) { |
|
378 | + if ($bill_times > 1) { |
|
379 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
380 | 380 | } else { |
381 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
381 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
382 | 382 | } |
383 | 383 | } else { |
384 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
384 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
385 | 385 | } |
386 | 386 | } else { |
387 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
387 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
388 | 388 | } |
389 | 389 | break; |
390 | 390 | } |
391 | 391 | |
392 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
392 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
393 | 393 | } |
394 | 394 | |
395 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
396 | - if ( empty( $invoice ) ) { |
|
395 | +function wpinv_subscription_payment_desc($invoice) { |
|
396 | + if (empty($invoice)) { |
|
397 | 397 | return NULL; |
398 | 398 | } |
399 | 399 | |
400 | 400 | $description = ''; |
401 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
402 | - if ( $item->has_free_trial() ) { |
|
401 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
402 | + if ($item->has_free_trial()) { |
|
403 | 403 | $trial_period = $item->get_trial_period(); |
404 | 404 | $trial_interval = $item->get_trial_interval(); |
405 | 405 | } else { |
@@ -407,45 +407,45 @@ discard block |
||
407 | 407 | $trial_interval = 0; |
408 | 408 | } |
409 | 409 | |
410 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
410 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
411 | 411 | } |
412 | 412 | |
413 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
413 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
417 | - $initial_total = wpinv_round_amount( $initial ); |
|
418 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
416 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
417 | + $initial_total = wpinv_round_amount($initial); |
|
418 | + $recurring_total = wpinv_round_amount($recurring); |
|
419 | 419 | |
420 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
420 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
421 | 421 | // Free trial |
422 | 422 | } else { |
423 | - if ( $bill_times == 1 ) { |
|
423 | + if ($bill_times == 1) { |
|
424 | 424 | $recurring_total = $initial_total; |
425 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
425 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
426 | 426 | $bill_times--; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
431 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
430 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
431 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
432 | 432 | |
433 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
433 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
434 | 434 | |
435 | - if ( $initial_total != $recurring_total ) { |
|
436 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
435 | + if ($initial_total != $recurring_total) { |
|
436 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
437 | 437 | |
438 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
438 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
439 | 439 | } else { |
440 | 440 | $description = $recurring; |
441 | 441 | } |
442 | 442 | |
443 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
443 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
444 | 444 | } |
445 | 445 | |
446 | -function wpinv_recurring_send_payment_failed( $invoice ) { |
|
447 | - if ( !empty( $invoice->ID ) ) { |
|
448 | - wpinv_failed_invoice_notification( $invoice->ID ); |
|
446 | +function wpinv_recurring_send_payment_failed($invoice) { |
|
447 | + if (!empty($invoice->ID)) { |
|
448 | + wpinv_failed_invoice_notification($invoice->ID); |
|
449 | 449 | } |
450 | 450 | } |
451 | -add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 ); |
|
452 | 451 | \ No newline at end of file |
452 | +add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1); |
|
453 | 453 | \ No newline at end of file |
@@ -47,6 +47,9 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | + /** |
|
51 | + * @param integer $code |
|
52 | + */ |
|
50 | 53 | public function send_status( $code ) { |
51 | 54 | status_header( $code ); |
52 | 55 | } |
@@ -195,6 +198,11 @@ discard block |
||
195 | 198 | class WPInv_API_Exception extends Exception { |
196 | 199 | protected $error_code; |
197 | 200 | |
201 | + /** |
|
202 | + * @param string $error_code |
|
203 | + * @param string $error_message |
|
204 | + * @param integer $http_status_code |
|
205 | + */ |
|
198 | 206 | public function __construct( $error_code, $error_message, $http_status_code ) { |
199 | 207 | $this->error_code = $error_code; |
200 | 208 | parent::__construct( $error_message, $http_status_code ); |
@@ -7,51 +7,51 @@ 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_API { |
15 | 15 | protected $post_type = 'wpi_invoice'; |
16 | 16 | |
17 | - public function __construct( $params = array() ) { |
|
17 | + public function __construct($params = array()) { |
|
18 | 18 | } |
19 | - public function insert_invoice( $data ) { |
|
19 | + public function insert_invoice($data) { |
|
20 | 20 | global $wpdb; |
21 | 21 | //wpinv_transaction_query( 'start' ); |
22 | 22 | |
23 | 23 | try { |
24 | - if ( empty( $data['invoice'] ) ) { |
|
25 | - throw new WPInv_API_Exception( 'wpinv_api_missing_invoice_data', sprintf( __( 'No %1$s data specified to create %1$s', 'invoicing' ), 'invoice' ), 400 ); |
|
24 | + if (empty($data['invoice'])) { |
|
25 | + throw new WPInv_API_Exception('wpinv_api_missing_invoice_data', sprintf(__('No %1$s data specified to create %1$s', 'invoicing'), 'invoice'), 400); |
|
26 | 26 | } |
27 | 27 | |
28 | - $data = apply_filters( 'wpinv_api_create_invoice_data', $data['invoice'], $this ); |
|
28 | + $data = apply_filters('wpinv_api_create_invoice_data', $data['invoice'], $this); |
|
29 | 29 | |
30 | - $invoice = wpinv_insert_invoice( $data, true ); |
|
31 | - if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) { |
|
32 | - throw new WPInv_API_Exception( 'wpinv_api_cannot_create_invoice', sprintf( __( 'Cannot create invoice: %s', 'invoicing' ), implode( ', ', $invoice->get_error_messages() ) ), 400 ); |
|
30 | + $invoice = wpinv_insert_invoice($data, true); |
|
31 | + if (empty($invoice->ID) || is_wp_error($invoice)) { |
|
32 | + throw new WPInv_API_Exception('wpinv_api_cannot_create_invoice', sprintf(__('Cannot create invoice: %s', 'invoicing'), implode(', ', $invoice->get_error_messages())), 400); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // HTTP 201 Created |
36 | - $this->send_status( 201 ); |
|
36 | + $this->send_status(201); |
|
37 | 37 | |
38 | - do_action( 'wpinv_api_create_invoice', $invoice->ID, $data, $this ); |
|
38 | + do_action('wpinv_api_create_invoice', $invoice->ID, $data, $this); |
|
39 | 39 | |
40 | 40 | //wpinv_transaction_query( 'commit' ); |
41 | 41 | |
42 | - return wpinv_get_invoice( $invoice->ID ); |
|
43 | - } catch ( WPInv_API_Exception $e ) { |
|
42 | + return wpinv_get_invoice($invoice->ID); |
|
43 | + } catch (WPInv_API_Exception $e) { |
|
44 | 44 | //wpinv_transaction_query( 'rollback' ); |
45 | 45 | |
46 | - return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); |
|
46 | + return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode())); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public function send_status( $code ) { |
|
51 | - status_header( $code ); |
|
50 | + public function send_status($code) { |
|
51 | + status_header($code); |
|
52 | 52 | } |
53 | 53 | |
54 | - protected function set_billing_details( $invoice, $data ) { |
|
54 | + protected function set_billing_details($invoice, $data) { |
|
55 | 55 | $address_fields = array( |
56 | 56 | 'user_id', |
57 | 57 | 'first_name', |
@@ -70,66 +70,66 @@ discard block |
||
70 | 70 | $billing_details = array(); |
71 | 71 | $user_id = $invoice->get_user_id(); |
72 | 72 | |
73 | - foreach ( $address_fields as $field ) { |
|
74 | - if ( isset( $data['billing_details'][ $field ] ) ) { |
|
75 | - $value = sanitize_text_field( $data['billing_details'][ $field ] ); |
|
73 | + foreach ($address_fields as $field) { |
|
74 | + if (isset($data['billing_details'][$field])) { |
|
75 | + $value = sanitize_text_field($data['billing_details'][$field]); |
|
76 | 76 | |
77 | - if ( $field == 'country' && empty( $value ) ) { |
|
78 | - if ( !empty( $invoice->country ) ) { |
|
77 | + if ($field == 'country' && empty($value)) { |
|
78 | + if (!empty($invoice->country)) { |
|
79 | 79 | $value = $invoice->country; |
80 | 80 | } else { |
81 | - $value = wpinv_default_billing_country( '', $user_id ); |
|
81 | + $value = wpinv_default_billing_country('', $user_id); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - if ( $field == 'state' && empty( $value ) ) { |
|
86 | - if ( !empty( $invoice->state ) ) { |
|
85 | + if ($field == 'state' && empty($value)) { |
|
86 | + if (!empty($invoice->state)) { |
|
87 | 87 | $value = $invoice->state; |
88 | 88 | } else { |
89 | 89 | $value = wpinv_get_default_state(); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $invoice->set( $field, $value ); |
|
93 | + $invoice->set($field, $value); |
|
94 | 94 | |
95 | - update_post_meta( $invoice->ID, '_wpinv_' . $field, $value ); |
|
95 | + update_post_meta($invoice->ID, '_wpinv_' . $field, $value); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | return $invoice; |
100 | 100 | } |
101 | 101 | |
102 | - protected function set_discount( $invoice, $data ) { |
|
103 | - if ( isset( $data['discount'] ) ) { |
|
104 | - $invoice->set( 'discount', wpinv_round_amount( $data['discount'] ) ); |
|
102 | + protected function set_discount($invoice, $data) { |
|
103 | + if (isset($data['discount'])) { |
|
104 | + $invoice->set('discount', wpinv_round_amount($data['discount'])); |
|
105 | 105 | |
106 | - update_post_meta( $invoice->ID, '_wpinv_discount', wpinv_round_amount( $data['discount'] ) ); |
|
106 | + update_post_meta($invoice->ID, '_wpinv_discount', wpinv_round_amount($data['discount'])); |
|
107 | 107 | |
108 | - if ( isset( $data['discount_code'] ) ) { |
|
109 | - $invoice->set( 'discount_code', $data['discount_code'] ); |
|
108 | + if (isset($data['discount_code'])) { |
|
109 | + $invoice->set('discount_code', $data['discount_code']); |
|
110 | 110 | |
111 | - update_post_meta( $invoice->ID, '_wpinv_discount_code', $data['discount_code'] ); |
|
111 | + update_post_meta($invoice->ID, '_wpinv_discount_code', $data['discount_code']); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | return $invoice; |
116 | 116 | } |
117 | 117 | |
118 | - protected function set_items( $invoice, $data ) { |
|
119 | - if ( !empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
118 | + protected function set_items($invoice, $data) { |
|
119 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
120 | 120 | $items_array = array(); |
121 | 121 | |
122 | - if ( !empty( $invoice->country ) ) { |
|
122 | + if (!empty($invoice->country)) { |
|
123 | 123 | $country = $invoice->country; |
124 | - } else if ( !empty( $data['billing_details']['country'] ) ) { |
|
124 | + } else if (!empty($data['billing_details']['country'])) { |
|
125 | 125 | $country = $data['billing_details']['country']; |
126 | 126 | } else { |
127 | - $country = wpinv_default_billing_country( '', $invoice->get_user_id() ); |
|
127 | + $country = wpinv_default_billing_country('', $invoice->get_user_id()); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( !empty( $invoice->state ) ) { |
|
130 | + if (!empty($invoice->state)) { |
|
131 | 131 | $state = $invoice->state; |
132 | - } else if ( !empty( $data['billing_details']['state'] ) ) { |
|
132 | + } else if (!empty($data['billing_details']['state'])) { |
|
133 | 133 | $state = $data['billing_details']['state']; |
134 | 134 | } else { |
135 | 135 | $state = wpinv_get_default_state(); |
@@ -138,54 +138,54 @@ discard block |
||
138 | 138 | $_POST['country'] = $country; |
139 | 139 | $_POST['state'] = $state; |
140 | 140 | |
141 | - $rate = wpinv_get_tax_rate( $country, $state, 'global' ); |
|
141 | + $rate = wpinv_get_tax_rate($country, $state, 'global'); |
|
142 | 142 | |
143 | 143 | $total_tax = 0; |
144 | - foreach ( $data['items'] as $item ) { |
|
145 | - $id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
146 | - $title = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : ''; |
|
147 | - $desc = isset( $item['description'] ) ? sanitize_text_field( $item['description'] ) : ''; |
|
148 | - $amount = isset( $item['amount'] ) ? wpinv_round_amount( $item['amount'] ) : 0; |
|
144 | + foreach ($data['items'] as $item) { |
|
145 | + $id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
146 | + $title = isset($item['title']) ? sanitize_text_field($item['title']) : ''; |
|
147 | + $desc = isset($item['description']) ? sanitize_text_field($item['description']) : ''; |
|
148 | + $amount = isset($item['amount']) ? wpinv_round_amount($item['amount']) : 0; |
|
149 | 149 | |
150 | - if ( !empty( $item['vat_rates_class'] ) ) { |
|
150 | + if (!empty($item['vat_rates_class'])) { |
|
151 | 151 | $vat_rates_class = $item['vat_rates_class']; |
152 | 152 | } else { |
153 | 153 | $vat_rates_class = '_standard'; |
154 | 154 | } |
155 | - $vat_rate = wpinv_get_tax_rate( $country, $state, $id ); |
|
155 | + $vat_rate = wpinv_get_tax_rate($country, $state, $id); |
|
156 | 156 | |
157 | - $tax = $amount > 0 ? ( $amount * 0.01 * (float)$vat_rate ) : 0; |
|
157 | + $tax = $amount > 0 ? ($amount * 0.01 * (float)$vat_rate) : 0; |
|
158 | 158 | $total_tax += $tax; |
159 | 159 | |
160 | 160 | $items_array[] = array( |
161 | 161 | 'id' => $id, |
162 | - 'title' => esc_html( $title ), |
|
163 | - 'description' => esc_html( $desc ), |
|
164 | - 'amount' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
165 | - 'subtotal' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
162 | + 'title' => esc_html($title), |
|
163 | + 'description' => esc_html($desc), |
|
164 | + 'amount' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
165 | + 'subtotal' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
166 | 166 | 'vat_rates_class' => $vat_rates_class, |
167 | 167 | 'vat_rate' => $vat_rate, |
168 | - 'tax' => $tax > 0 ? wpinv_round_amount( $tax ) : 0, |
|
168 | + 'tax' => $tax > 0 ? wpinv_round_amount($tax) : 0, |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
172 | - update_post_meta( $invoice->ID, '_wpinv_tax', wpinv_round_amount( $total_tax ) ); |
|
173 | - $invoice->set( 'tax', wpinv_round_amount( $total_tax ) ); |
|
172 | + update_post_meta($invoice->ID, '_wpinv_tax', wpinv_round_amount($total_tax)); |
|
173 | + $invoice->set('tax', wpinv_round_amount($total_tax)); |
|
174 | 174 | |
175 | - $items_array = apply_filters( 'wpinv_save_invoice_items', $items_array, $data['items'], $invoice ); |
|
175 | + $items_array = apply_filters('wpinv_save_invoice_items', $items_array, $data['items'], $invoice); |
|
176 | 176 | |
177 | - $invoice->set( 'items', $items_array ); |
|
178 | - update_post_meta( $invoice->ID, '_wpinv_items', $items_array ); |
|
177 | + $invoice->set('items', $items_array); |
|
178 | + update_post_meta($invoice->ID, '_wpinv_items', $items_array); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $invoice; |
182 | 182 | } |
183 | 183 | |
184 | - protected function set_invoice_meta( $invoice_id, $invoice_meta ) { |
|
185 | - foreach ( $invoice_meta as $meta_key => $meta_value ) { |
|
184 | + protected function set_invoice_meta($invoice_id, $invoice_meta) { |
|
185 | + foreach ($invoice_meta as $meta_key => $meta_value) { |
|
186 | 186 | |
187 | - if ( is_string( $meta_key) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) { |
|
188 | - update_post_meta( $invoice_id, $meta_key, $meta_value ); |
|
187 | + if (is_string($meta_key) && !is_protected_meta($meta_key) && is_scalar($meta_value)) { |
|
188 | + update_post_meta($invoice_id, $meta_key, $meta_value); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | class WPInv_API_Exception extends Exception { |
196 | 196 | protected $error_code; |
197 | 197 | |
198 | - public function __construct( $error_code, $error_message, $http_status_code ) { |
|
198 | + public function __construct($error_code, $error_message, $http_status_code) { |
|
199 | 199 | $this->error_code = $error_code; |
200 | - parent::__construct( $error_message, $http_status_code ); |
|
200 | + parent::__construct($error_message, $http_status_code); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | public function getErrorCode() { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,73 +14,73 @@ discard block |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | public function init() { |
17 | - do_action( 'wpinv_class_notes_init', $this ); |
|
17 | + do_action('wpinv_class_notes_init', $this); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function includes() { |
21 | - do_action( 'wpinv_class_notes_includes', $this ); |
|
21 | + do_action('wpinv_class_notes_includes', $this); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function actions() { |
25 | 25 | // Secure inovice notes |
26 | - add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
26 | + add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1); |
|
27 | 27 | |
28 | 28 | // Count comments |
29 | - add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 ); |
|
29 | + add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2); |
|
30 | 30 | |
31 | 31 | // Delete comments count cache whenever there is a new comment or a comment status changes |
32 | - add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
33 | - add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
32 | + add_action('wp_insert_comment', array($this, 'delete_comments_count_cache')); |
|
33 | + add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache')); |
|
34 | 34 | |
35 | - do_action( 'wpinv_class_notes_actions', $this ); |
|
35 | + do_action('wpinv_class_notes_actions', $this); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function set_invoice_note_type( $query ) { |
|
39 | - $post_ID = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
38 | + public function set_invoice_note_type($query) { |
|
39 | + $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
40 | 40 | |
41 | - if ( $post_ID && in_array(get_post_type( $post_ID ), array($this->invoice_post_type, 'wpi_quote' )) ) { |
|
41 | + if ($post_ID && in_array(get_post_type($post_ID), array($this->invoice_post_type, 'wpi_quote'))) { |
|
42 | 42 | $query->query_vars['type__in'] = $this->comment_type; |
43 | 43 | $query->query_vars['type__not_in'] = ''; |
44 | 44 | } else { |
45 | - if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) { |
|
46 | - if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) { |
|
47 | - $key = array_search( $this->comment_type, $type_in ); |
|
48 | - unset( $query->query_vars['type__in'][$key] ); |
|
49 | - } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) { |
|
45 | + if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) { |
|
46 | + if (is_array($type_in) && in_array($this->comment_type, $type_in)) { |
|
47 | + $key = array_search($this->comment_type, $type_in); |
|
48 | + unset($query->query_vars['type__in'][$key]); |
|
49 | + } else if (!is_array($type_in) && $type_in == $this->comment_type) { |
|
50 | 50 | $query->query_vars['type__in'] = ''; |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) { |
|
55 | - if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) { |
|
54 | + if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) { |
|
55 | + if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) { |
|
56 | 56 | $query->query_vars['type__not_in'][] = $this->comment_type; |
57 | - } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) { |
|
57 | + } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) { |
|
58 | 58 | $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in']; |
59 | 59 | $query->query_vars['type__not_in'][] = $this->comment_type; |
60 | 60 | } |
61 | 61 | } else { |
62 | - $query->query_vars['type__not_in'] = $this->comment_type; |
|
62 | + $query->query_vars['type__not_in'] = $this->comment_type; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | 66 | return $query; |
67 | 67 | } |
68 | 68 | |
69 | - public function get_invoice_notes( $invoice_id = 0, $type = '' ) { |
|
69 | + public function get_invoice_notes($invoice_id = 0, $type = '') { |
|
70 | 70 | $args = array( |
71 | 71 | 'post_id' => $invoice_id, |
72 | 72 | 'orderby' => 'comment_ID', |
73 | 73 | 'order' => 'ASC', |
74 | 74 | ); |
75 | 75 | |
76 | - if ( $type == 'customer' ) { |
|
76 | + if ($type == 'customer') { |
|
77 | 77 | $args['meta_key'] = '_wpi_customer_note'; |
78 | 78 | $args['meta_value'] = 1; |
79 | 79 | } |
80 | 80 | |
81 | - $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
81 | + $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type); |
|
82 | 82 | |
83 | - return get_comments( $args ); |
|
83 | + return get_comments($args); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return void |
92 | 92 | */ |
93 | 93 | public function delete_comments_count_cache() { |
94 | - delete_transient( 'wpinv_count_comments' ); |
|
94 | + delete_transient('wpinv_count_comments'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | * @param int $post_id Post ID. |
103 | 103 | * @return object |
104 | 104 | */ |
105 | - public function wp_count_comments( $stats, $post_id ) { |
|
105 | + public function wp_count_comments($stats, $post_id) { |
|
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - if ( 0 === $post_id ) { |
|
109 | - $stats = get_transient( 'wpinv_count_comments' ); |
|
108 | + if (0 === $post_id) { |
|
109 | + $stats = get_transient('wpinv_count_comments'); |
|
110 | 110 | |
111 | - if ( ! $stats ) { |
|
111 | + if (!$stats) { |
|
112 | 112 | $stats = array(); |
113 | 113 | |
114 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A ); |
|
114 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A); |
|
115 | 115 | |
116 | 116 | $total = 0; |
117 | 117 | $approved = array( |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | 'post-trashed' => 'post-trashed', |
123 | 123 | ); |
124 | 124 | |
125 | - foreach ( (array) $count as $row ) { |
|
125 | + foreach ((array)$count as $row) { |
|
126 | 126 | // Do not count post-trashed toward totals. |
127 | - if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) { |
|
127 | + if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) { |
|
128 | 128 | $total += $row['num_comments']; |
129 | 129 | } |
130 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
131 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
130 | + if (isset($approved[$row['comment_approved']])) { |
|
131 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | $stats['total_comments'] = $total; |
136 | 136 | $stats['all'] = $total; |
137 | - foreach ( $approved as $key ) { |
|
138 | - if ( empty( $stats[ $key ] ) ) { |
|
139 | - $stats[ $key ] = 0; |
|
137 | + foreach ($approved as $key) { |
|
138 | + if (empty($stats[$key])) { |
|
139 | + $stats[$key] = 0; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - $stats = (object) $stats; |
|
144 | - set_transient( 'wpinv_count_comments', $stats ); |
|
143 | + $stats = (object)$stats; |
|
144 | + set_transient('wpinv_count_comments', $stats); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 |
@@ -664,6 +664,9 @@ discard block |
||
664 | 664 | return $sent; |
665 | 665 | } |
666 | 666 | |
667 | +/** |
|
668 | + * @return string |
|
669 | + */ |
|
667 | 670 | function wpinv_mail_get_from_address() { |
668 | 671 | $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
669 | 672 | return sanitize_email( $from_address ); |
@@ -1123,6 +1126,9 @@ discard block |
||
1123 | 1126 | } |
1124 | 1127 | add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
1125 | 1128 | |
1129 | +/** |
|
1130 | + * @param string $email_type |
|
1131 | + */ |
|
1126 | 1132 | function wpinv_email_is_enabled( $email_type ) { |
1127 | 1133 | $emails = wpinv_get_emails(); |
1128 | 1134 | $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
@@ -7,12 +7,12 @@ 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_init_transactional_emails() { |
15 | - $email_actions = apply_filters( 'wpinv_email_actions', array( |
|
15 | + $email_actions = apply_filters('wpinv_email_actions', array( |
|
16 | 16 | 'wpinv_status_wpi-pending_to_wpi-processing', |
17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -28,79 +28,79 @@ discard block |
||
28 | 28 | 'wpinv_fully_refunded', |
29 | 29 | 'wpinv_partially_refunded', |
30 | 30 | 'wpinv_new_invoice_note' |
31 | - ) ); |
|
31 | + )); |
|
32 | 32 | |
33 | - foreach ( $email_actions as $action ) { |
|
34 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
33 | + foreach ($email_actions as $action) { |
|
34 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
35 | 35 | } |
36 | 36 | } |
37 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
37 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
38 | 38 | |
39 | 39 | // New invoice email |
40 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
41 | -add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
42 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
43 | -add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
44 | -add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
45 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
40 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
41 | +add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
42 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
43 | +add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
44 | +add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
45 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
46 | 46 | |
47 | 47 | // Cancelled invoice email |
48 | -add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
49 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
48 | +add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
49 | +add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
50 | 50 | |
51 | 51 | // Failed invoice email |
52 | -add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
53 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
52 | +add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
53 | +add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
54 | 54 | |
55 | 55 | // On hold invoice email |
56 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
57 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
56 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
57 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
58 | 58 | |
59 | 59 | // Processing invoice email |
60 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' ); |
|
60 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification'); |
|
61 | 61 | |
62 | 62 | // Paid invoice email |
63 | -add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' ); |
|
63 | +add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification'); |
|
64 | 64 | |
65 | 65 | // Refunded invoice email |
66 | -add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
67 | -add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' ); |
|
66 | +add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification'); |
|
67 | +add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification'); |
|
68 | 68 | |
69 | 69 | // Invoice note |
70 | -add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' ); |
|
70 | +add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification'); |
|
71 | 71 | |
72 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
73 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
74 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
75 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
76 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
77 | -add_action( 'wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4 ); |
|
72 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
73 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
74 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
75 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
76 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
77 | +add_action('wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4); |
|
78 | 78 | |
79 | 79 | function wpinv_send_transactional_email() { |
80 | 80 | $args = func_get_args(); |
81 | 81 | $function = current_filter() . '_notification'; |
82 | - do_action_ref_array( $function, $args ); |
|
82 | + do_action_ref_array($function, $args); |
|
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) { |
|
85 | +function wpinv_new_invoice_notification($invoice_id, $new_status = '') { |
|
86 | 86 | global $wpinv_email_search, $wpinv_email_replace; |
87 | 87 | |
88 | 88 | $email_type = 'new_invoice'; |
89 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
89 | + if (!wpinv_email_is_enabled($email_type)) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
93 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
94 | - if ( empty( $invoice ) ) { |
|
93 | + $invoice = wpinv_get_invoice($invoice_id); |
|
94 | + if (empty($invoice)) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
98 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
102 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
103 | - if ( !is_email( $recipient ) ) { |
|
102 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
103 | + if (!is_email($recipient)) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
@@ -117,41 +117,41 @@ discard block |
||
117 | 117 | $wpinv_email_search = $search; |
118 | 118 | $wpinv_email_replace = $replace; |
119 | 119 | |
120 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
121 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
122 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
123 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
120 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
121 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
122 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
123 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
124 | 124 | |
125 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
125 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
126 | 126 | 'invoice' => $invoice, |
127 | 127 | 'email_type' => $email_type, |
128 | 128 | 'email_heading' => $email_heading, |
129 | 129 | 'sent_to_admin' => true, |
130 | 130 | 'plain_text' => false, |
131 | - ) ); |
|
131 | + )); |
|
132 | 132 | |
133 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
133 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
136 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
137 | 137 | global $wpinv_email_search, $wpinv_email_replace; |
138 | 138 | |
139 | 139 | $email_type = 'cancelled_invoice'; |
140 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
140 | + if (!wpinv_email_is_enabled($email_type)) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
145 | - if ( empty( $invoice ) ) { |
|
144 | + $invoice = wpinv_get_invoice($invoice_id); |
|
145 | + if (empty($invoice)) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
149 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
154 | - if ( !is_email( $recipient ) ) { |
|
153 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
154 | + if (!is_email($recipient)) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
@@ -168,41 +168,41 @@ discard block |
||
168 | 168 | $wpinv_email_search = $search; |
169 | 169 | $wpinv_email_replace = $replace; |
170 | 170 | |
171 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
172 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
173 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
174 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
171 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
172 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
173 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
174 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
175 | 175 | |
176 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
176 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
177 | 177 | 'invoice' => $invoice, |
178 | 178 | 'email_type' => $email_type, |
179 | 179 | 'email_heading' => $email_heading, |
180 | 180 | 'sent_to_admin' => true, |
181 | 181 | 'plain_text' => false, |
182 | - ) ); |
|
182 | + )); |
|
183 | 183 | |
184 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
184 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
185 | 185 | } |
186 | 186 | |
187 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
187 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
188 | 188 | global $wpinv_email_search, $wpinv_email_replace; |
189 | 189 | |
190 | 190 | $email_type = 'failed_invoice'; |
191 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
191 | + if (!wpinv_email_is_enabled($email_type)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
195 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
196 | - if ( empty( $invoice ) ) { |
|
195 | + $invoice = wpinv_get_invoice($invoice_id); |
|
196 | + if (empty($invoice)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
200 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
200 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
205 | - if ( !is_email( $recipient ) ) { |
|
204 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
205 | + if (!is_email($recipient)) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | $wpinv_email_search = $search; |
220 | 220 | $wpinv_email_replace = $replace; |
221 | 221 | |
222 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
223 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
224 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
225 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
222 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
223 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
224 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
225 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
226 | 226 | |
227 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
227 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
228 | 228 | 'invoice' => $invoice, |
229 | 229 | 'email_type' => $email_type, |
230 | 230 | 'email_heading' => $email_heading, |
231 | 231 | 'sent_to_admin' => true, |
232 | 232 | 'plain_text' => false, |
233 | - ) ); |
|
233 | + )); |
|
234 | 234 | |
235 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
235 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
236 | 236 | } |
237 | 237 | |
238 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
238 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
239 | 239 | global $wpinv_email_search, $wpinv_email_replace; |
240 | 240 | |
241 | 241 | $email_type = 'onhold_invoice'; |
242 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
242 | + if (!wpinv_email_is_enabled($email_type)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
247 | - if ( empty( $invoice ) ) { |
|
246 | + $invoice = wpinv_get_invoice($invoice_id); |
|
247 | + if (empty($invoice)) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
251 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | |
255 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
256 | - if ( !is_email( $recipient ) ) { |
|
255 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
256 | + if (!is_email($recipient)) { |
|
257 | 257 | return false; |
258 | 258 | } |
259 | 259 | |
@@ -270,49 +270,49 @@ discard block |
||
270 | 270 | $wpinv_email_search = $search; |
271 | 271 | $wpinv_email_replace = $replace; |
272 | 272 | |
273 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
274 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
275 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
276 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
273 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
274 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
275 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
276 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
277 | 277 | |
278 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
278 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
279 | 279 | 'invoice' => $invoice, |
280 | 280 | 'email_type' => $email_type, |
281 | 281 | 'email_heading' => $email_heading, |
282 | 282 | 'sent_to_admin' => false, |
283 | 283 | 'plain_text' => false, |
284 | - ) ); |
|
284 | + )); |
|
285 | 285 | |
286 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
286 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
287 | 287 | |
288 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
289 | - $recipient = wpinv_get_admin_email(); |
|
290 | - $subject .= ' - ADMIN BCC COPY'; |
|
291 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
288 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
289 | + $recipient = wpinv_get_admin_email(); |
|
290 | + $subject .= ' - ADMIN BCC COPY'; |
|
291 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | return $sent; |
295 | 295 | } |
296 | 296 | |
297 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
297 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
298 | 298 | global $wpinv_email_search, $wpinv_email_replace; |
299 | 299 | |
300 | 300 | $email_type = 'processing_invoice'; |
301 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
301 | + if (!wpinv_email_is_enabled($email_type)) { |
|
302 | 302 | return false; |
303 | 303 | } |
304 | 304 | |
305 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
306 | - if ( empty( $invoice ) ) { |
|
305 | + $invoice = wpinv_get_invoice($invoice_id); |
|
306 | + if (empty($invoice)) { |
|
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
310 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
314 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
315 | - if ( !is_email( $recipient ) ) { |
|
314 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
315 | + if (!is_email($recipient)) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | |
@@ -329,49 +329,49 @@ discard block |
||
329 | 329 | $wpinv_email_search = $search; |
330 | 330 | $wpinv_email_replace = $replace; |
331 | 331 | |
332 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
333 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
334 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
335 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
332 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
333 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
334 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
335 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
336 | 336 | |
337 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
337 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
338 | 338 | 'invoice' => $invoice, |
339 | 339 | 'email_type' => $email_type, |
340 | 340 | 'email_heading' => $email_heading, |
341 | 341 | 'sent_to_admin' => false, |
342 | 342 | 'plain_text' => false, |
343 | - ) ); |
|
343 | + )); |
|
344 | 344 | |
345 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
345 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
346 | 346 | |
347 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
348 | - $recipient = wpinv_get_admin_email(); |
|
349 | - $subject .= ' - ADMIN BCC COPY'; |
|
350 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
347 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
348 | + $recipient = wpinv_get_admin_email(); |
|
349 | + $subject .= ' - ADMIN BCC COPY'; |
|
350 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $sent; |
354 | 354 | } |
355 | 355 | |
356 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
356 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
357 | 357 | global $wpinv_email_search, $wpinv_email_replace; |
358 | 358 | |
359 | 359 | $email_type = 'completed_invoice'; |
360 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
360 | + if (!wpinv_email_is_enabled($email_type)) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
365 | - if ( empty( $invoice ) ) { |
|
364 | + $invoice = wpinv_get_invoice($invoice_id); |
|
365 | + if (empty($invoice)) { |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
369 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
370 | 370 | return false; |
371 | 371 | } |
372 | 372 | |
373 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
374 | - if ( !is_email( $recipient ) ) { |
|
373 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
374 | + if (!is_email($recipient)) { |
|
375 | 375 | return false; |
376 | 376 | } |
377 | 377 | |
@@ -388,49 +388,49 @@ discard block |
||
388 | 388 | $wpinv_email_search = $search; |
389 | 389 | $wpinv_email_replace = $replace; |
390 | 390 | |
391 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
392 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
393 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
394 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
391 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
392 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
393 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
394 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
395 | 395 | |
396 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
396 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
397 | 397 | 'invoice' => $invoice, |
398 | 398 | 'email_type' => $email_type, |
399 | 399 | 'email_heading' => $email_heading, |
400 | 400 | 'sent_to_admin' => false, |
401 | 401 | 'plain_text' => false, |
402 | - ) ); |
|
402 | + )); |
|
403 | 403 | |
404 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
404 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
405 | 405 | |
406 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
407 | - $recipient = wpinv_get_admin_email(); |
|
408 | - $subject .= ' - ADMIN BCC COPY'; |
|
409 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
406 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
407 | + $recipient = wpinv_get_admin_email(); |
|
408 | + $subject .= ' - ADMIN BCC COPY'; |
|
409 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | return $sent; |
413 | 413 | } |
414 | 414 | |
415 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
415 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
416 | 416 | global $wpinv_email_search, $wpinv_email_replace; |
417 | 417 | |
418 | 418 | $email_type = 'refunded_invoice'; |
419 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
419 | + if (!wpinv_email_is_enabled($email_type)) { |
|
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | |
423 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
424 | - if ( empty( $invoice ) ) { |
|
423 | + $invoice = wpinv_get_invoice($invoice_id); |
|
424 | + if (empty($invoice)) { |
|
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
428 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
428 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
433 | - if ( !is_email( $recipient ) ) { |
|
432 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
433 | + if (!is_email($recipient)) { |
|
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
@@ -447,50 +447,50 @@ discard block |
||
447 | 447 | $wpinv_email_search = $search; |
448 | 448 | $wpinv_email_replace = $replace; |
449 | 449 | |
450 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
451 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
452 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
453 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
450 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
451 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
452 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
453 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
454 | 454 | |
455 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
455 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
456 | 456 | 'invoice' => $invoice, |
457 | 457 | 'email_type' => $email_type, |
458 | 458 | 'email_heading' => $email_heading, |
459 | 459 | 'sent_to_admin' => false, |
460 | 460 | 'plain_text' => false, |
461 | 461 | 'partial_refund' => false |
462 | - ) ); |
|
462 | + )); |
|
463 | 463 | |
464 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
464 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
465 | 465 | |
466 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
467 | - $recipient = wpinv_get_admin_email(); |
|
468 | - $subject .= ' - ADMIN BCC COPY'; |
|
469 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
466 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
467 | + $recipient = wpinv_get_admin_email(); |
|
468 | + $subject .= ' - ADMIN BCC COPY'; |
|
469 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | return $sent; |
473 | 473 | } |
474 | 474 | |
475 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
475 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
476 | 476 | global $wpinv_email_search, $wpinv_email_replace; |
477 | 477 | |
478 | 478 | $email_type = 'refunded_invoice'; |
479 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
479 | + if (!wpinv_email_is_enabled($email_type)) { |
|
480 | 480 | return false; |
481 | 481 | } |
482 | 482 | |
483 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
484 | - if ( empty( $invoice ) ) { |
|
483 | + $invoice = wpinv_get_invoice($invoice_id); |
|
484 | + if (empty($invoice)) { |
|
485 | 485 | return false; |
486 | 486 | } |
487 | 487 | |
488 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
488 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
489 | 489 | return false; |
490 | 490 | } |
491 | 491 | |
492 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
493 | - if ( !is_email( $recipient ) ) { |
|
492 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
493 | + if (!is_email($recipient)) { |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -507,53 +507,53 @@ discard block |
||
507 | 507 | $wpinv_email_search = $search; |
508 | 508 | $wpinv_email_replace = $replace; |
509 | 509 | |
510 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
511 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
512 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
513 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
510 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
511 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
512 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
513 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
514 | 514 | |
515 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
515 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
516 | 516 | 'invoice' => $invoice, |
517 | 517 | 'email_type' => $email_type, |
518 | 518 | 'email_heading' => $email_heading, |
519 | 519 | 'sent_to_admin' => false, |
520 | 520 | 'plain_text' => false, |
521 | 521 | 'partial_refund' => true |
522 | - ) ); |
|
522 | + )); |
|
523 | 523 | |
524 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
524 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
525 | 525 | |
526 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
527 | - $recipient = wpinv_get_admin_email(); |
|
528 | - $subject .= ' - ADMIN BCC COPY'; |
|
529 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
526 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
527 | + $recipient = wpinv_get_admin_email(); |
|
528 | + $subject .= ' - ADMIN BCC COPY'; |
|
529 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | return $sent; |
533 | 533 | } |
534 | 534 | |
535 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
535 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
536 | 536 | } |
537 | 537 | |
538 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
538 | +function wpinv_user_invoice_notification($invoice_id) { |
|
539 | 539 | global $wpinv_email_search, $wpinv_email_replace; |
540 | 540 | |
541 | 541 | $email_type = 'user_invoice'; |
542 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
542 | + if (!wpinv_email_is_enabled($email_type)) { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | |
546 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
547 | - if ( empty( $invoice ) ) { |
|
546 | + $invoice = wpinv_get_invoice($invoice_id); |
|
547 | + if (empty($invoice)) { |
|
548 | 548 | return false; |
549 | 549 | } |
550 | 550 | |
551 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
551 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
555 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
556 | - if ( !is_email( $recipient ) ) { |
|
555 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
556 | + if (!is_email($recipient)) { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 | |
@@ -570,53 +570,53 @@ discard block |
||
570 | 570 | $wpinv_email_search = $search; |
571 | 571 | $wpinv_email_replace = $replace; |
572 | 572 | |
573 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
574 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
575 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
576 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
573 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
574 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
575 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
576 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
577 | 577 | |
578 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
578 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
579 | 579 | 'invoice' => $invoice, |
580 | 580 | 'email_type' => $email_type, |
581 | 581 | 'email_heading' => $email_heading, |
582 | 582 | 'sent_to_admin' => false, |
583 | 583 | 'plain_text' => false, |
584 | - ) ); |
|
584 | + )); |
|
585 | 585 | |
586 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
586 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
588 | + if ($sent) { |
|
589 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
590 | 590 | } else { |
591 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
591 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
592 | 592 | } |
593 | 593 | |
594 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
594 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
595 | 595 | |
596 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
597 | - $recipient = wpinv_get_admin_email(); |
|
598 | - $subject .= ' - ADMIN BCC COPY'; |
|
599 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
596 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
597 | + $recipient = wpinv_get_admin_email(); |
|
598 | + $subject .= ' - ADMIN BCC COPY'; |
|
599 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | return $sent; |
603 | 603 | } |
604 | 604 | |
605 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
605 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
606 | 606 | global $wpinv_email_search, $wpinv_email_replace; |
607 | 607 | |
608 | 608 | $email_type = 'user_note'; |
609 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
609 | + if (!wpinv_email_is_enabled($email_type)) { |
|
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | |
613 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
614 | - if ( empty( $invoice ) ) { |
|
613 | + $invoice = wpinv_get_invoice($invoice_id); |
|
614 | + if (empty($invoice)) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
619 | - if ( !is_email( $recipient ) ) { |
|
618 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
619 | + if (!is_email($recipient)) { |
|
620 | 620 | return false; |
621 | 621 | } |
622 | 622 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | 'user_note' => '' |
625 | 625 | ); |
626 | 626 | |
627 | - $args = wp_parse_args( $args, $defaults ); |
|
627 | + $args = wp_parse_args($args, $defaults); |
|
628 | 628 | |
629 | 629 | $search = array(); |
630 | 630 | $search['invoice_number'] = '{invoice_number}'; |
@@ -643,46 +643,46 @@ discard block |
||
643 | 643 | $wpinv_email_search = $search; |
644 | 644 | $wpinv_email_replace = $replace; |
645 | 645 | |
646 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
647 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
648 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
649 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
646 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
647 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
648 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
649 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
650 | 650 | |
651 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
651 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
652 | 652 | 'invoice' => $invoice, |
653 | 653 | 'email_type' => $email_type, |
654 | 654 | 'email_heading' => $email_heading, |
655 | 655 | 'sent_to_admin' => false, |
656 | 656 | 'plain_text' => false, |
657 | 657 | 'customer_note' => $args['user_note'] |
658 | - ) ); |
|
658 | + )); |
|
659 | 659 | |
660 | - $content = wpinv_email_format_text( $content ); |
|
660 | + $content = wpinv_email_format_text($content); |
|
661 | 661 | |
662 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
662 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
663 | 663 | |
664 | 664 | return $sent; |
665 | 665 | } |
666 | 666 | |
667 | 667 | function wpinv_mail_get_from_address() { |
668 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
669 | - return sanitize_email( $from_address ); |
|
668 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
669 | + return sanitize_email($from_address); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | function wpinv_mail_get_from_name() { |
673 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
674 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
673 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
674 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
675 | 675 | } |
676 | 676 | |
677 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
678 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
679 | - return ( $active ? true : false ); |
|
677 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
678 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
679 | + return ($active ? true : false); |
|
680 | 680 | } |
681 | 681 | |
682 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
683 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
682 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
683 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
684 | 684 | |
685 | - switch ( $email_type ) { |
|
685 | + switch ($email_type) { |
|
686 | 686 | case 'html' : |
687 | 687 | $content_type = 'text/html'; |
688 | 688 | break; |
@@ -697,35 +697,35 @@ discard block |
||
697 | 697 | return $content_type; |
698 | 698 | } |
699 | 699 | |
700 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
701 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
702 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
703 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
700 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
701 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
702 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
703 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
704 | 704 | |
705 | - $message = wpinv_email_style_body( $message ); |
|
706 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
705 | + $message = wpinv_email_style_body($message); |
|
706 | + $message = apply_filters('wpinv_mail_content', $message); |
|
707 | 707 | |
708 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
708 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
709 | 709 | |
710 | - if ( !$sent ) { |
|
711 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject ); |
|
712 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
710 | + if (!$sent) { |
|
711 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject); |
|
712 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
713 | 713 | } |
714 | 714 | |
715 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
716 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
717 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
715 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
716 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
717 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
718 | 718 | |
719 | 719 | return $sent; |
720 | 720 | } |
721 | 721 | |
722 | 722 | function wpinv_get_emails() { |
723 | 723 | $overdue_days_options = array(); |
724 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
725 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
724 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
725 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
726 | 726 | |
727 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
728 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
727 | + for ($i = 2; $i <= 10; $i++) { |
|
728 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | // Default, built-in gateways |
@@ -733,130 +733,130 @@ discard block |
||
733 | 733 | 'new_invoice' => array( |
734 | 734 | 'email_new_invoice_header' => array( |
735 | 735 | 'id' => 'email_new_invoice_header', |
736 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
737 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
736 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
737 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
738 | 738 | 'type' => 'header', |
739 | 739 | ), |
740 | 740 | 'email_new_invoice_active' => array( |
741 | 741 | 'id' => 'email_new_invoice_active', |
742 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
743 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
742 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
743 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
744 | 744 | 'type' => 'checkbox', |
745 | 745 | 'std' => 1 |
746 | 746 | ), |
747 | 747 | 'email_new_invoice_subject' => array( |
748 | 748 | 'id' => 'email_new_invoice_subject', |
749 | - 'name' => __( 'Subject', 'invoicing' ), |
|
750 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
749 | + 'name' => __('Subject', 'invoicing'), |
|
750 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
751 | 751 | 'type' => 'text', |
752 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
752 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
753 | 753 | 'size' => 'large' |
754 | 754 | ), |
755 | 755 | 'email_new_invoice_heading' => array( |
756 | 756 | 'id' => 'email_new_invoice_heading', |
757 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
758 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
757 | + 'name' => __('Email Heading', 'invoicing'), |
|
758 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
759 | 759 | 'type' => 'text', |
760 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
760 | + 'std' => __('New payment invoice', 'invoicing'), |
|
761 | 761 | 'size' => 'large' |
762 | 762 | ), |
763 | 763 | ), |
764 | 764 | 'cancelled_invoice' => array( |
765 | 765 | 'email_cancelled_invoice_header' => array( |
766 | 766 | 'id' => 'email_cancelled_invoice_header', |
767 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
768 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
767 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
768 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
769 | 769 | 'type' => 'header', |
770 | 770 | ), |
771 | 771 | 'email_cancelled_invoice_active' => array( |
772 | 772 | 'id' => 'email_cancelled_invoice_active', |
773 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
774 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
773 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
774 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
775 | 775 | 'type' => 'checkbox', |
776 | 776 | 'std' => 1 |
777 | 777 | ), |
778 | 778 | 'email_cancelled_invoice_subject' => array( |
779 | 779 | 'id' => 'email_cancelled_invoice_subject', |
780 | - 'name' => __( 'Subject', 'invoicing' ), |
|
781 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
780 | + 'name' => __('Subject', 'invoicing'), |
|
781 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
782 | 782 | 'type' => 'text', |
783 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
783 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
784 | 784 | 'size' => 'large' |
785 | 785 | ), |
786 | 786 | 'email_cancelled_invoice_heading' => array( |
787 | 787 | 'id' => 'email_cancelled_invoice_heading', |
788 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
789 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
788 | + 'name' => __('Email Heading', 'invoicing'), |
|
789 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
790 | 790 | 'type' => 'text', |
791 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
791 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
792 | 792 | 'size' => 'large' |
793 | 793 | ), |
794 | 794 | ), |
795 | 795 | 'failed_invoice' => array( |
796 | 796 | 'email_failed_invoice_header' => array( |
797 | 797 | 'id' => 'email_failed_invoice_header', |
798 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
799 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
798 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
799 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
800 | 800 | 'type' => 'header', |
801 | 801 | ), |
802 | 802 | 'email_failed_invoice_active' => array( |
803 | 803 | 'id' => 'email_failed_invoice_active', |
804 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
805 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
804 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
805 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
806 | 806 | 'type' => 'checkbox', |
807 | 807 | 'std' => 1 |
808 | 808 | ), |
809 | 809 | 'email_failed_invoice_subject' => array( |
810 | 810 | 'id' => 'email_failed_invoice_subject', |
811 | - 'name' => __( 'Subject', 'invoicing' ), |
|
812 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
811 | + 'name' => __('Subject', 'invoicing'), |
|
812 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
813 | 813 | 'type' => 'text', |
814 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
814 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
815 | 815 | 'size' => 'large' |
816 | 816 | ), |
817 | 817 | 'email_failed_invoice_heading' => array( |
818 | 818 | 'id' => 'email_failed_invoice_heading', |
819 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
820 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
819 | + 'name' => __('Email Heading', 'invoicing'), |
|
820 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
821 | 821 | 'type' => 'text', |
822 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
822 | + 'std' => __('Failed invoice', 'invoicing'), |
|
823 | 823 | 'size' => 'large' |
824 | 824 | ) |
825 | 825 | ), |
826 | 826 | 'onhold_invoice' => array( |
827 | 827 | 'email_onhold_invoice_header' => array( |
828 | 828 | 'id' => 'email_onhold_invoice_header', |
829 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
830 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
829 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
830 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
831 | 831 | 'type' => 'header', |
832 | 832 | ), |
833 | 833 | 'email_onhold_invoice_active' => array( |
834 | 834 | 'id' => 'email_onhold_invoice_active', |
835 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
836 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
835 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
836 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
837 | 837 | 'type' => 'checkbox', |
838 | 838 | 'std' => 1 |
839 | 839 | ), |
840 | 840 | 'email_onhold_invoice_subject' => array( |
841 | 841 | 'id' => 'email_onhold_invoice_subject', |
842 | - 'name' => __( 'Subject', 'invoicing' ), |
|
843 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
842 | + 'name' => __('Subject', 'invoicing'), |
|
843 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
844 | 844 | 'type' => 'text', |
845 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
845 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
846 | 846 | 'size' => 'large' |
847 | 847 | ), |
848 | 848 | 'email_onhold_invoice_heading' => array( |
849 | 849 | 'id' => 'email_onhold_invoice_heading', |
850 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
851 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
850 | + 'name' => __('Email Heading', 'invoicing'), |
|
851 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
852 | 852 | 'type' => 'text', |
853 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
853 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
854 | 854 | 'size' => 'large' |
855 | 855 | ), |
856 | 856 | 'email_onhold_invoice_admin_bcc' => array( |
857 | 857 | 'id' => 'email_onhold_invoice_admin_bcc', |
858 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
859 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
858 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
859 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
860 | 860 | 'type' => 'checkbox', |
861 | 861 | 'std' => 1 |
862 | 862 | ), |
@@ -864,37 +864,37 @@ discard block |
||
864 | 864 | 'processing_invoice' => array( |
865 | 865 | 'email_processing_invoice_header' => array( |
866 | 866 | 'id' => 'email_processing_invoice_header', |
867 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
868 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
867 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
868 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
869 | 869 | 'type' => 'header', |
870 | 870 | ), |
871 | 871 | 'email_processing_invoice_active' => array( |
872 | 872 | 'id' => 'email_processing_invoice_active', |
873 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
874 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
873 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
874 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
875 | 875 | 'type' => 'checkbox', |
876 | 876 | 'std' => 1 |
877 | 877 | ), |
878 | 878 | 'email_processing_invoice_subject' => array( |
879 | 879 | 'id' => 'email_processing_invoice_subject', |
880 | - 'name' => __( 'Subject', 'invoicing' ), |
|
881 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
880 | + 'name' => __('Subject', 'invoicing'), |
|
881 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
882 | 882 | 'type' => 'text', |
883 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
883 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
884 | 884 | 'size' => 'large' |
885 | 885 | ), |
886 | 886 | 'email_processing_invoice_heading' => array( |
887 | 887 | 'id' => 'email_processing_invoice_heading', |
888 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
889 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
888 | + 'name' => __('Email Heading', 'invoicing'), |
|
889 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
890 | 890 | 'type' => 'text', |
891 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
891 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
892 | 892 | 'size' => 'large' |
893 | 893 | ), |
894 | 894 | 'email_processing_invoice_admin_bcc' => array( |
895 | 895 | 'id' => 'email_processing_invoice_admin_bcc', |
896 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
897 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
896 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
897 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
898 | 898 | 'type' => 'checkbox', |
899 | 899 | 'std' => 1 |
900 | 900 | ), |
@@ -902,37 +902,37 @@ discard block |
||
902 | 902 | 'completed_invoice' => array( |
903 | 903 | 'email_completed_invoice_header' => array( |
904 | 904 | 'id' => 'email_completed_invoice_header', |
905 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
906 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
905 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
906 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
907 | 907 | 'type' => 'header', |
908 | 908 | ), |
909 | 909 | 'email_completed_invoice_active' => array( |
910 | 910 | 'id' => 'email_completed_invoice_active', |
911 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
912 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
911 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
912 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
913 | 913 | 'type' => 'checkbox', |
914 | 914 | 'std' => 1 |
915 | 915 | ), |
916 | 916 | 'email_completed_invoice_subject' => array( |
917 | 917 | 'id' => 'email_completed_invoice_subject', |
918 | - 'name' => __( 'Subject', 'invoicing' ), |
|
919 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
918 | + 'name' => __('Subject', 'invoicing'), |
|
919 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
920 | 920 | 'type' => 'text', |
921 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
921 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
922 | 922 | 'size' => 'large' |
923 | 923 | ), |
924 | 924 | 'email_completed_invoice_heading' => array( |
925 | 925 | 'id' => 'email_completed_invoice_heading', |
926 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
927 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
926 | + 'name' => __('Email Heading', 'invoicing'), |
|
927 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
928 | 928 | 'type' => 'text', |
929 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
929 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
930 | 930 | 'size' => 'large' |
931 | 931 | ), |
932 | 932 | 'email_completed_invoice_admin_bcc' => array( |
933 | 933 | 'id' => 'email_completed_invoice_admin_bcc', |
934 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
935 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
934 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
935 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
936 | 936 | 'type' => 'checkbox', |
937 | 937 | ), |
938 | 938 | 'std' => 1 |
@@ -940,37 +940,37 @@ discard block |
||
940 | 940 | 'refunded_invoice' => array( |
941 | 941 | 'email_refunded_invoice_header' => array( |
942 | 942 | 'id' => 'email_refunded_invoice_header', |
943 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
944 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
943 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
944 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
945 | 945 | 'type' => 'header', |
946 | 946 | ), |
947 | 947 | 'email_refunded_invoice_active' => array( |
948 | 948 | 'id' => 'email_refunded_invoice_active', |
949 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
950 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
949 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
950 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
951 | 951 | 'type' => 'checkbox', |
952 | 952 | 'std' => 1 |
953 | 953 | ), |
954 | 954 | 'email_refunded_invoice_subject' => array( |
955 | 955 | 'id' => 'email_refunded_invoice_subject', |
956 | - 'name' => __( 'Subject', 'invoicing' ), |
|
957 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
956 | + 'name' => __('Subject', 'invoicing'), |
|
957 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
958 | 958 | 'type' => 'text', |
959 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
959 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
960 | 960 | 'size' => 'large' |
961 | 961 | ), |
962 | 962 | 'email_refunded_invoice_heading' => array( |
963 | 963 | 'id' => 'email_refunded_invoice_heading', |
964 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
965 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
964 | + 'name' => __('Email Heading', 'invoicing'), |
|
965 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
966 | 966 | 'type' => 'text', |
967 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
967 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
968 | 968 | 'size' => 'large' |
969 | 969 | ), |
970 | 970 | 'email_refunded_invoice_admin_bcc' => array( |
971 | 971 | 'id' => 'email_refunded_invoice_admin_bcc', |
972 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
973 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
972 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
973 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
974 | 974 | 'type' => 'checkbox', |
975 | 975 | 'std' => 1 |
976 | 976 | ), |
@@ -978,37 +978,37 @@ discard block |
||
978 | 978 | 'user_invoice' => array( |
979 | 979 | 'email_user_invoice_header' => array( |
980 | 980 | 'id' => 'email_user_invoice_header', |
981 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
982 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
981 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
982 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
983 | 983 | 'type' => 'header', |
984 | 984 | ), |
985 | 985 | 'email_user_invoice_active' => array( |
986 | 986 | 'id' => 'email_user_invoice_active', |
987 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
988 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
987 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
988 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
989 | 989 | 'type' => 'checkbox', |
990 | 990 | 'std' => 1 |
991 | 991 | ), |
992 | 992 | 'email_user_invoice_subject' => array( |
993 | 993 | 'id' => 'email_user_invoice_subject', |
994 | - 'name' => __( 'Subject', 'invoicing' ), |
|
995 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
994 | + 'name' => __('Subject', 'invoicing'), |
|
995 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
996 | 996 | 'type' => 'text', |
997 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
997 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
998 | 998 | 'size' => 'large' |
999 | 999 | ), |
1000 | 1000 | 'email_user_invoice_heading' => array( |
1001 | 1001 | 'id' => 'email_user_invoice_heading', |
1002 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1003 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
1002 | + 'name' => __('Email Heading', 'invoicing'), |
|
1003 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
1004 | 1004 | 'type' => 'text', |
1005 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
1005 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
1006 | 1006 | 'size' => 'large' |
1007 | 1007 | ), |
1008 | 1008 | 'email_user_invoice_admin_bcc' => array( |
1009 | 1009 | 'id' => 'email_user_invoice_admin_bcc', |
1010 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
1011 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
1010 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
1011 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
1012 | 1012 | 'type' => 'checkbox', |
1013 | 1013 | 'std' => 1 |
1014 | 1014 | ), |
@@ -1016,177 +1016,177 @@ discard block |
||
1016 | 1016 | 'user_note' => array( |
1017 | 1017 | 'email_user_note_header' => array( |
1018 | 1018 | 'id' => 'email_user_note_header', |
1019 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
1020 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
1019 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
1020 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
1021 | 1021 | 'type' => 'header', |
1022 | 1022 | ), |
1023 | 1023 | 'email_user_note_active' => array( |
1024 | 1024 | 'id' => 'email_user_note_active', |
1025 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1026 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1025 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1026 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1027 | 1027 | 'type' => 'checkbox', |
1028 | 1028 | 'std' => 1 |
1029 | 1029 | ), |
1030 | 1030 | 'email_user_note_subject' => array( |
1031 | 1031 | 'id' => 'email_user_note_subject', |
1032 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1033 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1032 | + 'name' => __('Subject', 'invoicing'), |
|
1033 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1034 | 1034 | 'type' => 'text', |
1035 | - 'std' => __( '[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
1035 | + 'std' => __('[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
1036 | 1036 | 'size' => 'large' |
1037 | 1037 | ), |
1038 | 1038 | 'email_user_note_heading' => array( |
1039 | 1039 | 'id' => 'email_user_note_heading', |
1040 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1041 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1040 | + 'name' => __('Email Heading', 'invoicing'), |
|
1041 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1042 | 1042 | 'type' => 'text', |
1043 | - 'std' => __( 'A note has been added to your {invoice_quote}', 'invoicing' ), |
|
1043 | + 'std' => __('A note has been added to your {invoice_quote}', 'invoicing'), |
|
1044 | 1044 | 'size' => 'large' |
1045 | 1045 | ), |
1046 | 1046 | ), |
1047 | 1047 | 'overdue' => array( |
1048 | 1048 | 'email_overdue_header' => array( |
1049 | 1049 | 'id' => 'email_overdue_header', |
1050 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
1051 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
1050 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
1051 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
1052 | 1052 | 'type' => 'header', |
1053 | 1053 | ), |
1054 | 1054 | 'email_overdue_active' => array( |
1055 | 1055 | 'id' => 'email_overdue_active', |
1056 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1057 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1056 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1057 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1058 | 1058 | 'type' => 'checkbox', |
1059 | 1059 | 'std' => 1 |
1060 | 1060 | ), |
1061 | 1061 | 'email_due_reminder_days' => array( |
1062 | 1062 | 'id' => 'email_due_reminder_days', |
1063 | - 'name' => __( 'When to Send', 'sliced-invoices' ), |
|
1064 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
1063 | + 'name' => __('When to Send', 'sliced-invoices'), |
|
1064 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
1065 | 1065 | 'default' => '', |
1066 | 1066 | 'type' => 'multicheck', |
1067 | 1067 | 'options' => $overdue_days_options, |
1068 | 1068 | ), |
1069 | 1069 | 'email_overdue_subject' => array( |
1070 | 1070 | 'id' => 'email_overdue_subject', |
1071 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1072 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1071 | + 'name' => __('Subject', 'invoicing'), |
|
1072 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1073 | 1073 | 'type' => 'text', |
1074 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
1074 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
1075 | 1075 | 'size' => 'large' |
1076 | 1076 | ), |
1077 | 1077 | 'email_overdue_heading' => array( |
1078 | 1078 | 'id' => 'email_overdue_heading', |
1079 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1080 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1079 | + 'name' => __('Email Heading', 'invoicing'), |
|
1080 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1081 | 1081 | 'type' => 'text', |
1082 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
1082 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
1083 | 1083 | 'size' => 'large' |
1084 | 1084 | ), |
1085 | 1085 | 'email_overdue_body' => array( |
1086 | 1086 | 'id' => 'email_overdue_body', |
1087 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1088 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
1087 | + 'name' => __('Email Content', 'invoicing'), |
|
1088 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
1089 | 1089 | 'type' => 'rich_editor', |
1090 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing' ), |
|
1090 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing'), |
|
1091 | 1091 | 'class' => 'large', |
1092 | 1092 | 'size' => 10, |
1093 | 1093 | ), |
1094 | 1094 | ), |
1095 | 1095 | ); |
1096 | 1096 | |
1097 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
1097 | + return apply_filters('wpinv_get_emails', $emails); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | -function wpinv_settings_emails( $settings = array() ) { |
|
1100 | +function wpinv_settings_emails($settings = array()) { |
|
1101 | 1101 | $emails = wpinv_get_emails(); |
1102 | 1102 | |
1103 | - if ( !empty( $emails ) ) { |
|
1104 | - foreach ( $emails as $key => $email ) { |
|
1103 | + if (!empty($emails)) { |
|
1104 | + foreach ($emails as $key => $email) { |
|
1105 | 1105 | $settings[$key] = $email; |
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
1109 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
1109 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
1110 | 1110 | } |
1111 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
1111 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
1112 | 1112 | |
1113 | -function wpinv_settings_sections_emails( $settings ) { |
|
1113 | +function wpinv_settings_sections_emails($settings) { |
|
1114 | 1114 | $emails = wpinv_get_emails(); |
1115 | 1115 | |
1116 | 1116 | if (!empty($emails)) { |
1117 | - foreach ($emails as $key => $email) { |
|
1118 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
1117 | + foreach ($emails as $key => $email) { |
|
1118 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | return $settings; |
1123 | 1123 | } |
1124 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
1124 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
1125 | 1125 | |
1126 | -function wpinv_email_is_enabled( $email_type ) { |
|
1126 | +function wpinv_email_is_enabled($email_type) { |
|
1127 | 1127 | $emails = wpinv_get_emails(); |
1128 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
1128 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
1129 | 1129 | |
1130 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
1130 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1134 | - switch ( $email_type ) { |
|
1133 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1134 | + switch ($email_type) { |
|
1135 | 1135 | case 'new_invoice': |
1136 | 1136 | case 'cancelled_invoice': |
1137 | 1137 | case 'failed_invoice': |
1138 | 1138 | $recipient = wpinv_get_admin_email(); |
1139 | 1139 | break; |
1140 | 1140 | default: |
1141 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1142 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
1141 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1142 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
1143 | 1143 | break; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
1146 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1150 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
1149 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1150 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
1151 | 1151 | |
1152 | - $subject = wpinv_email_format_text( $subject ); |
|
1152 | + $subject = wpinv_email_format_text($subject); |
|
1153 | 1153 | |
1154 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
1154 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1158 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
1157 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1158 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
1159 | 1159 | |
1160 | - $email_heading = wpinv_email_format_text( $email_heading ); |
|
1160 | + $email_heading = wpinv_email_format_text($email_heading); |
|
1161 | 1161 | |
1162 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
1162 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1166 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
1165 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1166 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
1167 | 1167 | |
1168 | - $content = wpinv_email_format_text( $content ); |
|
1168 | + $content = wpinv_email_format_text($content); |
|
1169 | 1169 | |
1170 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
1170 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1173 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1174 | 1174 | $from_name = wpinv_mail_get_from_address(); |
1175 | 1175 | $from_email = wpinv_mail_get_from_address(); |
1176 | 1176 | |
1177 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1177 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1178 | 1178 | |
1179 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
1180 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
1179 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
1180 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
1181 | 1181 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
1182 | 1182 | |
1183 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
1183 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1186 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1187 | 1187 | $attachments = array(); |
1188 | 1188 | |
1189 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
1189 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | function wpinv_email_global_vars() { |
@@ -1203,73 +1203,73 @@ discard block |
||
1203 | 1203 | $replace['sitename'] = $blogname; |
1204 | 1204 | $replace['site-title'] = $blogname; |
1205 | 1205 | |
1206 | - return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) ); |
|
1206 | + return apply_filters('wpinv_email_global_vars', array($search, $replace)); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | -function wpinv_email_format_text( $content ) { |
|
1209 | +function wpinv_email_format_text($content) { |
|
1210 | 1210 | global $wpinv_email_search, $wpinv_email_replace; |
1211 | 1211 | |
1212 | - if ( empty( $wpinv_email_search ) ) { |
|
1212 | + if (empty($wpinv_email_search)) { |
|
1213 | 1213 | $wpinv_email_search = array(); |
1214 | 1214 | } |
1215 | 1215 | |
1216 | - if ( empty( $wpinv_email_replace ) ) { |
|
1216 | + if (empty($wpinv_email_replace)) { |
|
1217 | 1217 | $wpinv_email_replace = array(); |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - $wpinv_email_search = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search ); |
|
1221 | - $wpinv_email_replace = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace ); |
|
1220 | + $wpinv_email_search = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search); |
|
1221 | + $wpinv_email_replace = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace); |
|
1222 | 1222 | |
1223 | 1223 | $global_vars = wpinv_email_global_vars(); |
1224 | 1224 | |
1225 | - $search = array_merge( $global_vars[0], $wpinv_email_search ); |
|
1226 | - $replace = array_merge( $global_vars[1], $wpinv_email_replace ); |
|
1225 | + $search = array_merge($global_vars[0], $wpinv_email_search); |
|
1226 | + $replace = array_merge($global_vars[1], $wpinv_email_replace); |
|
1227 | 1227 | |
1228 | - if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) { |
|
1228 | + if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) { |
|
1229 | 1229 | return $content; |
1230 | 1230 | } |
1231 | 1231 | |
1232 | - return str_replace( $search, $replace, $content ); |
|
1232 | + return str_replace($search, $replace, $content); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | -function wpinv_email_style_body( $content ) { |
|
1235 | +function wpinv_email_style_body($content) { |
|
1236 | 1236 | // make sure we only inline CSS for html emails |
1237 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
1237 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
1238 | 1238 | ob_start(); |
1239 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
1240 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
1239 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
1240 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
1241 | 1241 | |
1242 | 1242 | // apply CSS styles inline for picky email clients |
1243 | 1243 | try { |
1244 | - $emogrifier = new Emogrifier( $content, $css ); |
|
1244 | + $emogrifier = new Emogrifier($content, $css); |
|
1245 | 1245 | $content = $emogrifier->emogrify(); |
1246 | - } catch ( Exception $e ) { |
|
1247 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
1246 | + } catch (Exception $e) { |
|
1247 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | return $content; |
1251 | 1251 | } |
1252 | 1252 | |
1253 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1254 | - wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1253 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1254 | + wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | /** |
1258 | 1258 | * Get the email footer. |
1259 | 1259 | */ |
1260 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1261 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1260 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1261 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | -function wpinv_email_wrap_message( $message ) { |
|
1264 | +function wpinv_email_wrap_message($message) { |
|
1265 | 1265 | // Buffer |
1266 | 1266 | ob_start(); |
1267 | 1267 | |
1268 | - do_action( 'wpinv_email_header' ); |
|
1268 | + do_action('wpinv_email_header'); |
|
1269 | 1269 | |
1270 | - echo wpautop( wptexturize( $message ) ); |
|
1270 | + echo wpautop(wptexturize($message)); |
|
1271 | 1271 | |
1272 | - do_action( 'wpinv_email_footer' ); |
|
1272 | + do_action('wpinv_email_footer'); |
|
1273 | 1273 | |
1274 | 1274 | // Get contents |
1275 | 1275 | $message = ob_get_clean(); |
@@ -1277,86 +1277,86 @@ discard block |
||
1277 | 1277 | return $message; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1281 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1280 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1281 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1285 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1284 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
1285 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1289 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1288 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1289 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
1293 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1292 | +function wpinv_send_customer_invoice($data = array()) { |
|
1293 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1294 | 1294 | |
1295 | - if ( empty( $invoice_id ) ) { |
|
1295 | + if (empty($invoice_id)) { |
|
1296 | 1296 | return; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1300 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1299 | + if (!current_user_can('manage_options')) { |
|
1300 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
1303 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
1304 | 1304 | |
1305 | 1305 | $status = $sent ? 'email_sent' : 'email_fail'; |
1306 | 1306 | |
1307 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1308 | - wp_redirect( $redirect ); |
|
1307 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1308 | + wp_redirect($redirect); |
|
1309 | 1309 | exit; |
1310 | 1310 | } |
1311 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
1311 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
1312 | 1312 | |
1313 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
1314 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1313 | +function wpinv_send_overdue_reminder($data = array()) { |
|
1314 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1315 | 1315 | |
1316 | - if ( empty( $invoice_id ) ) { |
|
1316 | + if (empty($invoice_id)) { |
|
1317 | 1317 | return; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1321 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1320 | + if (!current_user_can('manage_options')) { |
|
1321 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
1324 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
1325 | 1325 | |
1326 | 1326 | $status = $sent ? 'email_sent' : 'email_fail'; |
1327 | 1327 | |
1328 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1329 | - wp_redirect( $redirect ); |
|
1328 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1329 | + wp_redirect($redirect); |
|
1330 | 1330 | exit; |
1331 | 1331 | } |
1332 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
1332 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
1333 | 1333 | |
1334 | -function wpinv_send_customer_note_email( $data ) { |
|
1335 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1334 | +function wpinv_send_customer_note_email($data) { |
|
1335 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1336 | 1336 | |
1337 | - if ( empty( $invoice_id ) ) { |
|
1337 | + if (empty($invoice_id)) { |
|
1338 | 1338 | return; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
1341 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
1342 | 1342 | } |
1343 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
1343 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
1344 | 1344 | |
1345 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
1346 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
1347 | - $date_format = get_option( 'date_format' ); |
|
1348 | - $time_format = get_option( 'time_format' ); |
|
1345 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
1346 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
1347 | + $date_format = get_option('date_format'); |
|
1348 | + $time_format = get_option('time_format'); |
|
1349 | 1349 | ?> |
1350 | 1350 | <div id="wpinv-email-notes"> |
1351 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
1351 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
1352 | 1352 | <ol class="wpinv-notes-lists"> |
1353 | 1353 | <?php |
1354 | - foreach ( $invoice_notes as $note ) { |
|
1355 | - $note_time = strtotime( $note->comment_date ); |
|
1354 | + foreach ($invoice_notes as $note) { |
|
1355 | + $note_time = strtotime($note->comment_date); |
|
1356 | 1356 | ?> |
1357 | 1357 | <li class="comment wpinv-note"> |
1358 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
1359 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
1358 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
1359 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
1360 | 1360 | </li> |
1361 | 1361 | <?php |
1362 | 1362 | } |
@@ -1365,21 +1365,21 @@ discard block |
||
1365 | 1365 | <?php |
1366 | 1366 | } |
1367 | 1367 | } |
1368 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
1368 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
1369 | 1369 | |
1370 | 1370 | function wpinv_email_payment_reminders() { |
1371 | 1371 | global $wpi_auto_reminder; |
1372 | - if ( !wpinv_get_option( 'email_overdue_active' ) ) { |
|
1372 | + if (!wpinv_get_option('email_overdue_active')) { |
|
1373 | 1373 | return; |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
1377 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : ''; |
|
1376 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
1377 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : ''; |
|
1378 | 1378 | |
1379 | - if ( empty( $reminder_days ) ) { |
|
1379 | + if (empty($reminder_days)) { |
|
1380 | 1380 | return; |
1381 | 1381 | } |
1382 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
1382 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
1383 | 1383 | |
1384 | 1384 | $args = array( |
1385 | 1385 | 'post_type' => 'wpi_invoice', |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | 'meta_query' => array( |
1390 | 1390 | array( |
1391 | 1391 | 'key' => '_wpinv_due_date', |
1392 | - 'value' => array( '', 'none' ), |
|
1392 | + 'value' => array('', 'none'), |
|
1393 | 1393 | 'compare' => 'NOT IN', |
1394 | 1394 | ) |
1395 | 1395 | ), |
@@ -1398,64 +1398,64 @@ discard block |
||
1398 | 1398 | 'order' => 'ASC', |
1399 | 1399 | ); |
1400 | 1400 | |
1401 | - $invoices = get_posts( $args ); |
|
1401 | + $invoices = get_posts($args); |
|
1402 | 1402 | |
1403 | - if ( empty( $invoices ) ) { |
|
1403 | + if (empty($invoices)) { |
|
1404 | 1404 | return; |
1405 | 1405 | } |
1406 | 1406 | |
1407 | - $date_to_send = array(); |
|
1407 | + $date_to_send = array(); |
|
1408 | 1408 | |
1409 | - foreach ( $invoices as $id ) { |
|
1410 | - $due_date = get_post_meta( $id, '_wpinv_due_date', true ); |
|
1409 | + foreach ($invoices as $id) { |
|
1410 | + $due_date = get_post_meta($id, '_wpinv_due_date', true); |
|
1411 | 1411 | |
1412 | - foreach ( $reminder_days as $key => $days ) { |
|
1413 | - if ( $days !== '' ) { |
|
1414 | - $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) ); |
|
1412 | + foreach ($reminder_days as $key => $days) { |
|
1413 | + if ($days !== '') { |
|
1414 | + $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS)); |
|
1415 | 1415 | } |
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | |
1419 | - $today = date_i18n( 'Y-m-d' ); |
|
1419 | + $today = date_i18n('Y-m-d'); |
|
1420 | 1420 | $wpi_auto_reminder = true; |
1421 | 1421 | |
1422 | - foreach ( $date_to_send as $id => $values ) { |
|
1423 | - if ( in_array( $today, $values ) ) { |
|
1424 | - $sent = get_post_meta( $id, '_wpinv_reminder_sent', true ); |
|
1422 | + foreach ($date_to_send as $id => $values) { |
|
1423 | + if (in_array($today, $values)) { |
|
1424 | + $sent = get_post_meta($id, '_wpinv_reminder_sent', true); |
|
1425 | 1425 | |
1426 | - if ( isset( $sent ) && !empty( $sent ) ) { |
|
1427 | - if ( !in_array( $today, $sent ) ) { |
|
1428 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1426 | + if (isset($sent) && !empty($sent)) { |
|
1427 | + if (!in_array($today, $sent)) { |
|
1428 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1429 | 1429 | } |
1430 | 1430 | } else { |
1431 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1431 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1432 | 1432 | } |
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | |
1436 | - $wpi_auto_reminder = false; |
|
1436 | + $wpi_auto_reminder = false; |
|
1437 | 1437 | } |
1438 | 1438 | } |
1439 | 1439 | |
1440 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
1440 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
1441 | 1441 | global $wpinv_email_search, $wpinv_email_replace; |
1442 | 1442 | |
1443 | 1443 | $email_type = 'overdue'; |
1444 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
1444 | + if (!wpinv_email_is_enabled($email_type)) { |
|
1445 | 1445 | return false; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1449 | - if ( empty( $invoice ) ) { |
|
1448 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1449 | + if (empty($invoice)) { |
|
1450 | 1450 | return false; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - if ( !$invoice->needs_payment() ) { |
|
1453 | + if (!$invoice->needs_payment()) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
1458 | - if ( !is_email( $recipient ) ) { |
|
1457 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
1458 | + if (!is_email($recipient)) { |
|
1459 | 1459 | return false; |
1460 | 1460 | } |
1461 | 1461 | |
@@ -1471,70 +1471,70 @@ discard block |
||
1471 | 1471 | $replace = array(); |
1472 | 1472 | $replace['full_name'] = $invoice->get_user_full_name(); |
1473 | 1473 | $replace['invoice_number'] = $invoice->get_number(); |
1474 | - $replace['invoice_due_date']= $invoice->get_due_date( true ); |
|
1475 | - $replace['invoice_total'] = $invoice->get_total( true ); |
|
1476 | - $replace['invoice_link'] = $invoice->get_view_url( true ); |
|
1477 | - $replace['invoice_pay_link']= $invoice->get_checkout_payment_url( false, true ); |
|
1478 | - $replace['is_was'] = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ); |
|
1474 | + $replace['invoice_due_date'] = $invoice->get_due_date(true); |
|
1475 | + $replace['invoice_total'] = $invoice->get_total(true); |
|
1476 | + $replace['invoice_link'] = $invoice->get_view_url(true); |
|
1477 | + $replace['invoice_pay_link'] = $invoice->get_checkout_payment_url(false, true); |
|
1478 | + $replace['is_was'] = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'); |
|
1479 | 1479 | |
1480 | 1480 | $wpinv_email_search = $search; |
1481 | 1481 | $wpinv_email_replace = $replace; |
1482 | 1482 | |
1483 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
1484 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
1485 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
1486 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
1483 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
1484 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
1485 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
1486 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
1487 | 1487 | |
1488 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
1488 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
1489 | 1489 | |
1490 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
1490 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
1491 | 1491 | 'invoice' => $invoice, |
1492 | 1492 | 'email_type' => $email_type, |
1493 | 1493 | 'email_heading' => $email_heading, |
1494 | 1494 | 'sent_to_admin' => false, |
1495 | 1495 | 'plain_text' => false, |
1496 | 1496 | 'message_body' => $message_body |
1497 | - ) ); |
|
1497 | + )); |
|
1498 | 1498 | |
1499 | - $content = wpinv_email_format_text( $content ); |
|
1499 | + $content = wpinv_email_format_text($content); |
|
1500 | 1500 | |
1501 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
1502 | - if ( $sent ) { |
|
1503 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
1501 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
1502 | + if ($sent) { |
|
1503 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | return $sent; |
1507 | 1507 | } |
1508 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
1508 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
1509 | 1509 | |
1510 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
1510 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
1511 | 1511 | global $wpi_auto_reminder; |
1512 | 1512 | |
1513 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
1513 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
1514 | 1514 | |
1515 | - if ( empty( $sent ) ) { |
|
1515 | + if (empty($sent)) { |
|
1516 | 1516 | $sent = array(); |
1517 | 1517 | } |
1518 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
1518 | + $sent[] = date_i18n('Y-m-d'); |
|
1519 | 1519 | |
1520 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
1520 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
1521 | 1521 | |
1522 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
1523 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1524 | - $invoice->add_note( $note, false, false, true ); |
|
1522 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
1523 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1524 | + $invoice->add_note($note, false, false, true); |
|
1525 | 1525 | } else { // Menual reminder note. |
1526 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1527 | - $invoice->add_note( $note ); |
|
1526 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1527 | + $invoice->add_note($note); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
1530 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
|
1531 | 1531 | |
1532 | -function wpinv_email_before_note_details( $invoice, $email_type, $sent_to_admin, $customer_note ) { |
|
1532 | +function wpinv_email_before_note_details($invoice, $email_type, $sent_to_admin, $customer_note) { |
|
1533 | 1533 | if ("wpi_invoice" === $invoice->post_type && !empty($customer_note)) { |
1534 | 1534 | $before_note = ''; |
1535 | - $before_note .= __( 'Hello, a note has just been added to your invoice:', 'invoicing' ); |
|
1536 | - $before_note .= '<blockquote class="wpinv-note">'.wpautop( wptexturize( $customer_note ) ).'</blockquote>'; |
|
1537 | - $before_note .= __( 'For your reference, your invoice details are shown below.', 'invoicing' ); |
|
1535 | + $before_note .= __('Hello, a note has just been added to your invoice:', 'invoicing'); |
|
1536 | + $before_note .= '<blockquote class="wpinv-note">' . wpautop(wptexturize($customer_note)) . '</blockquote>'; |
|
1537 | + $before_note .= __('For your reference, your invoice details are shown below.', 'invoicing'); |
|
1538 | 1538 | echo $before_note; |
1539 | 1539 | } |
1540 | 1540 | } |
1541 | 1541 | \ No newline at end of file |
@@ -155,65 +155,65 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_admin_messages() { |
158 | - global $wpinv_options, $pagenow, $post; |
|
158 | + global $wpinv_options, $pagenow, $post; |
|
159 | 159 | |
160 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
161 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
162 | - } |
|
160 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
161 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
162 | + } |
|
163 | 163 | |
164 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
165 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
166 | - } |
|
164 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
165 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
166 | + } |
|
167 | 167 | |
168 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
169 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
170 | - } |
|
168 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
169 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
170 | + } |
|
171 | 171 | |
172 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
173 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
174 | - } |
|
172 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
173 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
174 | + } |
|
175 | 175 | |
176 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
177 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
178 | - } |
|
176 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
177 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
178 | + } |
|
179 | 179 | |
180 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
181 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
182 | - } |
|
180 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
181 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
182 | + } |
|
183 | 183 | |
184 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
185 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
184 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
185 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
189 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
189 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
193 | 193 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
194 | 194 | } |
195 | 195 | |
196 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
197 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
198 | - } |
|
196 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
197 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
198 | + } |
|
199 | 199 | |
200 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
201 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
202 | - } |
|
200 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
201 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
202 | + } |
|
203 | 203 | |
204 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
205 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
206 | - } |
|
204 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
205 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
206 | + } |
|
207 | 207 | |
208 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
209 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
208 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
209 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
210 | 210 | |
211 | - if ( !empty( $message ) ) { |
|
212 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
213 | - } |
|
214 | - } |
|
211 | + if ( !empty( $message ) ) { |
|
212 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - settings_errors( 'wpinv-notices' ); |
|
216 | + settings_errors( 'wpinv-notices' ); |
|
217 | 217 | } |
218 | 218 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
219 | 219 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | break; |
277 | 277 | case 'id' : |
278 | 278 | echo $post->ID; |
279 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
279 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
280 | 280 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
281 | 281 | if ( $wpinv_euvat->allow_vat_rules() ) { |
282 | 282 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,239 +7,239 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
21 | - 'status' => __( 'Status', 'invoicing' ), |
|
22 | - 'ID' => __( 'ID', 'invoicing' ), |
|
23 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Date', 'invoicing'), |
|
21 | + 'status' => __('Status', 'invoicing'), |
|
22 | + 'ID' => __('ID', 'invoicing'), |
|
23 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
24 | 24 | ); |
25 | 25 | |
26 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
26 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
27 | 27 | } |
28 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
28 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
29 | 29 | |
30 | -function wpinv_bulk_actions( $actions ) { |
|
31 | - if ( isset( $actions['edit'] ) ) { |
|
32 | - unset( $actions['edit'] ); |
|
30 | +function wpinv_bulk_actions($actions) { |
|
31 | + if (isset($actions['edit'])) { |
|
32 | + unset($actions['edit']); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $actions; |
36 | 36 | } |
37 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
38 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
37 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
38 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
39 | 39 | |
40 | -function wpinv_sortable_columns( $columns ) { |
|
40 | +function wpinv_sortable_columns($columns) { |
|
41 | 41 | $columns = array( |
42 | - 'ID' => array( 'ID', true ), |
|
43 | - 'number' => array( 'number', false ), |
|
44 | - 'amount' => array( 'amount', false ), |
|
45 | - 'invoice_date' => array( 'date', false ), |
|
46 | - 'customer' => array( 'customer', false ), |
|
47 | - 'status' => array( 'status', false ), |
|
42 | + 'ID' => array('ID', true), |
|
43 | + 'number' => array('number', false), |
|
44 | + 'amount' => array('amount', false), |
|
45 | + 'invoice_date' => array('date', false), |
|
46 | + 'customer' => array('customer', false), |
|
47 | + 'status' => array('status', false), |
|
48 | 48 | ); |
49 | 49 | |
50 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
50 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
51 | 51 | } |
52 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
52 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
53 | 53 | |
54 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
55 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
54 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
55 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
56 | 56 | global $post, $wpi_invoice; |
57 | 57 | |
58 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
59 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
58 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
59 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $value = NULL; |
63 | 63 | |
64 | - switch ( $column_name ) { |
|
64 | + switch ($column_name) { |
|
65 | 65 | case 'email' : |
66 | - $value = $wpi_invoice->get_email(); |
|
66 | + $value = $wpi_invoice->get_email(); |
|
67 | 67 | break; |
68 | 68 | case 'customer' : |
69 | 69 | $customer_name = $wpi_invoice->get_user_full_name(); |
70 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
71 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
72 | - if ( $email = $wpi_invoice->get_email() ) { |
|
70 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
71 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
72 | + if ($email = $wpi_invoice->get_email()) { |
|
73 | 73 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
74 | 74 | } |
75 | 75 | break; |
76 | 76 | case 'amount' : |
77 | - echo $wpi_invoice->get_total( true ); |
|
77 | + echo $wpi_invoice->get_total(true); |
|
78 | 78 | break; |
79 | 79 | case 'invoice_date' : |
80 | - $date_format = get_option( 'date_format' ); |
|
81 | - $time_format = get_option( 'time_format' ); |
|
82 | - $date_time_format = $date_format . ' '. $time_format; |
|
80 | + $date_format = get_option('date_format'); |
|
81 | + $time_format = get_option('time_format'); |
|
82 | + $date_time_format = $date_format . ' ' . $time_format; |
|
83 | 83 | |
84 | - $t_time = get_the_time( $date_time_format ); |
|
84 | + $t_time = get_the_time($date_time_format); |
|
85 | 85 | $m_time = $post->post_date; |
86 | - $h_time = mysql2date( $date_format, $m_time ); |
|
86 | + $h_time = mysql2date($date_format, $m_time); |
|
87 | 87 | |
88 | 88 | $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
89 | 89 | break; |
90 | 90 | case 'status' : |
91 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
92 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && $gateway_title = $wpi_invoice->get_gateway_title() ) { |
|
93 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
91 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
92 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && $gateway_title = $wpi_invoice->get_gateway_title()) { |
|
93 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
94 | 94 | } |
95 | 95 | break; |
96 | 96 | case 'number' : |
97 | - $edit_link = get_edit_post_link( $post->ID ); |
|
98 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
97 | + $edit_link = get_edit_post_link($post->ID); |
|
98 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
99 | 99 | break; |
100 | 100 | case 'wpi_actions' : |
101 | 101 | $value = ''; |
102 | - if ( !empty( $post->post_name ) ) { |
|
103 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
102 | + if (!empty($post->post_name)) { |
|
103 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( $email = $wpi_invoice->get_email() ) { |
|
107 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
106 | + if ($email = $wpi_invoice->get_email()) { |
|
107 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | break; |
111 | 111 | default: |
112 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
112 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
113 | 113 | break; |
114 | 114 | |
115 | 115 | } |
116 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
116 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
117 | 117 | |
118 | - if ( $value !== NULL ) { |
|
118 | + if ($value !== NULL) { |
|
119 | 119 | echo $value; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | -function wpinv_admin_post_id( $id = 0 ) { |
|
123 | +function wpinv_admin_post_id($id = 0) { |
|
124 | 124 | global $post; |
125 | 125 | |
126 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
126 | + if (isset($id) && !empty($id)) { |
|
127 | 127 | return (int)$id; |
128 | - } else if ( get_the_ID() ) { |
|
129 | - return (int) get_the_ID(); |
|
130 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
131 | - return (int) $post->ID; |
|
132 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
133 | - return (int) $_GET['post']; |
|
134 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
135 | - return (int) $_GET['id']; |
|
136 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
137 | - return (int) $_POST['id']; |
|
128 | + } else if (get_the_ID()) { |
|
129 | + return (int)get_the_ID(); |
|
130 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
131 | + return (int)$post->ID; |
|
132 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
133 | + return (int)$_GET['post']; |
|
134 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
135 | + return (int)$_GET['id']; |
|
136 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
137 | + return (int)$_POST['id']; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return null; |
141 | 141 | } |
142 | 142 | |
143 | -function wpinv_admin_post_type( $id = 0 ) { |
|
144 | - if ( !$id ) { |
|
143 | +function wpinv_admin_post_type($id = 0) { |
|
144 | + if (!$id) { |
|
145 | 145 | $id = wpinv_admin_post_id(); |
146 | 146 | } |
147 | 147 | |
148 | - $type = get_post_type( $id ); |
|
148 | + $type = get_post_type($id); |
|
149 | 149 | |
150 | - if ( !$type ) { |
|
151 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
150 | + if (!$type) { |
|
151 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
154 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_admin_messages() { |
158 | 158 | global $wpinv_options, $pagenow, $post; |
159 | 159 | |
160 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
161 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
160 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
161 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
162 | 162 | } |
163 | 163 | |
164 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
165 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
164 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
165 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
166 | 166 | } |
167 | 167 | |
168 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
169 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
168 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
169 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
173 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
172 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
173 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
174 | 174 | } |
175 | 175 | |
176 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
177 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
176 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
177 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
178 | 178 | } |
179 | 179 | |
180 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
181 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
180 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
181 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
185 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
184 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
185 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
186 | 186 | } |
187 | 187 | |
188 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
189 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
188 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
189 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
193 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
192 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
193 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
194 | 194 | } |
195 | 195 | |
196 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
197 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
196 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
197 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
198 | 198 | } |
199 | 199 | |
200 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
201 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
200 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
201 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
202 | 202 | } |
203 | 203 | |
204 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
205 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
204 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
205 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
209 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
208 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
209 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
210 | 210 | |
211 | - if ( !empty( $message ) ) { |
|
212 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
211 | + if (!empty($message)) { |
|
212 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - settings_errors( 'wpinv-notices' ); |
|
216 | + settings_errors('wpinv-notices'); |
|
217 | 217 | } |
218 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
218 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
219 | 219 | |
220 | -function wpinv_items_columns( $existing_columns ) { |
|
220 | +function wpinv_items_columns($existing_columns) { |
|
221 | 221 | global $wpinv_euvat; |
222 | 222 | |
223 | 223 | $columns = array(); |
224 | 224 | $columns['cb'] = $existing_columns['cb']; |
225 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
226 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
227 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
228 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
225 | + $columns['title'] = __('Title', 'invoicing'); |
|
226 | + $columns['price'] = __('Price', 'invoicing'); |
|
227 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
228 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
229 | 229 | } |
230 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
231 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
230 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
231 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
232 | 232 | } |
233 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
234 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
235 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
236 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
233 | + $columns['type'] = __('Type', 'invoicing'); |
|
234 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
235 | + $columns['date'] = __('Date', 'invoicing'); |
|
236 | + $columns['id'] = __('ID', 'invoicing'); |
|
237 | 237 | |
238 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
238 | + return apply_filters('wpinv_items_columns', $columns); |
|
239 | 239 | } |
240 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
240 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
241 | 241 | |
242 | -function wpinv_items_sortable_columns( $columns ) { |
|
242 | +function wpinv_items_sortable_columns($columns) { |
|
243 | 243 | $columns['price'] = 'price'; |
244 | 244 | $columns['vat_rule'] = 'vat_rule'; |
245 | 245 | $columns['vat_class'] = 'vat_class'; |
@@ -249,156 +249,156 @@ discard block |
||
249 | 249 | |
250 | 250 | return $columns; |
251 | 251 | } |
252 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
252 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
253 | 253 | |
254 | -function wpinv_items_table_custom_column( $column ) { |
|
254 | +function wpinv_items_table_custom_column($column) { |
|
255 | 255 | global $wpinv_euvat, $post, $wpi_item; |
256 | 256 | |
257 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
258 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
257 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
258 | + $wpi_item = new WPInv_Item($post->ID); |
|
259 | 259 | } |
260 | 260 | |
261 | - switch ( $column ) { |
|
261 | + switch ($column) { |
|
262 | 262 | case 'price' : |
263 | - echo wpinv_item_price( $post->ID ); |
|
263 | + echo wpinv_item_price($post->ID); |
|
264 | 264 | break; |
265 | 265 | case 'vat_rule' : |
266 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
266 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
267 | 267 | break; |
268 | 268 | case 'vat_class' : |
269 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
269 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
270 | 270 | break; |
271 | 271 | case 'type' : |
272 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
272 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
273 | 273 | break; |
274 | 274 | case 'recurring' : |
275 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
275 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
276 | 276 | break; |
277 | 277 | case 'id' : |
278 | 278 | echo $post->ID; |
279 | 279 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
280 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
281 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
282 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
280 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
281 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
282 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
283 | 283 | } |
284 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
285 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
284 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
285 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
286 | 286 | } |
287 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
287 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
288 | 288 | </div>'; |
289 | 289 | break; |
290 | 290 | } |
291 | 291 | |
292 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
292 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
293 | 293 | } |
294 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
294 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
295 | 295 | |
296 | 296 | function wpinv_add_items_filters() { |
297 | 297 | global $wpinv_euvat, $typenow; |
298 | 298 | |
299 | 299 | // Checks if the current post type is 'item' |
300 | - if ( $typenow == 'wpi_item') { |
|
301 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
302 | - echo wpinv_html_select( array( |
|
303 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
300 | + if ($typenow == 'wpi_item') { |
|
301 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
302 | + echo wpinv_html_select(array( |
|
303 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
304 | 304 | 'name' => 'vat_rule', |
305 | 305 | 'id' => 'vat_rule', |
306 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
306 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
307 | 307 | 'show_option_all' => false, |
308 | 308 | 'show_option_none' => false, |
309 | 309 | 'class' => 'gdmbx2-text-medium', |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | } |
312 | 312 | |
313 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
314 | - echo wpinv_html_select( array( |
|
315 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
313 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
314 | + echo wpinv_html_select(array( |
|
315 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
316 | 316 | 'name' => 'vat_class', |
317 | 317 | 'id' => 'vat_class', |
318 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
318 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
319 | 319 | 'show_option_all' => false, |
320 | 320 | 'show_option_none' => false, |
321 | 321 | 'class' => 'gdmbx2-text-medium', |
322 | - ) ); |
|
322 | + )); |
|
323 | 323 | } |
324 | 324 | |
325 | - echo wpinv_html_select( array( |
|
326 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
325 | + echo wpinv_html_select(array( |
|
326 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
327 | 327 | 'name' => 'type', |
328 | 328 | 'id' => 'type', |
329 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
329 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
330 | 330 | 'show_option_all' => false, |
331 | 331 | 'show_option_none' => false, |
332 | 332 | 'class' => 'gdmbx2-text-medium', |
333 | - ) ); |
|
333 | + )); |
|
334 | 334 | |
335 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
335 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
336 | 336 | echo '<input type="hidden" name="all_posts" value="1" />'; |
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
340 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
340 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
341 | 341 | |
342 | -function wpinv_send_invoice_after_save( $post_id ) { |
|
342 | +function wpinv_send_invoice_after_save($post_id) { |
|
343 | 343 | // If this is just a revision, don't send the email. |
344 | - if ( wp_is_post_revision( $post_id ) ) { |
|
344 | + if (wp_is_post_revision($post_id)) { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - if ( !current_user_can( 'manage_options' ) || !('wpi_invoice' == get_post_type( $post_id )) ) { |
|
348 | + if (!current_user_can('manage_options') || !('wpi_invoice' == get_post_type($post_id))) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - if ( !empty( $_POST['wpi_save_send'] ) ) { |
|
353 | - wpinv_user_invoice_notification( $post_id ); |
|
352 | + if (!empty($_POST['wpi_save_send'])) { |
|
353 | + wpinv_user_invoice_notification($post_id); |
|
354 | 354 | } |
355 | 355 | } |
356 | -add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
356 | +add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1); |
|
357 | 357 | |
358 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
359 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
360 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
361 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
358 | +function wpinv_send_register_new_user($data, $postarr) { |
|
359 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
360 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
361 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
362 | 362 | |
363 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
364 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
365 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
366 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
367 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
368 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
363 | + if ($is_new_user && $email && !email_exists($email)) { |
|
364 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
365 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
366 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
367 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
368 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
369 | 369 | |
370 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
371 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
370 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
371 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
372 | 372 | $new_user_login = strstr($email, '@', true); |
373 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
374 | - $user_login = sanitize_user($new_user_login, true ); |
|
373 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
374 | + $user_login = sanitize_user($new_user_login, true); |
|
375 | 375 | } |
376 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
377 | - $user_append_text = rand(10,1000); |
|
378 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
376 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
377 | + $user_append_text = rand(10, 1000); |
|
378 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
381 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
382 | 382 | $user_login = $email; |
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
386 | 386 | $userdata = array( |
387 | 387 | 'user_login' => $user_login, |
388 | - 'user_pass' => wp_generate_password( 12, false ), |
|
389 | - 'user_email' => sanitize_text_field( $email ), |
|
388 | + 'user_pass' => wp_generate_password(12, false), |
|
389 | + 'user_email' => sanitize_text_field($email), |
|
390 | 390 | 'first_name' => $first_name, |
391 | 391 | 'last_name' => $last_name, |
392 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
392 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
393 | 393 | 'nickname' => $display_name, |
394 | 394 | 'display_name' => $display_name, |
395 | 395 | ); |
396 | 396 | |
397 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
397 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
398 | 398 | |
399 | - $new_user_id = wp_insert_user( $userdata ); |
|
399 | + $new_user_id = wp_insert_user($userdata); |
|
400 | 400 | |
401 | - if ( !is_wp_error( $new_user_id ) ) { |
|
401 | + if (!is_wp_error($new_user_id)) { |
|
402 | 402 | $data['post_author'] = $new_user_id; |
403 | 403 | $_POST['post_author'] = $new_user_id; |
404 | 404 | $_POST['post_author_override'] = $new_user_id; |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | |
420 | 420 | $meta = array(); |
421 | 421 | ///$meta['_wpinv_user_id'] = $new_user_id; |
422 | - foreach ( $meta_fields as $field ) { |
|
423 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
422 | + foreach ($meta_fields as $field) { |
|
423 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
424 | 424 | } |
425 | 425 | |
426 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
426 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
427 | 427 | |
428 | 428 | // Update user meta. |
429 | - foreach ( $meta as $key => $value ) { |
|
430 | - update_user_meta( $new_user_id, $key, $value ); |
|
429 | + foreach ($meta as $key => $value) { |
|
430 | + update_user_meta($new_user_id, $key, $value); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
433 | + if (function_exists('wp_send_new_user_notifications')) { |
|
434 | 434 | // Send email notifications related to the creation of new user. |
435 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
435 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
436 | 436 | } |
437 | 437 | } else { |
438 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
438 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | 443 | return $data; |
444 | 444 | } |
445 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
446 | 445 | \ No newline at end of file |
446 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
447 | 447 | \ No newline at end of file |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,256 +72,256 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - if ( $field == '_wpinv_price' ) { |
|
86 | - if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) { |
|
87 | - $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price. |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + if ($field == '_wpinv_price') { |
|
86 | + if (get_post_meta($post_id, '_wpinv_type', true) === 'package') { |
|
87 | + $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price. |
|
88 | 88 | } else { |
89 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
89 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
92 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
93 | 93 | } |
94 | 94 | |
95 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
96 | - update_post_meta( $post_id, $field, $value ); |
|
95 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
96 | + update_post_meta($post_id, $field, $value); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
101 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
100 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
101 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
106 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
107 | 107 | |
108 | 108 | function wpinv_register_item_meta_boxes() { |
109 | 109 | global $wpinv_euvat; |
110 | 110 | |
111 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
111 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
112 | 112 | |
113 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
114 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
113 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
114 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
118 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
117 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
118 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
119 | 119 | } |
120 | 120 | |
121 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
122 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
121 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
122 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function wpinv_register_discount_meta_boxes() { |
126 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
126 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
127 | 127 | } |
128 | 128 | |
129 | -function wpinv_discount_metabox_details( $post ) { |
|
129 | +function wpinv_discount_metabox_details($post) { |
|
130 | 130 | $discount_id = $post->ID; |
131 | - $discount = wpinv_get_discount( $discount_id ); |
|
131 | + $discount = wpinv_get_discount($discount_id); |
|
132 | 132 | |
133 | - $type = wpinv_get_discount_type( $discount_id ); |
|
134 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
135 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
136 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
137 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
138 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
139 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
140 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
133 | + $type = wpinv_get_discount_type($discount_id); |
|
134 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
135 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
136 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
137 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
138 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
139 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
140 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
141 | 141 | |
142 | 142 | $min_total = $min_total > 0 ? $min_total : ''; |
143 | 143 | $max_total = $max_total > 0 ? $max_total : ''; |
144 | 144 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
145 | 145 | ?> |
146 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
147 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
146 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
147 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
148 | 148 | <table class="form-table wpi-form-table"> |
149 | 149 | <tbody> |
150 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
151 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
150 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
151 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
152 | 152 | <tr> |
153 | 153 | <th valign="top" scope="row"> |
154 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
154 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
155 | 155 | </th> |
156 | 156 | <td> |
157 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
158 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
157 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
158 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
161 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
162 | 162 | <tr> |
163 | 163 | <th valign="top" scope="row"> |
164 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
164 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
165 | 165 | </th> |
166 | 166 | <td> |
167 | 167 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
168 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
169 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
168 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
169 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
170 | 170 | <?php } ?> |
171 | 171 | </select> |
172 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
172 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
173 | 173 | </td> |
174 | 174 | </tr> |
175 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
182 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
183 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
182 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
183 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
184 | 184 | </td> |
185 | 185 | </tr> |
186 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
186 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
187 | 187 | <tr> |
188 | 188 | <th valign="top" scope="row"> |
189 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
189 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
190 | 190 | </th> |
191 | 191 | <td> |
192 | - <p><?php echo wpinv_item_dropdown( array( |
|
192 | + <p><?php echo wpinv_item_dropdown(array( |
|
193 | 193 | 'name' => 'items[]', |
194 | 194 | 'id' => 'items', |
195 | 195 | 'selected' => $item_reqs, |
196 | 196 | 'multiple' => true, |
197 | 197 | 'chosen' => true, |
198 | 198 | 'class' => 'medium-text', |
199 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
199 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
200 | 200 | 'show_recurring' => true, |
201 | - ) ); ?> |
|
201 | + )); ?> |
|
202 | 202 | </p> |
203 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
203 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
204 | 204 | </td> |
205 | 205 | </tr> |
206 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
206 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
207 | 207 | <tr> |
208 | 208 | <th valign="top" scope="row"> |
209 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
209 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
210 | 210 | </th> |
211 | 211 | <td> |
212 | - <p><?php echo wpinv_item_dropdown( array( |
|
212 | + <p><?php echo wpinv_item_dropdown(array( |
|
213 | 213 | 'name' => 'excluded_items[]', |
214 | 214 | 'id' => 'excluded_items', |
215 | 215 | 'selected' => $excluded_items, |
216 | 216 | 'multiple' => true, |
217 | 217 | 'chosen' => true, |
218 | 218 | 'class' => 'medium-text', |
219 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
219 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
220 | 220 | 'show_recurring' => true, |
221 | - ) ); ?> |
|
221 | + )); ?> |
|
222 | 222 | </p> |
223 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
223 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
224 | 224 | </td> |
225 | 225 | </tr> |
226 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
226 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
227 | 227 | <tr> |
228 | 228 | <th valign="top" scope="row"> |
229 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
229 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
230 | 230 | </th> |
231 | 231 | <td> |
232 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>"> |
|
233 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
232 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>"> |
|
233 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
234 | 234 | </td> |
235 | 235 | </tr> |
236 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
236 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
237 | 237 | <tr> |
238 | 238 | <th valign="top" scope="row"> |
239 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
239 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
240 | 240 | </th> |
241 | 241 | <td> |
242 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>"> |
|
243 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
242 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>"> |
|
243 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
244 | 244 | </td> |
245 | 245 | </tr> |
246 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
246 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
247 | 247 | <tr> |
248 | 248 | <th valign="top" scope="row"> |
249 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
249 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
250 | 250 | </th> |
251 | 251 | <td> |
252 | 252 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
253 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
253 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
254 | 254 | </td> |
255 | 255 | </tr> |
256 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
256 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
257 | 257 | <tr> |
258 | 258 | <th valign="top" scope="row"> |
259 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
259 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
260 | 260 | </th> |
261 | 261 | <td> |
262 | 262 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
263 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | 272 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
273 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
274 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
273 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
274 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
275 | 275 | </select> |
276 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
276 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
277 | 277 | </td> |
278 | 278 | </tr> |
279 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
279 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
280 | 280 | <tr> |
281 | 281 | <th valign="top" scope="row"> |
282 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
282 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
283 | 283 | </th> |
284 | 284 | <td> |
285 | 285 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
286 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
286 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
287 | 287 | </td> |
288 | 288 | </tr> |
289 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
289 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
290 | 290 | <tr> |
291 | 291 | <th valign="top" scope="row"> |
292 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
292 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
293 | 293 | </th> |
294 | 294 | <td> |
295 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
296 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
295 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
296 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
297 | 297 | </td> |
298 | 298 | </tr> |
299 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
299 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
300 | 300 | </tbody> |
301 | 301 | </table> |
302 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
302 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
303 | 303 | <?php |
304 | 304 | } |
305 | 305 | |
306 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
307 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
306 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
307 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
308 | 308 | |
309 | - if ( $post_type != 'wpi_discount' ) { |
|
309 | + if ($post_type != 'wpi_discount') { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
313 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
317 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
318 | 318 | return; |
319 | 319 | } |
320 | 320 | |
321 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
321 | + if (!current_user_can('manage_options', $post_id)) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
325 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
325 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
326 | 326 | } |
327 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
328 | 327 | \ No newline at end of file |
328 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
329 | 329 | \ No newline at end of file |
@@ -21,6 +21,9 @@ |
||
21 | 21 | add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
22 | 22 | } |
23 | 23 | |
24 | + /** |
|
25 | + * @param string[] $function |
|
26 | + */ |
|
24 | 27 | public static function shortcode_wrapper( |
25 | 28 | $function, |
26 | 29 | $atts = array(), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
15 | 15 | ); |
16 | 16 | |
17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
17 | + foreach ($shortcodes as $shortcode => $function) { |
|
18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
19 | 19 | } |
20 | 20 | |
21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function shortcode_wrapper( |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | ) { |
33 | 33 | ob_start(); |
34 | 34 | |
35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
36 | - call_user_func( $function, $atts ); |
|
37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
36 | + call_user_func($function, $atts); |
|
37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
38 | 38 | |
39 | 39 | return ob_get_clean(); |
40 | 40 | } |
41 | 41 | |
42 | - public static function checkout( $atts = array(), $content = null ) { |
|
43 | - return wpinv_checkout_form( $atts, $content ); |
|
42 | + public static function checkout($atts = array(), $content = null) { |
|
43 | + return wpinv_checkout_form($atts, $content); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function messages( $atts, $content = null ) { |
|
46 | + public static function messages($atts, $content = null) { |
|
47 | 47 | ob_start(); |
48 | 48 | wpinv_print_errors(); |
49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
50 | 50 | } |
51 | 51 | |
52 | - public static function history( $atts, $content = null ) { |
|
53 | - return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts ); |
|
52 | + public static function history($atts, $content = null) { |
|
53 | + return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param array $atts |
60 | 60 | */ |
61 | - public static function history_output( $atts ) { |
|
62 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
63 | - wpinv_get_template_part( 'wpinv-invoice-history', $atts ); |
|
64 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
61 | + public static function history_output($atts) { |
|
62 | + do_action('wpinv_before_user_invoice_history'); |
|
63 | + wpinv_get_template_part('wpinv-invoice-history', $atts); |
|
64 | + do_action('wpinv_after_user_invoice_history'); |
|
65 | 65 | } |
66 | 66 | |
67 | - public static function receipt( $atts, $content = null ) { |
|
68 | - return wpinv_payment_receipt( $atts, $content ); |
|
67 | + public static function receipt($atts, $content = null) { |
|
68 | + return wpinv_payment_receipt($atts, $content); |
|
69 | 69 | } |
70 | 70 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | <tbody> |
32 | 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 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
36 | 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'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | |
54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
55 | 55 | <?php |
56 | - $actions = array( |
|
57 | - 'pay' => array( |
|
58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
56 | + $actions = array( |
|
57 | + 'pay' => array( |
|
58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
60 | 60 | 'class' => 'btn-success' |
61 | - ), |
|
61 | + ), |
|
62 | 62 | 'print' => array( |
63 | - 'url' => $invoice->get_view_url(), |
|
64 | - 'name' => __( 'Print', 'invoicing' ), |
|
63 | + 'url' => $invoice->get_view_url(), |
|
64 | + 'name' => __( 'Print', 'invoicing' ), |
|
65 | 65 | 'class' => 'btn-primary', |
66 | 66 | 'attrs' => 'target="_blank"' |
67 | - ) |
|
68 | - ); |
|
67 | + ) |
|
68 | + ); |
|
69 | 69 | |
70 | - if ( ! $invoice->needs_payment() ) { |
|
71 | - unset( $actions['pay'] ); |
|
72 | - } |
|
70 | + if ( ! $invoice->needs_payment() ) { |
|
71 | + unset( $actions['pay'] ); |
|
72 | + } |
|
73 | 73 | |
74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | - foreach ( $actions as $key => $action ) { |
|
76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | + foreach ( $actions as $key => $action ) { |
|
76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
77 | 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 | - } |
|
79 | - } |
|
80 | - ?> |
|
78 | + } |
|
79 | + } |
|
80 | + ?> |
|
81 | 81 | <?php endif; ?> |
82 | 82 | </td> |
83 | 83 | <?php endforeach; ?> |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
92 | 92 | <div class="invoicing-Pagination"> |
93 | 93 | <?php |
94 | - $big = 999999; |
|
95 | - |
|
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
102 | - |
|
103 | - echo paginate_links( array( |
|
104 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | - 'format' => '?paged=%#%', |
|
106 | - 'current' => max( 1, $current_page ), |
|
107 | - 'total' => $user_invoices->max_num_pages, |
|
108 | - ) ); |
|
109 | - ?> |
|
94 | + $big = 999999; |
|
95 | + |
|
96 | + if (get_query_var('paged')) |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + elseif (get_query_var('page')) |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + else |
|
101 | + $current_page = 1; |
|
102 | + |
|
103 | + echo paginate_links( array( |
|
104 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | + 'format' => '?paged=%#%', |
|
106 | + 'current' => max( 1, $current_page ), |
|
107 | + 'total' => $user_invoices->max_num_pages, |
|
108 | + ) ); |
|
109 | + ?> |
|
110 | 110 | </div> |
111 | 111 | <?php endif; ?> |
112 | 112 |
@@ -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; |
@@ -100,20 +100,20 @@ discard block |
||
100 | 100 | else |
101 | 101 | $current_page = 1; |
102 | 102 | |
103 | - echo paginate_links( array( |
|
104 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
103 | + echo paginate_links(array( |
|
104 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
105 | 105 | 'format' => '?paged=%#%', |
106 | - 'current' => max( 1, $current_page ), |
|
106 | + 'current' => max(1, $current_page), |
|
107 | 107 | 'total' => $user_invoices->max_num_pages, |
108 | - ) ); |
|
108 | + )); |
|
109 | 109 | ?> |
110 | 110 | </div> |
111 | 111 | <?php endif; ?> |
112 | 112 | |
113 | 113 | <?php } else { ?> |
114 | 114 | <div class="wpinv-empty alert-info"> |
115 | - <?php _e( 'No invoice has been made yet.', 'invoicing' ); ?> |
|
115 | + <?php _e('No invoice has been made yet.', 'invoicing'); ?> |
|
116 | 116 | </div> |
117 | 117 | <?php } ?> |
118 | 118 | |
119 | -<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?> |
|
119 | +<?php do_action('wpinv_after_user_invoices', $has_invoices); ?> |
@@ -93,12 +93,13 @@ |
||
93 | 93 | <?php |
94 | 94 | $big = 999999; |
95 | 95 | |
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
96 | + if (get_query_var('paged')) { |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + } elseif (get_query_var('page')) { |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + } else { |
|
101 | + $current_page = 1; |
|
102 | + } |
|
102 | 103 | |
103 | 104 | echo paginate_links( array( |
104 | 105 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |