@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | |
104 | 104 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
105 | 105 | if ( ! empty( $args ) && is_array( $args ) ) { |
106 | - extract( $args ); |
|
107 | - } |
|
106 | + extract( $args ); |
|
107 | + } |
|
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | - // Allow 3rd party plugin filter template file from their plugin. |
|
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
110 | + // Allow 3rd party plugin filter template file from their plugin. |
|
111 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
113 | + if ( ! file_exists( $located ) ) { |
|
114 | 114 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
115 | - return; |
|
116 | - } |
|
115 | + return; |
|
116 | + } |
|
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include( $located ); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
126 | - ob_start(); |
|
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | - return ob_get_clean(); |
|
126 | + ob_start(); |
|
127 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
128 | + return ob_get_clean(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -155,126 +155,126 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
158 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
159 | 159 | |
160 | - // Setup possible parts |
|
161 | - $templates = array(); |
|
162 | - if ( isset( $name ) ) |
|
163 | - $templates[] = $slug . '-' . $name . '.php'; |
|
164 | - $templates[] = $slug . '.php'; |
|
160 | + // Setup possible parts |
|
161 | + $templates = array(); |
|
162 | + if ( isset( $name ) ) |
|
163 | + $templates[] = $slug . '-' . $name . '.php'; |
|
164 | + $templates[] = $slug . '.php'; |
|
165 | 165 | |
166 | - // Allow template parts to be filtered |
|
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
166 | + // Allow template parts to be filtered |
|
167 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
168 | 168 | |
169 | - // Return the part that is found |
|
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
169 | + // Return the part that is found |
|
170 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
174 | - // No file found yet |
|
175 | - $located = false; |
|
174 | + // No file found yet |
|
175 | + $located = false; |
|
176 | 176 | |
177 | - // Try to find a template file |
|
178 | - foreach ( (array)$template_names as $template_name ) { |
|
177 | + // Try to find a template file |
|
178 | + foreach ( (array)$template_names as $template_name ) { |
|
179 | 179 | |
180 | - // Continue if template is empty |
|
181 | - if ( empty( $template_name ) ) |
|
182 | - continue; |
|
180 | + // Continue if template is empty |
|
181 | + if ( empty( $template_name ) ) |
|
182 | + continue; |
|
183 | 183 | |
184 | - // Trim off any slashes from the template name |
|
185 | - $template_name = ltrim( $template_name, '/' ); |
|
184 | + // Trim off any slashes from the template name |
|
185 | + $template_name = ltrim( $template_name, '/' ); |
|
186 | 186 | |
187 | - // try locating this template file by looping through the template paths |
|
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
187 | + // try locating this template file by looping through the template paths |
|
188 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
191 | - $located = $template_path . $template_name; |
|
192 | - break; |
|
193 | - } |
|
194 | - } |
|
190 | + if( file_exists( $template_path . $template_name ) ) { |
|
191 | + $located = $template_path . $template_name; |
|
192 | + break; |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
197 | - break; |
|
198 | - } |
|
199 | - } |
|
196 | + if( !empty( $located ) ) { |
|
197 | + break; |
|
198 | + } |
|
199 | + } |
|
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | + load_template( $located, $require_once ); |
|
203 | 203 | |
204 | - return $located; |
|
204 | + return $located; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function wpinv_get_theme_template_paths() { |
208 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
208 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
209 | 209 | |
210 | - $file_paths = array( |
|
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | - 100 => wpinv_get_templates_dir() |
|
214 | - ); |
|
210 | + $file_paths = array( |
|
211 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
213 | + 100 => wpinv_get_templates_dir() |
|
214 | + ); |
|
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
217 | 217 | |
218 | - // sort the file paths based on priority |
|
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
218 | + // sort the file paths based on priority |
|
219 | + ksort( $file_paths, SORT_NUMERIC ); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map( 'trailingslashit', $file_paths ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | - $pages = array(); |
|
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
230 | + $pages = array(); |
|
231 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
237 | - return; |
|
238 | - } |
|
236 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
237 | + return; |
|
238 | + } |
|
239 | 239 | |
240 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
240 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
241 | 241 | } |
242 | 242 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
243 | 243 | |
244 | 244 | function wpinv_add_body_classes( $class ) { |
245 | - $classes = (array)$class; |
|
245 | + $classes = (array)$class; |
|
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
248 | - $classes[] = 'wpinv-checkout'; |
|
249 | - $classes[] = 'wpinv-page'; |
|
250 | - } |
|
247 | + if( wpinv_is_checkout() ) { |
|
248 | + $classes[] = 'wpinv-checkout'; |
|
249 | + $classes[] = 'wpinv-page'; |
|
250 | + } |
|
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
253 | - $classes[] = 'wpinv-success'; |
|
254 | - $classes[] = 'wpinv-page'; |
|
255 | - } |
|
252 | + if( wpinv_is_success_page() ) { |
|
253 | + $classes[] = 'wpinv-success'; |
|
254 | + $classes[] = 'wpinv-page'; |
|
255 | + } |
|
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
258 | - $classes[] = 'wpinv-failed-transaction'; |
|
259 | - $classes[] = 'wpinv-page'; |
|
260 | - } |
|
257 | + if( wpinv_is_failed_transaction_page() ) { |
|
258 | + $classes[] = 'wpinv-failed-transaction'; |
|
259 | + $classes[] = 'wpinv-page'; |
|
260 | + } |
|
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
263 | - $classes[] = 'wpinv-history'; |
|
264 | - $classes[] = 'wpinv-page'; |
|
265 | - } |
|
262 | + if( wpinv_is_invoice_history_page() ) { |
|
263 | + $classes[] = 'wpinv-history'; |
|
264 | + $classes[] = 'wpinv-page'; |
|
265 | + } |
|
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
268 | - $classes[] = 'wpinv-subscription'; |
|
269 | - $classes[] = 'wpinv-page'; |
|
270 | - } |
|
267 | + if( wpinv_is_subscriptions_history_page() ) { |
|
268 | + $classes[] = 'wpinv-subscription'; |
|
269 | + $classes[] = 'wpinv-page'; |
|
270 | + } |
|
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
273 | - $classes[] = 'wpinv-test-mode'; |
|
274 | - $classes[] = 'wpinv-page'; |
|
275 | - } |
|
272 | + if( wpinv_is_test_mode() ) { |
|
273 | + $classes[] = 'wpinv-test-mode'; |
|
274 | + $classes[] = 'wpinv-page'; |
|
275 | + } |
|
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique( $classes ); |
|
278 | 278 | } |
279 | 279 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
280 | 280 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1409 | 1409 | |
1410 | 1410 | function wpinv_empty_cart_message() { |
1411 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1411 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | * @return void |
1419 | 1419 | */ |
1420 | 1420 | function wpinv_empty_checkout_cart() { |
1421 | - echo wpinv_empty_cart_message(); |
|
1421 | + echo wpinv_empty_cart_message(); |
|
1422 | 1422 | } |
1423 | 1423 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1424 | 1424 |
@@ -7,91 +7,91 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
26 | - if ( empty( $invoice ) ) { |
|
25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
26 | + if (empty($invoice)) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | ?> |
30 | 30 | <div class="row wpinv-top-bar no-print"> |
31 | 31 | <div class="container"> |
32 | 32 | <div class="col-xs-6"> |
33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
34 | 34 | </div> |
35 | 35 | <div class="col-xs-6 text-right"> |
36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | <?php |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
44 | - if ( empty( $invoice ) ) { |
|
43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
44 | + if (empty($invoice)) { |
|
45 | 45 | return; // Exit if invoice is not set. |
46 | 46 | } |
47 | 47 | |
48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
49 | - if ( $invoice->needs_payment() ) { |
|
50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
49 | + if ($invoice->needs_payment()) { |
|
50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
54 | 54 | } |
55 | 55 | |
56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
57 | - if ( empty( $invoice ) ) { |
|
56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
57 | + if (empty($invoice)) { |
|
58 | 58 | return; // Exit if invoice is not set. |
59 | 59 | } |
60 | 60 | |
61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
62 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
63 | - <?php if ( is_user_logged_in() ) { ?> |
|
64 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
62 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
63 | + <?php if (is_user_logged_in()) { ?> |
|
64 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
65 | 65 | <?php } |
66 | 66 | } |
67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_before_invoice_content( $content ) { |
|
70 | +function wpinv_before_invoice_content($content) { |
|
71 | 71 | global $post; |
72 | 72 | |
73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
74 | 74 | ob_start(); |
75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
76 | 76 | $content = ob_get_clean() . $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | return $content; |
80 | 80 | } |
81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
82 | 82 | |
83 | -function wpinv_after_invoice_content( $content ) { |
|
83 | +function wpinv_after_invoice_content($content) { |
|
84 | 84 | global $post; |
85 | 85 | |
86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
87 | 87 | ob_start(); |
88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
89 | 89 | $content .= ob_get_clean(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $content; |
93 | 93 | } |
94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
95 | 95 | |
96 | 96 | function wpinv_get_templates_dir() { |
97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
102 | 102 | } |
103 | 103 | |
104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
106 | - extract( $args ); |
|
104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
105 | + if (!empty($args) && is_array($args)) { |
|
106 | + extract($args); |
|
107 | 107 | } |
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
113 | + if (!file_exists($located)) { |
|
114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include($located); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
123 | 123 | } |
124 | 124 | |
125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
126 | 126 | ob_start(); |
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
128 | 128 | return ob_get_clean(); |
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
132 | - if ( ! $template_path ) { |
|
131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
132 | + if (!$template_path) { |
|
133 | 133 | $template_path = wpinv_template_path(); |
134 | 134 | } |
135 | 135 | |
136 | - if ( ! $default_path ) { |
|
136 | + if (!$default_path) { |
|
137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Look within passed path within the theme - this is priority. |
141 | 141 | $template = locate_template( |
142 | 142 | array( |
143 | - trailingslashit( $template_path ) . $template_name, |
|
143 | + trailingslashit($template_path) . $template_name, |
|
144 | 144 | $template_name |
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Get default templates/ |
149 | - if ( !$template && $default_path ) { |
|
150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
149 | + if (!$template && $default_path) { |
|
150 | + $template = trailingslashit($default_path) . $template_name; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Return what we found. |
154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
162 | + if (isset($name)) |
|
163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
164 | 164 | $templates[] = $slug . '.php'; |
165 | 165 | |
166 | 166 | // Allow template parts to be filtered |
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
168 | 168 | |
169 | 169 | // Return the part that is found |
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
171 | 171 | } |
172 | 172 | |
173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
174 | 174 | // No file found yet |
175 | 175 | $located = false; |
176 | 176 | |
177 | 177 | // Try to find a template file |
178 | - foreach ( (array)$template_names as $template_name ) { |
|
178 | + foreach ((array)$template_names as $template_name) { |
|
179 | 179 | |
180 | 180 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
181 | + if (empty($template_name)) |
|
182 | 182 | continue; |
183 | 183 | |
184 | 184 | // Trim off any slashes from the template name |
185 | - $template_name = ltrim( $template_name, '/' ); |
|
185 | + $template_name = ltrim($template_name, '/'); |
|
186 | 186 | |
187 | 187 | // try locating this template file by looping through the template paths |
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
190 | + if (file_exists($template_path . $template_name)) { |
|
191 | 191 | $located = $template_path . $template_name; |
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
196 | + if (!empty($located)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ((true == $load) && !empty($located)) |
|
202 | + load_template($located, $require_once); |
|
203 | 203 | |
204 | 204 | return $located; |
205 | 205 | } |
@@ -208,149 +208,149 @@ discard block |
||
208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
209 | 209 | |
210 | 210 | $file_paths = array( |
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
213 | 213 | 100 => wpinv_get_templates_dir() |
214 | 214 | ); |
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
217 | 217 | |
218 | 218 | // sort the file paths based on priority |
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
219 | + ksort($file_paths, SORT_NUMERIC); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map('trailingslashit', $file_paths); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | 230 | $pages = array(); |
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
231 | + $pages[] = wpinv_get_option('success_page'); |
|
232 | + $pages[] = wpinv_get_option('failure_page'); |
|
233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
241 | 241 | } |
242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
243 | 243 | |
244 | -function wpinv_add_body_classes( $class ) { |
|
244 | +function wpinv_add_body_classes($class) { |
|
245 | 245 | $classes = (array)$class; |
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
247 | + if (wpinv_is_checkout()) { |
|
248 | 248 | $classes[] = 'wpinv-checkout'; |
249 | 249 | $classes[] = 'wpinv-page'; |
250 | 250 | } |
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
252 | + if (wpinv_is_success_page()) { |
|
253 | 253 | $classes[] = 'wpinv-success'; |
254 | 254 | $classes[] = 'wpinv-page'; |
255 | 255 | } |
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
257 | + if (wpinv_is_failed_transaction_page()) { |
|
258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
259 | 259 | $classes[] = 'wpinv-page'; |
260 | 260 | } |
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
262 | + if (wpinv_is_invoice_history_page()) { |
|
263 | 263 | $classes[] = 'wpinv-history'; |
264 | 264 | $classes[] = 'wpinv-page'; |
265 | 265 | } |
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
267 | + if (wpinv_is_subscriptions_history_page()) { |
|
268 | 268 | $classes[] = 'wpinv-subscription'; |
269 | 269 | $classes[] = 'wpinv-page'; |
270 | 270 | } |
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
272 | + if (wpinv_is_test_mode()) { |
|
273 | 273 | $classes[] = 'wpinv-test-mode'; |
274 | 274 | $classes[] = 'wpinv-page'; |
275 | 275 | } |
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique($classes); |
|
278 | 278 | } |
279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
280 | 280 | |
281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
282 | - $args = array( 'nopaging' => true ); |
|
281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
282 | + $args = array('nopaging' => true); |
|
283 | 283 | |
284 | - if ( ! empty( $status ) ) |
|
284 | + if (!empty($status)) |
|
285 | 285 | $args['post_status'] = $status; |
286 | 286 | |
287 | - $discounts = wpinv_get_discounts( $args ); |
|
287 | + $discounts = wpinv_get_discounts($args); |
|
288 | 288 | $options = array(); |
289 | 289 | |
290 | - if ( $discounts ) { |
|
291 | - foreach ( $discounts as $discount ) { |
|
292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
290 | + if ($discounts) { |
|
291 | + foreach ($discounts as $discount) { |
|
292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
293 | 293 | } |
294 | 294 | } else { |
295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
296 | 296 | } |
297 | 297 | |
298 | - $output = wpinv_html_select( array( |
|
298 | + $output = wpinv_html_select(array( |
|
299 | 299 | 'name' => $name, |
300 | 300 | 'selected' => $selected, |
301 | 301 | 'options' => $options, |
302 | 302 | 'show_option_all' => false, |
303 | 303 | 'show_option_none' => false, |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | |
306 | 306 | return $output; |
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
310 | - $current = date( 'Y' ); |
|
311 | - $start_year = $current - absint( $years_before ); |
|
312 | - $end_year = $current + absint( $years_after ); |
|
313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
310 | + $current = date('Y'); |
|
311 | + $start_year = $current - absint($years_before); |
|
312 | + $end_year = $current + absint($years_after); |
|
313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
314 | 314 | $options = array(); |
315 | 315 | |
316 | - while ( $start_year <= $end_year ) { |
|
317 | - $options[ absint( $start_year ) ] = $start_year; |
|
316 | + while ($start_year <= $end_year) { |
|
317 | + $options[absint($start_year)] = $start_year; |
|
318 | 318 | $start_year++; |
319 | 319 | } |
320 | 320 | |
321 | - $output = wpinv_html_select( array( |
|
321 | + $output = wpinv_html_select(array( |
|
322 | 322 | 'name' => $name, |
323 | 323 | 'selected' => $selected, |
324 | 324 | 'options' => $options, |
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | 329 | return $output; |
330 | 330 | } |
331 | 331 | |
332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
333 | 333 | $month = 1; |
334 | 334 | $options = array(); |
335 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
335 | + $selected = empty($selected) ? date('n') : $selected; |
|
336 | 336 | |
337 | - while ( $month <= 12 ) { |
|
338 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
337 | + while ($month <= 12) { |
|
338 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
339 | 339 | $month++; |
340 | 340 | } |
341 | 341 | |
342 | - $output = wpinv_html_select( array( |
|
342 | + $output = wpinv_html_select(array( |
|
343 | 343 | 'name' => $name, |
344 | 344 | 'selected' => $selected, |
345 | 345 | 'options' => $options, |
346 | 346 | 'show_option_all' => false, |
347 | 347 | 'show_option_none' => false |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | |
350 | 350 | return $output; |
351 | 351 | } |
352 | 352 | |
353 | -function wpinv_html_select( $args = array() ) { |
|
353 | +function wpinv_html_select($args = array()) { |
|
354 | 354 | $defaults = array( |
355 | 355 | 'options' => array(), |
356 | 356 | 'name' => null, |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | 'selected' => 0, |
360 | 360 | 'placeholder' => null, |
361 | 361 | 'multiple' => false, |
362 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
363 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
362 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
363 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
364 | 364 | 'data' => array(), |
365 | 365 | 'onchange' => null, |
366 | 366 | 'required' => false, |
@@ -368,74 +368,74 @@ discard block |
||
368 | 368 | 'readonly' => false, |
369 | 369 | ); |
370 | 370 | |
371 | - $args = wp_parse_args( $args, $defaults ); |
|
371 | + $args = wp_parse_args($args, $defaults); |
|
372 | 372 | |
373 | 373 | $data_elements = ''; |
374 | - foreach ( $args['data'] as $key => $value ) { |
|
375 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
374 | + foreach ($args['data'] as $key => $value) { |
|
375 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
376 | 376 | } |
377 | 377 | |
378 | - if( $args['multiple'] ) { |
|
378 | + if ($args['multiple']) { |
|
379 | 379 | $multiple = ' MULTIPLE'; |
380 | 380 | } else { |
381 | 381 | $multiple = ''; |
382 | 382 | } |
383 | 383 | |
384 | - if( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | $options = ''; |
391 | - if( !empty( $args['onchange'] ) ) { |
|
392 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
391 | + if (!empty($args['onchange'])) { |
|
392 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
393 | 393 | } |
394 | 394 | |
395 | - if( !empty( $args['required'] ) ) { |
|
395 | + if (!empty($args['required'])) { |
|
396 | 396 | $options .= ' required="required"'; |
397 | 397 | } |
398 | 398 | |
399 | - if( !empty( $args['disabled'] ) ) { |
|
399 | + if (!empty($args['disabled'])) { |
|
400 | 400 | $options .= ' disabled'; |
401 | 401 | } |
402 | 402 | |
403 | - if( !empty( $args['readonly'] ) ) { |
|
403 | + if (!empty($args['readonly'])) { |
|
404 | 404 | $options .= ' readonly'; |
405 | 405 | } |
406 | 406 | |
407 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
408 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
407 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
408 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
409 | 409 | |
410 | - if ( $args['show_option_all'] ) { |
|
411 | - if( $args['multiple'] ) { |
|
412 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
410 | + if ($args['show_option_all']) { |
|
411 | + if ($args['multiple']) { |
|
412 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
413 | 413 | } else { |
414 | - $selected = selected( $args['selected'], 0, false ); |
|
414 | + $selected = selected($args['selected'], 0, false); |
|
415 | 415 | } |
416 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
416 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( !empty( $args['options'] ) ) { |
|
419 | + if (!empty($args['options'])) { |
|
420 | 420 | |
421 | - if ( $args['show_option_none'] ) { |
|
422 | - if( $args['multiple'] ) { |
|
423 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
421 | + if ($args['show_option_none']) { |
|
422 | + if ($args['multiple']) { |
|
423 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
424 | 424 | } else { |
425 | - $selected = selected( $args['selected'] === "", true, false ); |
|
425 | + $selected = selected($args['selected'] === "", true, false); |
|
426 | 426 | } |
427 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
427 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
428 | 428 | } |
429 | 429 | |
430 | - foreach( $args['options'] as $key => $option ) { |
|
430 | + foreach ($args['options'] as $key => $option) { |
|
431 | 431 | |
432 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
433 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
432 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
433 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
434 | 434 | } else { |
435 | - $selected = selected( $args['selected'], $key, false ); |
|
435 | + $selected = selected($args['selected'], $key, false); |
|
436 | 436 | } |
437 | 437 | |
438 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
438 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | return $output; |
445 | 445 | } |
446 | 446 | |
447 | -function wpinv_item_dropdown( $args = array() ) { |
|
447 | +function wpinv_item_dropdown($args = array()) { |
|
448 | 448 | $defaults = array( |
449 | 449 | 'name' => 'wpi_item', |
450 | 450 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | 'multiple' => false, |
453 | 453 | 'selected' => 0, |
454 | 454 | 'number' => 100, |
455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
456 | - 'data' => array( 'search-type' => 'item' ), |
|
455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
456 | + 'data' => array('search-type' => 'item'), |
|
457 | 457 | 'show_option_all' => false, |
458 | 458 | 'show_option_none' => false, |
459 | 459 | 'show_recurring' => false, |
460 | 460 | ); |
461 | 461 | |
462 | - $args = wp_parse_args( $args, $defaults ); |
|
462 | + $args = wp_parse_args($args, $defaults); |
|
463 | 463 | |
464 | 464 | $item_args = array( |
465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
468 | 468 | 'posts_per_page' => $args['number'] |
469 | 469 | ); |
470 | 470 | |
471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
472 | 472 | |
473 | - $items = get_posts( $item_args ); |
|
473 | + $items = get_posts($item_args); |
|
474 | 474 | $options = array(); |
475 | - if ( $items ) { |
|
476 | - foreach ( $items as $item ) { |
|
477 | - $title = esc_html( $item->post_title ); |
|
475 | + if ($items) { |
|
476 | + foreach ($items as $item) { |
|
477 | + $title = esc_html($item->post_title); |
|
478 | 478 | |
479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
479 | + if (!empty($args['show_recurring'])) { |
|
480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
481 | 481 | } |
482 | 482 | |
483 | - $options[ absint( $item->ID ) ] = $title; |
|
483 | + $options[absint($item->ID)] = $title; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | // This ensures that any selected items are included in the drop down |
488 | - if( is_array( $args['selected'] ) ) { |
|
489 | - foreach( $args['selected'] as $item ) { |
|
490 | - if( ! in_array( $item, $options ) ) { |
|
491 | - $title = get_the_title( $item ); |
|
492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
488 | + if (is_array($args['selected'])) { |
|
489 | + foreach ($args['selected'] as $item) { |
|
490 | + if (!in_array($item, $options)) { |
|
491 | + $title = get_the_title($item); |
|
492 | + if (!empty($args['show_recurring'])) { |
|
493 | + $title .= wpinv_get_item_suffix($item, false); |
|
494 | 494 | } |
495 | 495 | $options[$item] = $title; |
496 | 496 | } |
497 | 497 | } |
498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
500 | - $title = get_the_title( $args['selected'] ); |
|
501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
499 | + if (!in_array($args['selected'], $options)) { |
|
500 | + $title = get_the_title($args['selected']); |
|
501 | + if (!empty($args['show_recurring'])) { |
|
502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
503 | 503 | } |
504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $output = wpinv_html_select( array( |
|
508 | + $output = wpinv_html_select(array( |
|
509 | 509 | 'name' => $args['name'], |
510 | 510 | 'selected' => $args['selected'], |
511 | 511 | 'id' => $args['id'], |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | 'show_option_all' => $args['show_option_all'], |
517 | 517 | 'show_option_none' => $args['show_option_none'], |
518 | 518 | 'data' => $args['data'], |
519 | - ) ); |
|
519 | + )); |
|
520 | 520 | |
521 | 521 | return $output; |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_html_checkbox( $args = array() ) { |
|
524 | +function wpinv_html_checkbox($args = array()) { |
|
525 | 525 | $defaults = array( |
526 | 526 | 'name' => null, |
527 | 527 | 'current' => null, |
@@ -532,38 +532,38 @@ discard block |
||
532 | 532 | ) |
533 | 533 | ); |
534 | 534 | |
535 | - $args = wp_parse_args( $args, $defaults ); |
|
535 | + $args = wp_parse_args($args, $defaults); |
|
536 | 536 | |
537 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
537 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
538 | 538 | $options = ''; |
539 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
539 | + if (!empty($args['options']['disabled'])) { |
|
540 | 540 | $options .= ' disabled="disabled"'; |
541 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
541 | + } elseif (!empty($args['options']['readonly'])) { |
|
542 | 542 | $options .= ' readonly'; |
543 | 543 | } |
544 | 544 | |
545 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
545 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
549 | 549 | |
550 | -function wpinv_html_text( $args = array() ) { |
|
550 | +function wpinv_html_text($args = array()) { |
|
551 | 551 | // Backwards compatibility |
552 | - if ( func_num_args() > 1 ) { |
|
552 | + if (func_num_args() > 1) { |
|
553 | 553 | $args = func_get_args(); |
554 | 554 | |
555 | 555 | $name = $args[0]; |
556 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
557 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
558 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
556 | + $value = isset($args[1]) ? $args[1] : ''; |
|
557 | + $label = isset($args[2]) ? $args[2] : ''; |
|
558 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | $defaults = array( |
562 | 562 | 'id' => '', |
563 | - 'name' => isset( $name ) ? $name : 'text', |
|
564 | - 'value' => isset( $value ) ? $value : null, |
|
565 | - 'label' => isset( $label ) ? $label : null, |
|
566 | - 'desc' => isset( $desc ) ? $desc : null, |
|
563 | + 'name' => isset($name) ? $name : 'text', |
|
564 | + 'value' => isset($value) ? $value : null, |
|
565 | + 'label' => isset($label) ? $label : null, |
|
566 | + 'desc' => isset($desc) ? $desc : null, |
|
567 | 567 | 'placeholder' => '', |
568 | 568 | 'class' => 'regular-text', |
569 | 569 | 'disabled' => false, |
@@ -573,51 +573,51 @@ discard block |
||
573 | 573 | 'data' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
578 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
579 | 579 | $options = ''; |
580 | - if( $args['required'] ) { |
|
580 | + if ($args['required']) { |
|
581 | 581 | $options .= ' required="required"'; |
582 | 582 | } |
583 | - if( $args['readonly'] ) { |
|
583 | + if ($args['readonly']) { |
|
584 | 584 | $options .= ' readonly'; |
585 | 585 | } |
586 | - if( $args['readonly'] ) { |
|
586 | + if ($args['readonly']) { |
|
587 | 587 | $options .= ' readonly'; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $data = ''; |
591 | - if ( !empty( $args['data'] ) ) { |
|
592 | - foreach ( $args['data'] as $key => $value ) { |
|
593 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
591 | + if (!empty($args['data'])) { |
|
592 | + foreach ($args['data'] as $key => $value) { |
|
593 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
598 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
599 | - if ( ! empty( $args['desc'] ) ) { |
|
600 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
597 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
598 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
599 | + if (!empty($args['desc'])) { |
|
600 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
601 | 601 | } |
602 | 602 | |
603 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
603 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
604 | 604 | |
605 | 605 | $output .= '</span>'; |
606 | 606 | |
607 | 607 | return $output; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_date_field( $args = array() ) { |
|
611 | - if( empty( $args['class'] ) ) { |
|
610 | +function wpinv_html_date_field($args = array()) { |
|
611 | + if (empty($args['class'])) { |
|
612 | 612 | $args['class'] = 'wpiDatepicker'; |
613 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
613 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
614 | 614 | $args['class'] .= ' wpiDatepicker'; |
615 | 615 | } |
616 | 616 | |
617 | - return wpinv_html_text( $args ); |
|
617 | + return wpinv_html_text($args); |
|
618 | 618 | } |
619 | 619 | |
620 | -function wpinv_html_textarea( $args = array() ) { |
|
620 | +function wpinv_html_textarea($args = array()) { |
|
621 | 621 | $defaults = array( |
622 | 622 | 'name' => 'textarea', |
623 | 623 | 'value' => null, |
@@ -627,31 +627,31 @@ discard block |
||
627 | 627 | 'disabled' => false |
628 | 628 | ); |
629 | 629 | |
630 | - $args = wp_parse_args( $args, $defaults ); |
|
630 | + $args = wp_parse_args($args, $defaults); |
|
631 | 631 | |
632 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
632 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
633 | 633 | $disabled = ''; |
634 | - if( $args['disabled'] ) { |
|
634 | + if ($args['disabled']) { |
|
635 | 635 | $disabled = ' disabled="disabled"'; |
636 | 636 | } |
637 | 637 | |
638 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
639 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
640 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
638 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
639 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
640 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
641 | 641 | |
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | $output .= '</span>'; |
646 | 646 | |
647 | 647 | return $output; |
648 | 648 | } |
649 | 649 | |
650 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
650 | +function wpinv_html_ajax_user_search($args = array()) { |
|
651 | 651 | $defaults = array( |
652 | 652 | 'name' => 'user_id', |
653 | 653 | 'value' => null, |
654 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
654 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
655 | 655 | 'label' => null, |
656 | 656 | 'desc' => null, |
657 | 657 | 'class' => '', |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | 'data' => false |
661 | 661 | ); |
662 | 662 | |
663 | - $args = wp_parse_args( $args, $defaults ); |
|
663 | + $args = wp_parse_args($args, $defaults); |
|
664 | 664 | |
665 | 665 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
666 | 666 | |
667 | 667 | $output = '<span class="wpinv_user_search_wrap">'; |
668 | - $output .= wpinv_html_text( $args ); |
|
669 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
668 | + $output .= wpinv_html_text($args); |
|
669 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
670 | 670 | $output .= '</span>'; |
671 | 671 | |
672 | 672 | return $output; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function wpinv_ip_geolocation() { |
676 | 676 | global $wpinv_euvat; |
677 | 677 | |
678 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
678 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
679 | 679 | $content = ''; |
680 | 680 | $iso = ''; |
681 | 681 | $country = ''; |
@@ -686,69 +686,69 @@ discard block |
||
686 | 686 | $credit = ''; |
687 | 687 | $address = ''; |
688 | 688 | |
689 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
689 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
690 | 690 | try { |
691 | 691 | $iso = $geoip2_city->country->isoCode; |
692 | 692 | $country = $geoip2_city->country->name; |
693 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
693 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
694 | 694 | $city = $geoip2_city->city->name; |
695 | 695 | $longitude = $geoip2_city->location->longitude; |
696 | 696 | $latitude = $geoip2_city->location->latitude; |
697 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
698 | - } catch( Exception $e ) { } |
|
697 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
698 | + } catch (Exception $e) { } |
|
699 | 699 | } |
700 | 700 | |
701 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
701 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
702 | 702 | try { |
703 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
703 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
704 | 704 | |
705 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
705 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
706 | 706 | $iso = $load_xml->geoplugin_countryCode; |
707 | 707 | $country = $load_xml->geoplugin_countryName; |
708 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
709 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
708 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
709 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
710 | 710 | $longitude = $load_xml->geoplugin_longitude; |
711 | 711 | $latitude = $load_xml->geoplugin_latitude; |
712 | 712 | $credit = $load_xml->geoplugin_credit; |
713 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
713 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
714 | 714 | } |
715 | - } catch( Exception $e ) { } |
|
715 | + } catch (Exception $e) { } |
|
716 | 716 | } |
717 | 717 | |
718 | - if ( $iso && $longitude && $latitude ) { |
|
719 | - if ( $city ) { |
|
718 | + if ($iso && $longitude && $latitude) { |
|
719 | + if ($city) { |
|
720 | 720 | $address .= $city . ', '; |
721 | 721 | } |
722 | 722 | |
723 | - if ( $region ) { |
|
723 | + if ($region) { |
|
724 | 724 | $address .= $region . ', '; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $address .= $country . ' (' . $iso . ')'; |
728 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
729 | - $content .= '<p>'. $credit . '</p>'; |
|
728 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
729 | + $content .= '<p>' . $credit . '</p>'; |
|
730 | 730 | } else { |
731 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
731 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
732 | 732 | } |
733 | 733 | ?> |
734 | 734 | <!DOCTYPE html> |
735 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
735 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
736 | 736 | <body> |
737 | - <?php if ( $latitude && $latitude ) { ?> |
|
737 | + <?php if ($latitude && $latitude) { ?> |
|
738 | 738 | <div id="map"></div> |
739 | 739 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
740 | 740 | <script type="text/javascript"> |
741 | 741 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
742 | 742 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
743 | 743 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
744 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
744 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
745 | 745 | |
746 | 746 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
747 | 747 | |
748 | 748 | var marker = new L.Marker(latlng); |
749 | 749 | map.addLayer(marker); |
750 | 750 | |
751 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
751 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
752 | 752 | </script> |
753 | 753 | <?php } ?> |
754 | 754 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | <?php |
757 | 757 | exit; |
758 | 758 | } |
759 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
760 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
759 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
760 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
761 | 761 | |
762 | 762 | // Set up the template for the invoice. |
763 | -function wpinv_template( $template ) { |
|
763 | +function wpinv_template($template) { |
|
764 | 764 | global $post, $wp_query; |
765 | 765 | |
766 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
767 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
768 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
766 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
767 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
768 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
769 | 769 | } else { |
770 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
770 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | function wpinv_get_business_address() { |
778 | 778 | $business_address = wpinv_store_address(); |
779 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
779 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
780 | 780 | |
781 | 781 | /* |
782 | 782 | $default_country = wpinv_get_default_country(); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | |
801 | 801 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
802 | 802 | |
803 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
803 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | function wpinv_display_from_address() { |
@@ -810,192 +810,192 @@ discard block |
||
810 | 810 | if (empty($from_name)) { |
811 | 811 | $from_name = wpinv_get_business_name(); |
812 | 812 | } |
813 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
813 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
814 | 814 | <div class="wrapper col-xs-10"> |
815 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
816 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
817 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
815 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
816 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
817 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
818 | 818 | <?php } ?> |
819 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
820 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
819 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
820 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
821 | 821 | <?php } ?> |
822 | 822 | </div> |
823 | 823 | <?php |
824 | 824 | } |
825 | 825 | |
826 | -function wpinv_watermark( $id = 0 ) { |
|
827 | - $output = wpinv_get_watermark( $id ); |
|
826 | +function wpinv_watermark($id = 0) { |
|
827 | + $output = wpinv_get_watermark($id); |
|
828 | 828 | |
829 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
829 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_get_watermark( $id ) { |
|
833 | - if ( !$id > 0 ) { |
|
832 | +function wpinv_get_watermark($id) { |
|
833 | + if (!$id > 0) { |
|
834 | 834 | return NULL; |
835 | 835 | } |
836 | - $invoice = wpinv_get_invoice( $id ); |
|
836 | + $invoice = wpinv_get_invoice($id); |
|
837 | 837 | |
838 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
839 | - if ( $invoice->is_paid() ) { |
|
840 | - return __( 'Paid', 'invoicing' ); |
|
838 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
839 | + if ($invoice->is_paid()) { |
|
840 | + return __('Paid', 'invoicing'); |
|
841 | 841 | } |
842 | - if ( $invoice->is_refunded() ) { |
|
843 | - return __( 'Refunded', 'invoicing' ); |
|
842 | + if ($invoice->is_refunded()) { |
|
843 | + return __('Refunded', 'invoicing'); |
|
844 | 844 | } |
845 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
846 | - return __( 'Cancelled', 'invoicing' ); |
|
845 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
846 | + return __('Cancelled', 'invoicing'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | 850 | return NULL; |
851 | 851 | } |
852 | 852 | |
853 | -function wpinv_display_invoice_details( $invoice ) { |
|
853 | +function wpinv_display_invoice_details($invoice) { |
|
854 | 854 | global $wpinv_euvat; |
855 | 855 | |
856 | 856 | $invoice_id = $invoice->ID; |
857 | 857 | $vat_name = $wpinv_euvat->get_vat_name(); |
858 | 858 | $use_taxes = wpinv_use_taxes(); |
859 | 859 | |
860 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
860 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
861 | 861 | ?> |
862 | 862 | <table class="table table-bordered table-sm"> |
863 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
863 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
864 | 864 | <tr class="wpi-row-number"> |
865 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
866 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
865 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
866 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
867 | 867 | </tr> |
868 | 868 | <?php } ?> |
869 | 869 | <tr class="wpi-row-status"> |
870 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
871 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
870 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
871 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
872 | 872 | </tr> |
873 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
873 | + <?php if ($invoice->is_renewal()) { ?> |
|
874 | 874 | <tr class="wpi-row-parent"> |
875 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
876 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
875 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
876 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
877 | 877 | </tr> |
878 | 878 | <?php } ?> |
879 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
879 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
880 | 880 | <tr class="wpi-row-gateway"> |
881 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
881 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
882 | 882 | <td><?php echo $gateway_name; ?></td> |
883 | 883 | </tr> |
884 | 884 | <?php } ?> |
885 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
885 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
886 | 886 | <tr class="wpi-row-date"> |
887 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
887 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
888 | 888 | <td><?php echo $invoice_date; ?></td> |
889 | 889 | </tr> |
890 | 890 | <?php } ?> |
891 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
891 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
892 | 892 | <tr class="wpi-row-date"> |
893 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
893 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
894 | 894 | <td><?php echo $due_date; ?></td> |
895 | 895 | </tr> |
896 | 896 | <?php } ?> |
897 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
898 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
897 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
898 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
899 | 899 | <tr class="wpi-row-ovatno"> |
900 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
900 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
901 | 901 | <td><?php echo $owner_vat_number; ?></td> |
902 | 902 | </tr> |
903 | 903 | <?php } ?> |
904 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
904 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
906 | 906 | <tr class="wpi-row-uvatno"> |
907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
908 | 908 | <td><?php echo $user_vat_number; ?></td> |
909 | 909 | </tr> |
910 | 910 | <?php } ?> |
911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
914 | 914 | </tr> |
915 | 915 | </table> |
916 | 916 | <?php |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
921 | 921 | |
922 | - if ( empty( $invoice ) ) { |
|
922 | + if (empty($invoice)) { |
|
923 | 923 | return NULL; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $billing_details = $invoice->get_user_info(); |
927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
929 | 929 | |
930 | 930 | ob_start(); |
931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
932 | 932 | $output .= ob_get_clean(); |
933 | 933 | |
934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
935 | - if ( $company = $billing_details['company'] ) { |
|
936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
935 | + if ($company = $billing_details['company']) { |
|
936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
937 | 937 | } |
938 | 938 | $address_row = ''; |
939 | - if ( $address = $billing_details['address'] ) { |
|
940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
939 | + if ($address = $billing_details['address']) { |
|
940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | $address_fields = array(); |
944 | - if ( !empty( $billing_details['city'] ) ) { |
|
944 | + if (!empty($billing_details['city'])) { |
|
945 | 945 | $address_fields[] = $billing_details['city']; |
946 | 946 | } |
947 | 947 | |
948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
949 | - if ( !empty( $billing_details['state'] ) ) { |
|
950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
949 | + if (!empty($billing_details['state'])) { |
|
950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
951 | 951 | } |
952 | 952 | |
953 | - if ( !empty( $billing_country ) ) { |
|
954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
953 | + if (!empty($billing_country)) { |
|
954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( !empty( $address_fields ) ) { |
|
958 | - $address_fields = implode( ", ", $address_fields ); |
|
957 | + if (!empty($address_fields)) { |
|
958 | + $address_fields = implode(", ", $address_fields); |
|
959 | 959 | |
960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
960 | + if (!empty($billing_details['zip'])) { |
|
961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
962 | 962 | } |
963 | 963 | |
964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
965 | 965 | } |
966 | 966 | |
967 | - if ( $address_row ) { |
|
967 | + if ($address_row) { |
|
968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
969 | 969 | } |
970 | 970 | |
971 | - if ( $phone = $invoice->get_phone() ) { |
|
972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
971 | + if ($phone = $invoice->get_phone()) { |
|
972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
973 | 973 | } |
974 | - if ( $email = $invoice->get_email() ) { |
|
975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
974 | + if ($email = $invoice->get_email()) { |
|
975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | ob_start(); |
979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
980 | 980 | $output .= ob_get_clean(); |
981 | 981 | |
982 | 982 | $output .= '</div>'; |
983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
984 | 984 | |
985 | 985 | echo $output; |
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
992 | 992 | $use_taxes = wpinv_use_taxes(); |
993 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
993 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
994 | 994 | $use_taxes = true; |
995 | 995 | } |
996 | 996 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
997 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
998 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
997 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
998 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
999 | 999 | |
1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
1001 | 1001 | $ajax_cart_details = $cart_details; |
@@ -1004,64 +1004,64 @@ discard block |
||
1004 | 1004 | <table class="table table-sm table-bordered table-responsive"> |
1005 | 1005 | <thead> |
1006 | 1006 | <tr> |
1007 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1008 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1007 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1008 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1009 | 1009 | <?php if ($quantities_enabled) { ?> |
1010 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1010 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1011 | 1011 | <?php } ?> |
1012 | 1012 | <?php if ($use_taxes && !$zero_tax) { ?> |
1013 | 1013 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1014 | 1014 | <?php } ?> |
1015 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1015 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1016 | 1016 | </tr> |
1017 | 1017 | </thead> |
1018 | 1018 | <tbody> |
1019 | 1019 | <?php |
1020 | - if ( !empty( $cart_details ) ) { |
|
1021 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1020 | + if (!empty($cart_details)) { |
|
1021 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1022 | 1022 | |
1023 | 1023 | $count = 0; |
1024 | 1024 | $cols = 3; |
1025 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1026 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1027 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1028 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1029 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1025 | + foreach ($cart_details as $key => $cart_item) { |
|
1026 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1027 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1028 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1029 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1030 | 1030 | |
1031 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1031 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1032 | 1032 | $summary = ''; |
1033 | 1033 | $cols = 3; |
1034 | - if ( !empty($item) ) { |
|
1034 | + if (!empty($item)) { |
|
1035 | 1035 | $item_name = $item->get_name(); |
1036 | 1036 | $summary = $item->get_summary(); |
1037 | 1037 | } |
1038 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1038 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1039 | 1039 | |
1040 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1040 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1041 | 1041 | |
1042 | 1042 | $item_tax = ''; |
1043 | 1043 | $tax_rate = ''; |
1044 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1045 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1046 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1047 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1044 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1045 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1046 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1047 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1048 | 1048 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | $line_item_tax = $item_tax . $tax_rate; |
1052 | 1052 | |
1053 | - if ( $line_item_tax === '' ) { |
|
1053 | + if ($line_item_tax === '') { |
|
1054 | 1054 | $line_item_tax = 0; // Zero tax |
1055 | 1055 | } |
1056 | 1056 | |
1057 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1058 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1059 | - if ( $summary !== '' ) { |
|
1060 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1057 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1058 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1059 | + if ($summary !== '') { |
|
1060 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1061 | 1061 | } |
1062 | 1062 | $line_item .= '</td>'; |
1063 | 1063 | |
1064 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1064 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1065 | 1065 | if ($quantities_enabled) { |
1066 | 1066 | $cols++; |
1067 | 1067 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1070,55 +1070,55 @@ discard block |
||
1070 | 1070 | $cols++; |
1071 | 1071 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1072 | 1072 | } |
1073 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1073 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1074 | 1074 | $line_item .= '</tr>'; |
1075 | 1075 | |
1076 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1076 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1077 | 1077 | |
1078 | 1078 | $count++; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1081 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1082 | 1082 | ?> |
1083 | 1083 | <tr class="row-sub-total row_odd"> |
1084 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1085 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1084 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1085 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1086 | 1086 | </tr> |
1087 | 1087 | <?php |
1088 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1088 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1089 | 1089 | |
1090 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1091 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1090 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1091 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1092 | 1092 | ?> |
1093 | 1093 | <tr class="row-discount"> |
1094 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1095 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1094 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1095 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1096 | 1096 | </tr> |
1097 | 1097 | <?php |
1098 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1098 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | - if ( $use_taxes ) { |
|
1102 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1101 | + if ($use_taxes) { |
|
1102 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1103 | 1103 | ?> |
1104 | 1104 | <tr class="row-tax"> |
1105 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1106 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1105 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1106 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1107 | 1107 | </tr> |
1108 | 1108 | <?php |
1109 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1109 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1112 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1113 | 1113 | ?> |
1114 | 1114 | <tr class="table-active row-total"> |
1115 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1116 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1115 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1116 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1117 | 1117 | </tr> |
1118 | 1118 | <?php |
1119 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1119 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1120 | 1120 | |
1121 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1121 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1122 | 1122 | } |
1123 | 1123 | ?> |
1124 | 1124 | </tbody> |
@@ -1127,35 +1127,35 @@ discard block |
||
1127 | 1127 | echo ob_get_clean(); |
1128 | 1128 | } |
1129 | 1129 | |
1130 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1130 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1131 | 1131 | $use_taxes = wpinv_use_taxes(); |
1132 | 1132 | |
1133 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1133 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1134 | 1134 | ?> |
1135 | 1135 | <table class="table table-sm table-bordered table-responsive"> |
1136 | 1136 | <tbody> |
1137 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1137 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1138 | 1138 | <tr class="row-sub-total"> |
1139 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1140 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1139 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1140 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1141 | 1141 | </tr> |
1142 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1143 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1142 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1143 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1144 | 1144 | <tr class="row-discount"> |
1145 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1146 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1145 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1146 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1147 | 1147 | </tr> |
1148 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1148 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1149 | 1149 | <?php } ?> |
1150 | - <?php if ( $use_taxes ) { ?> |
|
1150 | + <?php if ($use_taxes) { ?> |
|
1151 | 1151 | <tr class="row-tax"> |
1152 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1153 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1152 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1153 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1154 | 1154 | </tr> |
1155 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1155 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1156 | 1156 | <?php } ?> |
1157 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1158 | - <?php foreach ( $fees as $fee ) { ?> |
|
1157 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1158 | + <?php foreach ($fees as $fee) { ?> |
|
1159 | 1159 | <tr class="row-fee"> |
1160 | 1160 | <td class="rate"><?php echo $fee['label']; ?></td> |
1161 | 1161 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1163,73 +1163,73 @@ discard block |
||
1163 | 1163 | <?php } ?> |
1164 | 1164 | <?php } ?> |
1165 | 1165 | <tr class="table-active row-total"> |
1166 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1167 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1166 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1167 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1168 | 1168 | </tr> |
1169 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1169 | + <?php do_action('wpinv_after_totals'); ?> |
|
1170 | 1170 | </tbody> |
1171 | 1171 | |
1172 | 1172 | </table> |
1173 | 1173 | |
1174 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1174 | + <?php do_action('wpinv_after_totals_table'); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1178 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1177 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1178 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1179 | 1179 | |
1180 | 1180 | ob_start(); |
1181 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1182 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1181 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1182 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1183 | 1183 | ?> |
1184 | 1184 | <div class="wpi-payment-info"> |
1185 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1186 | - <?php if ( $gateway_title ) { ?> |
|
1187 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1185 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1186 | + <?php if ($gateway_title) { ?> |
|
1187 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1188 | 1188 | <?php } ?> |
1189 | 1189 | </div> |
1190 | 1190 | <?php |
1191 | 1191 | } |
1192 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1192 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1193 | 1193 | $outout = ob_get_clean(); |
1194 | 1194 | |
1195 | - if ( $echo ) { |
|
1195 | + if ($echo) { |
|
1196 | 1196 | echo $outout; |
1197 | 1197 | } else { |
1198 | 1198 | return $outout; |
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
1202 | -function wpinv_display_style( $invoice ) { |
|
1203 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1202 | +function wpinv_display_style($invoice) { |
|
1203 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1204 | 1204 | |
1205 | - wp_print_styles( 'open-sans' ); |
|
1206 | - wp_print_styles( 'wpinv-single-style' ); |
|
1205 | + wp_print_styles('open-sans'); |
|
1206 | + wp_print_styles('wpinv-single-style'); |
|
1207 | 1207 | } |
1208 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1209 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1208 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1209 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1210 | 1210 | |
1211 | 1211 | function wpinv_checkout_billing_details() { |
1212 | 1212 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1213 | 1213 | if (empty($invoice_id)) { |
1214 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1214 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1215 | 1215 | return null; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1218 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1219 | 1219 | if (empty($invoice)) { |
1220 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1220 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1221 | 1221 | return null; |
1222 | 1222 | } |
1223 | 1223 | $user_id = $invoice->get_user_id(); |
1224 | 1224 | $user_info = $invoice->get_user_info(); |
1225 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1225 | + $address_info = wpinv_get_user_address($user_id); |
|
1226 | 1226 | |
1227 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1227 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1228 | 1228 | $user_info['first_name'] = $user_info['first_name']; |
1229 | 1229 | $user_info['last_name'] = $user_info['last_name']; |
1230 | 1230 | } |
1231 | 1231 | |
1232 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1232 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1233 | 1233 | $user_info['country'] = $address_info['country']; |
1234 | 1234 | $user_info['state'] = $address_info['state']; |
1235 | 1235 | $user_info['city'] = $address_info['city']; |
@@ -1245,98 +1245,98 @@ discard block |
||
1245 | 1245 | 'address' |
1246 | 1246 | ); |
1247 | 1247 | |
1248 | - foreach ( $address_fields as $field ) { |
|
1249 | - if ( empty( $user_info[$field] ) ) { |
|
1248 | + foreach ($address_fields as $field) { |
|
1249 | + if (empty($user_info[$field])) { |
|
1250 | 1250 | $user_info[$field] = $address_info[$field]; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1254 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | function wpinv_admin_get_line_items($invoice = array()) { |
1258 | 1258 | $item_quantities = wpinv_item_quantities_enabled(); |
1259 | 1259 | $use_taxes = wpinv_use_taxes(); |
1260 | 1260 | |
1261 | - if ( empty( $invoice ) ) { |
|
1261 | + if (empty($invoice)) { |
|
1262 | 1262 | return NULL; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | $cart_items = $invoice->get_cart_details(); |
1266 | - if ( empty( $cart_items ) ) { |
|
1266 | + if (empty($cart_items)) { |
|
1267 | 1267 | return NULL; |
1268 | 1268 | } |
1269 | 1269 | ob_start(); |
1270 | 1270 | |
1271 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1271 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1272 | 1272 | |
1273 | 1273 | $count = 0; |
1274 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1274 | + foreach ($cart_items as $key => $cart_item) { |
|
1275 | 1275 | $item_id = $cart_item['id']; |
1276 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1276 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1277 | 1277 | |
1278 | 1278 | if (empty($wpi_item)) { |
1279 | 1279 | continue; |
1280 | 1280 | } |
1281 | 1281 | |
1282 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1283 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1284 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1282 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1283 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1284 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1285 | 1285 | $can_remove = true; |
1286 | 1286 | |
1287 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1287 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1288 | 1288 | |
1289 | 1289 | $item_tax = ''; |
1290 | 1290 | $tax_rate = ''; |
1291 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1292 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1293 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1294 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1291 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1292 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1293 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1294 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1295 | 1295 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1296 | 1296 | } |
1297 | 1297 | $line_item_tax = $item_tax . $tax_rate; |
1298 | 1298 | |
1299 | - if ( $line_item_tax === '' ) { |
|
1299 | + if ($line_item_tax === '') { |
|
1300 | 1300 | $line_item_tax = 0; // Zero tax |
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1303 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1304 | 1304 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1305 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1306 | - if ( $summary !== '' ) { |
|
1307 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1305 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1306 | + if ($summary !== '') { |
|
1307 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1308 | 1308 | } |
1309 | 1309 | $line_item .= '</td>'; |
1310 | 1310 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1311 | 1311 | |
1312 | - if ( $item_quantities ) { |
|
1313 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1312 | + if ($item_quantities) { |
|
1313 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1314 | 1314 | $can_remove = false; |
1315 | 1315 | } |
1316 | 1316 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1317 | 1317 | } else { |
1318 | - if ( count( $cart_items ) == 1 ) { |
|
1318 | + if (count($cart_items) == 1) { |
|
1319 | 1319 | $can_remove = false; |
1320 | 1320 | } |
1321 | 1321 | } |
1322 | 1322 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1323 | 1323 | |
1324 | - if ( $use_taxes ) { |
|
1324 | + if ($use_taxes) { |
|
1325 | 1325 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1326 | 1326 | } |
1327 | 1327 | $line_item .= '<td class="action">'; |
1328 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1328 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1329 | 1329 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1330 | 1330 | } |
1331 | 1331 | $line_item .= '</td>'; |
1332 | 1332 | $line_item .= '</tr>'; |
1333 | 1333 | |
1334 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1334 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1335 | 1335 | |
1336 | 1336 | $count++; |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1339 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1340 | 1340 | |
1341 | 1341 | return ob_get_clean(); |
1342 | 1342 | } |
@@ -1347,35 +1347,35 @@ discard block |
||
1347 | 1347 | // Set current invoice id. |
1348 | 1348 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1349 | 1349 | |
1350 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1350 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1351 | 1351 | |
1352 | 1352 | ob_start(); |
1353 | 1353 | echo '<div id="wpinv_checkout_wrap">'; |
1354 | 1354 | |
1355 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1355 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1356 | 1356 | ?> |
1357 | 1357 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1358 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1358 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1359 | 1359 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1360 | 1360 | <?php |
1361 | - do_action( 'wpinv_checkout_form_top' ); |
|
1362 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1363 | - do_action( 'wpinv_checkout_cart' ); |
|
1364 | - do_action( 'wpinv_payment_mode_select' ); |
|
1365 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1361 | + do_action('wpinv_checkout_form_top'); |
|
1362 | + do_action('wpinv_checkout_billing_info'); |
|
1363 | + do_action('wpinv_checkout_cart'); |
|
1364 | + do_action('wpinv_payment_mode_select'); |
|
1365 | + do_action('wpinv_checkout_form_bottom') |
|
1366 | 1366 | ?> |
1367 | 1367 | </form> |
1368 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1368 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1369 | 1369 | </div><!--end #wpinv_checkout_form_wrap--> |
1370 | 1370 | <?php |
1371 | 1371 | } else { |
1372 | - do_action( 'wpinv_cart_empty' ); |
|
1372 | + do_action('wpinv_cart_empty'); |
|
1373 | 1373 | } |
1374 | 1374 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1375 | 1375 | return ob_get_clean(); |
1376 | 1376 | } |
1377 | 1377 | |
1378 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1378 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1379 | 1379 | global $ajax_cart_details; |
1380 | 1380 | $ajax_cart_details = $cart_details; |
1381 | 1381 | /* |
@@ -1390,25 +1390,25 @@ discard block |
||
1390 | 1390 | } |
1391 | 1391 | */ |
1392 | 1392 | ob_start(); |
1393 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1393 | + do_action('wpinv_before_checkout_cart'); |
|
1394 | 1394 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1395 | 1395 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1396 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1396 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1397 | 1397 | echo '</div>'; |
1398 | 1398 | echo '</div>'; |
1399 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1399 | + do_action('wpinv_after_checkout_cart'); |
|
1400 | 1400 | $content = ob_get_clean(); |
1401 | 1401 | |
1402 | - if ( $echo ) { |
|
1402 | + if ($echo) { |
|
1403 | 1403 | echo $content; |
1404 | 1404 | } else { |
1405 | 1405 | return $content; |
1406 | 1406 | } |
1407 | 1407 | } |
1408 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1408 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1409 | 1409 | |
1410 | 1410 | function wpinv_empty_cart_message() { |
1411 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1411 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1420,91 +1420,91 @@ discard block |
||
1420 | 1420 | function wpinv_empty_checkout_cart() { |
1421 | 1421 | echo wpinv_empty_cart_message(); |
1422 | 1422 | } |
1423 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1423 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1424 | 1424 | |
1425 | 1425 | function wpinv_save_cart_button() { |
1426 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1426 | + if (wpinv_is_cart_saving_disabled()) |
|
1427 | 1427 | return; |
1428 | 1428 | ?> |
1429 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
1429 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
1430 | 1430 | <?php |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | function wpinv_update_cart_button() { |
1434 | - if ( !wpinv_item_quantities_enabled() ) |
|
1434 | + if (!wpinv_item_quantities_enabled()) |
|
1435 | 1435 | return; |
1436 | 1436 | ?> |
1437 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1437 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1438 | 1438 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1439 | 1439 | <?php |
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | function wpinv_checkout_cart_columns() { |
1443 | 1443 | $default = 3; |
1444 | - if ( wpinv_item_quantities_enabled() ) { |
|
1444 | + if (wpinv_item_quantities_enabled()) { |
|
1445 | 1445 | $default++; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - if ( wpinv_use_taxes() ) { |
|
1448 | + if (wpinv_use_taxes()) { |
|
1449 | 1449 | $default++; |
1450 | 1450 | } |
1451 | 1451 | |
1452 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1452 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | function wpinv_display_cart_messages() { |
1456 | 1456 | global $wpi_session; |
1457 | 1457 | |
1458 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1458 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1459 | 1459 | |
1460 | - if ( $messages ) { |
|
1461 | - foreach ( $messages as $message_id => $message ) { |
|
1460 | + if ($messages) { |
|
1461 | + foreach ($messages as $message_id => $message) { |
|
1462 | 1462 | // Try and detect what type of message this is |
1463 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1463 | + if (strpos(strtolower($message), 'error')) { |
|
1464 | 1464 | $type = 'error'; |
1465 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1465 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1466 | 1466 | $type = 'success'; |
1467 | 1467 | } else { |
1468 | 1468 | $type = 'info'; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1471 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1472 | 1472 | |
1473 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1473 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1474 | 1474 | // Loop message codes and display messages |
1475 | 1475 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1476 | 1476 | echo '</div>'; |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // Remove all of the cart saving messages |
1480 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1480 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1481 | 1481 | } |
1482 | 1482 | } |
1483 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1483 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1484 | 1484 | |
1485 | 1485 | function wpinv_discount_field() { |
1486 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1486 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1487 | 1487 | return; // Only show before a payment method has been selected if ajax is disabled |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - if ( !wpinv_is_checkout() ) { |
|
1490 | + if (!wpinv_is_checkout()) { |
|
1491 | 1491 | return; |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1494 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1495 | 1495 | ?> |
1496 | 1496 | <div id="wpinv-discount-field" class="panel panel-default"> |
1497 | 1497 | <div class="panel-body"> |
1498 | 1498 | <p> |
1499 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1500 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1499 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1500 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1501 | 1501 | </p> |
1502 | 1502 | <div class="form-group row"> |
1503 | 1503 | <div class="col-sm-4"> |
1504 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1504 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1505 | 1505 | </div> |
1506 | 1506 | <div class="col-sm-3"> |
1507 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1507 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1508 | 1508 | </div> |
1509 | 1509 | <div style="clear:both"></div> |
1510 | 1510 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1517,10 +1517,10 @@ discard block |
||
1517 | 1517 | <?php |
1518 | 1518 | } |
1519 | 1519 | } |
1520 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1520 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1521 | 1521 | |
1522 | 1522 | function wpinv_agree_to_terms_js() { |
1523 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1523 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1524 | 1524 | ?> |
1525 | 1525 | <script type="text/javascript"> |
1526 | 1526 | jQuery(document).ready(function($){ |
@@ -1535,126 +1535,126 @@ discard block |
||
1535 | 1535 | <?php |
1536 | 1536 | } |
1537 | 1537 | } |
1538 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1538 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1539 | 1539 | |
1540 | 1540 | function wpinv_payment_mode_select() { |
1541 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1542 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1541 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1542 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1543 | 1543 | $page_URL = wpinv_get_current_page_url(); |
1544 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1544 | + $invoice = wpinv_get_invoice(0, true); |
|
1545 | 1545 | |
1546 | 1546 | do_action('wpinv_payment_mode_top'); |
1547 | 1547 | $invoice_id = (int)$invoice->ID; |
1548 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1548 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1549 | 1549 | ?> |
1550 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1551 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1550 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1551 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1552 | 1552 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1553 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1553 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1554 | 1554 | <div class="panel-body list-group wpi-payment_methods"> |
1555 | 1555 | <?php |
1556 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1556 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1557 | 1557 | |
1558 | - if ( !empty( $gateways ) ) { |
|
1559 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1560 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1561 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1562 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1558 | + if (!empty($gateways)) { |
|
1559 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1560 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1561 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1562 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1563 | 1563 | ?> |
1564 | 1564 | <div class="list-group-item"> |
1565 | 1565 | <div class="radio"> |
1566 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1566 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1567 | 1567 | </div> |
1568 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1569 | - <?php if ( !empty( $description ) ) { ?> |
|
1570 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1568 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1569 | + <?php if (!empty($description)) { ?> |
|
1570 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1571 | 1571 | <?php } ?> |
1572 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1572 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1573 | 1573 | </div> |
1574 | 1574 | </div> |
1575 | 1575 | <?php |
1576 | 1576 | } |
1577 | 1577 | } else { |
1578 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1578 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1581 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1582 | 1582 | ?> |
1583 | 1583 | </div> |
1584 | 1584 | </div> |
1585 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1585 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1586 | 1586 | </div> |
1587 | 1587 | <?php |
1588 | 1588 | do_action('wpinv_payment_mode_bottom'); |
1589 | 1589 | } |
1590 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1590 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1591 | 1591 | |
1592 | 1592 | function wpinv_checkout_billing_info() { |
1593 | - if ( wpinv_is_checkout() ) { |
|
1593 | + if (wpinv_is_checkout()) { |
|
1594 | 1594 | $logged_in = is_user_logged_in(); |
1595 | 1595 | $billing_details = wpinv_checkout_billing_details(); |
1596 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1596 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1597 | 1597 | ?> |
1598 | 1598 | <div id="wpinv-fields" class="clearfix"> |
1599 | 1599 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1600 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1600 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1601 | 1601 | <div id="wpinv-fields-box" class="panel-body"> |
1602 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1602 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1603 | 1603 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1604 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1604 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1605 | 1605 | <?php |
1606 | - echo wpinv_html_text( array( |
|
1606 | + echo wpinv_html_text(array( |
|
1607 | 1607 | 'id' => 'wpinv_first_name', |
1608 | 1608 | 'name' => 'wpinv_first_name', |
1609 | 1609 | 'value' => $billing_details['first_name'], |
1610 | 1610 | 'class' => 'wpi-input form-control', |
1611 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1612 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1613 | - ) ); |
|
1611 | + 'placeholder' => __('First name', 'invoicing'), |
|
1612 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1613 | + )); |
|
1614 | 1614 | ?> |
1615 | 1615 | </p> |
1616 | 1616 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1617 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1617 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1618 | 1618 | <?php |
1619 | - echo wpinv_html_text( array( |
|
1619 | + echo wpinv_html_text(array( |
|
1620 | 1620 | 'id' => 'wpinv_last_name', |
1621 | 1621 | 'name' => 'wpinv_last_name', |
1622 | 1622 | 'value' => $billing_details['last_name'], |
1623 | 1623 | 'class' => 'wpi-input form-control', |
1624 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1625 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1626 | - ) ); |
|
1624 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1625 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1626 | + )); |
|
1627 | 1627 | ?> |
1628 | 1628 | </p> |
1629 | 1629 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1630 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1630 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1631 | 1631 | <?php |
1632 | - echo wpinv_html_text( array( |
|
1632 | + echo wpinv_html_text(array( |
|
1633 | 1633 | 'id' => 'wpinv_address', |
1634 | 1634 | 'name' => 'wpinv_address', |
1635 | 1635 | 'value' => $billing_details['address'], |
1636 | 1636 | 'class' => 'wpi-input form-control', |
1637 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1638 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1639 | - ) ); |
|
1637 | + 'placeholder' => __('Address', 'invoicing'), |
|
1638 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1639 | + )); |
|
1640 | 1640 | ?> |
1641 | 1641 | </p> |
1642 | 1642 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1643 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1643 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1644 | 1644 | <?php |
1645 | - echo wpinv_html_text( array( |
|
1645 | + echo wpinv_html_text(array( |
|
1646 | 1646 | 'id' => 'wpinv_city', |
1647 | 1647 | 'name' => 'wpinv_city', |
1648 | 1648 | 'value' => $billing_details['city'], |
1649 | 1649 | 'class' => 'wpi-input form-control', |
1650 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1651 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1652 | - ) ); |
|
1650 | + 'placeholder' => __('City', 'invoicing'), |
|
1651 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1652 | + )); |
|
1653 | 1653 | ?> |
1654 | 1654 | </p> |
1655 | 1655 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1656 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1657 | - <?php echo wpinv_html_select( array( |
|
1656 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1657 | + <?php echo wpinv_html_select(array( |
|
1658 | 1658 | 'options' => wpinv_get_country_list(), |
1659 | 1659 | 'name' => 'wpinv_country', |
1660 | 1660 | 'id' => 'wpinv_country', |
@@ -1662,16 +1662,16 @@ discard block |
||
1662 | 1662 | 'show_option_all' => false, |
1663 | 1663 | 'show_option_none' => false, |
1664 | 1664 | 'class' => 'wpi-input form-control', |
1665 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1666 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1667 | - ) ); ?> |
|
1665 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1666 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1667 | + )); ?> |
|
1668 | 1668 | </p> |
1669 | 1669 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1670 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1670 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1671 | 1671 | <?php |
1672 | - $states = wpinv_get_country_states( $selected_country ); |
|
1673 | - if( !empty( $states ) ) { |
|
1674 | - echo wpinv_html_select( array( |
|
1672 | + $states = wpinv_get_country_states($selected_country); |
|
1673 | + if (!empty($states)) { |
|
1674 | + echo wpinv_html_select(array( |
|
1675 | 1675 | 'options' => $states, |
1676 | 1676 | 'name' => 'wpinv_state', |
1677 | 1677 | 'id' => 'wpinv_state', |
@@ -1679,61 +1679,61 @@ discard block |
||
1679 | 1679 | 'show_option_all' => false, |
1680 | 1680 | 'show_option_none' => false, |
1681 | 1681 | 'class' => 'wpi-input form-control', |
1682 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1683 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1684 | - ) ); |
|
1682 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1683 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1684 | + )); |
|
1685 | 1685 | } else { |
1686 | - echo wpinv_html_text( array( |
|
1686 | + echo wpinv_html_text(array( |
|
1687 | 1687 | 'name' => 'wpinv_state', |
1688 | 1688 | 'value' => $billing_details['state'], |
1689 | 1689 | 'id' => 'wpinv_state', |
1690 | 1690 | 'class' => 'wpi-input form-control', |
1691 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1692 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1693 | - ) ); |
|
1691 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1692 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1693 | + )); |
|
1694 | 1694 | } |
1695 | 1695 | ?> |
1696 | 1696 | </p> |
1697 | 1697 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1698 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1698 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1699 | 1699 | <?php |
1700 | - echo wpinv_html_text( array( |
|
1700 | + echo wpinv_html_text(array( |
|
1701 | 1701 | 'name' => 'wpinv_zip', |
1702 | 1702 | 'value' => $billing_details['zip'], |
1703 | 1703 | 'id' => 'wpinv_zip', |
1704 | 1704 | 'class' => 'wpi-input form-control', |
1705 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1706 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1707 | - ) ); |
|
1705 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1706 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1707 | + )); |
|
1708 | 1708 | ?> |
1709 | 1709 | </p> |
1710 | 1710 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1711 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1711 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1712 | 1712 | <?php |
1713 | - echo wpinv_html_text( array( |
|
1713 | + echo wpinv_html_text(array( |
|
1714 | 1714 | 'id' => 'wpinv_phone', |
1715 | 1715 | 'name' => 'wpinv_phone', |
1716 | 1716 | 'value' => $billing_details['phone'], |
1717 | 1717 | 'class' => 'wpi-input form-control', |
1718 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1719 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1720 | - ) ); |
|
1718 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1719 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1720 | + )); |
|
1721 | 1721 | ?> |
1722 | 1722 | </p> |
1723 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1723 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1724 | 1724 | <div class="clearfix"></div> |
1725 | 1725 | </div> |
1726 | 1726 | </div> |
1727 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1727 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1728 | 1728 | </div> |
1729 | 1729 | <?php |
1730 | 1730 | } |
1731 | 1731 | } |
1732 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1732 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1733 | 1733 | |
1734 | 1734 | function wpinv_checkout_hidden_fields() { |
1735 | 1735 | ?> |
1736 | - <?php if ( is_user_logged_in() ) { ?> |
|
1736 | + <?php if (is_user_logged_in()) { ?> |
|
1737 | 1737 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1738 | 1738 | <?php } ?> |
1739 | 1739 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1743,9 +1743,9 @@ discard block |
||
1743 | 1743 | function wpinv_checkout_button_purchase() { |
1744 | 1744 | ob_start(); |
1745 | 1745 | ?> |
1746 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1746 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1747 | 1747 | <?php |
1748 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1748 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | function wpinv_checkout_total() { |
@@ -1754,96 +1754,96 @@ discard block |
||
1754 | 1754 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1755 | 1755 | <div class="panel-body"> |
1756 | 1756 | <?php |
1757 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1757 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1758 | 1758 | ?> |
1759 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1759 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1760 | 1760 | <?php |
1761 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1761 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1762 | 1762 | ?> |
1763 | 1763 | </div> |
1764 | 1764 | </div> |
1765 | 1765 | <?php |
1766 | 1766 | } |
1767 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1767 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1768 | 1768 | |
1769 | 1769 | function wpinv_checkout_submit() { |
1770 | 1770 | ?> |
1771 | 1771 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1772 | 1772 | <div class="panel-body text-center"> |
1773 | 1773 | <?php |
1774 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1774 | + do_action('wpinv_purchase_form_before_submit'); |
|
1775 | 1775 | wpinv_checkout_hidden_fields(); |
1776 | 1776 | echo wpinv_checkout_button_purchase(); |
1777 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1777 | + do_action('wpinv_purchase_form_after_submit'); |
|
1778 | 1778 | ?> |
1779 | 1779 | </div> |
1780 | 1780 | </div> |
1781 | 1781 | <?php |
1782 | 1782 | } |
1783 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1783 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1784 | 1784 | |
1785 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1786 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1785 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1786 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1787 | 1787 | |
1788 | - if ( empty( $invoice ) ) { |
|
1788 | + if (empty($invoice)) { |
|
1789 | 1789 | return NULL; |
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | $billing_details = $invoice->get_user_info(); |
1793 | 1793 | $address_row = ''; |
1794 | - if ( $address = $billing_details['address'] ) { |
|
1795 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1794 | + if ($address = $billing_details['address']) { |
|
1795 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | $address_fields = array(); |
1799 | - if ( !empty( $billing_details['city'] ) ) { |
|
1799 | + if (!empty($billing_details['city'])) { |
|
1800 | 1800 | $address_fields[] = $billing_details['city']; |
1801 | 1801 | } |
1802 | 1802 | |
1803 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1804 | - if ( !empty( $billing_details['state'] ) ) { |
|
1805 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1803 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1804 | + if (!empty($billing_details['state'])) { |
|
1805 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1806 | 1806 | } |
1807 | 1807 | |
1808 | - if ( !empty( $billing_country ) ) { |
|
1809 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1808 | + if (!empty($billing_country)) { |
|
1809 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1810 | 1810 | } |
1811 | 1811 | |
1812 | - if ( !empty( $address_fields ) ) { |
|
1813 | - $address_fields = implode( ", ", $address_fields ); |
|
1812 | + if (!empty($address_fields)) { |
|
1813 | + $address_fields = implode(", ", $address_fields); |
|
1814 | 1814 | |
1815 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1815 | + if (!empty($billing_details['zip'])) { |
|
1816 | 1816 | $address_fields .= ' ' . $billing_details['zip']; |
1817 | 1817 | } |
1818 | 1818 | |
1819 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1819 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1820 | 1820 | } |
1821 | 1821 | ob_start(); |
1822 | 1822 | ?> |
1823 | 1823 | <table class="table table-bordered table-sm wpi-billing-details"> |
1824 | 1824 | <tbody> |
1825 | 1825 | <tr class="wpi-receipt-name"> |
1826 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1827 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1826 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1827 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1828 | 1828 | </tr> |
1829 | 1829 | <tr class="wpi-receipt-email"> |
1830 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1831 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1830 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1831 | + <td><?php echo $billing_details['email']; ?></td> |
|
1832 | 1832 | </tr> |
1833 | - <?php if ( $billing_details['company'] ) { ?> |
|
1833 | + <?php if ($billing_details['company']) { ?> |
|
1834 | 1834 | <tr class="wpi-receipt-company"> |
1835 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1836 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1835 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1836 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1837 | 1837 | </tr> |
1838 | 1838 | <?php } ?> |
1839 | 1839 | <tr class="wpi-receipt-address"> |
1840 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1841 | - <td><?php echo $address_row ;?></td> |
|
1840 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1841 | + <td><?php echo $address_row; ?></td> |
|
1842 | 1842 | </tr> |
1843 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1843 | + <?php if ($billing_details['phone']) { ?> |
|
1844 | 1844 | <tr class="wpi-receipt-phone"> |
1845 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1846 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1845 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1846 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1847 | 1847 | </tr> |
1848 | 1848 | <?php } ?> |
1849 | 1849 | </tbody> |
@@ -1851,76 +1851,76 @@ discard block |
||
1851 | 1851 | <?php |
1852 | 1852 | $output = ob_get_clean(); |
1853 | 1853 | |
1854 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1854 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1855 | 1855 | |
1856 | 1856 | echo $output; |
1857 | 1857 | } |
1858 | 1858 | |
1859 | -function wpinv_filter_success_page_content( $content ) { |
|
1860 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1861 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1862 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1859 | +function wpinv_filter_success_page_content($content) { |
|
1860 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1861 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1862 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1863 | 1863 | } |
1864 | 1864 | } |
1865 | 1865 | |
1866 | 1866 | return $content; |
1867 | 1867 | } |
1868 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1868 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1869 | 1869 | |
1870 | -function wpinv_receipt_actions( $invoice ) { |
|
1871 | - if ( !empty( $invoice ) ) { |
|
1870 | +function wpinv_receipt_actions($invoice) { |
|
1871 | + if (!empty($invoice)) { |
|
1872 | 1872 | $actions = array(); |
1873 | 1873 | |
1874 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1875 | - $actions['print'] = array( |
|
1876 | - 'url' => $invoice->get_view_url( true ), |
|
1877 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1874 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1875 | + $actions['print'] = array( |
|
1876 | + 'url' => $invoice->get_view_url(true), |
|
1877 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1878 | 1878 | 'class' => 'btn-primary', |
1879 | 1879 | ); |
1880 | 1880 | } |
1881 | 1881 | |
1882 | - if ( is_user_logged_in() ) { |
|
1882 | + if (is_user_logged_in()) { |
|
1883 | 1883 | $actions['history'] = array( |
1884 | 1884 | 'url' => wpinv_get_history_page_uri(), |
1885 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1885 | + 'name' => __('Invoice History', 'invoicing'), |
|
1886 | 1886 | 'class' => 'btn-warning', |
1887 | 1887 | ); |
1888 | 1888 | } |
1889 | 1889 | |
1890 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1890 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1891 | 1891 | |
1892 | - if ( !empty( $actions ) ) { |
|
1892 | + if (!empty($actions)) { |
|
1893 | 1893 | ?> |
1894 | 1894 | <div class="wpinv-receipt-actions text-right"> |
1895 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1896 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1895 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1896 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1897 | 1897 | <?php } ?> |
1898 | 1898 | </div> |
1899 | 1899 | <?php |
1900 | 1900 | } |
1901 | 1901 | } |
1902 | 1902 | } |
1903 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1903 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1904 | 1904 | |
1905 | -function wpinv_invoice_link( $invoice_id ) { |
|
1906 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1905 | +function wpinv_invoice_link($invoice_id) { |
|
1906 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1907 | 1907 | |
1908 | - if ( empty( $invoice ) ) { |
|
1908 | + if (empty($invoice)) { |
|
1909 | 1909 | return NULL; |
1910 | 1910 | } |
1911 | 1911 | |
1912 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1912 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1913 | 1913 | |
1914 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1914 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1915 | 1915 | } |
1916 | 1916 | |
1917 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1918 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1917 | +function wpinv_invoice_subscription_details($invoice) { |
|
1918 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1919 | 1919 | $subs_db = new WPInv_Subscriptions_DB; |
1920 | 1920 | $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1)); |
1921 | 1921 | $sub = reset($subs); |
1922 | 1922 | |
1923 | - if ( empty( $sub ) ) { |
|
1923 | + if (empty($sub)) { |
|
1924 | 1924 | return; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1931,15 +1931,15 @@ discard block |
||
1931 | 1931 | $payments = $sub->get_child_payments(); |
1932 | 1932 | ?> |
1933 | 1933 | <div class="wpinv-subscriptions-details"> |
1934 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1934 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1935 | 1935 | <table class="table"> |
1936 | 1936 | <thead> |
1937 | 1937 | <tr> |
1938 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1939 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1940 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1941 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1942 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1938 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1939 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1940 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1941 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1942 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1943 | 1943 | </tr> |
1944 | 1944 | </thead> |
1945 | 1945 | <tbody> |
@@ -1954,29 +1954,29 @@ discard block |
||
1954 | 1954 | </tbody> |
1955 | 1955 | </table> |
1956 | 1956 | </div> |
1957 | - <?php if ( !empty( $payments ) ) { ?> |
|
1957 | + <?php if (!empty($payments)) { ?> |
|
1958 | 1958 | <div class="wpinv-renewal-payments"> |
1959 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1959 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1960 | 1960 | <table class="table"> |
1961 | 1961 | <thead> |
1962 | 1962 | <tr> |
1963 | 1963 | <th>#</th> |
1964 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1965 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
1966 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1964 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1965 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
1966 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
1967 | 1967 | </tr> |
1968 | 1968 | </thead> |
1969 | 1969 | <tbody> |
1970 | 1970 | <?php |
1971 | 1971 | $i = 1; |
1972 | - foreach ( $payments as $payment ) { |
|
1972 | + foreach ($payments as $payment) { |
|
1973 | 1973 | $invoice_id = $payment->ID; |
1974 | 1974 | ?> |
1975 | 1975 | <tr> |
1976 | - <th scope="row"><?php echo $i;?></th> |
|
1977 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
1978 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
1979 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
1976 | + <th scope="row"><?php echo $i; ?></th> |
|
1977 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
1978 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
1979 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
1980 | 1980 | </tr> |
1981 | 1981 | <?php $i++; } ?> |
1982 | 1982 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -1988,52 +1988,52 @@ discard block |
||
1988 | 1988 | } |
1989 | 1989 | } |
1990 | 1990 | |
1991 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
1992 | - if ( empty( $invoice ) ) { |
|
1991 | +function wpinv_cart_total_label($label, $invoice) { |
|
1992 | + if (empty($invoice)) { |
|
1993 | 1993 | return $label; |
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | $prefix_label = ''; |
1997 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
1998 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
1999 | - } else if ( $invoice->is_renewal() ) { |
|
2000 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
1997 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
1998 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
1999 | + } else if ($invoice->is_renewal()) { |
|
2000 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2001 | 2001 | } |
2002 | 2002 | |
2003 | - if ( $prefix_label != '' ) { |
|
2004 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2003 | + if ($prefix_label != '') { |
|
2004 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | return $label; |
2008 | 2008 | } |
2009 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2010 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2011 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2009 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2010 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2011 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2012 | 2012 | |
2013 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2013 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2014 | 2014 | |
2015 | -function wpinv_invoice_print_description( $invoice ) { |
|
2016 | - if ( empty( $invoice ) ) { |
|
2015 | +function wpinv_invoice_print_description($invoice) { |
|
2016 | + if (empty($invoice)) { |
|
2017 | 2017 | return NULL; |
2018 | 2018 | } |
2019 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2019 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2020 | 2020 | ?> |
2021 | 2021 | <div class="row wpinv-lower"> |
2022 | 2022 | <div class="col-sm-12 wpinv-description"> |
2023 | - <?php echo wpautop( $description ); ?> |
|
2023 | + <?php echo wpautop($description); ?> |
|
2024 | 2024 | </div> |
2025 | 2025 | </div> |
2026 | 2026 | <?php |
2027 | 2027 | } |
2028 | 2028 | } |
2029 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2029 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2030 | 2030 | |
2031 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2032 | - if ( empty( $invoice ) ) { |
|
2031 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2032 | + if (empty($invoice)) { |
|
2033 | 2033 | return NULL; |
2034 | 2034 | } |
2035 | 2035 | |
2036 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2036 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2037 | 2037 | ?> |
2038 | 2038 | <div class="row wpinv-payments"> |
2039 | 2039 | <div class="col-sm-12"> |
@@ -2045,43 +2045,43 @@ discard block |
||
2045 | 2045 | } |
2046 | 2046 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2047 | 2047 | |
2048 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2049 | - if ( empty( $note ) ) { |
|
2048 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2049 | + if (empty($note)) { |
|
2050 | 2050 | return NULL; |
2051 | 2051 | } |
2052 | 2052 | |
2053 | - if ( is_int( $note ) ) { |
|
2054 | - $note = get_comment( $note ); |
|
2053 | + if (is_int($note)) { |
|
2054 | + $note = get_comment($note); |
|
2055 | 2055 | } |
2056 | 2056 | |
2057 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2057 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2058 | 2058 | return NULL; |
2059 | 2059 | } |
2060 | 2060 | |
2061 | - $note_classes = array( 'note' ); |
|
2062 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2061 | + $note_classes = array('note'); |
|
2062 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2063 | 2063 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2064 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2065 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2064 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2065 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2066 | 2066 | |
2067 | 2067 | ob_start(); |
2068 | 2068 | ?> |
2069 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2069 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2070 | 2070 | <div class="note_content"> |
2071 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2071 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2072 | 2072 | </div> |
2073 | 2073 | <p class="meta"> |
2074 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2075 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
2076 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2074 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2075 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
2076 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2077 | 2077 | <?php } ?> |
2078 | 2078 | </p> |
2079 | 2079 | </li> |
2080 | 2080 | <?php |
2081 | 2081 | $note_content = ob_get_clean(); |
2082 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2082 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2083 | 2083 | |
2084 | - if ( $echo ) { |
|
2084 | + if ($echo) { |
|
2085 | 2085 | echo $note_content; |
2086 | 2086 | } else { |
2087 | 2087 | return $note_content; |
@@ -2091,33 +2091,33 @@ discard block |
||
2091 | 2091 | function wpinv_invalid_invoice_content() { |
2092 | 2092 | global $post; |
2093 | 2093 | |
2094 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2094 | + $invoice = wpinv_get_invoice($post->ID); |
|
2095 | 2095 | |
2096 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2097 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2098 | - if ( is_user_logged_in() ) { |
|
2099 | - if ( wpinv_require_login_to_checkout() ) { |
|
2100 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2101 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2096 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2097 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2098 | + if (is_user_logged_in()) { |
|
2099 | + if (wpinv_require_login_to_checkout()) { |
|
2100 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2101 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2102 | 2102 | } |
2103 | 2103 | } |
2104 | 2104 | } else { |
2105 | - if ( wpinv_require_login_to_checkout() ) { |
|
2106 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2107 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2105 | + if (wpinv_require_login_to_checkout()) { |
|
2106 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2107 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2108 | 2108 | } |
2109 | 2109 | } |
2110 | 2110 | } |
2111 | 2111 | } else { |
2112 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2112 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2113 | 2113 | } |
2114 | 2114 | ?> |
2115 | 2115 | <div class="row wpinv-row-invalid"> |
2116 | 2116 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2117 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2117 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2118 | 2118 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2119 | 2119 | </div> |
2120 | 2120 | </div> |
2121 | 2121 | <?php |
2122 | 2122 | } |
2123 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2124 | 2123 | \ No newline at end of file |
2124 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2125 | 2125 | \ No newline at end of file |
@@ -159,8 +159,9 @@ discard block |
||
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
163 | - $templates[] = $slug . '-' . $name . '.php'; |
|
162 | + if ( isset( $name ) ) { |
|
163 | + $templates[] = $slug . '-' . $name . '.php'; |
|
164 | + } |
|
164 | 165 | $templates[] = $slug . '.php'; |
165 | 166 | |
166 | 167 | // Allow template parts to be filtered |
@@ -178,8 +179,9 @@ discard block |
||
178 | 179 | foreach ( (array)$template_names as $template_name ) { |
179 | 180 | |
180 | 181 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
182 | - continue; |
|
182 | + if ( empty( $template_name ) ) { |
|
183 | + continue; |
|
184 | + } |
|
183 | 185 | |
184 | 186 | // Trim off any slashes from the template name |
185 | 187 | $template_name = ltrim( $template_name, '/' ); |
@@ -198,8 +200,9 @@ discard block |
||
198 | 200 | } |
199 | 201 | } |
200 | 202 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
203 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
204 | + load_template( $located, $require_once ); |
|
205 | + } |
|
203 | 206 | |
204 | 207 | return $located; |
205 | 208 | } |
@@ -281,8 +284,9 @@ discard block |
||
281 | 284 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
282 | 285 | $args = array( 'nopaging' => true ); |
283 | 286 | |
284 | - if ( ! empty( $status ) ) |
|
285 | - $args['post_status'] = $status; |
|
287 | + if ( ! empty( $status ) ) { |
|
288 | + $args['post_status'] = $status; |
|
289 | + } |
|
286 | 290 | |
287 | 291 | $discounts = wpinv_get_discounts( $args ); |
288 | 292 | $options = array(); |
@@ -1423,17 +1427,19 @@ discard block |
||
1423 | 1427 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
1424 | 1428 | |
1425 | 1429 | function wpinv_save_cart_button() { |
1426 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1427 | - return; |
|
1428 | -?> |
|
1430 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
1431 | + return; |
|
1432 | + } |
|
1433 | + ?> |
|
1429 | 1434 | <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
1430 | 1435 | <?php |
1431 | 1436 | } |
1432 | 1437 | |
1433 | 1438 | function wpinv_update_cart_button() { |
1434 | - if ( !wpinv_item_quantities_enabled() ) |
|
1435 | - return; |
|
1436 | -?> |
|
1439 | + if ( !wpinv_item_quantities_enabled() ) { |
|
1440 | + return; |
|
1441 | + } |
|
1442 | + ?> |
|
1437 | 1443 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
1438 | 1444 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1439 | 1445 | <?php |
@@ -1,73 +1,73 @@ 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( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
8 | 8 | function wpinv_add_options_link() { |
9 | 9 | global $menu; |
10 | 10 | |
11 | - if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) { |
|
11 | + if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | - $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' ); |
|
15 | + $capability = apply_filters('invoicing_capability', 'manage_invoicing'); |
|
16 | 16 | |
17 | - if ( current_user_can( 'manage_options' ) ) { |
|
18 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
17 | + if (current_user_can('manage_options')) { |
|
18 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
19 | 19 | } |
20 | 20 | |
21 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
21 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
22 | 22 | |
23 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
23 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
24 | 24 | |
25 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', 'wpinv_options_page' ); |
|
25 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', 'wpinv_options_page'); |
|
26 | 26 | } |
27 | 27 | |
28 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
28 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
29 | 29 | function wpinv_remove_admin_submenus() { |
30 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
30 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
34 | -function wpinv_discount_columns( $existing_columns ) { |
|
33 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
34 | +function wpinv_discount_columns($existing_columns) { |
|
35 | 35 | $columns = array(); |
36 | 36 | $columns['cb'] = $existing_columns['cb']; |
37 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
38 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
39 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
40 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
41 | - $columns['start_date'] = __( 'Start Date', 'invoicing' ); |
|
42 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
43 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
37 | + $columns['name'] = __('Name', 'invoicing'); |
|
38 | + $columns['code'] = __('Code', 'invoicing'); |
|
39 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
40 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
41 | + $columns['start_date'] = __('Start Date', 'invoicing'); |
|
42 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
43 | + $columns['status'] = __('Status', 'invoicing'); |
|
44 | 44 | |
45 | 45 | return $columns; |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
49 | -function wpinv_discount_custom_column( $column ) { |
|
48 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
49 | +function wpinv_discount_custom_column($column) { |
|
50 | 50 | global $post; |
51 | 51 | |
52 | 52 | $discount = $post; |
53 | 53 | |
54 | - switch ( $column ) { |
|
54 | + switch ($column) { |
|
55 | 55 | case 'name' : |
56 | - echo get_the_title( $discount->ID ); |
|
56 | + echo get_the_title($discount->ID); |
|
57 | 57 | break; |
58 | 58 | case 'code' : |
59 | - echo wpinv_get_discount_code( $discount->ID ); |
|
59 | + echo wpinv_get_discount_code($discount->ID); |
|
60 | 60 | break; |
61 | 61 | case 'amount' : |
62 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
62 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
63 | 63 | break; |
64 | 64 | case 'usage_limit' : |
65 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
65 | + echo wpinv_get_discount_uses($discount->ID); |
|
66 | 66 | break; |
67 | 67 | case 'usage' : |
68 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
69 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
70 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
68 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
69 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
70 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
71 | 71 | } else { |
72 | 72 | $usage .= ' ∞'; |
73 | 73 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | echo $usage; |
76 | 76 | break; |
77 | 77 | case 'start_date' : |
78 | - if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) { |
|
79 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) ); |
|
78 | + if ($start_date = wpinv_get_discount_start_date($discount->ID)) { |
|
79 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date)); |
|
80 | 80 | } else { |
81 | 81 | $value = '-'; |
82 | 82 | } |
@@ -84,163 +84,163 @@ discard block |
||
84 | 84 | echo $value; |
85 | 85 | break; |
86 | 86 | case 'expiry_date' : |
87 | - if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) { |
|
88 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) ); |
|
87 | + if ($expiration = wpinv_get_discount_expiration($discount->ID)) { |
|
88 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration)); |
|
89 | 89 | } else { |
90 | - $value = __( 'Never', 'invoicing' ); |
|
90 | + $value = __('Never', 'invoicing'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | echo $value; |
94 | 94 | break; |
95 | 95 | break; |
96 | 96 | case 'description' : |
97 | - echo wp_kses_post( $post->post_excerpt ); |
|
97 | + echo wp_kses_post($post->post_excerpt); |
|
98 | 98 | break; |
99 | 99 | case 'status' : |
100 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
100 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
101 | 101 | |
102 | - echo wpinv_discount_status( $status ); |
|
102 | + echo wpinv_discount_status($status); |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
108 | -function wpinv_post_row_actions( $actions, $post ) { |
|
109 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
107 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
108 | +function wpinv_post_row_actions($actions, $post) { |
|
109 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
110 | 110 | |
111 | - if ( $post_type == 'wpi_invoice' ) { |
|
111 | + if ($post_type == 'wpi_invoice') { |
|
112 | 112 | $actions = array(); |
113 | 113 | } |
114 | 114 | |
115 | - if ( $post_type == 'wpi_discount' ) { |
|
116 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
115 | + if ($post_type == 'wpi_discount') { |
|
116 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $actions; |
120 | 120 | } |
121 | 121 | |
122 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
123 | - $row_actions = array(); |
|
124 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
125 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
122 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
123 | + $row_actions = array(); |
|
124 | + $edit_link = get_edit_post_link($discount->ID); |
|
125 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
126 | 126 | |
127 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
128 | - $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>'; |
|
129 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
130 | - $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>'; |
|
127 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
128 | + $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>'; |
|
129 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
130 | + $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>'; |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
134 | - if ( isset( $row_actions['delete'] ) ) { |
|
135 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
133 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
134 | + if (isset($row_actions['delete'])) { |
|
135 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
136 | 136 | } |
137 | 137 | } else { |
138 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
138 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
142 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
143 | 143 | |
144 | 144 | return $row_actions; |
145 | 145 | } |
146 | 146 | |
147 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
148 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
149 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
147 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
148 | +function wpinv_table_primary_column($default, $screen_id) { |
|
149 | + if ('edit-wpi_invoice' === $screen_id) { |
|
150 | 150 | return 'name'; |
151 | 151 | } |
152 | 152 | |
153 | 153 | return $default; |
154 | 154 | } |
155 | 155 | |
156 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
157 | - if ( !$display ) { |
|
156 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
157 | + if (!$display) { |
|
158 | 158 | return array(); |
159 | 159 | } |
160 | 160 | |
161 | 161 | $actions = array( |
162 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
163 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
164 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
162 | + 'activate' => __('Activate', 'invoicing'), |
|
163 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
164 | + 'delete' => __('Delete', 'invoicing'), |
|
165 | 165 | ); |
166 | 166 | $two = ''; |
167 | 167 | $which = 'top'; |
168 | 168 | echo '</div><div class="alignleft actions bulkactions">'; |
169 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
170 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
171 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
169 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
170 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
171 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
172 | 172 | |
173 | - foreach ( $actions as $name => $title ) { |
|
173 | + foreach ($actions as $name => $title) { |
|
174 | 174 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
175 | 175 | |
176 | 176 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
177 | 177 | } |
178 | 178 | echo "</select>"; |
179 | 179 | |
180 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
180 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
181 | 181 | |
182 | 182 | echo '</div><div class="alignleft actions">'; |
183 | 183 | } |
184 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
184 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
185 | 185 | |
186 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
187 | - if ( $post_type == 'wpi_discount' ) { |
|
186 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
187 | + if ($post_type == 'wpi_discount') { |
|
188 | 188 | $disable = true; |
189 | 189 | } |
190 | 190 | |
191 | 191 | return $disable; |
192 | 192 | } |
193 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
193 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
194 | 194 | |
195 | 195 | function wpinv_restrict_manage_posts() { |
196 | 196 | global $typenow; |
197 | 197 | |
198 | - if( 'wpi_discount' == $typenow ) { |
|
198 | + if ('wpi_discount' == $typenow) { |
|
199 | 199 | wpinv_discount_filters(); |
200 | 200 | } |
201 | 201 | } |
202 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
202 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
203 | 203 | |
204 | 204 | function wpinv_discount_filters() { |
205 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
205 | + echo wpinv_discount_bulk_actions(array(), true); |
|
206 | 206 | |
207 | 207 | ?> |
208 | 208 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
209 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
209 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
210 | 210 | <?php |
211 | 211 | $types = wpinv_get_discount_types(); |
212 | 212 | |
213 | - foreach ( $types as $name => $type ) { |
|
214 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
213 | + foreach ($types as $name => $type) { |
|
214 | + echo '<option value="' . esc_attr($name) . '"'; |
|
215 | 215 | |
216 | - if ( isset( $_GET['discount_type'] ) ) |
|
217 | - selected( $name, $_GET['discount_type'] ); |
|
216 | + if (isset($_GET['discount_type'])) |
|
217 | + selected($name, $_GET['discount_type']); |
|
218 | 218 | |
219 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
219 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
220 | 220 | } |
221 | 221 | ?> |
222 | 222 | </select> |
223 | 223 | <?php |
224 | 224 | } |
225 | 225 | |
226 | -function wpinv_request( $vars ) { |
|
226 | +function wpinv_request($vars) { |
|
227 | 227 | global $typenow, $wp_query, $wp_post_statuses; |
228 | 228 | |
229 | - if ( 'wpi_invoice' === $typenow ) { |
|
230 | - if ( !isset( $vars['post_status'] ) ) { |
|
229 | + if ('wpi_invoice' === $typenow) { |
|
230 | + if (!isset($vars['post_status'])) { |
|
231 | 231 | $post_statuses = wpinv_get_invoice_statuses(); |
232 | 232 | |
233 | - foreach ( $post_statuses as $status => $value ) { |
|
234 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
235 | - unset( $post_statuses[ $status ] ); |
|
233 | + foreach ($post_statuses as $status => $value) { |
|
234 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
235 | + unset($post_statuses[$status]); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
239 | + $vars['post_status'] = array_keys($post_statuses); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( isset( $vars['orderby'] ) ) { |
|
243 | - if ( 'amount' == $vars['orderby'] ) { |
|
242 | + if (isset($vars['orderby'])) { |
|
243 | + if ('amount' == $vars['orderby']) { |
|
244 | 244 | $vars = array_merge( |
245 | 245 | $vars, |
246 | 246 | array( |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | 'orderby' => 'meta_value_num' |
249 | 249 | ) |
250 | 250 | ); |
251 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
251 | + } else if ('customer' == $vars['orderby']) { |
|
252 | 252 | $vars = array_merge( |
253 | 253 | $vars, |
254 | 254 | array( |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'orderby' => 'meta_value' |
257 | 257 | ) |
258 | 258 | ); |
259 | - } else if ( 'number' == $vars['orderby'] ) { |
|
259 | + } else if ('number' == $vars['orderby']) { |
|
260 | 260 | $vars = array_merge( |
261 | 261 | $vars, |
262 | 262 | array( |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | 'orderby' => 'meta_value' |
265 | 265 | ) |
266 | 266 | ); |
267 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
267 | + } else if ('payment_date' == $vars['orderby']) { |
|
268 | 268 | $vars = array_merge( |
269 | 269 | $vars, |
270 | 270 | array( |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | ); |
275 | 275 | } |
276 | 276 | } |
277 | - } else if ( 'wpi_item' == $typenow ) { |
|
277 | + } else if ('wpi_item' == $typenow) { |
|
278 | 278 | // Check if 'orderby' is set to "price" |
279 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
279 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
280 | 280 | $vars = array_merge( |
281 | 281 | $vars, |
282 | 282 | array( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Check if "orderby" is set to "vat_rule" |
290 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
290 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
291 | 291 | $vars = array_merge( |
292 | 292 | $vars, |
293 | 293 | array( |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | // Check if "orderby" is set to "vat_class" |
301 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
301 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
302 | 302 | $vars = array_merge( |
303 | 303 | $vars, |
304 | 304 | array( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | // Check if "orderby" is set to "type" |
312 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
312 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
313 | 313 | $vars = array_merge( |
314 | 314 | $vars, |
315 | 315 | array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | // Check if "orderby" is set to "recurring" |
323 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
323 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
324 | 324 | $vars = array_merge( |
325 | 325 | $vars, |
326 | 326 | array( |
@@ -330,120 +330,120 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
333 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
334 | 334 | // Filter vat rule type |
335 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
335 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
336 | 336 | $meta_query[] = array( |
337 | 337 | 'key' => '_wpinv_vat_rule', |
338 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
338 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
339 | 339 | 'compare' => '=' |
340 | 340 | ); |
341 | 341 | } |
342 | 342 | |
343 | 343 | // Filter vat class |
344 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
344 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
345 | 345 | $meta_query[] = array( |
346 | 346 | 'key' => '_wpinv_vat_class', |
347 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
347 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
348 | 348 | 'compare' => '=' |
349 | 349 | ); |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Filter item type |
353 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
353 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
354 | 354 | $meta_query[] = array( |
355 | 355 | 'key' => '_wpinv_type', |
356 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
356 | + 'value' => sanitize_text_field($_GET['type']), |
|
357 | 357 | 'compare' => '=' |
358 | 358 | ); |
359 | 359 | } |
360 | 360 | |
361 | - if ( !empty( $meta_query ) ) { |
|
361 | + if (!empty($meta_query)) { |
|
362 | 362 | $vars['meta_query'] = $meta_query; |
363 | 363 | } |
364 | - } else if ( 'wpi_discount' == $typenow ) { |
|
365 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
364 | + } else if ('wpi_discount' == $typenow) { |
|
365 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
366 | 366 | // Filter vat rule type |
367 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
367 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
368 | 368 | $meta_query[] = array( |
369 | 369 | 'key' => '_wpi_discount_type', |
370 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
370 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
371 | 371 | 'compare' => '=' |
372 | 372 | ); |
373 | 373 | } |
374 | 374 | |
375 | - if ( !empty( $meta_query ) ) { |
|
375 | + if (!empty($meta_query)) { |
|
376 | 376 | $vars['meta_query'] = $meta_query; |
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | return $vars; |
381 | 381 | } |
382 | -add_filter( 'request', 'wpinv_request' ); |
|
382 | +add_filter('request', 'wpinv_request'); |
|
383 | 383 | |
384 | 384 | function wpinv_options_page() { |
385 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
385 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
386 | 386 | |
387 | - if ( $page !== 'wpinv-settings' ) { |
|
387 | + if ($page !== 'wpinv-settings') { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | 391 | $settings_tabs = wpinv_get_settings_tabs(); |
392 | 392 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
393 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
394 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
393 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
394 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
395 | 395 | $key = 'main'; |
396 | 396 | |
397 | - if ( is_array( $sections ) ) { |
|
398 | - $key = key( $sections ); |
|
397 | + if (is_array($sections)) { |
|
398 | + $key = key($sections); |
|
399 | 399 | } |
400 | 400 | |
401 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
402 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
401 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
402 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
403 | 403 | ob_start(); |
404 | 404 | ?> |
405 | 405 | <div class="wrap"> |
406 | 406 | <h1 class="nav-tab-wrapper"> |
407 | 407 | <?php |
408 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
409 | - $tab_url = add_query_arg( array( |
|
408 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
409 | + $tab_url = add_query_arg(array( |
|
410 | 410 | 'settings-updated' => false, |
411 | 411 | 'tab' => $tab_id, |
412 | - ) ); |
|
412 | + )); |
|
413 | 413 | |
414 | 414 | // Remove the section from the tabs so we always end up at the main section |
415 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
416 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
415 | + $tab_url = remove_query_arg('section', $tab_url); |
|
416 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
417 | 417 | |
418 | 418 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
419 | 419 | |
420 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
421 | - echo esc_html( $tab_name ); |
|
420 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
421 | + echo esc_html($tab_name); |
|
422 | 422 | echo '</a>'; |
423 | 423 | } |
424 | 424 | ?> |
425 | 425 | </h1> |
426 | 426 | <?php |
427 | - $number_of_sections = count( $sections ); |
|
427 | + $number_of_sections = count($sections); |
|
428 | 428 | $number = 0; |
429 | - if ( $number_of_sections > 1 ) { |
|
429 | + if ($number_of_sections > 1) { |
|
430 | 430 | echo '<div><ul class="subsubsub">'; |
431 | - foreach( $sections as $section_id => $section_name ) { |
|
431 | + foreach ($sections as $section_id => $section_name) { |
|
432 | 432 | echo '<li>'; |
433 | 433 | $number++; |
434 | - $tab_url = add_query_arg( array( |
|
434 | + $tab_url = add_query_arg(array( |
|
435 | 435 | 'settings-updated' => false, |
436 | 436 | 'tab' => $active_tab, |
437 | 437 | 'section' => $section_id |
438 | - ) ); |
|
439 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
438 | + )); |
|
439 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
440 | 440 | $class = ''; |
441 | - if ( $section == $section_id ) { |
|
441 | + if ($section == $section_id) { |
|
442 | 442 | $class = 'current'; |
443 | 443 | } |
444 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
444 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
445 | 445 | |
446 | - if ( $number != $number_of_sections ) { |
|
446 | + if ($number != $number_of_sections) { |
|
447 | 447 | echo ' | '; |
448 | 448 | } |
449 | 449 | echo '</li>'; |
@@ -455,19 +455,19 @@ discard block |
||
455 | 455 | <form method="post" action="options.php"> |
456 | 456 | <table class="form-table"> |
457 | 457 | <?php |
458 | - settings_fields( 'wpinv_settings' ); |
|
458 | + settings_fields('wpinv_settings'); |
|
459 | 459 | |
460 | - if ( 'main' === $section ) { |
|
461 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
460 | + if ('main' === $section) { |
|
461 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
462 | 462 | } |
463 | 463 | |
464 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
465 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
466 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
464 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
465 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
466 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
467 | 467 | |
468 | 468 | // For backwards compatibility |
469 | - if ( 'main' === $section ) { |
|
470 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
469 | + if ('main' === $section) { |
|
470 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
471 | 471 | } |
472 | 472 | ?> |
473 | 473 | </table> |
@@ -480,53 +480,53 @@ discard block |
||
480 | 480 | echo $content; |
481 | 481 | } |
482 | 482 | |
483 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
483 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
484 | 484 | global $pagenow, $typenow; |
485 | 485 | |
486 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
487 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
488 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
486 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
487 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
488 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
489 | 489 | } |
490 | 490 | |
491 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
491 | + if (!wpinv_item_is_editable($post_id)) { |
|
492 | 492 | $classes[] = 'wpi-editable-n'; |
493 | 493 | } |
494 | 494 | } |
495 | 495 | return $classes; |
496 | 496 | } |
497 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
497 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
498 | 498 | |
499 | 499 | function wpinv_check_quick_edit() { |
500 | 500 | global $pagenow, $current_screen, $wpinv_item_screen; |
501 | 501 | |
502 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
503 | - if ( empty( $wpinv_item_screen ) ) { |
|
504 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
502 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
503 | + if (empty($wpinv_item_screen)) { |
|
504 | + if ($current_screen->post_type == 'wpi_item') { |
|
505 | 505 | $wpinv_item_screen = 'y'; |
506 | 506 | } else { |
507 | 507 | $wpinv_item_screen = 'n'; |
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
512 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
513 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
511 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
512 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
513 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |
517 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
517 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
518 | 518 | |
519 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
520 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
521 | - unset( $actions['inline hide-if-no-js'] ); |
|
519 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
520 | + if (isset($actions['inline hide-if-no-js'])) { |
|
521 | + unset($actions['inline hide-if-no-js']); |
|
522 | 522 | } |
523 | 523 | |
524 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
525 | - if ( isset( $actions['trash'] ) ) { |
|
526 | - unset( $actions['trash'] ); |
|
524 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
525 | + if (isset($actions['trash'])) { |
|
526 | + unset($actions['trash']); |
|
527 | 527 | } |
528 | - if ( isset( $actions['delete'] ) ) { |
|
529 | - unset( $actions['delete'] ); |
|
528 | + if (isset($actions['delete'])) { |
|
529 | + unset($actions['delete']); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | * @param int $post_parent (default: 0) Parent for the new page |
544 | 544 | * @return int page ID |
545 | 545 | */ |
546 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
546 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
547 | 547 | global $wpdb; |
548 | 548 | |
549 | - $option_value = wpinv_get_option( $option ); |
|
549 | + $option_value = wpinv_get_option($option); |
|
550 | 550 | |
551 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
552 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
551 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
552 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
553 | 553 | // Valid page is already in place |
554 | 554 | return $page_object->ID; |
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | - if(!empty($post_parent)){ |
|
558 | + if (!empty($post_parent)) { |
|
559 | 559 | $page = get_page_by_path($post_parent); |
560 | 560 | if ($page) { |
561 | 561 | $post_parent = $page->ID; |
@@ -564,40 +564,40 @@ discard block |
||
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - if ( strlen( $page_content ) > 0 ) { |
|
567 | + if (strlen($page_content) > 0) { |
|
568 | 568 | // Search for an existing page with the specified page content (typically a shortcode) |
569 | - $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}%" ) ); |
|
569 | + $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}%")); |
|
570 | 570 | } else { |
571 | 571 | // Search for an existing page with the specified page slug |
572 | - $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 ) ); |
|
572 | + $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)); |
|
573 | 573 | } |
574 | 574 | |
575 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
575 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
576 | 576 | |
577 | - if ( $valid_page_found ) { |
|
578 | - if ( $option ) { |
|
579 | - wpinv_update_option( $option, $valid_page_found ); |
|
577 | + if ($valid_page_found) { |
|
578 | + if ($option) { |
|
579 | + wpinv_update_option($option, $valid_page_found); |
|
580 | 580 | } |
581 | 581 | return $valid_page_found; |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Search for a matching valid trashed page |
585 | - if ( strlen( $page_content ) > 0 ) { |
|
585 | + if (strlen($page_content) > 0) { |
|
586 | 586 | // Search for an existing page with the specified page content (typically a shortcode) |
587 | - $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}%" ) ); |
|
587 | + $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}%")); |
|
588 | 588 | } else { |
589 | 589 | // Search for an existing page with the specified page slug |
590 | - $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 ) ); |
|
590 | + $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)); |
|
591 | 591 | } |
592 | 592 | |
593 | - if ( $trashed_page_found ) { |
|
593 | + if ($trashed_page_found) { |
|
594 | 594 | $page_id = $trashed_page_found; |
595 | 595 | $page_data = array( |
596 | 596 | 'ID' => $page_id, |
597 | 597 | 'post_status' => 'publish', |
598 | 598 | 'post_parent' => $post_parent, |
599 | 599 | ); |
600 | - wp_update_post( $page_data ); |
|
600 | + wp_update_post($page_data); |
|
601 | 601 | } else { |
602 | 602 | $page_data = array( |
603 | 603 | 'post_status' => 'publish', |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | 'post_parent' => $post_parent, |
610 | 610 | 'comment_status' => 'closed', |
611 | 611 | ); |
612 | - $page_id = wp_insert_post( $page_data ); |
|
612 | + $page_id = wp_insert_post($page_data); |
|
613 | 613 | } |
614 | 614 | |
615 | - if ( $option ) { |
|
616 | - wpinv_update_option( $option, (int)$page_id ); |
|
615 | + if ($option) { |
|
616 | + wpinv_update_option($option, (int)$page_id); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $page_id; |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | 77 | <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]"> |
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,89 +183,89 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | - ) ); |
|
192 | + )); |
|
193 | 193 | ?> |
194 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
194 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | 195 | <?php } ?> |
196 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
197 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
196 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
197 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
198 | 198 | </div> |
199 | 199 | </div> |
200 | 200 | <?php |
201 | 201 | } |
202 | 202 | |
203 | - public static function prices( $post ) { |
|
203 | + public static function prices($post) { |
|
204 | 204 | $symbol = wpinv_currency_symbol(); |
205 | 205 | $position = wpinv_currency_position(); |
206 | - $item = new WPInv_Item( $post->ID ); |
|
206 | + $item = new WPInv_Item($post->ID); |
|
207 | 207 | |
208 | 208 | $price = $item->get_price(); |
209 | 209 | $is_recurring = $item->is_recurring(); |
210 | 210 | $period = $item->get_recurring_period(); |
211 | - $interval = absint( $item->get_recurring_interval() ); |
|
212 | - $times = absint( $item->get_recurring_limit() ); |
|
211 | + $interval = absint($item->get_recurring_interval()); |
|
212 | + $times = absint($item->get_recurring_limit()); |
|
213 | 213 | $free_trial = $item->has_free_trial(); |
214 | 214 | $trial_interval = $item->get_trial_interval(); |
215 | 215 | $trial_period = $item->get_trial_period(); |
216 | 216 | |
217 | 217 | $intervals = array(); |
218 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
218 | + for ($i = 1; $i <= 90; $i++) { |
|
219 | 219 | $intervals[$i] = $i; |
220 | 220 | } |
221 | 221 | |
222 | - $interval = $interval > 0 ? $interval : 1; |
|
222 | + $interval = $interval > 0 ? $interval : 1; |
|
223 | 223 | |
224 | 224 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
225 | 225 | ?> |
226 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
227 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
226 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
227 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
228 | 228 | </p> |
229 | 229 | <p class="wpinv-row-is-recurring"> |
230 | 230 | <label for="wpinv_is_recurring"> |
231 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
232 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
231 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
232 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
233 | 233 | </label> |
234 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
234 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
235 | 235 | </p> |
236 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
237 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
238 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
236 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
237 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
238 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
239 | 239 | 'options' => $intervals, |
240 | 240 | 'name' => 'wpinv_recurring_interval', |
241 | 241 | 'id' => 'wpinv_recurring_interval', |
242 | 242 | 'selected' => $interval, |
243 | 243 | 'show_option_all' => false, |
244 | 244 | 'show_option_none' => false |
245 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
246 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
245 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
246 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
247 | 247 | <span class="clear wpi-trial-clr"></span> |
248 | 248 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
249 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
250 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
249 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
250 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
251 | 251 | </label> |
252 | 252 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
253 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
253 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
254 | 254 | </label> |
255 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
256 | 256 | </p> |
257 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
258 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
257 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
258 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
259 | 259 | <?php |
260 | 260 | } |
261 | 261 | |
262 | - public static function vat_rules( $post ) { |
|
262 | + public static function vat_rules($post) { |
|
263 | 263 | global $wpinv_euvat; |
264 | 264 | |
265 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
265 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
266 | 266 | ?> |
267 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
268 | - <?php echo wpinv_html_select( array( |
|
267 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
268 | + <?php echo wpinv_html_select(array( |
|
269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
270 | 270 | 'name' => 'wpinv_vat_rules', |
271 | 271 | 'id' => 'wpinv_vat_rules', |
@@ -273,19 +273,19 @@ discard block |
||
273 | 273 | 'show_option_all' => false, |
274 | 274 | 'show_option_none' => false, |
275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
276 | - ) ); ?> |
|
276 | + )); ?> |
|
277 | 277 | </p> |
278 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
279 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
278 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
279 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
280 | 280 | <?php |
281 | 281 | } |
282 | 282 | |
283 | - public static function vat_classes( $post ) { |
|
283 | + public static function vat_classes($post) { |
|
284 | 284 | global $wpinv_euvat; |
285 | 285 | |
286 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
286 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
287 | 287 | ?> |
288 | - <p><?php echo wpinv_html_select( array( |
|
288 | + <p><?php echo wpinv_html_select(array( |
|
289 | 289 | 'options' => $wpinv_euvat->get_all_classes(), |
290 | 290 | 'name' => 'wpinv_vat_class', |
291 | 291 | 'id' => 'wpinv_vat_class', |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | 'show_option_all' => false, |
294 | 294 | 'show_option_none' => false, |
295 | 295 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
296 | - ) ); ?> |
|
296 | + )); ?> |
|
297 | 297 | </p> |
298 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
298 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
299 | 299 | <?php |
300 | 300 | } |
301 | 301 | |
302 | - public static function item_info( $post ) { |
|
303 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
304 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
302 | + public static function item_info($post) { |
|
303 | + $item_type = wpinv_get_item_type($post->ID); |
|
304 | + do_action('wpinv_item_info_metabox_before', $post); |
|
305 | 305 | ?> |
306 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
307 | - <?php echo wpinv_html_select( array( |
|
306 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
307 | + <?php echo wpinv_html_select(array( |
|
308 | 308 | 'options' => wpinv_get_item_types(), |
309 | 309 | 'name' => 'wpinv_item_type', |
310 | 310 | 'id' => 'wpinv_item_type', |
@@ -312,114 +312,114 @@ discard block |
||
312 | 312 | 'show_option_all' => false, |
313 | 313 | 'show_option_none' => false, |
314 | 314 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
315 | - ) ); ?> |
|
315 | + )); ?> |
|
316 | 316 | </p> |
317 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
317 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
318 | 318 | <?php |
319 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
319 | + do_action('wpinv_item_info_metabox_after', $post); |
|
320 | 320 | } |
321 | 321 | |
322 | - public static function meta_values( $post ) { |
|
323 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
322 | + public static function meta_values($post) { |
|
323 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
324 | 324 | 'type', |
325 | 325 | 'custom_id' |
326 | - ) ); |
|
326 | + )); |
|
327 | 327 | |
328 | - if ( empty( $meta_keys ) ) { |
|
328 | + if (empty($meta_keys)) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
332 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
333 | 333 | |
334 | - foreach ( $meta_keys as $meta_key ) { |
|
334 | + foreach ($meta_keys as $meta_key) { |
|
335 | 335 | ?> |
336 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
336 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
337 | 337 | <?php |
338 | 338 | } |
339 | 339 | |
340 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
340 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
341 | 341 | } |
342 | 342 | |
343 | - public static function save( $post_id, $data, $post ) { |
|
344 | - $invoice = new WPInv_Invoice( $post_id ); |
|
343 | + public static function save($post_id, $data, $post) { |
|
344 | + $invoice = new WPInv_Invoice($post_id); |
|
345 | 345 | |
346 | 346 | // Billing |
347 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
348 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
349 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
350 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
351 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
352 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
353 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
354 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
355 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
356 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
347 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
348 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
349 | + $company = sanitize_text_field($data['wpinv_company']); |
|
350 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
351 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
352 | + $address = sanitize_text_field($data['wpinv_address']); |
|
353 | + $city = sanitize_text_field($data['wpinv_city']); |
|
354 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
355 | + $country = sanitize_text_field($data['wpinv_country']); |
|
356 | + $state = sanitize_text_field($data['wpinv_state']); |
|
357 | 357 | |
358 | 358 | // Details |
359 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
360 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
361 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
362 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
359 | + $status = sanitize_text_field($data['wpinv_status']); |
|
360 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
361 | + $number = sanitize_text_field($data['wpinv_number']); |
|
362 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
363 | 363 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
364 | 364 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
365 | 365 | |
366 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
366 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
367 | 367 | |
368 | - $invoice->set( 'due_date', $due_date ); |
|
369 | - $invoice->set( 'first_name', $first_name ); |
|
370 | - $invoice->set( 'last_name', $last_name ); |
|
371 | - $invoice->set( 'company', $company ); |
|
372 | - $invoice->set( 'vat_number', $vat_number ); |
|
373 | - $invoice->set( 'phone', $phone ); |
|
374 | - $invoice->set( 'address', $address ); |
|
375 | - $invoice->set( 'city', $city ); |
|
376 | - $invoice->set( 'zip', $zip ); |
|
377 | - $invoice->set( 'country', $country ); |
|
378 | - $invoice->set( 'state', $state ); |
|
379 | - $invoice->set( 'status', $status ); |
|
368 | + $invoice->set('due_date', $due_date); |
|
369 | + $invoice->set('first_name', $first_name); |
|
370 | + $invoice->set('last_name', $last_name); |
|
371 | + $invoice->set('company', $company); |
|
372 | + $invoice->set('vat_number', $vat_number); |
|
373 | + $invoice->set('phone', $phone); |
|
374 | + $invoice->set('address', $address); |
|
375 | + $invoice->set('city', $city); |
|
376 | + $invoice->set('zip', $zip); |
|
377 | + $invoice->set('country', $country); |
|
378 | + $invoice->set('state', $state); |
|
379 | + $invoice->set('status', $status); |
|
380 | 380 | //$invoice->set( 'number', $number ); |
381 | 381 | //$invoice->set( 'discounts', $discounts ); |
382 | 382 | //$invoice->set( 'discount', $discount ); |
383 | - $invoice->set( 'ip', $ip ); |
|
383 | + $invoice->set('ip', $ip); |
|
384 | 384 | $invoice->old_status = $_POST['original_post_status']; |
385 | 385 | $invoice->currency = wpinv_get_currency(); |
386 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
387 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
386 | + if (!empty($data['wpinv_gateway'])) { |
|
387 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
388 | 388 | } |
389 | 389 | $saved = $invoice->save(); |
390 | 390 | |
391 | 391 | // Check for payment notes |
392 | - if ( !empty( $data['invoice_note'] ) ) { |
|
393 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
394 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
392 | + if (!empty($data['invoice_note'])) { |
|
393 | + $note = wp_kses($data['invoice_note'], array()); |
|
394 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
395 | 395 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
396 | 396 | |
397 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
397 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | // Update user address if empty. |
401 | - if ( $saved && !empty( $invoice ) ) { |
|
402 | - if ( $user_id = $invoice->get_user_id() ) { |
|
403 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
401 | + if ($saved && !empty($invoice)) { |
|
402 | + if ($user_id = $invoice->get_user_id()) { |
|
403 | + $user_address = wpinv_get_user_address($user_id, false); |
|
404 | 404 | |
405 | 405 | if (empty($user_address['first_name'])) { |
406 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
407 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
406 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
407 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
408 | 408 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
409 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
409 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
413 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
414 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
415 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
416 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
417 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
418 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
413 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
414 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
415 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
416 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
417 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
418 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
422 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
422 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | return $saved; |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | 10 | $statuses = wpinv_get_invoice_statuses(); |
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
28 | 28 | |
29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,35 +34,35 @@ discard block |
||
34 | 34 | <div class="gdmbx2-wrap form-table"> |
35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
39 | 39 | </div> |
40 | - <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
40 | + <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | <?php } ?> |
48 | - <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
49 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
48 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
49 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
50 | 50 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
51 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
52 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
51 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
52 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
53 | 53 | </div> |
54 | 54 | <?php } ?> |
55 | - <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?> |
|
55 | + <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?> |
|
56 | 56 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed"> |
57 | - <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div> |
|
58 | - <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div> |
|
57 | + <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div> |
|
58 | + <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div> |
|
59 | 59 | </div> |
60 | 60 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
61 | 61 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
62 | 62 | <div class="gdmbx-td"> |
63 | 63 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
64 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
65 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
64 | + <?php foreach ($statuses as $value => $label) { ?> |
|
65 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
66 | 66 | <?php } ?> |
67 | 67 | </select> |
68 | 68 | </div> |
@@ -70,117 +70,117 @@ discard block |
||
70 | 70 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
71 | 71 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
72 | 72 | <div class="gdmbx-td"> |
73 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
73 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
74 | 74 | </div> |
75 | 75 | </div> |
76 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); |
|
76 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); |
|
77 | 77 | $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id); |
78 | 78 | ?> |
79 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?> |
|
79 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?> |
|
80 | 80 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
81 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
81 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
82 | 82 | <div class="gdmbx-td"> |
83 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
83 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
84 | 84 | </div> |
85 | 85 | </div> |
86 | 86 | <?php } ?> |
87 | 87 | </div> |
88 | 88 | </div> |
89 | 89 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
90 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
90 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
91 | 91 | <select id="wpi_save_send" name="wpi_save_send"> |
92 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
93 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
92 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
93 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
94 | 94 | </select> |
95 | 95 | </p> |
96 | 96 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
97 | 97 | </div> |
98 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
98 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
99 | 99 | <?php |
100 | 100 | } |
101 | 101 | |
102 | - public static function resend_invoice( $post ) { |
|
102 | + public static function resend_invoice($post) { |
|
103 | 103 | global $wpi_mb_invoice; |
104 | 104 | |
105 | - if ( empty( $wpi_mb_invoice ) ) { |
|
105 | + if (empty($wpi_mb_invoice)) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $text = array( |
110 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
111 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
110 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
111 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
115 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
115 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
116 | 116 | |
117 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
117 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
118 | 118 | $email_actions = array(); |
119 | - $email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
120 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
119 | + $email_actions['email_url'] = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))); |
|
120 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
121 | 121 | |
122 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
122 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
123 | 123 | ?> |
124 | 124 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
125 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
126 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
127 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
125 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
126 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
127 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
128 | 128 | <?php } ?> |
129 | 129 | <?php |
130 | 130 | } |
131 | 131 | |
132 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
132 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
133 | 133 | } |
134 | 134 | |
135 | - public static function subscriptions( $post ) { |
|
136 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
135 | + public static function subscriptions($post) { |
|
136 | + $invoice = wpinv_get_invoice($post->ID); |
|
137 | 137 | |
138 | - if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
139 | - $subscription = wpinv_get_subscription( $invoice ); |
|
138 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
139 | + $subscription = wpinv_get_subscription($invoice); |
|
140 | 140 | |
141 | - if ( empty( $subscription ) ) { |
|
141 | + if (empty($subscription)) { |
|
142 | 142 | ?> |
143 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
143 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p> |
|
144 | 144 | <?php |
145 | 145 | return; |
146 | 146 | } |
147 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
148 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
149 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
147 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
148 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
149 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
150 | 150 | $payments = $subscription->get_child_payments(); |
151 | 151 | ?> |
152 | 152 | <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
153 | - <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
153 | + <?php if (!empty($subscription) && !empty($subscription->id)) { ?> |
|
154 | 154 | <p class="wpi-meta-row wpi-sub-id"> |
155 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
155 | + <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
156 | 156 | <?php } ?> |
157 | 157 | <p class="wpi-meta-row wpi-bill-cycle"> |
158 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
158 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?> |
|
159 | 159 | </p> |
160 | 160 | <p class="wpi-meta-row wpi-billed-times"> |
161 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
161 | + <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
162 | 162 | </p> |
163 | 163 | <p class="wpi-meta-row wpi-start-date"> |
164 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
164 | + <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
165 | 165 | </p> |
166 | 166 | <p class="wpi-meta-row wpi-end-date"> |
167 | - <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
167 | + <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
168 | 168 | </p> |
169 | - <?php if ( $subscription->status ) { ?> |
|
169 | + <?php if ($subscription->status) { ?> |
|
170 | 170 | <p class="wpi-meta-row wpi-sub-status"> |
171 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
171 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
172 | 172 | </p> |
173 | 173 | <?php } ?> |
174 | - <?php if ( !empty( $payments ) ) { ?> |
|
175 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
174 | + <?php if (!empty($payments)) { ?> |
|
175 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
176 | 176 | <ul id="wpi-sub-payments"> |
177 | - <?php foreach ( $payments as $payment ) { |
|
177 | + <?php foreach ($payments as $payment) { |
|
178 | 178 | $invoice_id = $payment->ID; |
179 | 179 | ?> |
180 | 180 | <li> |
181 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
182 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
183 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
181 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
182 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
183 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
184 | 184 | </li> |
185 | 185 | <?php } ?> |
186 | 186 | </ul> |
@@ -188,50 +188,50 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - public static function renewals( $post ) { |
|
192 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
191 | + public static function renewals($post) { |
|
192 | + $invoice = wpinv_get_invoice($post->ID); |
|
193 | 193 | |
194 | - if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
195 | - $parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
196 | - $parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
197 | - $subscription = wpinv_get_subscription( $invoice ); |
|
194 | + if (wpinv_is_subscription_payment($invoice)) { |
|
195 | + $parent_url = get_edit_post_link($invoice->parent_invoice); |
|
196 | + $parent_id = wpinv_get_invoice_number($invoice->parent_invoice); |
|
197 | + $subscription = wpinv_get_subscription($invoice); |
|
198 | 198 | ?> |
199 | - <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
199 | + <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
200 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - public static function payment_meta( $post ) { |
|
205 | + public static function payment_meta($post) { |
|
206 | 206 | global $wpi_mb_invoice; |
207 | 207 | |
208 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
209 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
208 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
209 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
210 | 210 | $set_dateway = true; |
211 | 211 | } |
212 | 212 | |
213 | 213 | ?> |
214 | 214 | <p class="wpi-meta-row"> |
215 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
216 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
215 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
216 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
217 | 217 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
218 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
219 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
218 | + <?php foreach ($gateways as $name => $gateway) { |
|
219 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | ?> |
223 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
223 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
224 | 224 | <?php } ?> |
225 | 225 | </select> |
226 | 226 | <?php } else { |
227 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) ); |
|
227 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway)); |
|
228 | 228 | } ?> |
229 | 229 | </p> |
230 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
231 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
230 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
231 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
232 | 232 | <?php } ?> |
233 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
234 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
233 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
234 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
235 | 235 | <?php } ?> |
236 | 236 | <?php |
237 | 237 | } |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if ( ! empty( $_GET['id'] ) ) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
15 | - return; |
|
15 | + return; |
|
16 | 16 | |
17 | - } |
|
18 | - ?> |
|
17 | + } |
|
18 | + ?> |
|
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
23 | 23 | </h1> |
24 | 24 | <?php |
25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | - $subscribers_table->prepare_items(); |
|
27 | - ?> |
|
25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
26 | + $subscribers_table->prepare_items(); |
|
27 | + ?> |
|
28 | 28 | |
29 | 29 | <form id="subscribers-filter" method="get"> |
30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
47 | 47 | */ |
48 | 48 | function wpinv_recurring_subscription_details() { |
49 | 49 | |
50 | - $render = true; |
|
50 | + $render = true; |
|
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | - } |
|
52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
54 | + } |
|
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int) $_GET['id']; |
|
61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | - } |
|
63 | + if ( empty( $sub ) ) { |
|
64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - ?> |
|
67 | + ?> |
|
68 | 68 | <div class="wrap"> |
69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | - ?> |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
95 | + ?> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | ?> |
136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
137 | - 'post' => $sub->product_id, |
|
138 | - 'action' => 'edit' |
|
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
137 | + 'post' => $sub->product_id, |
|
138 | + 'action' => 'edit' |
|
139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
@@ -299,58 +299,58 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
303 | - return; |
|
304 | - } |
|
302 | + if( empty( $_POST['sub_id'] ) ) { |
|
303 | + return; |
|
304 | + } |
|
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | - return; |
|
308 | - } |
|
306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | - return; |
|
312 | - } |
|
310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
311 | + return; |
|
312 | + } |
|
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | - } |
|
314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
316 | + } |
|
317 | 317 | |
318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | - $product_id = absint( $_POST['product_id'] ); |
|
322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | - $subscription->update( array( |
|
324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
325 | - 'expiration' => $expiration, |
|
326 | - 'profile_id' => $profile_id, |
|
327 | - 'product_id' => $product_id, |
|
328 | - 'transaction_id' => $transaction_id, |
|
329 | - ) ); |
|
318 | + $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | + $product_id = absint( $_POST['product_id'] ); |
|
322 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | + $subscription->update( array( |
|
324 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
325 | + 'expiration' => $expiration, |
|
326 | + 'profile_id' => $profile_id, |
|
327 | + 'product_id' => $product_id, |
|
328 | + 'transaction_id' => $transaction_id, |
|
329 | + ) ); |
|
330 | 330 | |
331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
331 | + $status = sanitize_text_field( $_POST['status'] ); |
|
332 | 332 | |
333 | - switch( $status ) { |
|
333 | + switch( $status ) { |
|
334 | 334 | |
335 | - case 'cancelled' : |
|
335 | + case 'cancelled' : |
|
336 | 336 | |
337 | - $subscription->cancel(); |
|
338 | - break; |
|
337 | + $subscription->cancel(); |
|
338 | + break; |
|
339 | 339 | |
340 | - case 'expired' : |
|
340 | + case 'expired' : |
|
341 | 341 | |
342 | - $subscription->expire(); |
|
343 | - break; |
|
342 | + $subscription->expire(); |
|
343 | + break; |
|
344 | 344 | |
345 | - case 'completed' : |
|
345 | + case 'completed' : |
|
346 | 346 | |
347 | - $subscription->complete(); |
|
348 | - break; |
|
347 | + $subscription->complete(); |
|
348 | + break; |
|
349 | 349 | |
350 | - } |
|
350 | + } |
|
351 | 351 | |
352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
353 | - exit; |
|
352 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
353 | + exit; |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -364,30 +364,30 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
366 | 366 | |
367 | - if( empty( $_POST['sub_id'] ) ) { |
|
368 | - return; |
|
369 | - } |
|
367 | + if( empty( $_POST['sub_id'] ) ) { |
|
368 | + return; |
|
369 | + } |
|
370 | 370 | |
371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
372 | - return; |
|
373 | - } |
|
371 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
372 | + return; |
|
373 | + } |
|
374 | 374 | |
375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
376 | - return; |
|
377 | - } |
|
375 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
376 | + return; |
|
377 | + } |
|
378 | 378 | |
379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
381 | - } |
|
379 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
381 | + } |
|
382 | 382 | |
383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
383 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
384 | 384 | |
385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
385 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
386 | 386 | |
387 | - $subscription->delete(); |
|
387 | + $subscription->delete(); |
|
388 | 388 | |
389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
390 | - exit; |
|
389 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
390 | + exit; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -180,8 +180,11 @@ discard block |
||
180 | 180 | <label for="tablecell"> |
181 | 181 | <?php if( 'trialling' == $sub->status ) : ?> |
182 | 182 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
183 | - <?php else: ?> |
|
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
183 | + <?php else { |
|
184 | + : ?> |
|
185 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
186 | +} |
|
187 | +?> |
|
185 | 188 | <?php endif; ?> |
186 | 189 | </label> |
187 | 190 | </td> |
@@ -251,7 +254,10 @@ discard block |
||
251 | 254 | </thead> |
252 | 255 | <tbody> |
253 | 256 | <?php if ( ! empty( $payments ) ) : ?> |
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
257 | + <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) { |
|
258 | + continue; |
|
259 | +} |
|
260 | +?> |
|
255 | 261 | <tr> |
256 | 262 | <td><?php echo $payment->ID; ?></td> |
257 | 263 | <td><?php echo $invoice->get_total( true ); ?></td> |
@@ -268,9 +274,12 @@ discard block |
||
268 | 274 | </td> |
269 | 275 | </tr> |
270 | 276 | <?php endforeach; ?> |
271 | - <?php else: ?> |
|
277 | + <?php else { |
|
278 | + : ?> |
|
272 | 279 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
280 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
281 | +} |
|
282 | +?></td> |
|
274 | 283 | </tr> |
275 | 284 | <?php endif; ?> |
276 | 285 | </tbody> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | function wpinv_subscriptions_page() { |
10 | 10 | |
11 | - if ( ! empty( $_GET['id'] ) ) { |
|
11 | + if (!empty($_GET['id'])) { |
|
12 | 12 | |
13 | 13 | wpinv_recurring_subscription_details(); |
14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <div class="wrap"> |
20 | 20 | |
21 | 21 | <h1> |
22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
23 | 23 | </h1> |
24 | 24 | <?php |
25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <input type="hidden" name="post_type" value="download" /> |
32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
33 | 33 | <?php $subscribers_table->views(); ?> |
34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
35 | 35 | <?php $subscribers_table->display(); ?> |
36 | 36 | |
37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
49 | 49 | |
50 | 50 | $render = true; |
51 | 51 | |
52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
52 | + if (!current_user_can('manage_invoicing')) { |
|
53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
54 | 54 | } |
55 | 55 | |
56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
58 | 58 | } |
59 | 59 | |
60 | - $sub_id = (int) $_GET['id']; |
|
61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
60 | + $sub_id = (int)$_GET['id']; |
|
61 | + $sub = new WPInv_Subscription($sub_id); |
|
62 | 62 | |
63 | - if ( empty( $sub ) ) { |
|
64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
63 | + if (empty($sub)) { |
|
64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | ?> |
68 | 68 | <div class="wrap"> |
69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
70 | 70 | |
71 | - <?php if ( $sub ) : ?> |
|
71 | + <?php if ($sub) : ?> |
|
72 | 72 | |
73 | 73 | <div id="wpinv-item-card-wrapper"> |
74 | 74 | |
75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
76 | 76 | |
77 | 77 | <div class="info-wrapper item-section"> |
78 | 78 | |
79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
80 | 80 | |
81 | 81 | <div class="item-info"> |
82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td class="row-title"> |
87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
88 | 88 | </td> |
89 | 89 | <td> |
90 | 90 | <?php |
91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
95 | 95 | ?> |
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <tr> |
99 | 99 | <td class="row-title"> |
100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
101 | 101 | </td> |
102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
103 | 103 | </tr> |
104 | 104 | <tr> |
105 | 105 | <td class="row-title"> |
106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
107 | 107 | </td> |
108 | 108 | <td> |
109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
110 | - <a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
110 | + <a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
111 | 111 | </td> |
112 | 112 | </tr> |
113 | 113 | <tr> |
114 | 114 | <td class="row-title"> |
115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
116 | 116 | </td> |
117 | 117 | <td> |
118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
119 | 119 | </tr> |
120 | 120 | <tr> |
121 | 121 | <td class="row-title"> |
122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
123 | 123 | </td> |
124 | 124 | <td> |
125 | 125 | <?php |
126 | - echo wpinv_item_dropdown( array( |
|
126 | + echo wpinv_item_dropdown(array( |
|
127 | 127 | 'name' => 'product_id', |
128 | 128 | 'id' => 'wpinv_invoice_item', |
129 | 129 | 'with_packages' => false, |
130 | 130 | 'show_recurring' => true, |
131 | 131 | 'selected' => $sub->product_id, |
132 | 132 | 'class' => 'wpinv-sub-product-id', |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | |
135 | 135 | ?> |
136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
137 | 137 | 'post' => $sub->product_id, |
138 | 138 | 'action' => 'edit' |
139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
140 | 140 | </td> |
141 | 141 | </tr> |
142 | 142 | <tr> |
143 | 143 | <td class="row-title"> |
144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
145 | 145 | </td> |
146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
147 | 147 | </tr> |
148 | 148 | <tr> |
149 | 149 | <td class="row-title"> |
150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
151 | 151 | </td> |
152 | 152 | <td> |
153 | 153 | <span class="wpinv-sub-profile-id"> |
154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
155 | 155 | </span> |
156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
157 | 157 | <span> – </span> |
158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | <tr> |
162 | 162 | <td class="row-title"> |
163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
164 | 164 | </td> |
165 | 165 | <td> |
166 | - <span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span> |
|
167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
166 | + <span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span> |
|
167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
168 | 168 | <span> – </span> |
169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
170 | 170 | </td> |
171 | 171 | </tr> |
172 | 172 | <tr> |
173 | 173 | <td class="row-title"> |
174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
175 | 175 | </td> |
176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
177 | 177 | </tr> |
178 | 178 | <tr> |
179 | 179 | <td class="row-title"> |
180 | 180 | <label for="tablecell"> |
181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
181 | + <?php if ('trialling' == $sub->status) : ?> |
|
182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
183 | 183 | <?php else: ?> |
184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
185 | 185 | <?php endif; ?> |
186 | 186 | </label> |
187 | 187 | </td> |
188 | 188 | <td> |
189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
190 | 190 | </td> |
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <td class="row-title"> |
194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
195 | 195 | </td> |
196 | 196 | <td> |
197 | 197 | <select name="status"> |
198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
205 | 205 | </select> |
206 | 206 | </td> |
207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
209 | 209 | </table> |
210 | 210 | </div> |
211 | 211 | <div id="wpinv-sub-notices"> |
212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
214 | 214 | </div> |
215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
219 | - <?php if( $sub->can_cancel() ) : ?> |
|
220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
219 | + <?php if ($sub->can_cancel()) : ?> |
|
220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
221 | 221 | <?php endif; ?> |
222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | </form> |
226 | 226 | </div> |
227 | 227 | |
228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
229 | 229 | |
230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
231 | 231 | |
232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
233 | 233 | |
234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
235 | 235 | |
236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
240 | 240 | <?php endif; ?> |
241 | 241 | <table class="wp-list-table widefat striped payments"> |
242 | 242 | <thead> |
243 | 243 | <tr> |
244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
250 | 250 | </tr> |
251 | 251 | </thead> |
252 | 252 | <tbody> |
253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
253 | + <?php if (!empty($payments)) : ?> |
|
254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
255 | 255 | <tr> |
256 | 256 | <td><?php echo $payment->ID; ?></td> |
257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
260 | 260 | <td> |
261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
263 | 263 | </td> |
264 | 264 | <td class="column-wpi_actions"> |
265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
266 | 266 | </a> |
267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
268 | 268 | </td> |
269 | 269 | </tr> |
270 | 270 | <?php endforeach; ?> |
271 | 271 | <?php else: ?> |
272 | 272 | <tr> |
273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
274 | 274 | </tr> |
275 | 275 | <?php endif; ?> |
276 | 276 | </tbody> |
277 | 277 | <tfoot></tfoot> |
278 | 278 | </table> |
279 | 279 | |
280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
285 | 285 | </div> |
286 | 286 | |
287 | 287 | <?php endif; ?> |
@@ -299,38 +299,38 @@ discard block |
||
299 | 299 | */ |
300 | 300 | function wpinv_recurring_process_subscription_update() { |
301 | 301 | |
302 | - if( empty( $_POST['sub_id'] ) ) { |
|
302 | + if (empty($_POST['sub_id'])) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
310 | + if (!current_user_can('manage_invoicing')) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
316 | 316 | } |
317 | 317 | |
318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
321 | - $product_id = absint( $_POST['product_id'] ); |
|
322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
323 | - $subscription->update( array( |
|
324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
318 | + $expiration = date('Y-m-d 23:59:59', strtotime($_POST['expiration'])); |
|
319 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
320 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
321 | + $product_id = absint($_POST['product_id']); |
|
322 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
323 | + $subscription->update(array( |
|
324 | + 'status' => sanitize_text_field($_POST['status']), |
|
325 | 325 | 'expiration' => $expiration, |
326 | 326 | 'profile_id' => $profile_id, |
327 | 327 | 'product_id' => $product_id, |
328 | 328 | 'transaction_id' => $transaction_id, |
329 | - ) ); |
|
329 | + )); |
|
330 | 330 | |
331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
331 | + $status = sanitize_text_field($_POST['status']); |
|
332 | 332 | |
333 | - switch( $status ) { |
|
333 | + switch ($status) { |
|
334 | 334 | |
335 | 335 | case 'cancelled' : |
336 | 336 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
352 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
353 | 353 | exit; |
354 | 354 | |
355 | 355 | } |
356 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
356 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Handles subscription deletion |
@@ -364,30 +364,30 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
366 | 366 | |
367 | - if( empty( $_POST['sub_id'] ) ) { |
|
367 | + if (empty($_POST['sub_id'])) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
371 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
375 | + if (!current_user_can('manage_invoicing')) { |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
379 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
380 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
381 | 381 | } |
382 | 382 | |
383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
383 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
384 | 384 | |
385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
385 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
386 | 386 | |
387 | 387 | $subscription->delete(); |
388 | 388 | |
389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
389 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
390 | 390 | exit; |
391 | 391 | |
392 | 392 | } |
393 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
393 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,92 +72,92 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
226 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
281 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
314 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
351 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |
@@ -176,69 +176,69 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | - global $wpinv_options, $pagenow, $post; |
|
179 | + global $wpinv_options, $pagenow, $post; |
|
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | - } |
|
181 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
183 | + } |
|
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | - } |
|
185 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
187 | + } |
|
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | - } |
|
189 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
191 | + } |
|
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | - } |
|
193 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
195 | + } |
|
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | - } |
|
197 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
199 | + } |
|
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | - } |
|
201 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
203 | + } |
|
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | - } |
|
205 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
207 | + } |
|
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
214 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
218 | 218 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | - } |
|
221 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | - } |
|
225 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
227 | + } |
|
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | - } |
|
229 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
231 | + } |
|
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | - } |
|
239 | - } |
|
236 | + if ( !empty( $message ) ) { |
|
237 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors( 'wpinv-notices' ); |
|
242 | 242 | } |
243 | 243 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
244 | 244 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
304 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
305 | 305 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
306 | 306 | if ( $wpinv_euvat->allow_vat_rules() ) { |
307 | 307 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,264 +7,264 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
83 | - $time_format = get_option( 'time_format' ); |
|
84 | - $date_time_format = $date_format . ' '. $time_format; |
|
82 | + $date_format = get_option('date_format'); |
|
83 | + $time_format = get_option('time_format'); |
|
84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
85 | 85 | |
86 | - $t_time = get_the_time( $date_time_format ); |
|
86 | + $t_time = get_the_time($date_time_format); |
|
87 | 87 | $m_time = $post->post_date; |
88 | - $h_time = mysql2date( $date_format, $m_time ); |
|
88 | + $h_time = mysql2date($date_format, $m_time); |
|
89 | 89 | |
90 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
90 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
91 | 91 | break; |
92 | 92 | case 'payment_date' : |
93 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
94 | - $date_format = get_option( 'date_format' ); |
|
95 | - $time_format = get_option( 'time_format' ); |
|
96 | - $date_time_format = $date_format . ' '. $time_format; |
|
93 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
94 | + $date_format = get_option('date_format'); |
|
95 | + $time_format = get_option('time_format'); |
|
96 | + $date_time_format = $date_format . ' ' . $time_format; |
|
97 | 97 | |
98 | - $t_time = get_the_time( $date_time_format ); |
|
98 | + $t_time = get_the_time($date_time_format); |
|
99 | 99 | $m_time = $date_completed; |
100 | - $h_time = mysql2date( $date_format, $m_time ); |
|
100 | + $h_time = mysql2date($date_format, $m_time); |
|
101 | 101 | |
102 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
102 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
103 | 103 | } else { |
104 | 104 | $value = '-'; |
105 | 105 | } |
106 | 106 | break; |
107 | 107 | case 'status' : |
108 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
109 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
110 | - if ( 1 == $is_viewed ) { |
|
111 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
108 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
109 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
110 | + if (1 == $is_viewed) { |
|
111 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
112 | 112 | } |
113 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) { |
|
114 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
113 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) { |
|
114 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
115 | 115 | } |
116 | 116 | break; |
117 | 117 | case 'number' : |
118 | - $edit_link = get_edit_post_link( $post->ID ); |
|
119 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | + $edit_link = get_edit_post_link($post->ID); |
|
119 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
120 | 120 | break; |
121 | 121 | case 'wpi_actions' : |
122 | 122 | $value = ''; |
123 | - if ( !empty( $post->post_name ) ) { |
|
124 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
123 | + if (!empty($post->post_name)) { |
|
124 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( $email = $wpi_invoice->get_email() ) { |
|
128 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
127 | + if ($email = $wpi_invoice->get_email()) { |
|
128 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | break; |
132 | 132 | default: |
133 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
133 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
134 | 134 | break; |
135 | 135 | |
136 | 136 | } |
137 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
137 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
138 | 138 | |
139 | - if ( $value !== NULL ) { |
|
139 | + if ($value !== NULL) { |
|
140 | 140 | echo $value; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | -function wpinv_admin_post_id( $id = 0 ) { |
|
144 | +function wpinv_admin_post_id($id = 0) { |
|
145 | 145 | global $post; |
146 | 146 | |
147 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
147 | + if (isset($id) && !empty($id)) { |
|
148 | 148 | return (int)$id; |
149 | - } else if ( get_the_ID() ) { |
|
150 | - return (int) get_the_ID(); |
|
151 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
152 | - return (int) $post->ID; |
|
153 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
154 | - return (int) $_GET['post']; |
|
155 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
156 | - return (int) $_GET['id']; |
|
157 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
158 | - return (int) $_POST['id']; |
|
149 | + } else if (get_the_ID()) { |
|
150 | + return (int)get_the_ID(); |
|
151 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
152 | + return (int)$post->ID; |
|
153 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
154 | + return (int)$_GET['post']; |
|
155 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
156 | + return (int)$_GET['id']; |
|
157 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
158 | + return (int)$_POST['id']; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_admin_post_type( $id = 0 ) { |
|
165 | - if ( !$id ) { |
|
164 | +function wpinv_admin_post_type($id = 0) { |
|
165 | + if (!$id) { |
|
166 | 166 | $id = wpinv_admin_post_id(); |
167 | 167 | } |
168 | 168 | |
169 | - $type = get_post_type( $id ); |
|
169 | + $type = get_post_type($id); |
|
170 | 170 | |
171 | - if ( !$type ) { |
|
172 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
171 | + if (!$type) { |
|
172 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
173 | 173 | } |
174 | 174 | |
175 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
175 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | function wpinv_admin_messages() { |
179 | 179 | global $wpinv_options, $pagenow, $post; |
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
181 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
182 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
185 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
186 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
189 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
190 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
193 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
194 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
197 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
198 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
201 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
202 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
205 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
206 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
210 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
210 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
214 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
213 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
214 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
215 | 215 | } |
216 | 216 | |
217 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
218 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
217 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
218 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
219 | 219 | } |
220 | 220 | |
221 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
222 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
221 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
222 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
226 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
225 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
226 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
230 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
229 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
230 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
234 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
234 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
235 | 235 | |
236 | - if ( !empty( $message ) ) { |
|
237 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
236 | + if (!empty($message)) { |
|
237 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - settings_errors( 'wpinv-notices' ); |
|
241 | + settings_errors('wpinv-notices'); |
|
242 | 242 | } |
243 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
243 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
244 | 244 | |
245 | -function wpinv_items_columns( $existing_columns ) { |
|
245 | +function wpinv_items_columns($existing_columns) { |
|
246 | 246 | global $wpinv_euvat; |
247 | 247 | |
248 | 248 | $columns = array(); |
249 | 249 | $columns['cb'] = $existing_columns['cb']; |
250 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
251 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
252 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
253 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
250 | + $columns['title'] = __('Title', 'invoicing'); |
|
251 | + $columns['price'] = __('Price', 'invoicing'); |
|
252 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
253 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
254 | 254 | } |
255 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
256 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
255 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
256 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
257 | 257 | } |
258 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
259 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
260 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
261 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
258 | + $columns['type'] = __('Type', 'invoicing'); |
|
259 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
260 | + $columns['date'] = __('Date', 'invoicing'); |
|
261 | + $columns['id'] = __('ID', 'invoicing'); |
|
262 | 262 | |
263 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
263 | + return apply_filters('wpinv_items_columns', $columns); |
|
264 | 264 | } |
265 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
265 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
266 | 266 | |
267 | -function wpinv_items_sortable_columns( $columns ) { |
|
267 | +function wpinv_items_sortable_columns($columns) { |
|
268 | 268 | $columns['price'] = 'price'; |
269 | 269 | $columns['vat_rule'] = 'vat_rule'; |
270 | 270 | $columns['vat_class'] = 'vat_class'; |
@@ -274,151 +274,151 @@ discard block |
||
274 | 274 | |
275 | 275 | return $columns; |
276 | 276 | } |
277 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
277 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
278 | 278 | |
279 | -function wpinv_items_table_custom_column( $column ) { |
|
279 | +function wpinv_items_table_custom_column($column) { |
|
280 | 280 | global $wpinv_euvat, $post, $wpi_item; |
281 | 281 | |
282 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
283 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
282 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
283 | + $wpi_item = new WPInv_Item($post->ID); |
|
284 | 284 | } |
285 | 285 | |
286 | - switch ( $column ) { |
|
286 | + switch ($column) { |
|
287 | 287 | case 'price' : |
288 | - echo wpinv_item_price( $post->ID ); |
|
288 | + echo wpinv_item_price($post->ID); |
|
289 | 289 | break; |
290 | 290 | case 'vat_rule' : |
291 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
291 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
292 | 292 | break; |
293 | 293 | case 'vat_class' : |
294 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
294 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
295 | 295 | break; |
296 | 296 | case 'type' : |
297 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
297 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
298 | 298 | break; |
299 | 299 | case 'recurring' : |
300 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
300 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
301 | 301 | break; |
302 | 302 | case 'id' : |
303 | 303 | echo $post->ID; |
304 | 304 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
305 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
306 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
307 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
305 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
306 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
307 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
308 | 308 | } |
309 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
310 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
309 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
310 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
311 | 311 | } |
312 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
312 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
313 | 313 | </div>'; |
314 | 314 | break; |
315 | 315 | } |
316 | 316 | |
317 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
317 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
318 | 318 | } |
319 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
319 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
320 | 320 | |
321 | 321 | function wpinv_add_items_filters() { |
322 | 322 | global $wpinv_euvat, $typenow; |
323 | 323 | |
324 | 324 | // Checks if the current post type is 'item' |
325 | - if ( $typenow == 'wpi_item') { |
|
326 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
327 | - echo wpinv_html_select( array( |
|
328 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
325 | + if ($typenow == 'wpi_item') { |
|
326 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
327 | + echo wpinv_html_select(array( |
|
328 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
329 | 329 | 'name' => 'vat_rule', |
330 | 330 | 'id' => 'vat_rule', |
331 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
331 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
332 | 332 | 'show_option_all' => false, |
333 | 333 | 'show_option_none' => false, |
334 | 334 | 'class' => 'gdmbx2-text-medium', |
335 | - ) ); |
|
335 | + )); |
|
336 | 336 | } |
337 | 337 | |
338 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
339 | - echo wpinv_html_select( array( |
|
340 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
338 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
339 | + echo wpinv_html_select(array( |
|
340 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
341 | 341 | 'name' => 'vat_class', |
342 | 342 | 'id' => 'vat_class', |
343 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
343 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | 346 | 'class' => 'gdmbx2-text-medium', |
347 | - ) ); |
|
347 | + )); |
|
348 | 348 | } |
349 | 349 | |
350 | - echo wpinv_html_select( array( |
|
351 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
350 | + echo wpinv_html_select(array( |
|
351 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
352 | 352 | 'name' => 'type', |
353 | 353 | 'id' => 'type', |
354 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
354 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
355 | 355 | 'show_option_all' => false, |
356 | 356 | 'show_option_none' => false, |
357 | 357 | 'class' => 'gdmbx2-text-medium', |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
360 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
361 | 361 | echo '<input type="hidden" name="all_posts" value="1" />'; |
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
365 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
365 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
366 | 366 | |
367 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
368 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
367 | +function wpinv_send_invoice_after_save($invoice) { |
|
368 | + if (empty($_POST['wpi_save_send'])) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
373 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
372 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
373 | + wpinv_user_invoice_notification($invoice->ID); |
|
374 | 374 | } |
375 | 375 | } |
376 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
376 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
377 | 377 | |
378 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
379 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
380 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
381 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
378 | +function wpinv_send_register_new_user($data, $postarr) { |
|
379 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
380 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
381 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
382 | 382 | |
383 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
384 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
385 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
386 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
387 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
388 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
383 | + if ($is_new_user && $email && !email_exists($email)) { |
|
384 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
385 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
386 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
387 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
388 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
389 | 389 | |
390 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
391 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
390 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
391 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
392 | 392 | $new_user_login = strstr($email, '@', true); |
393 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
394 | - $user_login = sanitize_user($new_user_login, true ); |
|
393 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
394 | + $user_login = sanitize_user($new_user_login, true); |
|
395 | 395 | } |
396 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
397 | - $user_append_text = rand(10,1000); |
|
398 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
396 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
397 | + $user_append_text = rand(10, 1000); |
|
398 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
401 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
402 | 402 | $user_login = $email; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | 406 | $userdata = array( |
407 | 407 | 'user_login' => $user_login, |
408 | - 'user_pass' => wp_generate_password( 12, false ), |
|
409 | - 'user_email' => sanitize_text_field( $email ), |
|
408 | + 'user_pass' => wp_generate_password(12, false), |
|
409 | + 'user_email' => sanitize_text_field($email), |
|
410 | 410 | 'first_name' => $first_name, |
411 | 411 | 'last_name' => $last_name, |
412 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
412 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
413 | 413 | 'nickname' => $display_name, |
414 | 414 | 'display_name' => $display_name, |
415 | 415 | ); |
416 | 416 | |
417 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
417 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
418 | 418 | |
419 | - $new_user_id = wp_insert_user( $userdata ); |
|
419 | + $new_user_id = wp_insert_user($userdata); |
|
420 | 420 | |
421 | - if ( !is_wp_error( $new_user_id ) ) { |
|
421 | + if (!is_wp_error($new_user_id)) { |
|
422 | 422 | $data['post_author'] = $new_user_id; |
423 | 423 | $_POST['post_author'] = $new_user_id; |
424 | 424 | $_POST['post_author_override'] = $new_user_id; |
@@ -439,69 +439,69 @@ discard block |
||
439 | 439 | |
440 | 440 | $meta = array(); |
441 | 441 | ///$meta['_wpinv_user_id'] = $new_user_id; |
442 | - foreach ( $meta_fields as $field ) { |
|
443 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
442 | + foreach ($meta_fields as $field) { |
|
443 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
444 | 444 | } |
445 | 445 | |
446 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
446 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
447 | 447 | |
448 | 448 | // Update user meta. |
449 | - foreach ( $meta as $key => $value ) { |
|
450 | - update_user_meta( $new_user_id, $key, $value ); |
|
449 | + foreach ($meta as $key => $value) { |
|
450 | + update_user_meta($new_user_id, $key, $value); |
|
451 | 451 | } |
452 | 452 | |
453 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
453 | + if (function_exists('wp_send_new_user_notifications')) { |
|
454 | 454 | // Send email notifications related to the creation of new user. |
455 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
455 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
456 | 456 | } |
457 | 457 | } else { |
458 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
458 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | 463 | return $data; |
464 | 464 | } |
465 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
465 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
466 | 466 | |
467 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
467 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
468 | 468 | $all_gateways = wpinv_get_payment_gateways(); |
469 | 469 | |
470 | - if ( !empty( $all_gateways ) ) { |
|
470 | + if (!empty($all_gateways)) { |
|
471 | 471 | $gateways = array(); |
472 | 472 | |
473 | - foreach ( $all_gateways as $key => $gateway ) { |
|
474 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
473 | + foreach ($all_gateways as $key => $gateway) { |
|
474 | + if (wpinv_gateway_support_subscription($key)) { |
|
475 | 475 | $gateways[] = $gateway['admin_label']; |
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | - if ( !empty( $gateways ) ) { |
|
479 | + if (!empty($gateways)) { |
|
480 | 480 | ?> |
481 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
481 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
482 | 482 | <?php |
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
486 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
487 | 487 | |
488 | -function wpinv_post_updated_messages( $messages ) { |
|
488 | +function wpinv_post_updated_messages($messages) { |
|
489 | 489 | global $post, $post_ID; |
490 | 490 | |
491 | 491 | $messages['wpi_discount'] = array( |
492 | 492 | 0 => '', |
493 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
494 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
495 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
496 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
497 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
498 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
499 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
500 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
501 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
502 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
493 | + 1 => __('Discount updated.', 'invoicing'), |
|
494 | + 2 => __('Custom field updated.', 'invoicing'), |
|
495 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
496 | + 4 => __('Discount updated.', 'invoicing'), |
|
497 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
498 | + 6 => __('Discount updated.', 'invoicing'), |
|
499 | + 7 => __('Discount saved.', 'invoicing'), |
|
500 | + 8 => __('Discount submitted.', 'invoicing'), |
|
501 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
502 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
503 | 503 | ); |
504 | 504 | |
505 | 505 | return $messages; |
506 | 506 | } |
507 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
508 | 507 | \ No newline at end of file |
508 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
509 | 509 | \ No newline at end of file |
@@ -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 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,61 +133,61 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <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> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <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> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <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'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <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']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?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' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?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'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?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 ); ?> |
|
159 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
158 | + <?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); ?> |
|
159 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
162 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
161 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
162 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
165 | - <?php echo $invoice->get_total( true ); ?> |
|
164 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
165 | + <?php echo $invoice->get_total(true); ?> |
|
166 | 166 | |
167 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
167 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
168 | 168 | <?php |
169 | 169 | $actions = array( |
170 | 170 | 'pay' => array( |
171 | 171 | 'url' => $invoice->get_checkout_payment_url(), |
172 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
172 | + 'name' => __('Pay Now', 'invoicing'), |
|
173 | 173 | 'class' => 'btn-success' |
174 | 174 | ), |
175 | 175 | 'print' => array( |
176 | 176 | 'url' => $invoice->get_view_url(), |
177 | - 'name' => __( 'Print', 'invoicing' ), |
|
177 | + 'name' => __('Print', 'invoicing'), |
|
178 | 178 | 'class' => 'btn-primary', |
179 | 179 | 'attrs' => 'target="_blank"' |
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->needs_payment() ) { |
|
184 | - unset( $actions['pay'] ); |
|
183 | + if (!$invoice->needs_payment()) { |
|
184 | + unset($actions['pay']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
188 | - foreach ( $actions as $key => $action ) { |
|
187 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
188 | + foreach ($actions as $key => $action) { |
|
189 | 189 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
190 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
190 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | ?> |
@@ -215,64 +215,64 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | <?php |
217 | 217 | |
218 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
218 | + do_action('wpinv_bp_invoices_after_content'); |
|
219 | 219 | } else { |
220 | 220 | ?> |
221 | 221 | <div id="message" class="info"> |
222 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
222 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
223 | 223 | </div> |
224 | 224 | <?php |
225 | 225 | } |
226 | 226 | |
227 | - if ( defined( 'DOING_AJAX' ) ) { |
|
227 | + if (defined('DOING_AJAX')) { |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - public function has_invoices( $args = '' ) { |
|
232 | + public function has_invoices($args = '') { |
|
233 | 233 | global $invoices_template; |
234 | 234 | |
235 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
235 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
236 | 236 | // Parse arguments. |
237 | - $r = bp_parse_args( $args, array( |
|
237 | + $r = bp_parse_args($args, array( |
|
238 | 238 | 'status' => 'all', |
239 | 239 | 'page_arg' => 'bpage', |
240 | 240 | 'page' => 1, |
241 | 241 | 'per_page' => $per_page > 0 ? $per_page : 20, |
242 | 242 | 'max' => false, |
243 | 243 | 'user_id' => bp_loggedin_user_id(), |
244 | - ), 'has_invoices' ); |
|
244 | + ), 'has_invoices'); |
|
245 | 245 | |
246 | 246 | |
247 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
247 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
248 | 248 | $r['per_page'] = (int)$r['max']; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Get the invoices. |
252 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
252 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
253 | 253 | |
254 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
254 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | public function setup_invoice_count() { |
258 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
259 | - $invoices = wpinv_get_invoices( $query ); |
|
258 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
259 | + $invoices = wpinv_get_invoices($query); |
|
260 | 260 | |
261 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
261 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public function pagination_count() { |
265 | 265 | global $invoices_template; |
266 | 266 | |
267 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
268 | - $from_num = bp_core_number_format( $start_num ); |
|
269 | - $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 ) ); |
|
270 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
267 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
268 | + $from_num = bp_core_number_format($start_num); |
|
269 | + $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)); |
|
270 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
271 | 271 | |
272 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
273 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
272 | + if (1 == $invoices_template->total_invoice_count) { |
|
273 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
274 | 274 | } else { |
275 | - $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 ); |
|
275 | + $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); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $message; |
@@ -281,32 +281,32 @@ discard block |
||
281 | 281 | function pagination_links() { |
282 | 282 | global $invoices_template; |
283 | 283 | |
284 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
284 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
285 | 285 | } |
286 | 286 | |
287 | - public function bp_section( $settings = array() ) { |
|
288 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
287 | + public function bp_section($settings = array()) { |
|
288 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
289 | 289 | return $settings; |
290 | 290 | } |
291 | 291 | |
292 | - public function bp_settings( $settings = array() ) { |
|
292 | + public function bp_settings($settings = array()) { |
|
293 | 293 | $settings['wpinv_bp'] = array( |
294 | 294 | 'wpinv_bp_labels' => array( |
295 | 295 | 'id' => 'wpinv_bp_settings', |
296 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
296 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
297 | 297 | 'desc' => '', |
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | 'wpinv_bp_hide_menu' => array( |
301 | 301 | 'id' => 'wpinv_bp_hide_menu', |
302 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
303 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
302 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
303 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
304 | 304 | 'type' => 'checkbox', |
305 | 305 | ), |
306 | 306 | 'wpinv_menu_position' => array( |
307 | 307 | 'id' => 'wpinv_menu_position', |
308 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
309 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
308 | + 'name' => __('Menu position', 'invoicing'), |
|
309 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
310 | 310 | 'type' => 'number', |
311 | 311 | 'size' => 'small', |
312 | 312 | 'min' => '1', |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | ), |
317 | 317 | 'wpinv_bp_per_page' => array( |
318 | 318 | 'id' => 'wpinv_bp_per_page', |
319 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
320 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
319 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
320 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
321 | 321 | 'type' => 'number', |
322 | 322 | 'size' => 'small', |
323 | 323 | 'min' => '1', |
@@ -342,25 +342,25 @@ discard block |
||
342 | 342 | public $pag_links = ''; |
343 | 343 | public $total_invoice_count = 0; |
344 | 344 | |
345 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
346 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
345 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
346 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
347 | 347 | |
348 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
349 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
350 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
348 | + $this->pag_arg = sanitize_key($page_arg); |
|
349 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
350 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
351 | 351 | |
352 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
353 | - if ( !empty( $status ) && $status != 'all' ) { |
|
352 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
353 | + if (!empty($status) && $status != 'all') { |
|
354 | 354 | $query_args['status'] = $status; |
355 | 355 | } |
356 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
356 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
357 | 357 | |
358 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
359 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
358 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
359 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
360 | 360 | $this->invoices['total'] = $invoices->found_posts; |
361 | 361 | } |
362 | 362 | |
363 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
363 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
364 | 364 | $this->total_invoice_count = (int)$this->invoices['total']; |
365 | 365 | } else { |
366 | 366 | $this->total_invoice_count = (int)$max; |
@@ -368,52 +368,52 @@ discard block |
||
368 | 368 | |
369 | 369 | $this->invoices = $this->invoices['invoices']; |
370 | 370 | |
371 | - $invoice_count = count( $this->invoices ); |
|
371 | + $invoice_count = count($this->invoices); |
|
372 | 372 | |
373 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
373 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
374 | 374 | $this->invoice_count = (int)$invoice_count; |
375 | 375 | } else { |
376 | 376 | $this->invoice_count = (int)$max; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
380 | - $this->pag_links = paginate_links( array( |
|
381 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
379 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
380 | + $this->pag_links = paginate_links(array( |
|
381 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
382 | 382 | 'format' => '', |
383 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
383 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
384 | 384 | 'current' => (int)$this->pag_page, |
385 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
386 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
385 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
386 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
387 | 387 | 'mid_size' => 1, |
388 | 388 | 'add_args' => array(), |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | public function has_invoices() { |
394 | - return (bool) ! empty( $this->invoice_count ); |
|
394 | + return (bool)!empty($this->invoice_count); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | public function next_invoice() { |
398 | 398 | $this->current_invoice++; |
399 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
399 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
400 | 400 | |
401 | 401 | return $this->invoice; |
402 | 402 | } |
403 | 403 | |
404 | 404 | public function rewind_invoices() { |
405 | 405 | $this->current_invoice = -1; |
406 | - if ( $this->invoice_count > 0 ) { |
|
406 | + if ($this->invoice_count > 0) { |
|
407 | 407 | $this->invoice = $this->invoices[0]; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | public function invoices() { |
412 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
412 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
413 | 413 | return true; |
414 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
414 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
415 | 415 | |
416 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
416 | + do_action('wpinv_bp_invoice_loop_end'); |
|
417 | 417 | |
418 | 418 | $this->rewind_invoices(); |
419 | 419 | } |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | $this->in_the_loop = true; |
428 | 428 | $this->invoice = $this->next_invoice(); |
429 | 429 | |
430 | - if ( 0 === $this->current_invoice ) { |
|
431 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
430 | + if (0 === $this->current_invoice) { |
|
431 | + do_action('wpinv_bp_invoice_loop_start'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -438,9 +438,9 @@ discard block |
||
438 | 438 | |
439 | 439 | $bp->invoicing = new WPInv_BP_Component(); |
440 | 440 | |
441 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
442 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
443 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
444 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
441 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
442 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
443 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
444 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
445 | 445 | } |
446 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
447 | 446 | \ No newline at end of file |
447 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
448 | 448 | \ No newline at end of file |
@@ -7,206 +7,206 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_get_payment_gateways() { |
15 | 15 | // Default, built-in gateways |
16 | 16 | $gateways = array( |
17 | 17 | 'paypal' => array( |
18 | - 'admin_label' => __( 'PayPal Standard', 'invoicing' ), |
|
19 | - 'checkout_label' => __( 'PayPal Standard', 'invoicing' ), |
|
18 | + 'admin_label' => __('PayPal Standard', 'invoicing'), |
|
19 | + 'checkout_label' => __('PayPal Standard', 'invoicing'), |
|
20 | 20 | 'ordering' => 1, |
21 | 21 | ), |
22 | 22 | 'authorizenet' => array( |
23 | - 'admin_label' => __( 'Authorize.Net (AIM)', 'invoicing' ), |
|
24 | - 'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ), |
|
23 | + 'admin_label' => __('Authorize.Net (AIM)', 'invoicing'), |
|
24 | + 'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'), |
|
25 | 25 | 'ordering' => 4, |
26 | 26 | ), |
27 | 27 | 'worldpay' => array( |
28 | - 'admin_label' => __( 'Worldpay', 'invoicing' ), |
|
29 | - 'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ), |
|
28 | + 'admin_label' => __('Worldpay', 'invoicing'), |
|
29 | + 'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'), |
|
30 | 30 | 'ordering' => 5, |
31 | 31 | ), |
32 | 32 | 'bank_transfer' => array( |
33 | - 'admin_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
34 | - 'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
33 | + 'admin_label' => __('Pre Bank Transfer', 'invoicing'), |
|
34 | + 'checkout_label' => __('Pre Bank Transfer', 'invoicing'), |
|
35 | 35 | 'ordering' => 11, |
36 | 36 | ), |
37 | 37 | 'manual' => array( |
38 | - 'admin_label' => __( 'Test Payment', 'invoicing' ), |
|
39 | - 'checkout_label' => __( 'Test Payment', 'invoicing' ), |
|
38 | + 'admin_label' => __('Test Payment', 'invoicing'), |
|
39 | + 'checkout_label' => __('Test Payment', 'invoicing'), |
|
40 | 40 | 'ordering' => 12, |
41 | 41 | ), |
42 | 42 | ); |
43 | 43 | |
44 | - return apply_filters( 'wpinv_payment_gateways', $gateways ); |
|
44 | + return apply_filters('wpinv_payment_gateways', $gateways); |
|
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
47 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
48 | 48 | global $wpinv_options; |
49 | 49 | |
50 | 50 | $gateways = array(); |
51 | - foreach ( $all_gateways as $key => $gateway ) { |
|
52 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
53 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
51 | + foreach ($all_gateways as $key => $gateway) { |
|
52 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
53 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
54 | 54 | } |
55 | 55 | |
56 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
56 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
57 | 57 | } |
58 | 58 | |
59 | - asort( $gateways ); |
|
59 | + asort($gateways); |
|
60 | 60 | |
61 | - foreach ( $gateways as $gateway => $key ) { |
|
61 | + foreach ($gateways as $gateway => $key) { |
|
62 | 62 | $gateways[$gateway] = $all_gateways[$gateway]; |
63 | 63 | } |
64 | 64 | |
65 | 65 | return $gateways; |
66 | 66 | } |
67 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
67 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
68 | 68 | |
69 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
69 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
70 | 70 | $gateways = wpinv_get_payment_gateways(); |
71 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
71 | + $enabled = wpinv_get_option('gateways', false); |
|
72 | 72 | |
73 | 73 | $gateway_list = array(); |
74 | 74 | |
75 | - foreach ( $gateways as $key => $gateway ) { |
|
76 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
77 | - $gateway_list[ $key ] = $gateway; |
|
75 | + foreach ($gateways as $key => $gateway) { |
|
76 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
77 | + $gateway_list[$key] = $gateway; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if ( true === $sort ) { |
|
82 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
81 | + if (true === $sort) { |
|
82 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
83 | 83 | |
84 | 84 | // Reorder our gateways so the default is first |
85 | 85 | $default_gateway_id = wpinv_get_default_gateway(); |
86 | 86 | |
87 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
88 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
89 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
87 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
88 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
89 | + unset($gateway_list[$default_gateway_id]); |
|
90 | 90 | |
91 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
91 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
95 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
96 | 96 | } |
97 | 97 | |
98 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
98 | +function wpinv_sort_gateway_order($a, $b) { |
|
99 | 99 | return $a['ordering'] - $b['ordering']; |
100 | 100 | } |
101 | 101 | |
102 | -function wpinv_is_gateway_active( $gateway ) { |
|
102 | +function wpinv_is_gateway_active($gateway) { |
|
103 | 103 | $gateways = wpinv_get_enabled_payment_gateways(); |
104 | 104 | |
105 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
105 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
106 | 106 | |
107 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
107 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | function wpinv_get_default_gateway() { |
111 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
111 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
112 | 112 | |
113 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
113 | + if (!wpinv_is_gateway_active($default)) { |
|
114 | 114 | $gateways = wpinv_get_enabled_payment_gateways(); |
115 | - $gateways = array_keys( $gateways ); |
|
116 | - $default = reset( $gateways ); |
|
115 | + $gateways = array_keys($gateways); |
|
116 | + $default = reset($gateways); |
|
117 | 117 | } |
118 | 118 | |
119 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
119 | + return apply_filters('wpinv_default_gateway', $default); |
|
120 | 120 | } |
121 | 121 | |
122 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
122 | +function wpinv_get_gateway_admin_label($gateway) { |
|
123 | 123 | $gateways = wpinv_get_payment_gateways(); |
124 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
125 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
124 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
125 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
126 | 126 | |
127 | - if( $gateway == 'manual' && $payment ) { |
|
128 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
129 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
127 | + if ($gateway == 'manual' && $payment) { |
|
128 | + if (!((float)wpinv_payment_total($payment) > 0)) { |
|
129 | + $label = __('Free Purchase', 'invoicing'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
133 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_get_gateway_description( $gateway ) { |
|
136 | +function wpinv_get_gateway_description($gateway) { |
|
137 | 137 | global $wpinv_options; |
138 | 138 | |
139 | - $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
139 | + $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
140 | 140 | |
141 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
141 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
142 | 142 | } |
143 | 143 | |
144 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
145 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
144 | +function wpinv_get_gateway_button_label($gateway) { |
|
145 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
146 | 146 | } |
147 | 147 | |
148 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
148 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
149 | 149 | $gateways = wpinv_get_payment_gateways(); |
150 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
150 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
151 | 151 | |
152 | - if( $gateway == 'manual' ) { |
|
153 | - $label = __( 'Manual Payment', 'invoicing' ); |
|
152 | + if ($gateway == 'manual') { |
|
153 | + $label = __('Manual Payment', 'invoicing'); |
|
154 | 154 | } |
155 | 155 | |
156 | - return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway ); |
|
156 | + return apply_filters('wpinv_gateway_checkout_label', $label, $gateway); |
|
157 | 157 | } |
158 | 158 | |
159 | -function wpinv_settings_sections_gateways( $settings ) { |
|
159 | +function wpinv_settings_sections_gateways($settings) { |
|
160 | 160 | $gateways = wpinv_get_payment_gateways(); |
161 | 161 | |
162 | 162 | if (!empty($gateways)) { |
163 | - foreach ($gateways as $key => $gateway) { |
|
163 | + foreach ($gateways as $key => $gateway) { |
|
164 | 164 | $settings[$key] = $gateway['admin_label']; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | return $settings; |
169 | 169 | } |
170 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
170 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
171 | 171 | |
172 | -function wpinv_settings_gateways( $settings ) { |
|
172 | +function wpinv_settings_gateways($settings) { |
|
173 | 173 | $gateways = wpinv_get_payment_gateways(); |
174 | 174 | |
175 | 175 | if (!empty($gateways)) { |
176 | - foreach ($gateways as $key => $gateway) { |
|
176 | + foreach ($gateways as $key => $gateway) { |
|
177 | 177 | $setting = array(); |
178 | 178 | $setting[$key . '_header'] = array( |
179 | 179 | 'id' => 'gateway_header', |
180 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
180 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
181 | 181 | 'custom' => $key, |
182 | 182 | 'type' => 'gateway_header', |
183 | 183 | ); |
184 | 184 | $setting[$key . '_active'] = array( |
185 | 185 | 'id' => $key . '_active', |
186 | - 'name' => __( 'Active', 'invoicing' ), |
|
187 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
186 | + 'name' => __('Active', 'invoicing'), |
|
187 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
188 | 188 | 'type' => 'checkbox', |
189 | 189 | ); |
190 | 190 | |
191 | 191 | $setting[$key . '_title'] = array( |
192 | 192 | 'id' => $key . '_title', |
193 | - 'name' => __( 'Title', 'invoicing' ), |
|
194 | - 'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ), |
|
193 | + 'name' => __('Title', 'invoicing'), |
|
194 | + 'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'), |
|
195 | 195 | 'type' => 'text', |
196 | 196 | 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '' |
197 | 197 | ); |
198 | 198 | |
199 | 199 | $setting[$key . '_desc'] = array( |
200 | 200 | 'id' => $key . '_desc', |
201 | - 'name' => __( 'Description', 'invoicing' ), |
|
202 | - 'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ), |
|
201 | + 'name' => __('Description', 'invoicing'), |
|
202 | + 'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'), |
|
203 | 203 | 'type' => 'text', |
204 | 204 | 'size' => 'large' |
205 | 205 | ); |
206 | 206 | |
207 | 207 | $setting[$key . '_ordering'] = array( |
208 | 208 | 'id' => $key . '_ordering', |
209 | - 'name' => __( 'Display Order', 'invoicing' ), |
|
209 | + 'name' => __('Display Order', 'invoicing'), |
|
210 | 210 | 'type' => 'number', |
211 | 211 | 'size' => 'small', |
212 | 212 | 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | 'step' => '1' |
216 | 216 | ); |
217 | 217 | |
218 | - $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key ); |
|
219 | - $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting ); |
|
218 | + $setting = apply_filters('wpinv_gateway_settings', $setting, $key); |
|
219 | + $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting); |
|
220 | 220 | |
221 | 221 | $settings[$key] = $setting; |
222 | 222 | } |
@@ -224,106 +224,106 @@ discard block |
||
224 | 224 | |
225 | 225 | return $settings; |
226 | 226 | } |
227 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
227 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
228 | 228 | |
229 | -function wpinv_gateway_header_callback( $args ) { |
|
230 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
229 | +function wpinv_gateway_header_callback($args) { |
|
230 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
231 | 231 | } |
232 | 232 | |
233 | -function wpinv_get_gateway_supports( $gateway ) { |
|
233 | +function wpinv_get_gateway_supports($gateway) { |
|
234 | 234 | $gateways = wpinv_get_enabled_payment_gateways(); |
235 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
236 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
235 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
236 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
237 | 237 | } |
238 | 238 | |
239 | -function wpinv_gateway_supports_buy_now( $gateway ) { |
|
240 | - $supports = wpinv_get_gateway_supports( $gateway ); |
|
241 | - $ret = in_array( 'buy_now', $supports ); |
|
242 | - return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway ); |
|
239 | +function wpinv_gateway_supports_buy_now($gateway) { |
|
240 | + $supports = wpinv_get_gateway_supports($gateway); |
|
241 | + $ret = in_array('buy_now', $supports); |
|
242 | + return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | function wpinv_shop_supports_buy_now() { |
246 | 246 | $gateways = wpinv_get_enabled_payment_gateways(); |
247 | 247 | $ret = false; |
248 | 248 | |
249 | - if ( !wpinv_use_taxes() && $gateways ) { |
|
250 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
251 | - if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) { |
|
249 | + if (!wpinv_use_taxes() && $gateways) { |
|
250 | + foreach ($gateways as $gateway_id => $gateway) { |
|
251 | + if (wpinv_gateway_supports_buy_now($gateway_id)) { |
|
252 | 252 | $ret = true; |
253 | 253 | break; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | - return apply_filters( 'wpinv_shop_supports_buy_now', $ret ); |
|
258 | + return apply_filters('wpinv_shop_supports_buy_now', $ret); |
|
259 | 259 | } |
260 | 260 | |
261 | -function wpinv_send_to_gateway( $gateway, $payment_data ) { |
|
262 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' ); |
|
261 | +function wpinv_send_to_gateway($gateway, $payment_data) { |
|
262 | + $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway'); |
|
263 | 263 | |
264 | 264 | // $gateway must match the ID used when registering the gateway |
265 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
265 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | function wpinv_show_gateways() { |
269 | 269 | $gateways = wpinv_get_enabled_payment_gateways(); |
270 | 270 | $show_gateways = false; |
271 | 271 | |
272 | - $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false; |
|
272 | + $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false; |
|
273 | 273 | |
274 | - if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) { |
|
274 | + if (count($gateways) > 1 && empty($chosen_gateway)) { |
|
275 | 275 | $show_gateways = true; |
276 | - if ( wpinv_get_cart_total() <= 0 ) { |
|
276 | + if (wpinv_get_cart_total() <= 0) { |
|
277 | 277 | $show_gateways = false; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if ( !$show_gateways && wpinv_cart_has_recurring_item() ) { |
|
281 | + if (!$show_gateways && wpinv_cart_has_recurring_item()) { |
|
282 | 282 | $show_gateways = true; |
283 | 283 | } |
284 | 284 | |
285 | - return apply_filters( 'wpinv_show_gateways', $show_gateways ); |
|
285 | + return apply_filters('wpinv_show_gateways', $show_gateways); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
289 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
288 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
289 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
290 | 290 | |
291 | 291 | $chosen = false; |
292 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
292 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
293 | 293 | $chosen = $invoice->get_gateway(); |
294 | 294 | } |
295 | 295 | |
296 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
296 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
297 | 297 | |
298 | - if ( false !== $chosen ) { |
|
299 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
298 | + if (false !== $chosen) { |
|
299 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( ! empty ( $chosen ) ) { |
|
303 | - $enabled_gateway = urldecode( $chosen ); |
|
304 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
302 | + if (!empty ($chosen)) { |
|
303 | + $enabled_gateway = urldecode($chosen); |
|
304 | + } else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) { |
|
305 | 305 | $enabled_gateway = 'manual'; |
306 | 306 | } else { |
307 | 307 | $enabled_gateway = wpinv_get_default_gateway(); |
308 | 308 | } |
309 | 309 | |
310 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
311 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
310 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
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 | |
317 | 317 | } |
318 | 318 | |
319 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
319 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
320 | 320 | } |
321 | 321 | |
322 | -function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
323 | - return wpinv_error_log( $message, $title ); |
|
322 | +function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
323 | + return wpinv_error_log($message, $title); |
|
324 | 324 | } |
325 | 325 | |
326 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
326 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
327 | 327 | $ret = 0; |
328 | 328 | $args = array( |
329 | 329 | 'meta_key' => '_wpinv_gateway', |
@@ -334,48 +334,48 @@ discard block |
||
334 | 334 | 'fields' => 'ids' |
335 | 335 | ); |
336 | 336 | |
337 | - $payments = new WP_Query( $args ); |
|
337 | + $payments = new WP_Query($args); |
|
338 | 338 | |
339 | - if( $payments ) |
|
339 | + if ($payments) |
|
340 | 340 | $ret = $payments->post_count; |
341 | 341 | return $ret; |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_settings_update_gateways( $input ) { |
|
344 | +function wpinv_settings_update_gateways($input) { |
|
345 | 345 | global $wpinv_options; |
346 | 346 | |
347 | - if ( !empty( $input['save_gateway'] ) ) { |
|
348 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
347 | + if (!empty($input['save_gateway'])) { |
|
348 | + $gateways = wpinv_get_option('gateways', false); |
|
349 | 349 | $gateways = !empty($gateways) ? $gateways : array(); |
350 | 350 | $gateway = $input['save_gateway']; |
351 | 351 | |
352 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
352 | + if (!empty($input[$gateway . '_active'])) { |
|
353 | 353 | $gateways[$gateway] = 1; |
354 | 354 | } else { |
355 | - if ( isset( $gateways[$gateway] ) ) { |
|
356 | - unset( $gateways[$gateway] ); |
|
355 | + if (isset($gateways[$gateway])) { |
|
356 | + unset($gateways[$gateway]); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
360 | 360 | $input['gateways'] = $gateways; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $input['default_gateway'] ) ) { |
|
363 | + if (!empty($input['default_gateway'])) { |
|
364 | 364 | $gateways = wpinv_get_payment_gateways(); |
365 | 365 | |
366 | - foreach ( $gateways as $key => $gateway ) { |
|
367 | - $active = 0; |
|
368 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
366 | + foreach ($gateways as $key => $gateway) { |
|
367 | + $active = 0; |
|
368 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
369 | 369 | $active = 1; |
370 | 370 | } |
371 | 371 | |
372 | 372 | $input[$key . '_active'] = $active; |
373 | 373 | |
374 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
374 | + if (empty($wpinv_options[$key . '_title'])) { |
|
375 | 375 | $input[$key . '_title'] = $gateway['checkout_label']; |
376 | 376 | } |
377 | 377 | |
378 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
378 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
379 | 379 | $input[$key . '_ordering'] = $gateway['ordering']; |
380 | 380 | } |
381 | 381 | } |
@@ -383,27 +383,27 @@ discard block |
||
383 | 383 | |
384 | 384 | return $input; |
385 | 385 | } |
386 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
386 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
387 | 387 | |
388 | 388 | // PayPal Standard settings |
389 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
390 | - $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' ); |
|
391 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
389 | +function wpinv_gateway_settings_paypal($setting) { |
|
390 | + $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'); |
|
391 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
392 | 392 | |
393 | 393 | $setting['paypal_sandbox'] = array( |
394 | 394 | 'type' => 'checkbox', |
395 | 395 | 'id' => 'paypal_sandbox', |
396 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
397 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
396 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
397 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
398 | 398 | 'std' => 1 |
399 | 399 | ); |
400 | 400 | |
401 | 401 | $setting['paypal_email'] = array( |
402 | 402 | 'type' => 'text', |
403 | 403 | 'id' => 'paypal_email', |
404 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
405 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
406 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
404 | + 'name' => __('PayPal Email', 'invoicing'), |
|
405 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
406 | + 'std' => __('[email protected]', 'invoicing'), |
|
407 | 407 | ); |
408 | 408 | /* |
409 | 409 | $setting['paypal_ipn_url'] = array( |
@@ -417,123 +417,123 @@ discard block |
||
417 | 417 | |
418 | 418 | return $setting; |
419 | 419 | } |
420 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
420 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
421 | 421 | |
422 | 422 | // Pre Bank Transfer settings |
423 | -function wpinv_gateway_settings_bank_transfer( $setting ) { |
|
424 | - $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ); |
|
423 | +function wpinv_gateway_settings_bank_transfer($setting) { |
|
424 | + $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'); |
|
425 | 425 | |
426 | 426 | $setting['bank_transfer_ac_name'] = array( |
427 | 427 | 'type' => 'text', |
428 | 428 | 'id' => 'bank_transfer_ac_name', |
429 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
430 | - 'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ), |
|
431 | - 'std' => __( 'Mr. John Martin', 'invoicing' ), |
|
429 | + 'name' => __('Account Name', 'invoicing'), |
|
430 | + 'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'), |
|
431 | + 'std' => __('Mr. John Martin', 'invoicing'), |
|
432 | 432 | ); |
433 | 433 | |
434 | 434 | $setting['bank_transfer_ac_no'] = array( |
435 | 435 | 'type' => 'text', |
436 | 436 | 'id' => 'bank_transfer_ac_no', |
437 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
438 | - 'desc' => __( 'Enter your bank account number.', 'invoicing' ), |
|
439 | - 'std' => __( 'TEST1234567890', 'invoicing' ), |
|
437 | + 'name' => __('Account Number', 'invoicing'), |
|
438 | + 'desc' => __('Enter your bank account number.', 'invoicing'), |
|
439 | + 'std' => __('TEST1234567890', 'invoicing'), |
|
440 | 440 | ); |
441 | 441 | |
442 | 442 | $setting['bank_transfer_bank_name'] = array( |
443 | 443 | 'type' => 'text', |
444 | 444 | 'id' => 'bank_transfer_bank_name', |
445 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
446 | - 'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ), |
|
447 | - 'std' => __( 'ICICI Bank', 'invoicing' ), |
|
445 | + 'name' => __('Bank Name', 'invoicing'), |
|
446 | + 'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'), |
|
447 | + 'std' => __('ICICI Bank', 'invoicing'), |
|
448 | 448 | ); |
449 | 449 | |
450 | 450 | $setting['bank_transfer_ifsc'] = array( |
451 | 451 | 'type' => 'text', |
452 | 452 | 'id' => 'bank_transfer_ifsc', |
453 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
454 | - 'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ), |
|
455 | - 'std' => __( 'ICIC0001234', 'invoicing' ), |
|
453 | + 'name' => __('IFSC Code', 'invoicing'), |
|
454 | + 'desc' => __('Enter your bank IFSC code.', 'invoicing'), |
|
455 | + 'std' => __('ICIC0001234', 'invoicing'), |
|
456 | 456 | ); |
457 | 457 | |
458 | 458 | $setting['bank_transfer_iban'] = array( |
459 | 459 | 'type' => 'text', |
460 | 460 | 'id' => 'bank_transfer_iban', |
461 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
462 | - 'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ), |
|
463 | - 'std' => __( 'GB29NWBK60161331926819', 'invoicing' ), |
|
461 | + 'name' => __('IBAN', 'invoicing'), |
|
462 | + 'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'), |
|
463 | + 'std' => __('GB29NWBK60161331926819', 'invoicing'), |
|
464 | 464 | ); |
465 | 465 | |
466 | 466 | $setting['bank_transfer_bic'] = array( |
467 | 467 | 'type' => 'text', |
468 | 468 | 'id' => 'bank_transfer_bic', |
469 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
470 | - 'std' => __( 'ICICGB2L129', 'invoicing' ), |
|
469 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
470 | + 'std' => __('ICICGB2L129', 'invoicing'), |
|
471 | 471 | ); |
472 | 472 | |
473 | 473 | $setting['bank_transfer_sort_code'] = array( |
474 | 474 | 'type' => 'text', |
475 | 475 | 'id' => 'bank_transfer_sort_code', |
476 | - 'name' => __( 'Sort Code', 'invoicing' ), |
|
477 | - 'std' => __( '12-34-56', 'invoicing' ), |
|
476 | + 'name' => __('Sort Code', 'invoicing'), |
|
477 | + 'std' => __('12-34-56', 'invoicing'), |
|
478 | 478 | ); |
479 | 479 | |
480 | 480 | $setting['bank_transfer_info'] = array( |
481 | 481 | 'id' => 'bank_transfer_info', |
482 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
483 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
482 | + 'name' => __('Instructions', 'invoicing'), |
|
483 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
484 | 484 | 'type' => 'textarea', |
485 | - 'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ), |
|
485 | + 'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'), |
|
486 | 486 | 'cols' => 37, |
487 | 487 | 'rows' => 5 |
488 | 488 | ); |
489 | 489 | |
490 | 490 | return $setting; |
491 | 491 | } |
492 | -add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 ); |
|
492 | +add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1); |
|
493 | 493 | |
494 | 494 | // Authorize.Net settings |
495 | -function wpinv_gateway_settings_authorizenet( $setting ) { |
|
496 | - $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' ); |
|
497 | - $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing' ); |
|
495 | +function wpinv_gateway_settings_authorizenet($setting) { |
|
496 | + $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing'); |
|
497 | + $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing'); |
|
498 | 498 | |
499 | 499 | $setting['authorizenet_sandbox'] = array( |
500 | 500 | 'type' => 'checkbox', |
501 | 501 | 'id' => 'authorizenet_sandbox', |
502 | - 'name' => __( 'Authorize.Net Test Mode', 'invoicing' ), |
|
503 | - 'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ), |
|
502 | + 'name' => __('Authorize.Net Test Mode', 'invoicing'), |
|
503 | + 'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'), |
|
504 | 504 | 'std' => 1 |
505 | 505 | ); |
506 | 506 | |
507 | 507 | $setting['authorizenet_login_id'] = array( |
508 | 508 | 'type' => 'text', |
509 | 509 | 'id' => 'authorizenet_login_id', |
510 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
511 | - 'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ), |
|
510 | + 'name' => __('API Login ID', 'invoicing'), |
|
511 | + 'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'), |
|
512 | 512 | 'std' => '2j4rBekUnD', |
513 | 513 | ); |
514 | 514 | |
515 | 515 | $setting['authorizenet_transaction_key'] = array( |
516 | 516 | 'type' => 'text', |
517 | 517 | 'id' => 'authorizenet_transaction_key', |
518 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
519 | - 'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ), |
|
518 | + 'name' => __('Transaction Key', 'invoicing'), |
|
519 | + 'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'), |
|
520 | 520 | 'std' => '4vyBUOJgR74679xa', |
521 | 521 | ); |
522 | 522 | |
523 | 523 | $setting['authorizenet_md5_hash'] = array( |
524 | 524 | 'type' => 'text', |
525 | 525 | 'id' => 'authorizenet_md5_hash', |
526 | - 'name' => __( 'MD5-Hash', 'invoicing' ), |
|
527 | - 'desc' => __( 'The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ), |
|
526 | + 'name' => __('MD5-Hash', 'invoicing'), |
|
527 | + 'desc' => __('The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'), |
|
528 | 528 | 'std' => '', |
529 | 529 | ); |
530 | 530 | |
531 | 531 | $setting['authorizenet_ipn_url'] = array( |
532 | 532 | 'type' => 'ipn_url', |
533 | 533 | 'id' => 'authorizenet_ipn_url', |
534 | - 'name' => __( 'Silent Post URL', 'invoicing' ), |
|
535 | - 'std' => wpinv_get_ipn_url( 'authorizenet' ), |
|
536 | - 'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ), |
|
534 | + 'name' => __('Silent Post URL', 'invoicing'), |
|
535 | + 'std' => wpinv_get_ipn_url('authorizenet'), |
|
536 | + 'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'), |
|
537 | 537 | 'size' => 'large', |
538 | 538 | 'custom' => 'authorizenet', |
539 | 539 | 'readonly' => true |
@@ -541,26 +541,26 @@ discard block |
||
541 | 541 | |
542 | 542 | return $setting; |
543 | 543 | } |
544 | -add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 ); |
|
544 | +add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1); |
|
545 | 545 | |
546 | 546 | // Worldpay settings |
547 | -function wpinv_gateway_settings_worldpay( $setting ) { |
|
548 | - $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' ); |
|
549 | - $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing' ); |
|
547 | +function wpinv_gateway_settings_worldpay($setting) { |
|
548 | + $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing'); |
|
549 | + $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing'); |
|
550 | 550 | |
551 | 551 | $setting['worldpay_sandbox'] = array( |
552 | 552 | 'type' => 'checkbox', |
553 | 553 | 'id' => 'worldpay_sandbox', |
554 | - 'name' => __( 'Worldpay Test Mode', 'invoicing' ), |
|
555 | - 'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ), |
|
554 | + 'name' => __('Worldpay Test Mode', 'invoicing'), |
|
555 | + 'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'), |
|
556 | 556 | 'std' => 1 |
557 | 557 | ); |
558 | 558 | |
559 | 559 | $setting['worldpay_instId'] = array( |
560 | 560 | 'type' => 'text', |
561 | 561 | 'id' => 'worldpay_instId', |
562 | - 'name' => __( 'Installation Id', 'invoicing' ), |
|
563 | - 'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ), |
|
562 | + 'name' => __('Installation Id', 'invoicing'), |
|
563 | + 'desc' => __('Your installation id. Ex: 211616', 'invoicing'), |
|
564 | 564 | 'std' => '211616', |
565 | 565 | ); |
566 | 566 | /* |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $setting['worldpay_ipn_url'] = array( |
577 | 577 | 'type' => 'ipn_url', |
578 | 578 | 'id' => 'worldpay_ipn_url', |
579 | - 'name' => __( 'Worldpay Callback Url', 'invoicing' ), |
|
580 | - 'std' => wpinv_get_ipn_url( 'worldpay' ), |
|
581 | - 'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>' ), |
|
579 | + 'name' => __('Worldpay Callback Url', 'invoicing'), |
|
580 | + 'std' => wpinv_get_ipn_url('worldpay'), |
|
581 | + 'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>'), |
|
582 | 582 | 'size' => 'large', |
583 | 583 | 'custom' => 'worldpay', |
584 | 584 | 'readonly' => true |
@@ -586,99 +586,99 @@ discard block |
||
586 | 586 | |
587 | 587 | return $setting; |
588 | 588 | } |
589 | -add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 ); |
|
589 | +add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1); |
|
590 | 590 | |
591 | -function wpinv_ipn_url_callback( $args ) { |
|
592 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
591 | +function wpinv_ipn_url_callback($args) { |
|
592 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
593 | 593 | |
594 | 594 | $attrs = $args['readonly'] ? ' readonly' : ''; |
595 | 595 | |
596 | - $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
597 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
596 | + $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
597 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
598 | 598 | |
599 | 599 | echo $html; |
600 | 600 | } |
601 | 601 | |
602 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
603 | - if ( empty( $gateway ) ) { |
|
602 | +function wpinv_is_test_mode($gateway = '') { |
|
603 | + if (empty($gateway)) { |
|
604 | 604 | return false; |
605 | 605 | } |
606 | 606 | |
607 | - $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false ); |
|
607 | + $is_test_mode = wpinv_get_option($gateway . '_sandbox', false); |
|
608 | 608 | |
609 | - return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway ); |
|
609 | + return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway); |
|
610 | 610 | } |
611 | 611 | |
612 | -function wpinv_get_ipn_url( $gateway = '', $args = array() ) { |
|
613 | - $data = array( 'wpi-listener' => 'IPN' ); |
|
612 | +function wpinv_get_ipn_url($gateway = '', $args = array()) { |
|
613 | + $data = array('wpi-listener' => 'IPN'); |
|
614 | 614 | |
615 | - if ( !empty( $gateway ) ) { |
|
616 | - $data['wpi-gateway'] = wpinv_sanitize_key( $gateway ); |
|
615 | + if (!empty($gateway)) { |
|
616 | + $data['wpi-gateway'] = wpinv_sanitize_key($gateway); |
|
617 | 617 | } |
618 | 618 | |
619 | - $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data; |
|
619 | + $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data; |
|
620 | 620 | |
621 | - $ipn_url = add_query_arg( $args, home_url( 'index.php' ) ); |
|
621 | + $ipn_url = add_query_arg($args, home_url('index.php')); |
|
622 | 622 | |
623 | - return apply_filters( 'wpinv_ipn_url', $ipn_url ); |
|
623 | + return apply_filters('wpinv_ipn_url', $ipn_url); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | function wpinv_listen_for_payment_ipn() { |
627 | 627 | // Regular PayPal IPN |
628 | - if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) { |
|
629 | - do_action( 'wpinv_verify_payment_ipn' ); |
|
628 | + if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') { |
|
629 | + do_action('wpinv_verify_payment_ipn'); |
|
630 | 630 | |
631 | - if ( !empty( $_GET['wpi-gateway'] ) ) { |
|
632 | - wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ ); |
|
633 | - do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' ); |
|
631 | + if (!empty($_GET['wpi-gateway'])) { |
|
632 | + wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__); |
|
633 | + do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn'); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | } |
637 | -add_action( 'init', 'wpinv_listen_for_payment_ipn' ); |
|
637 | +add_action('init', 'wpinv_listen_for_payment_ipn'); |
|
638 | 638 | |
639 | 639 | function wpinv_get_bank_instructions() { |
640 | - $bank_instructions = wpinv_get_option( 'bank_transfer_info' ); |
|
640 | + $bank_instructions = wpinv_get_option('bank_transfer_info'); |
|
641 | 641 | |
642 | - return apply_filters( 'wpinv_bank_instructions', $bank_instructions ); |
|
642 | + return apply_filters('wpinv_bank_instructions', $bank_instructions); |
|
643 | 643 | } |
644 | 644 | |
645 | -function wpinv_get_bank_info( $filtered = false ) { |
|
645 | +function wpinv_get_bank_info($filtered = false) { |
|
646 | 646 | $bank_fields = array( |
647 | - 'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ), |
|
648 | - 'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ), |
|
649 | - 'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ), |
|
650 | - 'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ), |
|
651 | - 'bank_transfer_iban' => __( 'IBAN', 'invoicing' ), |
|
652 | - 'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
653 | - 'bank_transfer_sort_code' => __( 'Sort Code', 'invoicing' ) |
|
647 | + 'bank_transfer_ac_name' => __('Account Name', 'invoicing'), |
|
648 | + 'bank_transfer_ac_no' => __('Account Number', 'invoicing'), |
|
649 | + 'bank_transfer_bank_name' => __('Bank Name', 'invoicing'), |
|
650 | + 'bank_transfer_ifsc' => __('IFSC code', 'invoicing'), |
|
651 | + 'bank_transfer_iban' => __('IBAN', 'invoicing'), |
|
652 | + 'bank_transfer_bic' => __('BIC/Swift code', 'invoicing'), |
|
653 | + 'bank_transfer_sort_code' => __('Sort Code', 'invoicing') |
|
654 | 654 | ); |
655 | 655 | |
656 | 656 | $bank_info = array(); |
657 | - foreach ( $bank_fields as $field => $label ) { |
|
658 | - if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) { |
|
657 | + foreach ($bank_fields as $field => $label) { |
|
658 | + if ($filtered && !($value = wpinv_get_option($field))) { |
|
659 | 659 | continue; |
660 | 660 | } |
661 | 661 | |
662 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
662 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
663 | 663 | } |
664 | 664 | |
665 | - return apply_filters( 'wpinv_bank_info', $bank_info, $filtered ); |
|
665 | + return apply_filters('wpinv_bank_info', $bank_info, $filtered); |
|
666 | 666 | } |
667 | 667 | |
668 | -function wpinv_get_post_data( $method = 'request' ) { |
|
668 | +function wpinv_get_post_data($method = 'request') { |
|
669 | 669 | $data = array(); |
670 | 670 | $request = $_REQUEST; |
671 | 671 | |
672 | - if ( $method == 'post' ) { |
|
673 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
672 | + if ($method == 'post') { |
|
673 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
674 | 674 | return $data; |
675 | 675 | } |
676 | 676 | |
677 | 677 | $request = $_POST; |
678 | 678 | } |
679 | 679 | |
680 | - if ( $method == 'get' ) { |
|
681 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) { |
|
680 | + if ($method == 'get') { |
|
681 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') { |
|
682 | 682 | return $data; |
683 | 683 | } |
684 | 684 | |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | $post_data = ''; |
690 | 690 | |
691 | 691 | // Fallback just in case post_max_size is lower than needed |
692 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
693 | - $post_data = file_get_contents( 'php://input' ); |
|
692 | + if (ini_get('allow_url_fopen')) { |
|
693 | + $post_data = file_get_contents('php://input'); |
|
694 | 694 | } else { |
695 | 695 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
696 | - ini_set( 'post_max_size', '12M' ); |
|
696 | + ini_set('post_max_size', '12M'); |
|
697 | 697 | } |
698 | 698 | // Start the encoded data collection with notification command |
699 | 699 | $encoded_data = 'cmd=_notify-validate'; |
@@ -702,58 +702,58 @@ discard block |
||
702 | 702 | $arg_separator = wpinv_get_php_arg_separator_output(); |
703 | 703 | |
704 | 704 | // Verify there is a post_data |
705 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
705 | + if ($post_data || strlen($post_data) > 0) { |
|
706 | 706 | // Append the data |
707 | 707 | $encoded_data .= $arg_separator . $post_data; |
708 | 708 | } else { |
709 | 709 | // Check if POST is empty |
710 | - if ( empty( $request ) ) { |
|
710 | + if (empty($request)) { |
|
711 | 711 | // Nothing to do |
712 | 712 | return; |
713 | 713 | } else { |
714 | 714 | // Loop through each POST |
715 | - foreach ( $request as $key => $value ) { |
|
715 | + foreach ($request as $key => $value) { |
|
716 | 716 | // Encode the value and append the data |
717 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
717 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Convert collected post data to an array |
723 | - parse_str( $encoded_data, $data ); |
|
723 | + parse_str($encoded_data, $data); |
|
724 | 724 | |
725 | - foreach ( $data as $key => $value ) { |
|
726 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
727 | - $new_key = str_replace( '&', '&', $key ); |
|
728 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
725 | + foreach ($data as $key => $value) { |
|
726 | + if (false !== strpos($key, 'amp;')) { |
|
727 | + $new_key = str_replace('&', '&', $key); |
|
728 | + $new_key = str_replace('amp;', '&', $new_key); |
|
729 | 729 | |
730 | - unset( $data[ $key ] ); |
|
731 | - $data[ $new_key ] = sanitize_text_field( $value ); |
|
730 | + unset($data[$key]); |
|
731 | + $data[$new_key] = sanitize_text_field($value); |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | |
735 | 735 | return $data; |
736 | 736 | } |
737 | 737 | |
738 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
738 | +function wpinv_gateway_support_subscription($gateway) { |
|
739 | 739 | $return = false; |
740 | 740 | |
741 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
742 | - $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false ); |
|
741 | + if (wpinv_is_gateway_active($gateway)) { |
|
742 | + $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | return $return; |
746 | 746 | } |
747 | 747 | |
748 | -function wpinv_payment_gateways_on_cart( $gateways = array() ) { |
|
749 | - if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) { |
|
750 | - foreach ( $gateways as $gateway => $info ) { |
|
751 | - if ( !wpinv_gateway_support_subscription( $gateway ) ) { |
|
752 | - unset( $gateways[$gateway] ); |
|
748 | +function wpinv_payment_gateways_on_cart($gateways = array()) { |
|
749 | + if (!empty($gateways) && wpinv_cart_has_recurring_item()) { |
|
750 | + foreach ($gateways as $gateway => $info) { |
|
751 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
752 | + unset($gateways[$gateway]); |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | } |
756 | 756 | |
757 | 757 | return $gateways; |
758 | 758 | } |
759 | -add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 ); |
|
760 | 759 | \ No newline at end of file |
760 | +add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1); |
|
761 | 761 | \ No newline at end of file |