@@ -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 = getpaid_tax()->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 |
@@ -196,8 +196,9 @@ |
||
196 | 196 | foreach ( $types as $name => $type ) { |
197 | 197 | echo '<option value="' . esc_attr( $name ) . '"'; |
198 | 198 | |
199 | - if ( isset( $_GET['discount_type'] ) ) |
|
200 | - selected( $name, $_GET['discount_type'] ); |
|
199 | + if ( isset( $_GET['discount_type'] ) ) { |
|
200 | + selected( $name, $_GET['discount_type'] ); |
|
201 | + } |
|
201 | 202 | |
202 | 203 | echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
203 | 204 | } |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code' : |
15 | 15 | echo $discount->get_code(); |
16 | 16 | break; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | echo $discount->get_usage(); |
22 | 22 | break; |
23 | 23 | case 'start_date' : |
24 | - if ( $discount->has_start_date() ) { |
|
25 | - $value = date_i18n( get_option( 'date_format' ), strtotime( $discount->get_start_date() ) ); |
|
24 | + if ($discount->has_start_date()) { |
|
25 | + $value = date_i18n(get_option('date_format'), strtotime($discount->get_start_date())); |
|
26 | 26 | } else { |
27 | 27 | $value = '—'; |
28 | 28 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | echo $value; |
31 | 31 | break; |
32 | 32 | case 'expiry_date' : |
33 | - if ( $discount->has_expiration_date() ) { |
|
34 | - $value = date_i18n( get_option( 'date_format' ), strtotime( $discount->get_expiration_date() ) ); |
|
33 | + if ($discount->has_expiration_date()) { |
|
34 | + $value = date_i18n(get_option('date_format'), strtotime($discount->get_expiration_date())); |
|
35 | 35 | } else { |
36 | - $value = __( 'Never', 'invoicing' ); |
|
36 | + $value = __('Never', 'invoicing'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | echo $value; |
@@ -41,30 +41,30 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
45 | -function wpinv_post_row_actions( $actions, $post ) { |
|
46 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
44 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
45 | +function wpinv_post_row_actions($actions, $post) { |
|
46 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
47 | 47 | |
48 | - if ( $post_type == 'wpi_invoice' ) { |
|
48 | + if ($post_type == 'wpi_invoice') { |
|
49 | 49 | $actions = array(); |
50 | 50 | } |
51 | 51 | |
52 | - if ( $post_type == 'wpi_discount' ) { |
|
53 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
52 | + if ($post_type == 'wpi_discount') { |
|
53 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return $actions; |
57 | 57 | } |
58 | 58 | |
59 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
60 | - $row_actions = array(); |
|
61 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
62 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
59 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
60 | + $row_actions = array(); |
|
61 | + $edit_link = get_edit_post_link($discount->ID); |
|
62 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
63 | 63 | |
64 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
65 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
66 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
67 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
64 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
65 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
66 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
67 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $delete_url = esc_url( |
@@ -78,110 +78,110 @@ discard block |
||
78 | 78 | 'wpinv_discount_nonce' |
79 | 79 | ) |
80 | 80 | ); |
81 | - $row_actions['delete'] = '<a href="' . $delete_url . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
81 | + $row_actions['delete'] = '<a href="' . $delete_url . '">' . __('Delete', 'invoicing') . '</a>'; |
|
82 | 82 | |
83 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
83 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
84 | 84 | |
85 | 85 | return $row_actions; |
86 | 86 | } |
87 | 87 | |
88 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
89 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
90 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
88 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
89 | +function wpinv_table_primary_column($default, $screen_id) { |
|
90 | + if ('edit-wpi_invoice' === $screen_id) { |
|
91 | 91 | return 'name'; |
92 | 92 | } |
93 | 93 | |
94 | 94 | return $default; |
95 | 95 | } |
96 | 96 | |
97 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
98 | - if ( !$display ) { |
|
97 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
98 | + if (!$display) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | $actions = array( |
103 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
104 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
105 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
103 | + 'activate' => __('Activate', 'invoicing'), |
|
104 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
105 | + 'delete' => __('Delete', 'invoicing'), |
|
106 | 106 | ); |
107 | 107 | $two = ''; |
108 | 108 | $which = 'top'; |
109 | 109 | echo '</div><div class="alignleft actions bulkactions">'; |
110 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
111 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
112 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
110 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
111 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
112 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
113 | 113 | |
114 | - foreach ( $actions as $name => $title ) { |
|
114 | + foreach ($actions as $name => $title) { |
|
115 | 115 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
116 | 116 | |
117 | 117 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
118 | 118 | } |
119 | 119 | echo "</select>"; |
120 | 120 | |
121 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
121 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
122 | 122 | |
123 | 123 | echo '</div><div class="alignleft actions">'; |
124 | 124 | } |
125 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
125 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
126 | 126 | |
127 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
128 | - if ( $post_type == 'wpi_discount' ) { |
|
127 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
128 | + if ($post_type == 'wpi_discount') { |
|
129 | 129 | $disable = true; |
130 | 130 | } |
131 | 131 | |
132 | 132 | return $disable; |
133 | 133 | } |
134 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
134 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
135 | 135 | |
136 | 136 | function wpinv_restrict_manage_posts() { |
137 | 137 | global $typenow; |
138 | 138 | |
139 | - if( 'wpi_discount' == $typenow ) { |
|
139 | + if ('wpi_discount' == $typenow) { |
|
140 | 140 | wpinv_discount_filters(); |
141 | 141 | } |
142 | 142 | } |
143 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
143 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
144 | 144 | |
145 | 145 | function wpinv_discount_filters() { |
146 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
146 | + echo wpinv_discount_bulk_actions(array(), true); |
|
147 | 147 | |
148 | 148 | ?> |
149 | 149 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
150 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
150 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
151 | 151 | <?php |
152 | 152 | $types = wpinv_get_discount_types(); |
153 | 153 | |
154 | - foreach ( $types as $name => $type ) { |
|
155 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
154 | + foreach ($types as $name => $type) { |
|
155 | + echo '<option value="' . esc_attr($name) . '"'; |
|
156 | 156 | |
157 | - if ( isset( $_GET['discount_type'] ) ) |
|
158 | - selected( $name, $_GET['discount_type'] ); |
|
157 | + if (isset($_GET['discount_type'])) |
|
158 | + selected($name, $_GET['discount_type']); |
|
159 | 159 | |
160 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
160 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
161 | 161 | } |
162 | 162 | ?> |
163 | 163 | </select> |
164 | 164 | <?php |
165 | 165 | } |
166 | 166 | |
167 | -function wpinv_request( $vars ) { |
|
167 | +function wpinv_request($vars) { |
|
168 | 168 | global $typenow, $wp_query, $wp_post_statuses; |
169 | 169 | |
170 | - if ( 'wpi_invoice' === $typenow ) { |
|
171 | - if ( !isset( $vars['post_status'] ) ) { |
|
170 | + if ('wpi_invoice' === $typenow) { |
|
171 | + if (!isset($vars['post_status'])) { |
|
172 | 172 | $post_statuses = wpinv_get_invoice_statuses(); |
173 | 173 | |
174 | - foreach ( $post_statuses as $status => $value ) { |
|
175 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
176 | - unset( $post_statuses[ $status ] ); |
|
174 | + foreach ($post_statuses as $status => $value) { |
|
175 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
176 | + unset($post_statuses[$status]); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
180 | + $vars['post_status'] = array_keys($post_statuses); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $vars['orderby'] ) ) { |
|
184 | - if ( 'amount' == $vars['orderby'] ) { |
|
183 | + if (isset($vars['orderby'])) { |
|
184 | + if ('amount' == $vars['orderby']) { |
|
185 | 185 | $vars = array_merge( |
186 | 186 | $vars, |
187 | 187 | array( |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'orderby' => 'meta_value_num' |
190 | 190 | ) |
191 | 191 | ); |
192 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
192 | + } else if ('customer' == $vars['orderby']) { |
|
193 | 193 | $vars = array_merge( |
194 | 194 | $vars, |
195 | 195 | array( |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | 'orderby' => 'meta_value' |
198 | 198 | ) |
199 | 199 | ); |
200 | - } else if ( 'number' == $vars['orderby'] ) { |
|
200 | + } else if ('number' == $vars['orderby']) { |
|
201 | 201 | $vars = array_merge( |
202 | 202 | $vars, |
203 | 203 | array( |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'orderby' => 'meta_value' |
206 | 206 | ) |
207 | 207 | ); |
208 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
208 | + } else if ('payment_date' == $vars['orderby']) { |
|
209 | 209 | $vars = array_merge( |
210 | 210 | $vars, |
211 | 211 | array( |
@@ -215,73 +215,73 @@ discard block |
||
215 | 215 | ); |
216 | 216 | } |
217 | 217 | } |
218 | - } else if ( 'wpi_discount' == $typenow ) { |
|
219 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
218 | + } else if ('wpi_discount' == $typenow) { |
|
219 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
220 | 220 | // Filter vat rule type |
221 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
221 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
222 | 222 | $meta_query[] = array( |
223 | 223 | 'key' => '_wpi_discount_type', |
224 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
224 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
225 | 225 | 'compare' => '=' |
226 | 226 | ); |
227 | 227 | } |
228 | 228 | |
229 | - if ( !empty( $meta_query ) ) { |
|
229 | + if (!empty($meta_query)) { |
|
230 | 230 | $vars['meta_query'] = $meta_query; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | return $vars; |
235 | 235 | } |
236 | -add_filter( 'request', 'wpinv_request' ); |
|
236 | +add_filter('request', 'wpinv_request'); |
|
237 | 237 | |
238 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
238 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
239 | 239 | global $pagenow, $typenow; |
240 | 240 | |
241 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
242 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
243 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
241 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
242 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
243 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
246 | + if (!wpinv_item_is_editable($post_id)) { |
|
247 | 247 | $classes[] = 'wpi-editable-n'; |
248 | 248 | } |
249 | 249 | } |
250 | 250 | return $classes; |
251 | 251 | } |
252 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
252 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
253 | 253 | |
254 | 254 | function wpinv_check_quick_edit() { |
255 | 255 | global $pagenow, $current_screen, $wpinv_item_screen; |
256 | 256 | |
257 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
258 | - if ( empty( $wpinv_item_screen ) ) { |
|
259 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
257 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
258 | + if (empty($wpinv_item_screen)) { |
|
259 | + if ($current_screen->post_type == 'wpi_item') { |
|
260 | 260 | $wpinv_item_screen = 'y'; |
261 | 261 | } else { |
262 | 262 | $wpinv_item_screen = 'n'; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
267 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
268 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
266 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
267 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
268 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | } |
272 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
272 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
273 | 273 | |
274 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
275 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
276 | - unset( $actions['inline hide-if-no-js'] ); |
|
274 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
275 | + if (isset($actions['inline hide-if-no-js'])) { |
|
276 | + unset($actions['inline hide-if-no-js']); |
|
277 | 277 | } |
278 | 278 | |
279 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
280 | - if ( isset( $actions['trash'] ) ) { |
|
281 | - unset( $actions['trash'] ); |
|
279 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
280 | + if (isset($actions['trash'])) { |
|
281 | + unset($actions['trash']); |
|
282 | 282 | } |
283 | - if ( isset( $actions['delete'] ) ) { |
|
284 | - unset( $actions['delete'] ); |
|
283 | + if (isset($actions['delete'])) { |
|
284 | + unset($actions['delete']); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | * @param int $post_parent (default: 0) Parent for the new page |
299 | 299 | * @return int page ID |
300 | 300 | */ |
301 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
301 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
302 | 302 | global $wpdb; |
303 | 303 | |
304 | - $option_value = wpinv_get_option( $option ); |
|
304 | + $option_value = wpinv_get_option($option); |
|
305 | 305 | |
306 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
307 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
306 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
307 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
308 | 308 | // Valid page is already in place |
309 | 309 | return $page_object->ID; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - if(!empty($post_parent)){ |
|
313 | + if (!empty($post_parent)) { |
|
314 | 314 | $page = get_page_by_path($post_parent); |
315 | 315 | if ($page) { |
316 | 316 | $post_parent = $page->ID; |
@@ -319,40 +319,40 @@ discard block |
||
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - if ( strlen( $page_content ) > 0 ) { |
|
322 | + if (strlen($page_content) > 0) { |
|
323 | 323 | // Search for an existing page with the specified page content (typically a shortcode) |
324 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
324 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
325 | 325 | } else { |
326 | 326 | // Search for an existing page with the specified page slug |
327 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
327 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
328 | 328 | } |
329 | 329 | |
330 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
330 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
331 | 331 | |
332 | - if ( $valid_page_found ) { |
|
333 | - if ( $option ) { |
|
334 | - wpinv_update_option( $option, $valid_page_found ); |
|
332 | + if ($valid_page_found) { |
|
333 | + if ($option) { |
|
334 | + wpinv_update_option($option, $valid_page_found); |
|
335 | 335 | } |
336 | 336 | return $valid_page_found; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Search for a matching valid trashed page |
340 | - if ( strlen( $page_content ) > 0 ) { |
|
340 | + if (strlen($page_content) > 0) { |
|
341 | 341 | // Search for an existing page with the specified page content (typically a shortcode) |
342 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
342 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
343 | 343 | } else { |
344 | 344 | // Search for an existing page with the specified page slug |
345 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
345 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( $trashed_page_found ) { |
|
348 | + if ($trashed_page_found) { |
|
349 | 349 | $page_id = $trashed_page_found; |
350 | 350 | $page_data = array( |
351 | 351 | 'ID' => $page_id, |
352 | 352 | 'post_status' => 'publish', |
353 | 353 | 'post_parent' => $post_parent, |
354 | 354 | ); |
355 | - wp_update_post( $page_data ); |
|
355 | + wp_update_post($page_data); |
|
356 | 356 | } else { |
357 | 357 | $page_data = array( |
358 | 358 | 'post_status' => 'publish', |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | 'post_parent' => $post_parent, |
365 | 365 | 'comment_status' => 'closed', |
366 | 366 | ); |
367 | - $page_id = wp_insert_post( $page_data ); |
|
367 | + $page_id = wp_insert_post($page_data); |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( $option ) { |
|
371 | - wpinv_update_option( $option, (int)$page_id ); |
|
370 | + if ($option) { |
|
371 | + wpinv_update_option($option, (int) $page_id); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | return $page_id; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
311 | 311 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
312 | 312 | $enabled_gateway = wpinv_get_default_gateway(); |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | $enabled_gateway = $gateways[0]; |
315 | 315 | } |
316 | 316 | |
@@ -336,8 +336,9 @@ discard block |
||
336 | 336 | |
337 | 337 | $payments = new WP_Query( $args ); |
338 | 338 | |
339 | - if( $payments ) |
|
340 | - $ret = $payments->post_count; |
|
339 | + if( $payments ) { |
|
340 | + $ret = $payments->post_count; |
|
341 | + } |
|
341 | 342 | return $ret; |
342 | 343 | } |
343 | 344 |
@@ -268,26 +268,26 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
271 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
271 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
272 | 272 | |
273 | 273 | $chosen = false; |
274 | 274 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
275 | 275 | $chosen = $invoice->get_gateway(); |
276 | 276 | } |
277 | 277 | |
278 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
278 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
279 | 279 | |
280 | - if ( false !== $chosen ) { |
|
281 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
282 | - } |
|
280 | + if ( false !== $chosen ) { |
|
281 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
282 | + } |
|
283 | 283 | |
284 | - if ( ! empty ( $chosen ) ) { |
|
285 | - $enabled_gateway = urldecode( $chosen ); |
|
286 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
287 | - $enabled_gateway = 'manual'; |
|
288 | - } else { |
|
289 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
290 | - } |
|
284 | + if ( ! empty ( $chosen ) ) { |
|
285 | + $enabled_gateway = urldecode( $chosen ); |
|
286 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
287 | + $enabled_gateway = 'manual'; |
|
288 | + } else { |
|
289 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
290 | + } |
|
291 | 291 | |
292 | 292 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
293 | 293 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
301 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
309 | - $ret = 0; |
|
310 | - $args = array( |
|
311 | - 'meta_key' => '_wpinv_gateway', |
|
312 | - 'meta_value' => $gateway_id, |
|
313 | - 'nopaging' => true, |
|
314 | - 'post_type' => 'wpi_invoice', |
|
315 | - 'post_status' => $status, |
|
316 | - 'fields' => 'ids' |
|
317 | - ); |
|
309 | + $ret = 0; |
|
310 | + $args = array( |
|
311 | + 'meta_key' => '_wpinv_gateway', |
|
312 | + 'meta_value' => $gateway_id, |
|
313 | + 'nopaging' => true, |
|
314 | + 'post_type' => 'wpi_invoice', |
|
315 | + 'post_status' => $status, |
|
316 | + 'fields' => 'ids' |
|
317 | + ); |
|
318 | 318 | |
319 | - $payments = new WP_Query( $args ); |
|
319 | + $payments = new WP_Query( $args ); |
|
320 | 320 | |
321 | - if( $payments ) |
|
322 | - $ret = $payments->post_count; |
|
323 | - return $ret; |
|
321 | + if( $payments ) |
|
322 | + $ret = $payments->post_count; |
|
323 | + return $ret; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | function wpinv_settings_update_gateways( $input ) { |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | $required_fields = wpinv_checkout_required_fields(); |
855 | 855 | |
856 | 856 | // Loop through required fields and show error messages |
857 | - if ( !empty( $required_fields ) ) { |
|
857 | + if ( !empty( $required_fields ) ) { |
|
858 | 858 | foreach ( $required_fields as $field_name => $value ) { |
859 | 859 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
860 | 860 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,141 +11,141 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | global $wpinv_options; |
19 | 19 | |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
23 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
39 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
40 | 40 | $gateways = wpinv_get_payment_gateways(); |
41 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
41 | + $enabled = wpinv_get_option('gateways', false); |
|
42 | 42 | |
43 | 43 | $gateway_list = array(); |
44 | 44 | |
45 | - foreach ( $gateways as $key => $gateway ) { |
|
46 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
47 | - $gateway_list[ $key ] = $gateway; |
|
45 | + foreach ($gateways as $key => $gateway) { |
|
46 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
47 | + $gateway_list[$key] = $gateway; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - if ( true === $sort ) { |
|
52 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
51 | + if (true === $sort) { |
|
52 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
53 | 53 | |
54 | 54 | // Reorder our gateways so the default is first |
55 | 55 | $default_gateway_id = wpinv_get_default_gateway(); |
56 | 56 | |
57 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
58 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
59 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
57 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
58 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
59 | + unset($gateway_list[$default_gateway_id]); |
|
60 | 60 | |
61 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
61 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
65 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
66 | 66 | } |
67 | 67 | |
68 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
68 | +function wpinv_sort_gateway_order($a, $b) { |
|
69 | 69 | return $a['ordering'] - $b['ordering']; |
70 | 70 | } |
71 | 71 | |
72 | -function wpinv_is_gateway_active( $gateway ) { |
|
72 | +function wpinv_is_gateway_active($gateway) { |
|
73 | 73 | $gateways = wpinv_get_enabled_payment_gateways(); |
74 | 74 | |
75 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
75 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
76 | 76 | |
77 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
77 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | function wpinv_get_default_gateway() { |
81 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
81 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
82 | 82 | |
83 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
83 | + if (!wpinv_is_gateway_active($default)) { |
|
84 | 84 | $gateways = wpinv_get_enabled_payment_gateways(); |
85 | - $gateways = array_keys( $gateways ); |
|
86 | - $default = reset( $gateways ); |
|
85 | + $gateways = array_keys($gateways); |
|
86 | + $default = reset($gateways); |
|
87 | 87 | } |
88 | 88 | |
89 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
89 | + return apply_filters('wpinv_default_gateway', $default); |
|
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
92 | +function wpinv_get_gateway_admin_label($gateway) { |
|
93 | 93 | $gateways = wpinv_get_payment_gateways(); |
94 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
95 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
94 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
95 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
96 | 96 | |
97 | - if( $gateway == 'manual' && $payment ) { |
|
98 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
99 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
97 | + if ($gateway == 'manual' && $payment) { |
|
98 | + if (!((float) wpinv_payment_total($payment) > 0)) { |
|
99 | + $label = __('Free Purchase', 'invoicing'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
103 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
104 | 104 | } |
105 | 105 | |
106 | -function wpinv_get_gateway_description( $gateway ) { |
|
106 | +function wpinv_get_gateway_description($gateway) { |
|
107 | 107 | global $wpinv_options; |
108 | 108 | |
109 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
109 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
110 | 110 | |
111 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
111 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
115 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
114 | +function wpinv_get_gateway_button_label($gateway) { |
|
115 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
116 | 116 | } |
117 | 117 | |
118 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
118 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
119 | 119 | $gateways = wpinv_get_payment_gateways(); |
120 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
120 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
121 | 121 | |
122 | - if ( $gateway == 'none' ) { |
|
123 | - $label = __( 'None', 'invoicing' ); |
|
122 | + if ($gateway == 'none') { |
|
123 | + $label = __('None', 'invoicing'); |
|
124 | 124 | } |
125 | 125 | |
126 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
126 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
127 | 127 | } |
128 | 128 | |
129 | -function wpinv_settings_sections_gateways( $settings ) { |
|
129 | +function wpinv_settings_sections_gateways($settings) { |
|
130 | 130 | $gateways = wpinv_get_payment_gateways(); |
131 | 131 | |
132 | 132 | if (!empty($gateways)) { |
133 | - foreach ($gateways as $key => $gateway) { |
|
133 | + foreach ($gateways as $key => $gateway) { |
|
134 | 134 | $settings[$key] = $gateway['admin_label']; |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | 138 | return $settings; |
139 | 139 | } |
140 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
140 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * Adds GateWay settings. |
144 | 144 | */ |
145 | -function wpinv_settings_gateways( $settings ) { |
|
145 | +function wpinv_settings_gateways($settings) { |
|
146 | 146 | |
147 | 147 | // Loop through each gateway. |
148 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
148 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
149 | 149 | |
150 | 150 | $gateway_settings = array( |
151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | "{$key}_header" => array( |
154 | 154 | |
155 | 155 | 'id' => "{$key}_gateway_header", |
156 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
156 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
157 | 157 | 'custom' => $key, |
158 | 158 | 'type' => 'gateway_header', |
159 | 159 | |
@@ -162,56 +162,56 @@ discard block |
||
162 | 162 | // Activate/Deactivate a gateway. |
163 | 163 | "{$key}_active" => array( |
164 | 164 | 'id' => $key . '_active', |
165 | - 'name' => __( 'Activate', 'invoicing' ), |
|
166 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
165 | + 'name' => __('Activate', 'invoicing'), |
|
166 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
167 | 167 | 'type' => 'checkbox', |
168 | 168 | ), |
169 | 169 | |
170 | 170 | // Activate/Deactivate sandbox. |
171 | 171 | "{$key}_sandbox" => array( |
172 | 172 | 'id' => $key . '_sandbox', |
173 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
174 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
173 | + 'name' => __('Sandbox', 'invoicing'), |
|
174 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
175 | 175 | 'type' => 'checkbox', |
176 | 176 | ), |
177 | 177 | |
178 | 178 | // Checkout title. |
179 | 179 | "{$key}_title" => array( |
180 | 180 | 'id' => $key . '_title', |
181 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
182 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
181 | + 'name' => __('Checkout Title', 'invoicing'), |
|
182 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
183 | 183 | 'type' => 'text', |
184 | 184 | ), |
185 | 185 | |
186 | 186 | // Checkout description. |
187 | 187 | "{$key}_desc" => array( |
188 | 188 | 'id' => $key . '_desc', |
189 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
190 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
189 | + 'name' => __('Checkout Description', 'invoicing'), |
|
190 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
191 | 191 | 'type' => 'text', |
192 | 192 | ), |
193 | 193 | |
194 | 194 | // Checkout order. |
195 | 195 | "{$key}_ordering" => array( |
196 | 196 | 'id' => $key . '_ordering', |
197 | - 'name' => __( 'Priority', 'invoicing' ), |
|
198 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
197 | + 'name' => __('Priority', 'invoicing'), |
|
198 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
199 | 199 | 'type' => 'number', |
200 | 200 | 'step' => '1', |
201 | 201 | 'min' => '-100000', |
202 | 202 | 'max' => '100000', |
203 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
203 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
204 | 204 | ), |
205 | 205 | |
206 | 206 | ); |
207 | 207 | |
208 | 208 | // Maybe remove the sandbox. |
209 | - if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) { |
|
210 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
209 | + if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) { |
|
210 | + unset($gateway_settings["{$key}_sandbox"]); |
|
211 | 211 | } |
212 | 212 | |
213 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
214 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
213 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
214 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
215 | 215 | |
216 | 216 | $settings[$key] = $gateway_settings; |
217 | 217 | } |
@@ -219,38 +219,38 @@ discard block |
||
219 | 219 | return $settings; |
220 | 220 | |
221 | 221 | } |
222 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
222 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
223 | 223 | |
224 | -function wpinv_gateway_header_callback( $args ) { |
|
225 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
224 | +function wpinv_gateway_header_callback($args) { |
|
225 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
226 | 226 | } |
227 | 227 | |
228 | -function wpinv_get_gateway_supports( $gateway ) { |
|
228 | +function wpinv_get_gateway_supports($gateway) { |
|
229 | 229 | $gateways = wpinv_get_enabled_payment_gateways(); |
230 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
231 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
230 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
231 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
232 | 232 | } |
233 | 233 | |
234 | -function wpinv_gateway_supports_buy_now( $gateway ) { |
|
235 | - $supports = wpinv_get_gateway_supports( $gateway ); |
|
236 | - $ret = in_array( 'buy_now', $supports ); |
|
237 | - return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway ); |
|
234 | +function wpinv_gateway_supports_buy_now($gateway) { |
|
235 | + $supports = wpinv_get_gateway_supports($gateway); |
|
236 | + $ret = in_array('buy_now', $supports); |
|
237 | + return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | function wpinv_shop_supports_buy_now() { |
241 | 241 | $gateways = wpinv_get_enabled_payment_gateways(); |
242 | 242 | $ret = false; |
243 | 243 | |
244 | - if ( !wpinv_use_taxes() && $gateways ) { |
|
245 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
246 | - if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) { |
|
244 | + if (!wpinv_use_taxes() && $gateways) { |
|
245 | + foreach ($gateways as $gateway_id => $gateway) { |
|
246 | + if (wpinv_gateway_supports_buy_now($gateway_id)) { |
|
247 | 247 | $ret = true; |
248 | 248 | break; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - return apply_filters( 'wpinv_shop_supports_buy_now', $ret ); |
|
253 | + return apply_filters('wpinv_shop_supports_buy_now', $ret); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -258,61 +258,61 @@ discard block |
||
258 | 258 | $gateways = wpinv_get_enabled_payment_gateways(); |
259 | 259 | $show_gateways = false; |
260 | 260 | |
261 | - $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false; |
|
261 | + $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false; |
|
262 | 262 | |
263 | - if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) { |
|
263 | + if (count($gateways) > 1 && empty($chosen_gateway)) { |
|
264 | 264 | $show_gateways = true; |
265 | - if ( wpinv_get_cart_total() <= 0 ) { |
|
265 | + if (wpinv_get_cart_total() <= 0) { |
|
266 | 266 | $show_gateways = false; |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | - if ( !$show_gateways && wpinv_cart_has_recurring_item() ) { |
|
270 | + if (!$show_gateways && wpinv_cart_has_recurring_item()) { |
|
271 | 271 | $show_gateways = true; |
272 | 272 | } |
273 | 273 | |
274 | - return apply_filters( 'wpinv_show_gateways', $show_gateways ); |
|
274 | + return apply_filters('wpinv_show_gateways', $show_gateways); |
|
275 | 275 | } |
276 | 276 | |
277 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
278 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
277 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
278 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
279 | 279 | |
280 | 280 | $chosen = false; |
281 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
281 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
282 | 282 | $chosen = $invoice->get_gateway(); |
283 | 283 | } |
284 | 284 | |
285 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
285 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
286 | 286 | |
287 | - if ( false !== $chosen ) { |
|
288 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
287 | + if (false !== $chosen) { |
|
288 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
289 | 289 | } |
290 | 290 | |
291 | - if ( ! empty ( $chosen ) ) { |
|
292 | - $enabled_gateway = urldecode( $chosen ); |
|
293 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
291 | + if (!empty ($chosen)) { |
|
292 | + $enabled_gateway = urldecode($chosen); |
|
293 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
294 | 294 | $enabled_gateway = 'manual'; |
295 | 295 | } else { |
296 | 296 | $enabled_gateway = wpinv_get_default_gateway(); |
297 | 297 | } |
298 | 298 | |
299 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
300 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
299 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
300 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
301 | 301 | $enabled_gateway = wpinv_get_default_gateway(); |
302 | - }else{ |
|
302 | + } else { |
|
303 | 303 | $enabled_gateway = $gateways[0]; |
304 | 304 | } |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
308 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
309 | 309 | } |
310 | 310 | |
311 | -function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
312 | - return wpinv_error_log( $message, $title ); |
|
311 | +function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
312 | + return wpinv_error_log($message, $title); |
|
313 | 313 | } |
314 | 314 | |
315 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
315 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
316 | 316 | $ret = 0; |
317 | 317 | $args = array( |
318 | 318 | 'meta_key' => '_wpinv_gateway', |
@@ -323,48 +323,48 @@ discard block |
||
323 | 323 | 'fields' => 'ids' |
324 | 324 | ); |
325 | 325 | |
326 | - $payments = new WP_Query( $args ); |
|
326 | + $payments = new WP_Query($args); |
|
327 | 327 | |
328 | - if( $payments ) |
|
328 | + if ($payments) |
|
329 | 329 | $ret = $payments->post_count; |
330 | 330 | return $ret; |
331 | 331 | } |
332 | 332 | |
333 | -function wpinv_settings_update_gateways( $input ) { |
|
333 | +function wpinv_settings_update_gateways($input) { |
|
334 | 334 | global $wpinv_options; |
335 | 335 | |
336 | - if ( !empty( $input['save_gateway'] ) ) { |
|
337 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
336 | + if (!empty($input['save_gateway'])) { |
|
337 | + $gateways = wpinv_get_option('gateways', false); |
|
338 | 338 | $gateways = !empty($gateways) ? $gateways : array(); |
339 | 339 | $gateway = $input['save_gateway']; |
340 | 340 | |
341 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
341 | + if (!empty($input[$gateway . '_active'])) { |
|
342 | 342 | $gateways[$gateway] = 1; |
343 | 343 | } else { |
344 | - if ( isset( $gateways[$gateway] ) ) { |
|
345 | - unset( $gateways[$gateway] ); |
|
344 | + if (isset($gateways[$gateway])) { |
|
345 | + unset($gateways[$gateway]); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | 349 | $input['gateways'] = $gateways; |
350 | 350 | } |
351 | 351 | |
352 | - if ( !empty( $input['default_gateway'] ) ) { |
|
352 | + if (!empty($input['default_gateway'])) { |
|
353 | 353 | $gateways = wpinv_get_payment_gateways(); |
354 | 354 | |
355 | - foreach ( $gateways as $key => $gateway ) { |
|
356 | - $active = 0; |
|
357 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
355 | + foreach ($gateways as $key => $gateway) { |
|
356 | + $active = 0; |
|
357 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
358 | 358 | $active = 1; |
359 | 359 | } |
360 | 360 | |
361 | 361 | $input[$key . '_active'] = $active; |
362 | 362 | |
363 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
363 | + if (empty($wpinv_options[$key . '_title'])) { |
|
364 | 364 | $input[$key . '_title'] = $gateway['checkout_label']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
367 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
368 | 368 | $input[$key . '_ordering'] = $gateway['ordering']; |
369 | 369 | } |
370 | 370 | } |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | |
373 | 373 | return $input; |
374 | 374 | } |
375 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
375 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
376 | 376 | |
377 | 377 | // PayPal Standard settings |
378 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
379 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
380 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
378 | +function wpinv_gateway_settings_paypal($setting) { |
|
379 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
380 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
381 | 381 | |
382 | 382 | $setting['paypal_sandbox'] = array( |
383 | 383 | 'type' => 'checkbox', |
384 | 384 | 'id' => 'paypal_sandbox', |
385 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
386 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
385 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
386 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
387 | 387 | 'std' => 1 |
388 | 388 | ); |
389 | 389 | |
390 | 390 | $setting['paypal_email'] = array( |
391 | 391 | 'type' => 'text', |
392 | 392 | 'id' => 'paypal_email', |
393 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
394 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
395 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
393 | + 'name' => __('PayPal Email', 'invoicing'), |
|
394 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
395 | + 'std' => __('[email protected]', 'invoicing'), |
|
396 | 396 | ); |
397 | 397 | /* |
398 | 398 | $setting['paypal_ipn_url'] = array( |
@@ -406,18 +406,18 @@ discard block |
||
406 | 406 | |
407 | 407 | return $setting; |
408 | 408 | } |
409 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
409 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
410 | 410 | |
411 | 411 | /** |
412 | 412 | * Displays the ipn url field. |
413 | 413 | */ |
414 | -function wpinv_ipn_url_callback( $args ) { |
|
415 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
414 | +function wpinv_ipn_url_callback($args) { |
|
415 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
416 | 416 | |
417 | 417 | $attrs = $args['readonly'] ? ' readonly' : ''; |
418 | 418 | |
419 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
420 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
419 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
420 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
421 | 421 | |
422 | 422 | echo $html; |
423 | 423 | } |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @return bool |
431 | 431 | */ |
432 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
433 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false ); |
|
434 | - return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway ); |
|
432 | +function wpinv_is_test_mode($gateway = '') { |
|
433 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false); |
|
434 | + return apply_filters('wpinv_is_test_mode', $sandbox, $gateway); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return string |
444 | 444 | */ |
445 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
445 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
446 | 446 | $args = wp_parse_args( |
447 | 447 | array( |
448 | 448 | 'wpi-listener' => 'IPN', |
@@ -451,24 +451,24 @@ discard block |
||
451 | 451 | $args |
452 | 452 | ); |
453 | 453 | |
454 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
454 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
455 | 455 | |
456 | 456 | } |
457 | 457 | |
458 | -function wpinv_get_post_data( $method = 'request' ) { |
|
458 | +function wpinv_get_post_data($method = 'request') { |
|
459 | 459 | $data = array(); |
460 | 460 | $request = $_REQUEST; |
461 | 461 | |
462 | - if ( $method == 'post' ) { |
|
463 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
462 | + if ($method == 'post') { |
|
463 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
464 | 464 | return $data; |
465 | 465 | } |
466 | 466 | |
467 | 467 | $request = $_POST; |
468 | 468 | } |
469 | 469 | |
470 | - if ( $method == 'get' ) { |
|
471 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) { |
|
470 | + if ($method == 'get') { |
|
471 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') { |
|
472 | 472 | return $data; |
473 | 473 | } |
474 | 474 | |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | $post_data = ''; |
480 | 480 | |
481 | 481 | // Fallback just in case post_max_size is lower than needed |
482 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
483 | - $post_data = file_get_contents( 'php://input' ); |
|
482 | + if (ini_get('allow_url_fopen')) { |
|
483 | + $post_data = file_get_contents('php://input'); |
|
484 | 484 | } else { |
485 | 485 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
486 | - ini_set( 'post_max_size', '12M' ); |
|
486 | + ini_set('post_max_size', '12M'); |
|
487 | 487 | } |
488 | 488 | // Start the encoded data collection with notification command |
489 | 489 | $encoded_data = 'cmd=_notify-validate'; |
@@ -492,33 +492,33 @@ discard block |
||
492 | 492 | $arg_separator = wpinv_get_php_arg_separator_output(); |
493 | 493 | |
494 | 494 | // Verify there is a post_data |
495 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
495 | + if ($post_data || strlen($post_data) > 0) { |
|
496 | 496 | // Append the data |
497 | 497 | $encoded_data .= $arg_separator . $post_data; |
498 | 498 | } else { |
499 | 499 | // Check if POST is empty |
500 | - if ( empty( $request ) ) { |
|
500 | + if (empty($request)) { |
|
501 | 501 | // Nothing to do |
502 | 502 | return; |
503 | 503 | } else { |
504 | 504 | // Loop through each POST |
505 | - foreach ( $request as $key => $value ) { |
|
505 | + foreach ($request as $key => $value) { |
|
506 | 506 | // Encode the value and append the data |
507 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
507 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | 512 | // Convert collected post data to an array |
513 | - wp_parse_str( $encoded_data, $data ); |
|
513 | + wp_parse_str($encoded_data, $data); |
|
514 | 514 | |
515 | - foreach ( $data as $key => $value ) { |
|
516 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
517 | - $new_key = str_replace( '&', '&', $key ); |
|
518 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
515 | + foreach ($data as $key => $value) { |
|
516 | + if (false !== strpos($key, 'amp;')) { |
|
517 | + $new_key = str_replace('&', '&', $key); |
|
518 | + $new_key = str_replace('amp;', '&', $new_key); |
|
519 | 519 | |
520 | - unset( $data[ $key ] ); |
|
521 | - $data[ $new_key ] = sanitize_text_field( $value ); |
|
520 | + unset($data[$key]); |
|
521 | + $data[$new_key] = sanitize_text_field($value); |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -528,12 +528,12 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * Checks if a given gateway supports subscription payments. |
530 | 530 | */ |
531 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
531 | +function wpinv_gateway_support_subscription($gateway) { |
|
532 | 532 | $supports = false; |
533 | 533 | |
534 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
535 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
536 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway ); |
|
534 | + if (wpinv_is_gateway_active($gateway)) { |
|
535 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
536 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | return $supports; |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | * @param array $gateways an array of gateways. |
546 | 546 | * @param GetPaid_Payment_Form $form payment form. |
547 | 547 | */ |
548 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
548 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
549 | 549 | |
550 | - if ( $form->is_recurring() ) { |
|
550 | + if ($form->is_recurring()) { |
|
551 | 551 | |
552 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
552 | + foreach (array_keys($gateways) as $gateway) { |
|
553 | 553 | |
554 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
555 | - unset( $gateways[$gateway] ); |
|
554 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
555 | + unset($gateways[$gateway]); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | } |
@@ -561,24 +561,24 @@ discard block |
||
561 | 561 | |
562 | 562 | return $gateways; |
563 | 563 | } |
564 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
564 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
|
565 | 565 | |
566 | 566 | /** |
567 | 567 | * Validates checkout fields. |
568 | 568 | * |
569 | 569 | * @param GetPaid_Payment_Form_Submission $submission |
570 | 570 | */ |
571 | -function wpinv_checkout_validate_gateway( $submission ) { |
|
571 | +function wpinv_checkout_validate_gateway($submission) { |
|
572 | 572 | |
573 | 573 | $data = $submission->get_data(); |
574 | 574 | |
575 | 575 | // Non-recurring gateways should not be allowed to process recurring invoices. |
576 | - if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
577 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) ); |
|
576 | + if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
577 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment.', 'invoicing')); |
|
578 | 578 | } |
579 | 579 | |
580 | - if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
581 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
580 | + if (!wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
581 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing')); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | } |
@@ -586,84 +586,84 @@ discard block |
||
586 | 586 | /** |
587 | 587 | * Validates a zip code. |
588 | 588 | */ |
589 | -function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
589 | +function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') { |
|
590 | 590 | |
591 | - if ( empty( $zip ) || empty( $country_code ) ){ |
|
591 | + if (empty($zip) || empty($country_code)) { |
|
592 | 592 | return false; |
593 | 593 | } |
594 | 594 | |
595 | 595 | // Prepare the country code. |
596 | - $country_code = strtoupper( trim( $country_code ) ); |
|
596 | + $country_code = strtoupper(trim($country_code)); |
|
597 | 597 | |
598 | 598 | // Fetch the regexes. |
599 | - $zip_regex = wpinv_get_data( 'zip-regexes' ); |
|
599 | + $zip_regex = wpinv_get_data('zip-regexes'); |
|
600 | 600 | |
601 | 601 | // Check if it is valid. |
602 | - $is_valid = ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ); |
|
602 | + $is_valid = !isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip); |
|
603 | 603 | |
604 | - return apply_filters( 'wpinv_is_zip_valid', $is_valid, $zip, $country_code ); |
|
604 | + return apply_filters('wpinv_is_zip_valid', $is_valid, $zip, $country_code); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | function wpinv_checkout_validate_agree_to_terms() { |
608 | 608 | // Validate agree to terms |
609 | - if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) { |
|
609 | + if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) { |
|
610 | 610 | // User did not agree |
611 | - wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) ); |
|
611 | + wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing'))); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | function wpinv_checkout_validate_invoice_user() { |
616 | 616 | global $wpi_cart, $user_ID; |
617 | 617 | |
618 | - if(empty($wpi_cart)){ |
|
618 | + if (empty($wpi_cart)) { |
|
619 | 619 | $wpi_cart = wpinv_get_invoice_cart(); |
620 | 620 | } |
621 | 621 | |
622 | - $invoice_user = (int)$wpi_cart->get_user_id(); |
|
622 | + $invoice_user = (int) $wpi_cart->get_user_id(); |
|
623 | 623 | $valid_user_data = array( |
624 | 624 | 'user_id' => $invoice_user |
625 | 625 | ); |
626 | 626 | |
627 | 627 | // If guest checkout allowed |
628 | - if ( !wpinv_require_login_to_checkout() ) { |
|
628 | + if (!wpinv_require_login_to_checkout()) { |
|
629 | 629 | return $valid_user_data; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Verify there is a user_ID |
633 | - if ( $user_ID == $invoice_user ) { |
|
633 | + if ($user_ID == $invoice_user) { |
|
634 | 634 | // Get the logged in user data |
635 | - $user_data = get_userdata( $user_ID ); |
|
636 | - $required_fields = wpinv_checkout_required_fields(); |
|
635 | + $user_data = get_userdata($user_ID); |
|
636 | + $required_fields = wpinv_checkout_required_fields(); |
|
637 | 637 | |
638 | 638 | // Loop through required fields and show error messages |
639 | - if ( !empty( $required_fields ) ) { |
|
640 | - foreach ( $required_fields as $field_name => $value ) { |
|
641 | - if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
|
642 | - wpinv_set_error( $value['error_id'], $value['error_message'] ); |
|
639 | + if (!empty($required_fields)) { |
|
640 | + foreach ($required_fields as $field_name => $value) { |
|
641 | + if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) { |
|
642 | + wpinv_set_error($value['error_id'], $value['error_message']); |
|
643 | 643 | } |
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | 647 | // Verify data |
648 | - if ( $user_data ) { |
|
648 | + if ($user_data) { |
|
649 | 649 | // Collected logged in user data |
650 | 650 | $valid_user_data = array( |
651 | 651 | 'user_id' => $user_ID, |
652 | - 'email' => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email, |
|
653 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name, |
|
654 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name'] ) ? sanitize_text_field( $_POST['wpinv_last_name'] ) : $user_data->last_name, |
|
652 | + 'email' => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email, |
|
653 | + 'first_name' => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name, |
|
654 | + 'last_name' => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name, |
|
655 | 655 | ); |
656 | 656 | |
657 | - if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) { |
|
658 | - wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) ); |
|
657 | + if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) { |
|
658 | + wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing')); |
|
659 | 659 | } |
660 | 660 | } else { |
661 | 661 | // Set invalid user error |
662 | - wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) ); |
|
662 | + wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing')); |
|
663 | 663 | } |
664 | 664 | } else { |
665 | 665 | // Set invalid user error |
666 | - wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) ); |
|
666 | + wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing')); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | // Return user data |
@@ -675,18 +675,18 @@ discard block |
||
675 | 675 | |
676 | 676 | $data = array(); |
677 | 677 | |
678 | - if ( is_user_logged_in() ) { |
|
679 | - if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) { |
|
680 | - $data['user_id'] = (int)get_current_user_id(); |
|
678 | + if (is_user_logged_in()) { |
|
679 | + if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) { |
|
680 | + $data['user_id'] = (int) get_current_user_id(); |
|
681 | 681 | } else { |
682 | - wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) ); |
|
682 | + wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing')); |
|
683 | 683 | } |
684 | 684 | } else { |
685 | 685 | // If guest checkout allowed |
686 | - if ( !wpinv_require_login_to_checkout() ) { |
|
686 | + if (!wpinv_require_login_to_checkout()) { |
|
687 | 687 | $data['user_id'] = 0; |
688 | 688 | } else { |
689 | - wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) ); |
|
689 | + wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing')); |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
@@ -700,41 +700,41 @@ discard block |
||
700 | 700 | * @param WPInv_Invoice $invoice |
701 | 701 | * @param GetPaid_Payment_Form_Submission $submission |
702 | 702 | */ |
703 | -function wpinv_process_checkout( $invoice, $submission ) { |
|
703 | +function wpinv_process_checkout($invoice, $submission) { |
|
704 | 704 | |
705 | 705 | // No need to send free invoices to the gateway. |
706 | - if ( $invoice->is_free() ) { |
|
707 | - $invoice->set_gateway( 'none' ); |
|
708 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
706 | + if ($invoice->is_free()) { |
|
707 | + $invoice->set_gateway('none'); |
|
708 | + $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true); |
|
709 | 709 | $invoice->mark_paid(); |
710 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
710 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | // Clear an checkout errors. |
714 | 714 | wpinv_clear_errors(); |
715 | 715 | |
716 | 716 | // Fires before sending to the gateway. |
717 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
717 | + do_action('getpaid_checkout_before_gateway', $invoice, $submission); |
|
718 | 718 | |
719 | 719 | // Allow the sumission data to be modified before it is sent to the gateway. |
720 | 720 | $submission_data = $submission->get_data(); |
721 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice ); |
|
722 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
721 | + $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice); |
|
722 | + $submission_data = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice); |
|
723 | 723 | |
724 | 724 | // Validate the currency. |
725 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
726 | - wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) ); |
|
725 | + if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) { |
|
726 | + wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing')); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | // Check to see if we have any errors. |
730 | - if ( wpinv_get_errors() ) { |
|
730 | + if (wpinv_get_errors()) { |
|
731 | 731 | wpinv_send_back_to_checkout(); |
732 | 732 | } |
733 | 733 | |
734 | 734 | // Send info to the gateway for payment processing |
735 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
735 | + do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission); |
|
736 | 736 | |
737 | 737 | // Backwards compatibility. |
738 | - wpinv_send_to_gateway( $submission_gateway, $invoice->get_payment_meta() ); |
|
738 | + wpinv_send_to_gateway($submission_gateway, $invoice->get_payment_meta()); |
|
739 | 739 | |
740 | 740 | } |