@@ -103,7 +103,10 @@ discard block |
||
103 | 103 | <?php } ?> |
104 | 104 | |
105 | 105 | <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) { |
|
107 | + echo ' style="display:none;"'; |
|
108 | +} |
|
109 | +?>> |
|
107 | 110 | <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
108 | 111 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
109 | 112 | <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
@@ -118,7 +121,10 @@ discard block |
||
118 | 121 | <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
119 | 122 | |
120 | 123 | <?php if ( $use_taxes ) { ?> |
121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
124 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) { |
|
125 | + echo ' style="display:none;"'; |
|
126 | +} |
|
127 | +?>> |
|
122 | 128 | <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
123 | 129 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
124 | 130 | <strong><?php echo $tax_label; ?>:</strong> |
@@ -6,144 +6,144 @@ |
||
6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns; |
7 | 7 | $invoice = wpinv_get_invoice_cart(); |
8 | 8 | $currency = $invoice->get_currency(); |
9 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
9 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
10 | 10 | $quantities_enabled = wpinv_item_quantities_enabled(); |
11 | 11 | $use_taxes = wpinv_use_taxes(); |
12 | 12 | $tax_label = $wpinv_euvat->tax_label(); |
13 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
13 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
14 | 14 | ?> |
15 | 15 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
16 | 16 | <thead> |
17 | 17 | <tr class="wpinv_cart_header_row"> |
18 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
19 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
20 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
21 | - <?php if ( $quantities_enabled ) { ?> |
|
22 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
18 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
19 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
20 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
21 | + <?php if ($quantities_enabled) { ?> |
|
22 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
23 | 23 | <?php } ?> |
24 | - <?php if ( $use_taxes ) { ?> |
|
24 | + <?php if ($use_taxes) { ?> |
|
25 | 25 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
26 | 26 | <?php } ?> |
27 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
28 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
27 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
28 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
29 | 29 | </tr> |
30 | 30 | </thead> |
31 | 31 | <tbody> |
32 | 32 | <?php |
33 | - do_action( 'wpinv_cart_items_before' ); |
|
33 | + do_action('wpinv_cart_items_before'); |
|
34 | 34 | |
35 | - if ( $cart_items ) { |
|
36 | - foreach ( $cart_items as $key => $item ) { |
|
37 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
35 | + if ($cart_items) { |
|
36 | + foreach ($cart_items as $key => $item) { |
|
37 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
38 | 38 | ?> |
39 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
40 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
39 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
40 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
41 | 41 | <td class="wpinv_cart_item_name text-left"> |
42 | 42 | <?php |
43 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
43 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
44 | 44 | echo '<div class="wpinv_cart_item_image">'; |
45 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
45 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
46 | 46 | echo '</div>'; |
47 | 47 | } |
48 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
48 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
49 | 49 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
50 | - $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice ); |
|
51 | - if ( !empty( $summary ) ) { |
|
50 | + $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice); |
|
51 | + if (!empty($summary)) { |
|
52 | 52 | echo $summary; |
53 | 53 | } |
54 | 54 | ?> |
55 | 55 | </td> |
56 | 56 | <td class="wpinv_cart_item_price text-right"> |
57 | 57 | <?php |
58 | - echo wpinv_cart_item_price( $item, $currency ); |
|
59 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
58 | + echo wpinv_cart_item_price($item, $currency); |
|
59 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
60 | 60 | ?> |
61 | 61 | </td> |
62 | - <?php if ( $quantities_enabled ) { ?> |
|
62 | + <?php if ($quantities_enabled) { ?> |
|
63 | 63 | <td class="wpinv_cart_item_qty text-right"> |
64 | 64 | <?php |
65 | - echo wpinv_get_cart_item_quantity( $item ); |
|
66 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
65 | + echo wpinv_get_cart_item_quantity($item); |
|
66 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
67 | 67 | ?> |
68 | 68 | </td> |
69 | 69 | <?php } ?> |
70 | - <?php if ( $use_taxes ) { ?> |
|
70 | + <?php if ($use_taxes) { ?> |
|
71 | 71 | <td class="wpinv_cart_item_tax text-right"> |
72 | 72 | <?php |
73 | 73 | |
74 | - if ( $invoice->is_taxable() ) { |
|
75 | - echo wpinv_cart_item_tax( $item, $currency ); |
|
74 | + if ($invoice->is_taxable()) { |
|
75 | + echo wpinv_cart_item_tax($item, $currency); |
|
76 | 76 | } else { |
77 | 77 | echo 0; |
78 | 78 | } |
79 | 79 | |
80 | 80 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
81 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
81 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
82 | 82 | ?> |
83 | 83 | </td> |
84 | 84 | <?php } ?> |
85 | 85 | <td class="wpinv_cart_item_subtotal text-right"> |
86 | 86 | <?php |
87 | - echo wpinv_cart_item_subtotal( $item, $currency ); |
|
88 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
87 | + echo wpinv_cart_item_subtotal($item, $currency); |
|
88 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
89 | 89 | ?> |
90 | 90 | </td> |
91 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
91 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
92 | 92 | </tr> |
93 | 93 | <?php } ?> |
94 | 94 | <?php } ?> |
95 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
96 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
95 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
96 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
97 | 97 | </tbody> |
98 | 98 | <tfoot> |
99 | 99 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
100 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
100 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
101 | 101 | <tr class="wpinv_cart_footer_row"> |
102 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
103 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
104 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
102 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
103 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
104 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
105 | 105 | </td> |
106 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
106 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
107 | 107 | </tr> |
108 | 108 | <?php } ?> |
109 | 109 | |
110 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
111 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
112 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
113 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
114 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
110 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
111 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
112 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
113 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
114 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
115 | 115 | </td> |
116 | 116 | <td class="wpinv_cart_subtotal text-right"> |
117 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items, $currency ); ?></span> |
|
117 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items, $currency); ?></span> |
|
118 | 118 | </td> |
119 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
119 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
120 | 120 | </tr> |
121 | 121 | <?php } ?> |
122 | 122 | |
123 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
123 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
124 | 124 | |
125 | - <?php if ( $use_taxes ) { ?> |
|
126 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
127 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
128 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
125 | + <?php if ($use_taxes) { ?> |
|
126 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
127 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
128 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
129 | 129 | <strong><?php echo $tax_label; ?>:</strong> |
130 | 130 | </td> |
131 | 131 | <td class="wpinv_cart_tax text-right"> |
132 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items, false, $currency, $invoice ) ); ?></span> |
|
132 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items, false, $currency, $invoice)); ?></span> |
|
133 | 133 | </td> |
134 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
134 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
135 | 135 | </tr> |
136 | 136 | <?php } ?> |
137 | 137 | |
138 | 138 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
139 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
140 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
141 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
139 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
140 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
141 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
142 | 142 | </td> |
143 | 143 | <td class="wpinv_cart_total text-right"> |
144 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
144 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
145 | 145 | </td> |
146 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
146 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
147 | 147 | </tr> |
148 | 148 | </tfoot> |
149 | 149 | </table> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
|
7 | -$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
|
6 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text')); |
|
7 | +$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : ''; |
|
8 | 8 | ?> |
9 | 9 | </div> |
10 | 10 | </td> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
7 | 8 | $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -if ( !isset( $email_heading ) ) { |
|
6 | +if (!isset($email_heading)) { |
|
7 | 7 | global $email_heading; |
8 | 8 | } |
9 | 9 | ?> |
10 | 10 | <!DOCTYPE html> |
11 | 11 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>"> |
12 | 12 | <head> |
13 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
13 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
14 | 14 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
15 | 15 | <meta name="robots" content="noindex,nofollow"> |
16 | 16 | <title><?php echo wpinv_get_blogname(); ?></title> |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | <td align="center" valign="top"> |
23 | 23 | <div id="template_header_image"> |
24 | 24 | <?php |
25 | - if ( $img = wpinv_get_option( 'email_header_image' ) ) { |
|
26 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
25 | + if ($img = wpinv_get_option('email_header_image')) { |
|
26 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
27 | 27 | } |
28 | 28 | ?> |
29 | 29 | </div> |
30 | 30 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
31 | - <?php if ( !empty( $email_heading ) ) { ?> |
|
31 | + <?php if (!empty($email_heading)) { ?> |
|
32 | 32 | <tr> |
33 | 33 | <td align="center" valign="top"> |
34 | 34 | <!-- Header --> |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | if ( !isset( $email_heading ) ) { |
7 | 8 | global $email_heading; |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | -if ( ! empty( $message_body ) ) { |
|
9 | - echo wpautop( wptexturize( $message_body ) ); |
|
8 | +if (!empty($message_body)) { |
|
9 | + echo wpautop(wptexturize($message_body)); |
|
10 | 10 | } |
11 | 11 | |
12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
13 | 13 | |
14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
15 | 15 | |
16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
17 | 17 | |
18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
19 | 18 | \ No newline at end of file |
19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | // Load colours |
7 | 8 | $bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | 6 | // Load colours |
7 | -$bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
|
8 | -$body = wpinv_get_option( 'email_body_background_color', '#fdfdfd' ); |
|
9 | -$base = wpinv_get_option( 'email_base_color', '#557da2' ); |
|
10 | -$base_text = wpinv_light_or_dark( $base, '#202020', '#ffffff' ); |
|
11 | -$text = wpinv_get_option( 'email_text_color', '#505050' ); |
|
7 | +$bg = wpinv_get_option('email_background_color', '#f5f5f5'); |
|
8 | +$body = wpinv_get_option('email_body_background_color', '#fdfdfd'); |
|
9 | +$base = wpinv_get_option('email_base_color', '#557da2'); |
|
10 | +$base_text = wpinv_light_or_dark($base, '#202020', '#ffffff'); |
|
11 | +$text = wpinv_get_option('email_text_color', '#505050'); |
|
12 | 12 | |
13 | -$bg_darker_10 = wpinv_hex_darker( $bg, 10 ); |
|
14 | -$body_darker_10 = wpinv_hex_darker( $body, 10 ); |
|
15 | -$base_lighter_20 = wpinv_hex_lighter( $base, 20 ); |
|
16 | -$base_lighter_40 = wpinv_hex_lighter( $base, 40 ); |
|
17 | -$text_lighter_20 = wpinv_hex_lighter( $text, 20 ); |
|
13 | +$bg_darker_10 = wpinv_hex_darker($bg, 10); |
|
14 | +$body_darker_10 = wpinv_hex_darker($body, 10); |
|
15 | +$base_lighter_20 = wpinv_hex_lighter($base, 20); |
|
16 | +$base_lighter_40 = wpinv_hex_lighter($base, 40); |
|
17 | +$text_lighter_20 = wpinv_hex_lighter($text, 20); |
|
18 | 18 | |
19 | 19 | // !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
20 | 20 | ?> |
21 | 21 | #wrapper { |
22 | - background-color: <?php echo esc_attr( $bg ); ?>; |
|
22 | + background-color: <?php echo esc_attr($bg); ?>; |
|
23 | 23 | margin: 0; |
24 | 24 | -webkit-text-size-adjust: none !important; |
25 | 25 | padding: 3%; |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | #template_container { |
42 | 42 | box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; |
43 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
44 | - border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>; |
|
43 | + background-color: <?php echo esc_attr($body); ?>; |
|
44 | + border: 1px solid <?php echo esc_attr($bg_darker_10); ?>; |
|
45 | 45 | border-radius: 3px !important; |
46 | 46 | } |
47 | 47 | |
48 | 48 | #template_header { |
49 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
49 | + background-color: <?php echo esc_attr($base); ?>; |
|
50 | 50 | border-radius: 3px 3px 0 0 !important; |
51 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
51 | + color: <?php echo esc_attr($base_text); ?>; |
|
52 | 52 | border-bottom: 0; |
53 | 53 | font-weight: bold; |
54 | 54 | line-height: 100%; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | #template_header h1 { |
64 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
64 | + color: <?php echo esc_attr($base_text); ?>; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | #template_footer td { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | #template_footer #credit { |
74 | 74 | border:0; |
75 | - color: <?php echo esc_attr( $base_lighter_40 ); ?>; |
|
75 | + color: <?php echo esc_attr($base_lighter_40); ?>; |
|
76 | 76 | font-family: Arial; |
77 | 77 | font-size:12px; |
78 | 78 | line-height:125%; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | #body_content { |
84 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
84 | + background-color: <?php echo esc_attr($body); ?>; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | #body_content table td { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | #body_content_inner { |
104 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
104 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
105 | 105 | font-family: Arial,Helvetica,sans-serif; |
106 | 106 | font-size: 14px; |
107 | 107 | line-height: 150%; |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | .td { |
112 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
113 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
112 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
113 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | .text { |
117 | - color: <?php echo esc_attr( $text ); ?>; |
|
117 | + color: <?php echo esc_attr($text); ?>; |
|
118 | 118 | font-family: Arial,Helvetica,sans-serif; |
119 | 119 | } |
120 | 120 | |
121 | 121 | .link { |
122 | - color: <?php echo esc_attr( $base ); ?>; |
|
122 | + color: <?php echo esc_attr($base); ?>; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | #header_wrapper { |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | h1 { |
131 | - color: <?php echo esc_attr( $base ); ?>; |
|
131 | + color: <?php echo esc_attr($base); ?>; |
|
132 | 132 | font-family: Arial,Helvetica,sans-serif; |
133 | 133 | font-size: 30px; |
134 | 134 | font-weight: 300; |
135 | 135 | line-height: 150%; |
136 | 136 | margin: 0; |
137 | 137 | text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>; |
138 | - text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>; |
|
138 | + text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>; |
|
139 | 139 | -webkit-font-smoothing: antialiased; |
140 | 140 | } |
141 | 141 | |
142 | 142 | h2 { |
143 | - color: <?php echo esc_attr( $base ); ?>; |
|
143 | + color: <?php echo esc_attr($base); ?>; |
|
144 | 144 | display: block; |
145 | 145 | font-family: Arial,Helvetica,sans-serif; |
146 | 146 | font-size: 18px; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | h3 { |
154 | - color: <?php echo esc_attr( $base ); ?>; |
|
154 | + color: <?php echo esc_attr($base); ?>; |
|
155 | 155 | display: block; |
156 | 156 | font-family: Arial,Helvetica,sans-serif; |
157 | 157 | font-size: 16px; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | a { |
165 | - color: <?php echo esc_attr( $base ); ?>; |
|
165 | + color: <?php echo esc_attr($base); ?>; |
|
166 | 166 | font-weight: normal; |
167 | 167 | text-decoration: underline; |
168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | .table-bordered { |
183 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
183 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
184 | 184 | border-collapse: collapse; |
185 | 185 | border-spacing: 0; |
186 | 186 | width: 100%; |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | |
189 | 189 | .table-bordered th, |
190 | 190 | .table-bordered td { |
191 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
192 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
191 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
192 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
193 | 193 | font-size: 14px; |
194 | 194 | } |
195 | 195 | .small { |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | text-decoration: none; |
289 | 289 | } |
290 | 290 | .btn-default { |
291 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
292 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
293 | - border-color: <?php echo esc_attr( $base ); ?>; |
|
291 | + color: <?php echo esc_attr($base_text); ?>; |
|
292 | + background-color: <?php echo esc_attr($base); ?>; |
|
293 | + border-color: <?php echo esc_attr($base); ?>; |
|
294 | 294 | } |
295 | 295 | .btn-primary { |
296 | 296 | color: #fff; |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
7 | 8 | <div id="wpinv-email-billing"> |
@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
6 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
7 | 7 | <div id="wpinv-email-billing"> |
8 | - <h3 class="wpinv-address-t"><?php echo apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ); ?></h3> |
|
8 | + <h3 class="wpinv-address-t"><?php echo apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing')); ?></h3> |
|
9 | 9 | |
10 | 10 | <table class="table table-bordered table-sm wpi-billing-details"> |
11 | 11 | <tbody> |
12 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
12 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
13 | 13 | <tr class="wpi-receipt-name"> |
14 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
15 | - <td><?php if ( $sent_to_admin && $invoice->user_id ) { ?><a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ) ;?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a><?php } else { echo esc_html( $invoice->get_user_full_name() ); } ?></td> |
|
14 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
15 | + <td><?php if ($sent_to_admin && $invoice->user_id) { ?><a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a><?php } else { echo esc_html($invoice->get_user_full_name()); } ?></td> |
|
16 | 16 | </tr> |
17 | 17 | <tr class="wpi-receipt-email"> |
18 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
19 | - <td><?php echo $invoice->get_email() ;?></td> |
|
18 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
19 | + <td><?php echo $invoice->get_email(); ?></td> |
|
20 | 20 | </tr> |
21 | - <?php if ( $invoice->company ) { ?> |
|
21 | + <?php if ($invoice->company) { ?> |
|
22 | 22 | <tr class="wpi-receipt-company"> |
23 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
24 | - <td><?php echo esc_html( $invoice->company ) ;?></td> |
|
23 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
24 | + <td><?php echo esc_html($invoice->company); ?></td> |
|
25 | 25 | </tr> |
26 | 26 | <?php } ?> |
27 | 27 | <tr class="wpi-receipt-address"> |
28 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
29 | - <td><?php echo wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ;?></td> |
|
28 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
29 | + <td><?php echo wpinv_get_invoice_address_markup($invoice->get_user_info()); ?></td> |
|
30 | 30 | </tr> |
31 | - <?php if ( $invoice->phone ) { ?> |
|
31 | + <?php if ($invoice->phone) { ?> |
|
32 | 32 | <tr class="wpi-receipt-phone"> |
33 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
34 | - <td><?php echo esc_html( $invoice->phone ) ;?></td> |
|
33 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
34 | + <td><?php echo esc_html($invoice->phone); ?></td> |
|
35 | 35 | </tr> |
36 | 36 | <?php } ?> |
37 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
37 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
38 | 38 | </tbody> |
39 | 39 | </table> |
40 | 40 | </div> |
41 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
42 | 41 | \ No newline at end of file |
42 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
|
43 | 43 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | global $wpinv_euvat; |
7 | 8 |
@@ -1,68 +1,68 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | 6 | global $wpinv_euvat; |
7 | 7 | |
8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
9 | -$invoice_url = $invoice->get_view_url( true ); |
|
8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
9 | +$invoice_url = $invoice->get_view_url(true); |
|
10 | 10 | $use_taxes = wpinv_use_taxes(); |
11 | 11 | $vat_name = $wpinv_euvat->get_vat_name(); |
12 | 12 | |
13 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
13 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
14 | 14 | <div id="wpinv-email-details"> |
15 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3> |
|
15 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3> |
|
16 | 16 | <table class="table table-bordered table-sm"> |
17 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
17 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
18 | 18 | <tr> |
19 | - <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td> |
|
20 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
19 | + <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td> |
|
20 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
21 | 21 | </tr> |
22 | 22 | <?php } ?> |
23 | 23 | <tr> |
24 | - <td><?php echo apply_filters( 'wpinv_invoice_status_title', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td> |
|
25 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
24 | + <td><?php echo apply_filters('wpinv_invoice_status_title', __('Invoice Status', 'invoicing'), $invoice); ?></td> |
|
25 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
26 | 26 | </tr> |
27 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
27 | + <?php if ($invoice->is_renewal()) { ?> |
|
28 | 28 | <tr> |
29 | - <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td> |
|
30 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
29 | + <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td> |
|
30 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
31 | 31 | </tr> |
32 | 32 | <?php } ?> |
33 | - <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
34 | - <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td> |
|
33 | + <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
34 | + <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td> |
|
35 | 35 | <td><?php echo $gateway_title; ?></td> |
36 | 36 | <?php } ?> |
37 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
37 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
38 | 38 | <tr> |
39 | - <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td> |
|
40 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
39 | + <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td> |
|
40 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
41 | 41 | </tr> |
42 | 42 | <?php } ?> |
43 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
43 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
44 | 44 | <tr> |
45 | - <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td> |
|
46 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
45 | + <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td> |
|
46 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
47 | 47 | </tr> |
48 | 48 | <?php } ?> |
49 | - <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?> |
|
50 | - <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?> |
|
49 | + <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?> |
|
50 | + <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?> |
|
51 | 51 | <tr> |
52 | - <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
52 | + <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
53 | 53 | <td><?php echo $owner_vat_number; ?></td> |
54 | 54 | </tr> |
55 | 55 | <?php } ?> |
56 | - <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?> |
|
56 | + <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?> |
|
57 | 57 | <tr> |
58 | - <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
58 | + <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
59 | 59 | <td><?php echo $user_vat_number; ?></td> |
60 | 60 | </tr> |
61 | 61 | <?php } ?> |
62 | 62 | <tr class="table-active"> |
63 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
64 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
63 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
64 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
65 | 65 | </tr> |
66 | 66 | </table> |
67 | 67 | </div> |
68 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
69 | 68 | \ No newline at end of file |
69 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
70 | 70 | \ No newline at end of file |
@@ -348,7 +348,7 @@ |
||
348 | 348 | |
349 | 349 | $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
350 | 350 | if ( !empty( $status ) && $status != 'all' ) { |
351 | - $query_args['status'] = $status; |
|
351 | + $query_args['status'] = $status; |
|
352 | 352 | } |
353 | 353 | $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
354 | 354 |
@@ -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 | |
@@ -9,42 +9,42 @@ discard block |
||
9 | 9 | |
10 | 10 | public function __construct() { |
11 | 11 | |
12 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
13 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
12 | + if (!defined('WPINV_BP_SLUG')) { |
|
13 | + define('WPINV_BP_SLUG', 'invoices'); |
|
14 | 14 | } |
15 | 15 | |
16 | - add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) ); |
|
17 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) ); |
|
18 | - add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 ); |
|
19 | - add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 ); |
|
20 | - add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 ); |
|
16 | + add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content')); |
|
17 | + add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content')); |
|
18 | + add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1); |
|
19 | + add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1); |
|
20 | + add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2); |
|
21 | 21 | add_action('bp_setup_nav', array($this, 'setup_nav'), 15); |
22 | 22 | |
23 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
23 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
24 | 24 | $position = $position !== '' && $position !== false ? $position : 91; |
25 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
26 | - $this->id = WPINV_BP_SLUG; |
|
25 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
26 | + $this->id = WPINV_BP_SLUG; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function setup_nav() { |
30 | 30 | |
31 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) { |
|
31 | + if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){ |
|
35 | + if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $count = $this->get_invoice_count(); |
40 | - $class = ( 0 === $count ) ? 'no-count' : 'count'; |
|
40 | + $class = (0 === $count) ? 'no-count' : 'count'; |
|
41 | 41 | |
42 | 42 | $main_nav_name = sprintf( |
43 | - __( 'My Invoices %s', 'invoicing' ), |
|
43 | + __('My Invoices %s', 'invoicing'), |
|
44 | 44 | sprintf( |
45 | 45 | '<span class="%s">%s</span>', |
46 | - esc_attr( $class ), |
|
47 | - bp_core_number_format( $count ) |
|
46 | + esc_attr($class), |
|
47 | + bp_core_number_format($count) |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | |
@@ -52,31 +52,31 @@ discard block |
||
52 | 52 | 'name' => $main_nav_name, |
53 | 53 | 'slug' => WPINV_BP_SLUG, |
54 | 54 | 'position' => $this->position, |
55 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
55 | + 'screen_function' => array($this, 'invoices_screen'), |
|
56 | 56 | 'default_subnav_slug' => 'invoices', |
57 | 57 | 'item_css_id' => $this->id |
58 | 58 | ); |
59 | 59 | |
60 | - bp_core_new_nav_item( $main_nav ); |
|
60 | + bp_core_new_nav_item($main_nav); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function invoices_screen() { |
64 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
64 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
68 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
69 | 69 | |
70 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
70 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
71 | 71 | |
72 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
72 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public function invoices_content() { |
76 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
76 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
77 | 77 | global $invoices_template; |
78 | 78 | |
79 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
79 | + do_action('wpinv_bp_invoices_before_content'); |
|
80 | 80 | ?> |
81 | 81 | <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative"> |
82 | 82 | <div id="pag-top" class="pagination"> |
@@ -90,61 +90,61 @@ discard block |
||
90 | 90 | <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0"> |
91 | 91 | <thead> |
92 | 92 | <tr> |
93 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
94 | - <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> |
|
93 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
94 | + <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> |
|
95 | 95 | <?php endforeach; ?> |
96 | 96 | </tr> |
97 | 97 | </thead> |
98 | 98 | <tbody> |
99 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
99 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
100 | 100 | ?> |
101 | 101 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
102 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
103 | - <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'] ); ?>"> |
|
104 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
105 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
106 | - |
|
107 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
108 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
109 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
102 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
103 | + <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']); ?>"> |
|
104 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
105 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
106 | + |
|
107 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
108 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
109 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
110 | 110 | </a> |
111 | 111 | |
112 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
113 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
112 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
113 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
114 | 114 | |
115 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
116 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
115 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
116 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
117 | 117 | |
118 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
119 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
118 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
119 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
120 | 120 | |
121 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
122 | - <?php echo $invoice->get_total( true ); ?> |
|
121 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
122 | + <?php echo $invoice->get_total(true); ?> |
|
123 | 123 | |
124 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
124 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
125 | 125 | <?php |
126 | 126 | $actions = array( |
127 | 127 | 'pay' => array( |
128 | 128 | 'url' => $invoice->get_checkout_payment_url(), |
129 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
129 | + 'name' => __('Pay Now', 'invoicing'), |
|
130 | 130 | 'class' => 'btn-success' |
131 | 131 | ), |
132 | 132 | 'print' => array( |
133 | 133 | 'url' => $invoice->get_view_url(), |
134 | - 'name' => __( 'Print', 'invoicing' ), |
|
134 | + 'name' => __('Print', 'invoicing'), |
|
135 | 135 | 'class' => 'btn-primary', |
136 | 136 | 'attrs' => 'target="_blank"' |
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | |
140 | - if ( ! $invoice->needs_payment() ) { |
|
141 | - unset( $actions['pay'] ); |
|
140 | + if (!$invoice->needs_payment()) { |
|
141 | + unset($actions['pay']); |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
145 | - foreach ( $actions as $key => $action ) { |
|
144 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
145 | + foreach ($actions as $key => $action) { |
|
146 | 146 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
147 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
147 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | ?> |
@@ -172,64 +172,64 @@ discard block |
||
172 | 172 | </div> |
173 | 173 | <?php |
174 | 174 | |
175 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
175 | + do_action('wpinv_bp_invoices_after_content'); |
|
176 | 176 | } else { |
177 | 177 | ?> |
178 | 178 | <div id="message" class="info"> |
179 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
179 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
180 | 180 | </div> |
181 | 181 | <?php |
182 | 182 | } |
183 | 183 | |
184 | - if ( defined( 'DOING_AJAX' ) ) { |
|
184 | + if (defined('DOING_AJAX')) { |
|
185 | 185 | exit; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - public function has_invoices( $args = '' ) { |
|
189 | + public function has_invoices($args = '') { |
|
190 | 190 | global $invoices_template; |
191 | 191 | |
192 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
192 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
193 | 193 | // Parse arguments. |
194 | - $r = bp_parse_args( $args, array( |
|
194 | + $r = bp_parse_args($args, array( |
|
195 | 195 | 'status' => 'all', |
196 | 196 | 'page_arg' => 'bpage', |
197 | 197 | 'page' => 1, |
198 | 198 | 'per_page' => $per_page > 0 ? $per_page : 20, |
199 | 199 | 'max' => false, |
200 | 200 | 'user_id' => bp_displayed_user_id(), |
201 | - ), 'has_invoices' ); |
|
201 | + ), 'has_invoices'); |
|
202 | 202 | |
203 | 203 | |
204 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
205 | - $r['per_page'] = (int)$r['max']; |
|
204 | + if (!empty($r['max']) && ((int) $r['per_page'] > (int) $r['max'])) { |
|
205 | + $r['per_page'] = (int) $r['max']; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Get the invoices. |
209 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
209 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
210 | 210 | |
211 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
211 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public function get_invoice_count() { |
215 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
216 | - $invoices = wpinv_get_invoices( $query ); |
|
215 | + $query = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
216 | + $invoices = wpinv_get_invoices($query); |
|
217 | 217 | |
218 | - return !empty( $invoices ) ? count( $invoices ) : 0; |
|
218 | + return !empty($invoices) ? count($invoices) : 0; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | public function pagination_count() { |
222 | 222 | global $invoices_template; |
223 | 223 | |
224 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
225 | - $from_num = bp_core_number_format( $start_num ); |
|
226 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
227 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
224 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
225 | + $from_num = bp_core_number_format($start_num); |
|
226 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
227 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
228 | 228 | |
229 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
230 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
229 | + if (1 == $invoices_template->total_invoice_count) { |
|
230 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
231 | 231 | } else { |
232 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
232 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | return $message; |
@@ -238,32 +238,32 @@ discard block |
||
238 | 238 | function pagination_links() { |
239 | 239 | global $invoices_template; |
240 | 240 | |
241 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
241 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
242 | 242 | } |
243 | 243 | |
244 | - public function bp_section( $settings = array() ) { |
|
245 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
244 | + public function bp_section($settings = array()) { |
|
245 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
246 | 246 | return $settings; |
247 | 247 | } |
248 | 248 | |
249 | - public function bp_settings( $settings = array() ) { |
|
249 | + public function bp_settings($settings = array()) { |
|
250 | 250 | $settings['wpinv_bp'] = array( |
251 | 251 | 'wpinv_bp_labels' => array( |
252 | 252 | 'id' => 'wpinv_bp_settings', |
253 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
253 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
254 | 254 | 'desc' => '', |
255 | 255 | 'type' => 'header', |
256 | 256 | ), |
257 | 257 | 'wpinv_bp_hide_menu' => array( |
258 | 258 | 'id' => 'wpinv_bp_hide_menu', |
259 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
260 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
259 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
260 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
261 | 261 | 'type' => 'checkbox', |
262 | 262 | ), |
263 | 263 | 'wpinv_menu_position' => array( |
264 | 264 | 'id' => 'wpinv_menu_position', |
265 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
266 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
265 | + 'name' => __('Menu position', 'invoicing'), |
|
266 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
267 | 267 | 'type' => 'number', |
268 | 268 | 'size' => 'small', |
269 | 269 | 'min' => '1', |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | ), |
274 | 274 | 'wpinv_bp_per_page' => array( |
275 | 275 | 'id' => 'wpinv_bp_per_page', |
276 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
277 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
276 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
277 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
278 | 278 | 'type' => 'number', |
279 | 279 | 'size' => 'small', |
280 | 280 | 'min' => '1', |
@@ -287,20 +287,20 @@ discard block |
||
287 | 287 | return $settings; |
288 | 288 | } |
289 | 289 | |
290 | - public function wp_nav_menu_objects($items, $args){ |
|
291 | - if(!is_user_logged_in()){ |
|
290 | + public function wp_nav_menu_objects($items, $args) { |
|
291 | + if (!is_user_logged_in()) { |
|
292 | 292 | return $items; |
293 | 293 | } |
294 | 294 | |
295 | - if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){ |
|
295 | + if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) { |
|
296 | 296 | return $items; |
297 | 297 | } |
298 | 298 | |
299 | 299 | $user_id = get_current_user_id(); |
300 | - $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG; |
|
300 | + $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG; |
|
301 | 301 | $history_link = wpinv_get_history_page_uri(); |
302 | - foreach ( $items as $item ) { |
|
303 | - $item->url = str_replace( $history_link, $link, $item->url ); |
|
302 | + foreach ($items as $item) { |
|
303 | + $item->url = str_replace($history_link, $link, $item->url); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | return $items; |
@@ -318,78 +318,78 @@ discard block |
||
318 | 318 | public $pag_links = ''; |
319 | 319 | public $total_invoice_count = 0; |
320 | 320 | |
321 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
322 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
321 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
322 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
323 | 323 | |
324 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
325 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
326 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
324 | + $this->pag_arg = sanitize_key($page_arg); |
|
325 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
326 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
327 | 327 | |
328 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
329 | - if ( !empty( $status ) && $status != 'all' ) { |
|
328 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
329 | + if (!empty($status) && $status != 'all') { |
|
330 | 330 | $query_args['status'] = $status; |
331 | 331 | } |
332 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
332 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
333 | 333 | |
334 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
335 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
334 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
335 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
336 | 336 | $this->invoices['total'] = $invoices->found_posts; |
337 | 337 | } |
338 | 338 | |
339 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
340 | - $this->total_invoice_count = (int)$this->invoices['total']; |
|
339 | + if (empty($max) || ($max >= (int) $this->invoices['total'])) { |
|
340 | + $this->total_invoice_count = (int) $this->invoices['total']; |
|
341 | 341 | } else { |
342 | - $this->total_invoice_count = (int)$max; |
|
342 | + $this->total_invoice_count = (int) $max; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $this->invoices = $this->invoices['invoices']; |
346 | 346 | |
347 | - $invoice_count = count( $this->invoices ); |
|
347 | + $invoice_count = count($this->invoices); |
|
348 | 348 | |
349 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
350 | - $this->invoice_count = (int)$invoice_count; |
|
349 | + if (empty($max) || ($max >= (int) $invoice_count)) { |
|
350 | + $this->invoice_count = (int) $invoice_count; |
|
351 | 351 | } else { |
352 | - $this->invoice_count = (int)$max; |
|
352 | + $this->invoice_count = (int) $max; |
|
353 | 353 | } |
354 | 354 | |
355 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
356 | - $this->pag_links = paginate_links( array( |
|
357 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
355 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
356 | + $this->pag_links = paginate_links(array( |
|
357 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
358 | 358 | 'format' => '', |
359 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
360 | - 'current' => (int)$this->pag_page, |
|
361 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
362 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
359 | + 'total' => ceil((int) $this->total_invoice_count / (int) $this->pag_num), |
|
360 | + 'current' => (int) $this->pag_page, |
|
361 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
362 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
363 | 363 | 'mid_size' => 1, |
364 | 364 | 'add_args' => array(), |
365 | - ) ); |
|
365 | + )); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | 369 | public function has_invoices() { |
370 | - return (bool) ! empty( $this->invoice_count ); |
|
370 | + return (bool) !empty($this->invoice_count); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | public function next_invoice() { |
374 | 374 | $this->current_invoice++; |
375 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
375 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
376 | 376 | |
377 | 377 | return $this->invoice; |
378 | 378 | } |
379 | 379 | |
380 | 380 | public function rewind_invoices() { |
381 | 381 | $this->current_invoice = -1; |
382 | - if ( $this->invoice_count > 0 ) { |
|
382 | + if ($this->invoice_count > 0) { |
|
383 | 383 | $this->invoice = $this->invoices[0]; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | 387 | public function invoices() { |
388 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
388 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
389 | 389 | return true; |
390 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
390 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
391 | 391 | |
392 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
392 | + do_action('wpinv_bp_invoice_loop_end'); |
|
393 | 393 | |
394 | 394 | $this->rewind_invoices(); |
395 | 395 | } |
@@ -403,19 +403,19 @@ discard block |
||
403 | 403 | $this->in_the_loop = true; |
404 | 404 | $this->invoice = $this->next_invoice(); |
405 | 405 | |
406 | - if ( 0 === $this->current_invoice ) { |
|
407 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
406 | + if (0 === $this->current_invoice) { |
|
407 | + do_action('wpinv_bp_invoice_loop_start'); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | 412 | function wpinv_bp_setup_component() { |
413 | 413 | |
414 | - if(!class_exists( 'BuddyPress' )){ |
|
414 | + if (!class_exists('BuddyPress')) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | 418 | new WPInv_BP_Component(); |
419 | 419 | |
420 | 420 | } |
421 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
422 | 421 | \ No newline at end of file |
422 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
423 | 423 | \ No newline at end of file |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | if ( !empty( $args ) ) { |
69 | 69 | // Check for backward compatibility |
70 | - if ( is_string( $args ) ) |
|
71 | - $args = str_replace( '?', '', $args ); |
|
70 | + if ( is_string( $args ) ) { |
|
71 | + $args = str_replace( '?', '', $args ); |
|
72 | + } |
|
72 | 73 | |
73 | 74 | $args = wp_parse_args( $args ); |
74 | 75 | |
@@ -87,8 +88,9 @@ discard block |
||
87 | 88 | |
88 | 89 | if ( !empty( $args ) ) { |
89 | 90 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
91 | + if ( is_string( $args ) ) { |
|
92 | + $args = str_replace( '?', '', $args ); |
|
93 | + } |
|
92 | 94 | |
93 | 95 | $args = wp_parse_args( $args ); |
94 | 96 | |
@@ -108,8 +110,9 @@ discard block |
||
108 | 110 | |
109 | 111 | if ( !empty( $args ) ) { |
110 | 112 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
113 | + if ( is_string( $args ) ) { |
|
114 | + $args = str_replace( '?', '', $args ); |
|
115 | + } |
|
113 | 116 | |
114 | 117 | $args = wp_parse_args( $args ); |
115 | 118 | |
@@ -132,8 +135,9 @@ discard block |
||
132 | 135 | |
133 | 136 | if ( ! empty( $args ) ) { |
134 | 137 | // Check for backward compatibility |
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
138 | + if ( is_string( $args ) ) { |
|
139 | + $args = str_replace( '?', '', $args ); |
|
140 | + } |
|
137 | 141 | |
138 | 142 | $args = wp_parse_args( $args ); |
139 | 143 | |
@@ -148,8 +152,9 @@ discard block |
||
148 | 152 | $success_page = wpinv_get_option( 'success_page', 0 ); |
149 | 153 | $success_page = get_permalink( $success_page ); |
150 | 154 | |
151 | - if ( $query_string ) |
|
152 | - $success_page .= $query_string; |
|
155 | + if ( $query_string ) { |
|
156 | + $success_page .= $query_string; |
|
157 | + } |
|
153 | 158 | |
154 | 159 | return apply_filters( 'wpinv_success_page_url', $success_page ); |
155 | 160 | } |
@@ -158,8 +163,9 @@ discard block |
||
158 | 163 | $uri = wpinv_get_option( 'failure_page', '' ); |
159 | 164 | $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
160 | 165 | |
161 | - if ( $extras ) |
|
162 | - $uri .= $extras; |
|
166 | + if ( $extras ) { |
|
167 | + $uri .= $extras; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
165 | 171 | } |
@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | - $can_checkout = true; // Always true for now |
|
34 | + $can_checkout = true; // Always true for now |
|
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | + $page_id = absint( $page_id ); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | + $page_id = absint( $page_id ); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | + $ret = $ret ? is_page( $ret ) : false; |
|
63 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_send_to_success_page( $args = null ) { |
73 | - $redirect = wpinv_get_success_page_uri(); |
|
73 | + $redirect = wpinv_get_success_page_uri(); |
|
74 | 74 | |
75 | 75 | if ( !empty( $args ) ) { |
76 | 76 | // Check for backward compatibility |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | function wpinv_send_to_failed_page( $args = null ) { |
93 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
94 | 94 | |
95 | 95 | if ( !empty( $args ) ) { |
96 | 96 | // Check for backward compatibility |
@@ -110,73 +110,73 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | function wpinv_get_checkout_uri( $args = array() ) { |
113 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
114 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
113 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
114 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
115 | 115 | |
116 | - if ( !empty( $args ) ) { |
|
117 | - // Check for backward compatibility |
|
118 | - if ( is_string( $args ) ) |
|
119 | - $args = str_replace( '?', '', $args ); |
|
116 | + if ( !empty( $args ) ) { |
|
117 | + // Check for backward compatibility |
|
118 | + if ( is_string( $args ) ) |
|
119 | + $args = str_replace( '?', '', $args ); |
|
120 | 120 | |
121 | - $args = wp_parse_args( $args ); |
|
121 | + $args = wp_parse_args( $args ); |
|
122 | 122 | |
123 | - $uri = add_query_arg( $args, $uri ); |
|
124 | - } |
|
123 | + $uri = add_query_arg( $args, $uri ); |
|
124 | + } |
|
125 | 125 | |
126 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
127 | 127 | |
128 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
129 | 129 | |
130 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
131 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
132 | - } |
|
130 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
131 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
132 | + } |
|
133 | 133 | |
134 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | function wpinv_send_back_to_checkout( $args = array() ) { |
138 | - $redirect = wpinv_get_checkout_uri(); |
|
138 | + $redirect = wpinv_get_checkout_uri(); |
|
139 | 139 | |
140 | - if ( ! empty( $args ) ) { |
|
141 | - // Check for backward compatibility |
|
142 | - if ( is_string( $args ) ) |
|
143 | - $args = str_replace( '?', '', $args ); |
|
140 | + if ( ! empty( $args ) ) { |
|
141 | + // Check for backward compatibility |
|
142 | + if ( is_string( $args ) ) |
|
143 | + $args = str_replace( '?', '', $args ); |
|
144 | 144 | |
145 | - $args = wp_parse_args( $args ); |
|
145 | + $args = wp_parse_args( $args ); |
|
146 | 146 | |
147 | - $redirect = add_query_arg( $args, $redirect ); |
|
148 | - } |
|
147 | + $redirect = add_query_arg( $args, $redirect ); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | do_action( 'wpinv_pre_send_back_to_checkout', $args ); |
151 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
152 | - exit; |
|
151 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
152 | + exit; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | function wpinv_get_success_page_url( $query_string = null ) { |
156 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
157 | - $success_page = get_permalink( $success_page ); |
|
156 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
157 | + $success_page = get_permalink( $success_page ); |
|
158 | 158 | |
159 | - if ( $query_string ) |
|
160 | - $success_page .= $query_string; |
|
159 | + if ( $query_string ) |
|
160 | + $success_page .= $query_string; |
|
161 | 161 | |
162 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
162 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
166 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
168 | 168 | |
169 | - if ( $extras ) |
|
170 | - $uri .= $extras; |
|
169 | + if ( $extras ) |
|
170 | + $uri .= $extras; |
|
171 | 171 | |
172 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
172 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | function wpinv_is_failed_transaction_page() { |
176 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
177 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
177 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
179 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -251,36 +251,36 @@ discard block |
||
251 | 251 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
252 | 252 | |
253 | 253 | if ( $require_billing_details ) { |
254 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
255 | - $required_fields['first_name'] = array( |
|
256 | - 'error_id' => 'invalid_first_name', |
|
257 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
258 | - ); |
|
259 | - } |
|
260 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
261 | - $required_fields['address'] = array( |
|
262 | - 'error_id' => 'invalid_address', |
|
263 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
264 | - ); |
|
265 | - } |
|
266 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
267 | - $required_fields['city'] = array( |
|
268 | - 'error_id' => 'invalid_city', |
|
269 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
270 | - ); |
|
271 | - } |
|
272 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
273 | - $required_fields['state'] = array( |
|
274 | - 'error_id' => 'invalid_state', |
|
275 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
276 | - ); |
|
277 | - } |
|
278 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
279 | - $required_fields['country'] = array( |
|
280 | - 'error_id' => 'invalid_country', |
|
281 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
282 | - ); |
|
283 | - } |
|
254 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
255 | + $required_fields['first_name'] = array( |
|
256 | + 'error_id' => 'invalid_first_name', |
|
257 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
258 | + ); |
|
259 | + } |
|
260 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
261 | + $required_fields['address'] = array( |
|
262 | + 'error_id' => 'invalid_address', |
|
263 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
264 | + ); |
|
265 | + } |
|
266 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
267 | + $required_fields['city'] = array( |
|
268 | + 'error_id' => 'invalid_city', |
|
269 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
270 | + ); |
|
271 | + } |
|
272 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
273 | + $required_fields['state'] = array( |
|
274 | + 'error_id' => 'invalid_state', |
|
275 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
276 | + ); |
|
277 | + } |
|
278 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
279 | + $required_fields['country'] = array( |
|
280 | + 'error_id' => 'invalid_country', |
|
281 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
282 | + ); |
|
283 | + } |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -7,197 +7,197 @@ 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_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
48 | + $page_id = absint($page_id); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option('success_page', false); |
|
55 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
62 | + $ret = $ret ? is_page($ret) : false; |
|
63 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | -function wpinv_send_to_success_page( $args = null ) { |
|
72 | +function wpinv_send_to_success_page($args = null) { |
|
73 | 73 | $redirect = wpinv_get_success_page_uri(); |
74 | 74 | |
75 | - if ( !empty( $args ) ) { |
|
75 | + if (!empty($args)) { |
|
76 | 76 | // Check for backward compatibility |
77 | - if ( is_string( $args ) ) |
|
78 | - $args = str_replace( '?', '', $args ); |
|
77 | + if (is_string($args)) |
|
78 | + $args = str_replace('?', '', $args); |
|
79 | 79 | |
80 | - $args = wp_parse_args( $args ); |
|
80 | + $args = wp_parse_args($args); |
|
81 | 81 | |
82 | - $redirect = add_query_arg( $args, $redirect ); |
|
82 | + $redirect = add_query_arg($args, $redirect); |
|
83 | 83 | } |
84 | 84 | |
85 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
85 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
86 | 86 | |
87 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
88 | - wp_redirect( $redirect ); |
|
87 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
88 | + wp_redirect($redirect); |
|
89 | 89 | exit; |
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_send_to_failed_page( $args = null ) { |
|
92 | +function wpinv_send_to_failed_page($args = null) { |
|
93 | 93 | $redirect = wpinv_get_failed_transaction_uri(); |
94 | 94 | |
95 | - if ( !empty( $args ) ) { |
|
95 | + if (!empty($args)) { |
|
96 | 96 | // Check for backward compatibility |
97 | - if ( is_string( $args ) ) |
|
98 | - $args = str_replace( '?', '', $args ); |
|
97 | + if (is_string($args)) |
|
98 | + $args = str_replace('?', '', $args); |
|
99 | 99 | |
100 | - $args = wp_parse_args( $args ); |
|
100 | + $args = wp_parse_args($args); |
|
101 | 101 | |
102 | - $redirect = add_query_arg( $args, $redirect ); |
|
102 | + $redirect = add_query_arg($args, $redirect); |
|
103 | 103 | } |
104 | 104 | |
105 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
105 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
106 | 106 | |
107 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
108 | - wp_redirect( $redirect ); |
|
107 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
108 | + wp_redirect($redirect); |
|
109 | 109 | exit; |
110 | 110 | } |
111 | 111 | |
112 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
113 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
114 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | +function wpinv_get_checkout_uri($args = array()) { |
|
113 | + $uri = wpinv_get_option('checkout_page', false); |
|
114 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
115 | 115 | |
116 | - if ( !empty( $args ) ) { |
|
116 | + if (!empty($args)) { |
|
117 | 117 | // Check for backward compatibility |
118 | - if ( is_string( $args ) ) |
|
119 | - $args = str_replace( '?', '', $args ); |
|
118 | + if (is_string($args)) |
|
119 | + $args = str_replace('?', '', $args); |
|
120 | 120 | |
121 | - $args = wp_parse_args( $args ); |
|
121 | + $args = wp_parse_args($args); |
|
122 | 122 | |
123 | - $uri = add_query_arg( $args, $uri ); |
|
123 | + $uri = add_query_arg($args, $uri); |
|
124 | 124 | } |
125 | 125 | |
126 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
127 | 127 | |
128 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
129 | 129 | |
130 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
131 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
130 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
131 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
135 | 135 | } |
136 | 136 | |
137 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
137 | +function wpinv_send_back_to_checkout($args = array()) { |
|
138 | 138 | $redirect = wpinv_get_checkout_uri(); |
139 | 139 | |
140 | - if ( ! empty( $args ) ) { |
|
140 | + if (!empty($args)) { |
|
141 | 141 | // Check for backward compatibility |
142 | - if ( is_string( $args ) ) |
|
143 | - $args = str_replace( '?', '', $args ); |
|
142 | + if (is_string($args)) |
|
143 | + $args = str_replace('?', '', $args); |
|
144 | 144 | |
145 | - $args = wp_parse_args( $args ); |
|
145 | + $args = wp_parse_args($args); |
|
146 | 146 | |
147 | - $redirect = add_query_arg( $args, $redirect ); |
|
147 | + $redirect = add_query_arg($args, $redirect); |
|
148 | 148 | } |
149 | 149 | |
150 | - do_action( 'wpinv_pre_send_back_to_checkout', $args ); |
|
151 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | + do_action('wpinv_pre_send_back_to_checkout', $args); |
|
151 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
152 | 152 | exit; |
153 | 153 | } |
154 | 154 | |
155 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
156 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
157 | - $success_page = get_permalink( $success_page ); |
|
155 | +function wpinv_get_success_page_url($query_string = null) { |
|
156 | + $success_page = wpinv_get_option('success_page', 0); |
|
157 | + $success_page = get_permalink($success_page); |
|
158 | 158 | |
159 | - if ( $query_string ) |
|
159 | + if ($query_string) |
|
160 | 160 | $success_page .= $query_string; |
161 | 161 | |
162 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
162 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
163 | 163 | } |
164 | 164 | |
165 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
166 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
165 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
166 | + $uri = wpinv_get_option('failure_page', ''); |
|
167 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
168 | 168 | |
169 | - if ( $extras ) |
|
169 | + if ($extras) |
|
170 | 170 | $uri .= $extras; |
171 | 171 | |
172 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
172 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | function wpinv_is_failed_transaction_page() { |
176 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
177 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | + $ret = wpinv_get_option('failure_page', false); |
|
177 | + $ret = isset($ret) ? is_page($ret) : false; |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
179 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
180 | 180 | } |
181 | 181 | |
182 | -function wpinv_transaction_query( $type = 'start' ) { |
|
182 | +function wpinv_transaction_query($type = 'start') { |
|
183 | 183 | global $wpdb; |
184 | 184 | |
185 | 185 | $wpdb->hide_errors(); |
186 | 186 | |
187 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
188 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
187 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
188 | + define('WPINV_USE_TRANSACTIONS', true); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
192 | - switch ( $type ) { |
|
191 | + if (WPINV_USE_TRANSACTIONS) { |
|
192 | + switch ($type) { |
|
193 | 193 | case 'commit' : |
194 | - $wpdb->query( 'COMMIT' ); |
|
194 | + $wpdb->query('COMMIT'); |
|
195 | 195 | break; |
196 | 196 | case 'rollback' : |
197 | - $wpdb->query( 'ROLLBACK' ); |
|
197 | + $wpdb->query('ROLLBACK'); |
|
198 | 198 | break; |
199 | 199 | default : |
200 | - $wpdb->query( 'START TRANSACTION' ); |
|
200 | + $wpdb->query('START TRANSACTION'); |
|
201 | 201 | break; |
202 | 202 | } |
203 | 203 | } |
@@ -206,157 +206,157 @@ discard block |
||
206 | 206 | function wpinv_get_prefix() { |
207 | 207 | $invoice_prefix = 'INV-'; |
208 | 208 | |
209 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
209 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_get_business_logo() { |
213 | - $business_logo = wpinv_get_option( 'logo' ); |
|
214 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
213 | + $business_logo = wpinv_get_option('logo'); |
|
214 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | function wpinv_get_business_name() { |
218 | 218 | $business_name = wpinv_get_option('store_name'); |
219 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
219 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function wpinv_get_blogname() { |
223 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
223 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | function wpinv_get_admin_email() { |
227 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
228 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
227 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
228 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | function wpinv_get_business_website() { |
232 | - $business_website = home_url( '/' ); |
|
233 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
232 | + $business_website = home_url('/'); |
|
233 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
234 | 234 | } |
235 | 235 | |
236 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
236 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
237 | 237 | $terms_text = ''; |
238 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
238 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | function wpinv_get_business_footer() { |
242 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
243 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
244 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
242 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
243 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
244 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_required_fields() { |
248 | 248 | $required_fields = array(); |
249 | 249 | |
250 | 250 | // Let payment gateways and other extensions determine if address fields should be required |
251 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
251 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
252 | 252 | |
253 | - if ( $require_billing_details ) { |
|
254 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
253 | + if ($require_billing_details) { |
|
254 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
255 | 255 | $required_fields['first_name'] = array( |
256 | 256 | 'error_id' => 'invalid_first_name', |
257 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
257 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
258 | 258 | ); |
259 | 259 | } |
260 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
260 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
261 | 261 | $required_fields['address'] = array( |
262 | 262 | 'error_id' => 'invalid_address', |
263 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
263 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
264 | 264 | ); |
265 | 265 | } |
266 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
266 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
267 | 267 | $required_fields['city'] = array( |
268 | 268 | 'error_id' => 'invalid_city', |
269 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
269 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
270 | 270 | ); |
271 | 271 | } |
272 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
272 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
273 | 273 | $required_fields['state'] = array( |
274 | 274 | 'error_id' => 'invalid_state', |
275 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
275 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
276 | 276 | ); |
277 | 277 | } |
278 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
278 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
279 | 279 | $required_fields['country'] = array( |
280 | 280 | 'error_id' => 'invalid_country', |
281 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
281 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
282 | 282 | ); |
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
286 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | function wpinv_is_ssl_enforced() { |
290 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
291 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
290 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
291 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | function wpinv_schedule_events() { |
295 | 295 | |
296 | 296 | // Get the timestamp for the next event. |
297 | - $timestamp = wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ); |
|
297 | + $timestamp = wp_next_scheduled('wpinv_register_schedule_event_twicedaily'); |
|
298 | 298 | |
299 | - if ( $timestamp ) { |
|
300 | - wp_unschedule_event( $timestamp, 'wpinv_register_schedule_event_twicedaily' ); |
|
299 | + if ($timestamp) { |
|
300 | + wp_unschedule_event($timestamp, 'wpinv_register_schedule_event_twicedaily'); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( ! wp_next_scheduled( 'wpinv_register_schedule_event_daily' ) ) { |
|
304 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'wpinv_register_schedule_event_daily' ); |
|
303 | + if (!wp_next_scheduled('wpinv_register_schedule_event_daily')) { |
|
304 | + wp_schedule_event(current_time('timestamp'), 'daily', 'wpinv_register_schedule_event_daily'); |
|
305 | 305 | } |
306 | 306 | } |
307 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
307 | +add_action('wp', 'wpinv_schedule_events'); |
|
308 | 308 | |
309 | 309 | function wpinv_schedule_event_twicedaily() { |
310 | 310 | wpinv_email_payment_reminders(); |
311 | 311 | wpinv_email_renewal_reminders(); |
312 | 312 | } |
313 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
313 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
314 | 314 | |
315 | 315 | function wpinv_require_login_to_checkout() { |
316 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
317 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
316 | + $return = wpinv_get_option('login_to_checkout', false); |
|
317 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_sequential_number_active( $type = '' ) { |
|
321 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
322 | - if ( null !== $check ) { |
|
320 | +function wpinv_sequential_number_active($type = '') { |
|
321 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
322 | + if (null !== $check) { |
|
323 | 323 | return $check; |
324 | 324 | } |
325 | 325 | |
326 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
326 | + return wpinv_get_option('sequential_invoice_number'); |
|
327 | 327 | } |
328 | 328 | |
329 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
329 | +function wpinv_switch_to_locale($locale = NULL) { |
|
330 | 330 | global $invoicing, $wpi_switch_locale; |
331 | 331 | |
332 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
333 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
332 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
333 | + $locale = empty($locale) ? get_locale() : $locale; |
|
334 | 334 | |
335 | - switch_to_locale( $locale ); |
|
335 | + switch_to_locale($locale); |
|
336 | 336 | |
337 | 337 | $wpi_switch_locale = $locale; |
338 | 338 | |
339 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
339 | + add_filter('plugin_locale', 'get_locale'); |
|
340 | 340 | |
341 | 341 | $invoicing->load_textdomain(); |
342 | 342 | |
343 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
343 | + do_action('wpinv_switch_to_locale', $locale); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | function wpinv_restore_locale() { |
348 | 348 | global $invoicing, $wpi_switch_locale; |
349 | 349 | |
350 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
350 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
351 | 351 | restore_previous_locale(); |
352 | 352 | |
353 | 353 | $wpi_switch_locale = NULL; |
354 | 354 | |
355 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
355 | + remove_filter('plugin_locale', 'get_locale'); |
|
356 | 356 | |
357 | 357 | $invoicing->load_textdomain(); |
358 | 358 | |
359 | - do_action( 'wpinv_restore_locale' ); |
|
359 | + do_action('wpinv_restore_locale'); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | * Returns the default form's id. |
365 | 365 | */ |
366 | 366 | function wpinv_get_default_payment_form() { |
367 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
367 | + $form = get_option('wpinv_default_payment_form'); |
|
368 | 368 | |
369 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
369 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
370 | 370 | $form = wp_insert_post( |
371 | 371 | array( |
372 | 372 | 'post_type' => 'wpi_payment_form', |
373 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
373 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
374 | 374 | 'post_status' => 'publish', |
375 | 375 | 'meta_input' => array( |
376 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
376 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
377 | 377 | 'wpinv_form_items' => array(), |
378 | 378 | ) |
379 | 379 | ) |
380 | 380 | ); |
381 | 381 | |
382 | - update_option( 'wpinv_default_payment_form', $form ); |
|
382 | + update_option('wpinv_default_payment_form', $form); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | return $form; |