@@ -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,66 +1004,66 @@ 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 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
1057 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
1058 | 1058 | |
1059 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1060 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1061 | - if ( $summary !== '' ) { |
|
1062 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1059 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1060 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1061 | + if ($summary !== '') { |
|
1062 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1063 | 1063 | } |
1064 | 1064 | $line_item .= '</td>'; |
1065 | 1065 | |
1066 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1066 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1067 | 1067 | if ($quantities_enabled) { |
1068 | 1068 | $cols++; |
1069 | 1069 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1072,55 +1072,55 @@ discard block |
||
1072 | 1072 | $cols++; |
1073 | 1073 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1074 | 1074 | } |
1075 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1075 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1076 | 1076 | $line_item .= '</tr>'; |
1077 | 1077 | |
1078 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1078 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1079 | 1079 | |
1080 | 1080 | $count++; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1083 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1084 | 1084 | ?> |
1085 | 1085 | <tr class="row-sub-total row_odd"> |
1086 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1087 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1086 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1087 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1088 | 1088 | </tr> |
1089 | 1089 | <?php |
1090 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1090 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1091 | 1091 | |
1092 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1093 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1092 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1093 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1094 | 1094 | ?> |
1095 | 1095 | <tr class="row-discount"> |
1096 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1097 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1096 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1097 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1098 | 1098 | </tr> |
1099 | 1099 | <?php |
1100 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1100 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | - if ( $use_taxes ) { |
|
1104 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1103 | + if ($use_taxes) { |
|
1104 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1105 | 1105 | ?> |
1106 | 1106 | <tr class="row-tax"> |
1107 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1108 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1107 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1108 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1109 | 1109 | </tr> |
1110 | 1110 | <?php |
1111 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1111 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1114 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1115 | 1115 | ?> |
1116 | 1116 | <tr class="table-active row-total"> |
1117 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1118 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1117 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1118 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1119 | 1119 | </tr> |
1120 | 1120 | <?php |
1121 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1121 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1122 | 1122 | |
1123 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1123 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1124 | 1124 | } |
1125 | 1125 | ?> |
1126 | 1126 | </tbody> |
@@ -1129,35 +1129,35 @@ discard block |
||
1129 | 1129 | echo ob_get_clean(); |
1130 | 1130 | } |
1131 | 1131 | |
1132 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1132 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1133 | 1133 | $use_taxes = wpinv_use_taxes(); |
1134 | 1134 | |
1135 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1135 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1136 | 1136 | ?> |
1137 | 1137 | <table class="table table-sm table-bordered table-responsive"> |
1138 | 1138 | <tbody> |
1139 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1139 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1140 | 1140 | <tr class="row-sub-total"> |
1141 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1142 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1141 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1142 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1143 | 1143 | </tr> |
1144 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1145 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1144 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1145 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1146 | 1146 | <tr class="row-discount"> |
1147 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1148 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1147 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1148 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1149 | 1149 | </tr> |
1150 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1150 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1151 | 1151 | <?php } ?> |
1152 | - <?php if ( $use_taxes ) { ?> |
|
1152 | + <?php if ($use_taxes) { ?> |
|
1153 | 1153 | <tr class="row-tax"> |
1154 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1155 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1154 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1155 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1156 | 1156 | </tr> |
1157 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1157 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1158 | 1158 | <?php } ?> |
1159 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1160 | - <?php foreach ( $fees as $fee ) { ?> |
|
1159 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1160 | + <?php foreach ($fees as $fee) { ?> |
|
1161 | 1161 | <tr class="row-fee"> |
1162 | 1162 | <td class="rate"><?php echo $fee['label']; ?></td> |
1163 | 1163 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1165,82 +1165,82 @@ discard block |
||
1165 | 1165 | <?php } ?> |
1166 | 1166 | <?php } ?> |
1167 | 1167 | <tr class="table-active row-total"> |
1168 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1169 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1168 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1169 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1170 | 1170 | </tr> |
1171 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1171 | + <?php do_action('wpinv_after_totals'); ?> |
|
1172 | 1172 | </tbody> |
1173 | 1173 | |
1174 | 1174 | </table> |
1175 | 1175 | |
1176 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1176 | + <?php do_action('wpinv_after_totals_table'); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1180 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1179 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1180 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1181 | 1181 | |
1182 | 1182 | ob_start(); |
1183 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1184 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1183 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1184 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1185 | 1185 | ?> |
1186 | 1186 | <div class="wpi-payment-info"> |
1187 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1188 | - <?php if ( $gateway_title ) { ?> |
|
1189 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1187 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1188 | + <?php if ($gateway_title) { ?> |
|
1189 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1190 | 1190 | <?php } ?> |
1191 | 1191 | </div> |
1192 | 1192 | <?php |
1193 | 1193 | } |
1194 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1194 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1195 | 1195 | $outout = ob_get_clean(); |
1196 | 1196 | |
1197 | - if ( $echo ) { |
|
1197 | + if ($echo) { |
|
1198 | 1198 | echo $outout; |
1199 | 1199 | } else { |
1200 | 1200 | return $outout; |
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | |
1204 | -function wpinv_display_style( $invoice ) { |
|
1205 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1204 | +function wpinv_display_style($invoice) { |
|
1205 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1206 | 1206 | |
1207 | - wp_print_styles( 'open-sans' ); |
|
1208 | - wp_print_styles( 'wpinv-single-style' ); |
|
1207 | + wp_print_styles('open-sans'); |
|
1208 | + wp_print_styles('wpinv-single-style'); |
|
1209 | 1209 | |
1210 | 1210 | $custom_css = wpinv_get_option('template_custom_css'); |
1211 | - if(isset($custom_css) && !empty($custom_css)){ |
|
1212 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1213 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1211 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1212 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1213 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1214 | 1214 | echo '<style type="text/css">'; |
1215 | 1215 | echo $custom_css; |
1216 | 1216 | echo '</style>'; |
1217 | 1217 | } |
1218 | 1218 | } |
1219 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1220 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1219 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1220 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1221 | 1221 | |
1222 | 1222 | function wpinv_checkout_billing_details() { |
1223 | 1223 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1224 | 1224 | if (empty($invoice_id)) { |
1225 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1225 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1226 | 1226 | return null; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1229 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1230 | 1230 | if (empty($invoice)) { |
1231 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1231 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1232 | 1232 | return null; |
1233 | 1233 | } |
1234 | 1234 | $user_id = $invoice->get_user_id(); |
1235 | 1235 | $user_info = $invoice->get_user_info(); |
1236 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1236 | + $address_info = wpinv_get_user_address($user_id); |
|
1237 | 1237 | |
1238 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1238 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1239 | 1239 | $user_info['first_name'] = $user_info['first_name']; |
1240 | 1240 | $user_info['last_name'] = $user_info['last_name']; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1243 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1244 | 1244 | $user_info['country'] = $address_info['country']; |
1245 | 1245 | $user_info['state'] = $address_info['state']; |
1246 | 1246 | $user_info['city'] = $address_info['city']; |
@@ -1256,98 +1256,98 @@ discard block |
||
1256 | 1256 | 'address' |
1257 | 1257 | ); |
1258 | 1258 | |
1259 | - foreach ( $address_fields as $field ) { |
|
1260 | - if ( empty( $user_info[$field] ) ) { |
|
1259 | + foreach ($address_fields as $field) { |
|
1260 | + if (empty($user_info[$field])) { |
|
1261 | 1261 | $user_info[$field] = $address_info[$field]; |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | |
1265 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1265 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | function wpinv_admin_get_line_items($invoice = array()) { |
1269 | 1269 | $item_quantities = wpinv_item_quantities_enabled(); |
1270 | 1270 | $use_taxes = wpinv_use_taxes(); |
1271 | 1271 | |
1272 | - if ( empty( $invoice ) ) { |
|
1272 | + if (empty($invoice)) { |
|
1273 | 1273 | return NULL; |
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | $cart_items = $invoice->get_cart_details(); |
1277 | - if ( empty( $cart_items ) ) { |
|
1277 | + if (empty($cart_items)) { |
|
1278 | 1278 | return NULL; |
1279 | 1279 | } |
1280 | 1280 | ob_start(); |
1281 | 1281 | |
1282 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1282 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1283 | 1283 | |
1284 | 1284 | $count = 0; |
1285 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1285 | + foreach ($cart_items as $key => $cart_item) { |
|
1286 | 1286 | $item_id = $cart_item['id']; |
1287 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1287 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1288 | 1288 | |
1289 | 1289 | if (empty($wpi_item)) { |
1290 | 1290 | continue; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1294 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1295 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1293 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1294 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1295 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1296 | 1296 | $can_remove = true; |
1297 | 1297 | |
1298 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1298 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1299 | 1299 | |
1300 | 1300 | $item_tax = ''; |
1301 | 1301 | $tax_rate = ''; |
1302 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1303 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1304 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1305 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1302 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1303 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1304 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1305 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1306 | 1306 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1307 | 1307 | } |
1308 | 1308 | $line_item_tax = $item_tax . $tax_rate; |
1309 | 1309 | |
1310 | - if ( $line_item_tax === '' ) { |
|
1310 | + if ($line_item_tax === '') { |
|
1311 | 1311 | $line_item_tax = 0; // Zero tax |
1312 | 1312 | } |
1313 | 1313 | |
1314 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1314 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1315 | 1315 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1316 | - $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 ); |
|
1317 | - if ( $summary !== '' ) { |
|
1318 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1316 | + $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); |
|
1317 | + if ($summary !== '') { |
|
1318 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1319 | 1319 | } |
1320 | 1320 | $line_item .= '</td>'; |
1321 | 1321 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1322 | 1322 | |
1323 | - if ( $item_quantities ) { |
|
1324 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1323 | + if ($item_quantities) { |
|
1324 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1325 | 1325 | $can_remove = false; |
1326 | 1326 | } |
1327 | 1327 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1328 | 1328 | } else { |
1329 | - if ( count( $cart_items ) == 1 ) { |
|
1329 | + if (count($cart_items) == 1) { |
|
1330 | 1330 | $can_remove = false; |
1331 | 1331 | } |
1332 | 1332 | } |
1333 | 1333 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1334 | 1334 | |
1335 | - if ( $use_taxes ) { |
|
1335 | + if ($use_taxes) { |
|
1336 | 1336 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1337 | 1337 | } |
1338 | 1338 | $line_item .= '<td class="action">'; |
1339 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1339 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1340 | 1340 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1341 | 1341 | } |
1342 | 1342 | $line_item .= '</td>'; |
1343 | 1343 | $line_item .= '</tr>'; |
1344 | 1344 | |
1345 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1345 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1346 | 1346 | |
1347 | 1347 | $count++; |
1348 | 1348 | } |
1349 | 1349 | |
1350 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1350 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1351 | 1351 | |
1352 | 1352 | return ob_get_clean(); |
1353 | 1353 | } |
@@ -1358,35 +1358,35 @@ discard block |
||
1358 | 1358 | // Set current invoice id. |
1359 | 1359 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1360 | 1360 | |
1361 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1361 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1362 | 1362 | |
1363 | 1363 | ob_start(); |
1364 | 1364 | echo '<div id="wpinv_checkout_wrap">'; |
1365 | 1365 | |
1366 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1366 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1367 | 1367 | ?> |
1368 | 1368 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1369 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1369 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1370 | 1370 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1371 | 1371 | <?php |
1372 | - do_action( 'wpinv_checkout_form_top' ); |
|
1373 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1374 | - do_action( 'wpinv_checkout_cart' ); |
|
1375 | - do_action( 'wpinv_payment_mode_select' ); |
|
1376 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1372 | + do_action('wpinv_checkout_form_top'); |
|
1373 | + do_action('wpinv_checkout_billing_info'); |
|
1374 | + do_action('wpinv_checkout_cart'); |
|
1375 | + do_action('wpinv_payment_mode_select'); |
|
1376 | + do_action('wpinv_checkout_form_bottom') |
|
1377 | 1377 | ?> |
1378 | 1378 | </form> |
1379 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1379 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1380 | 1380 | </div><!--end #wpinv_checkout_form_wrap--> |
1381 | 1381 | <?php |
1382 | 1382 | } else { |
1383 | - do_action( 'wpinv_cart_empty' ); |
|
1383 | + do_action('wpinv_cart_empty'); |
|
1384 | 1384 | } |
1385 | 1385 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1386 | 1386 | return ob_get_clean(); |
1387 | 1387 | } |
1388 | 1388 | |
1389 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1389 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1390 | 1390 | global $ajax_cart_details; |
1391 | 1391 | $ajax_cart_details = $cart_details; |
1392 | 1392 | /* |
@@ -1401,25 +1401,25 @@ discard block |
||
1401 | 1401 | } |
1402 | 1402 | */ |
1403 | 1403 | ob_start(); |
1404 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1404 | + do_action('wpinv_before_checkout_cart'); |
|
1405 | 1405 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1406 | 1406 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1407 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1407 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1408 | 1408 | echo '</div>'; |
1409 | 1409 | echo '</div>'; |
1410 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1410 | + do_action('wpinv_after_checkout_cart'); |
|
1411 | 1411 | $content = ob_get_clean(); |
1412 | 1412 | |
1413 | - if ( $echo ) { |
|
1413 | + if ($echo) { |
|
1414 | 1414 | echo $content; |
1415 | 1415 | } else { |
1416 | 1416 | return $content; |
1417 | 1417 | } |
1418 | 1418 | } |
1419 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1419 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1420 | 1420 | |
1421 | 1421 | function wpinv_empty_cart_message() { |
1422 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1422 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | /** |
@@ -1431,91 +1431,91 @@ discard block |
||
1431 | 1431 | function wpinv_empty_checkout_cart() { |
1432 | 1432 | echo wpinv_empty_cart_message(); |
1433 | 1433 | } |
1434 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1434 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1435 | 1435 | |
1436 | 1436 | function wpinv_save_cart_button() { |
1437 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1437 | + if (wpinv_is_cart_saving_disabled()) |
|
1438 | 1438 | return; |
1439 | 1439 | ?> |
1440 | - <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> |
|
1440 | + <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> |
|
1441 | 1441 | <?php |
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | function wpinv_update_cart_button() { |
1445 | - if ( !wpinv_item_quantities_enabled() ) |
|
1445 | + if (!wpinv_item_quantities_enabled()) |
|
1446 | 1446 | return; |
1447 | 1447 | ?> |
1448 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1448 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1449 | 1449 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1450 | 1450 | <?php |
1451 | 1451 | } |
1452 | 1452 | |
1453 | 1453 | function wpinv_checkout_cart_columns() { |
1454 | 1454 | $default = 3; |
1455 | - if ( wpinv_item_quantities_enabled() ) { |
|
1455 | + if (wpinv_item_quantities_enabled()) { |
|
1456 | 1456 | $default++; |
1457 | 1457 | } |
1458 | 1458 | |
1459 | - if ( wpinv_use_taxes() ) { |
|
1459 | + if (wpinv_use_taxes()) { |
|
1460 | 1460 | $default++; |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1463 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | function wpinv_display_cart_messages() { |
1467 | 1467 | global $wpi_session; |
1468 | 1468 | |
1469 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1469 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1470 | 1470 | |
1471 | - if ( $messages ) { |
|
1472 | - foreach ( $messages as $message_id => $message ) { |
|
1471 | + if ($messages) { |
|
1472 | + foreach ($messages as $message_id => $message) { |
|
1473 | 1473 | // Try and detect what type of message this is |
1474 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1474 | + if (strpos(strtolower($message), 'error')) { |
|
1475 | 1475 | $type = 'error'; |
1476 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1476 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1477 | 1477 | $type = 'success'; |
1478 | 1478 | } else { |
1479 | 1479 | $type = 'info'; |
1480 | 1480 | } |
1481 | 1481 | |
1482 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1482 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1483 | 1483 | |
1484 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1484 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1485 | 1485 | // Loop message codes and display messages |
1486 | 1486 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1487 | 1487 | echo '</div>'; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // Remove all of the cart saving messages |
1491 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1491 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1492 | 1492 | } |
1493 | 1493 | } |
1494 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1494 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1495 | 1495 | |
1496 | 1496 | function wpinv_discount_field() { |
1497 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1497 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1498 | 1498 | return; // Only show before a payment method has been selected if ajax is disabled |
1499 | 1499 | } |
1500 | 1500 | |
1501 | - if ( !wpinv_is_checkout() ) { |
|
1501 | + if (!wpinv_is_checkout()) { |
|
1502 | 1502 | return; |
1503 | 1503 | } |
1504 | 1504 | |
1505 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1505 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1506 | 1506 | ?> |
1507 | 1507 | <div id="wpinv-discount-field" class="panel panel-default"> |
1508 | 1508 | <div class="panel-body"> |
1509 | 1509 | <p> |
1510 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1511 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1510 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1511 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1512 | 1512 | </p> |
1513 | 1513 | <div class="form-group row"> |
1514 | 1514 | <div class="col-sm-4"> |
1515 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1515 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1516 | 1516 | </div> |
1517 | 1517 | <div class="col-sm-3"> |
1518 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1518 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1519 | 1519 | </div> |
1520 | 1520 | <div style="clear:both"></div> |
1521 | 1521 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1528,10 +1528,10 @@ discard block |
||
1528 | 1528 | <?php |
1529 | 1529 | } |
1530 | 1530 | } |
1531 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1531 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1532 | 1532 | |
1533 | 1533 | function wpinv_agree_to_terms_js() { |
1534 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1534 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1535 | 1535 | ?> |
1536 | 1536 | <script type="text/javascript"> |
1537 | 1537 | jQuery(document).ready(function($){ |
@@ -1546,126 +1546,126 @@ discard block |
||
1546 | 1546 | <?php |
1547 | 1547 | } |
1548 | 1548 | } |
1549 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1549 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1550 | 1550 | |
1551 | 1551 | function wpinv_payment_mode_select() { |
1552 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1553 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1552 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1553 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1554 | 1554 | $page_URL = wpinv_get_current_page_url(); |
1555 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1555 | + $invoice = wpinv_get_invoice(0, true); |
|
1556 | 1556 | |
1557 | 1557 | do_action('wpinv_payment_mode_top'); |
1558 | 1558 | $invoice_id = (int)$invoice->ID; |
1559 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1559 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1560 | 1560 | ?> |
1561 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1562 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1561 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1562 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1563 | 1563 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1564 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1564 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1565 | 1565 | <div class="panel-body list-group wpi-payment_methods"> |
1566 | 1566 | <?php |
1567 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1567 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1568 | 1568 | |
1569 | - if ( !empty( $gateways ) ) { |
|
1570 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1571 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1572 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1573 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1569 | + if (!empty($gateways)) { |
|
1570 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1571 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1572 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1573 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1574 | 1574 | ?> |
1575 | 1575 | <div class="list-group-item"> |
1576 | 1576 | <div class="radio"> |
1577 | - <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> |
|
1577 | + <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> |
|
1578 | 1578 | </div> |
1579 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1580 | - <?php if ( !empty( $description ) ) { ?> |
|
1581 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
1579 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1580 | + <?php if (!empty($description)) { ?> |
|
1581 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
1582 | 1582 | <?php } ?> |
1583 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1583 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1584 | 1584 | </div> |
1585 | 1585 | </div> |
1586 | 1586 | <?php |
1587 | 1587 | } |
1588 | 1588 | } else { |
1589 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1589 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1590 | 1590 | } |
1591 | 1591 | |
1592 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1592 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1593 | 1593 | ?> |
1594 | 1594 | </div> |
1595 | 1595 | </div> |
1596 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1596 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1597 | 1597 | </div> |
1598 | 1598 | <?php |
1599 | 1599 | do_action('wpinv_payment_mode_bottom'); |
1600 | 1600 | } |
1601 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1601 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1602 | 1602 | |
1603 | 1603 | function wpinv_checkout_billing_info() { |
1604 | - if ( wpinv_is_checkout() ) { |
|
1604 | + if (wpinv_is_checkout()) { |
|
1605 | 1605 | $logged_in = is_user_logged_in(); |
1606 | 1606 | $billing_details = wpinv_checkout_billing_details(); |
1607 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1607 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1608 | 1608 | ?> |
1609 | 1609 | <div id="wpinv-fields" class="clearfix"> |
1610 | 1610 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1611 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1611 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1612 | 1612 | <div id="wpinv-fields-box" class="panel-body"> |
1613 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1613 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1614 | 1614 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1615 | - <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> |
|
1615 | + <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> |
|
1616 | 1616 | <?php |
1617 | - echo wpinv_html_text( array( |
|
1617 | + echo wpinv_html_text(array( |
|
1618 | 1618 | 'id' => 'wpinv_first_name', |
1619 | 1619 | 'name' => 'wpinv_first_name', |
1620 | 1620 | 'value' => $billing_details['first_name'], |
1621 | 1621 | 'class' => 'wpi-input form-control', |
1622 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1623 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1624 | - ) ); |
|
1622 | + 'placeholder' => __('First name', 'invoicing'), |
|
1623 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1624 | + )); |
|
1625 | 1625 | ?> |
1626 | 1626 | </p> |
1627 | 1627 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1628 | - <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> |
|
1628 | + <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> |
|
1629 | 1629 | <?php |
1630 | - echo wpinv_html_text( array( |
|
1630 | + echo wpinv_html_text(array( |
|
1631 | 1631 | 'id' => 'wpinv_last_name', |
1632 | 1632 | 'name' => 'wpinv_last_name', |
1633 | 1633 | 'value' => $billing_details['last_name'], |
1634 | 1634 | 'class' => 'wpi-input form-control', |
1635 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1636 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1637 | - ) ); |
|
1635 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1636 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1637 | + )); |
|
1638 | 1638 | ?> |
1639 | 1639 | </p> |
1640 | 1640 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1641 | - <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> |
|
1641 | + <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> |
|
1642 | 1642 | <?php |
1643 | - echo wpinv_html_text( array( |
|
1643 | + echo wpinv_html_text(array( |
|
1644 | 1644 | 'id' => 'wpinv_address', |
1645 | 1645 | 'name' => 'wpinv_address', |
1646 | 1646 | 'value' => $billing_details['address'], |
1647 | 1647 | 'class' => 'wpi-input form-control', |
1648 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1649 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1650 | - ) ); |
|
1648 | + 'placeholder' => __('Address', 'invoicing'), |
|
1649 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1650 | + )); |
|
1651 | 1651 | ?> |
1652 | 1652 | </p> |
1653 | 1653 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1654 | - <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> |
|
1654 | + <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> |
|
1655 | 1655 | <?php |
1656 | - echo wpinv_html_text( array( |
|
1656 | + echo wpinv_html_text(array( |
|
1657 | 1657 | 'id' => 'wpinv_city', |
1658 | 1658 | 'name' => 'wpinv_city', |
1659 | 1659 | 'value' => $billing_details['city'], |
1660 | 1660 | 'class' => 'wpi-input form-control', |
1661 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1662 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1663 | - ) ); |
|
1661 | + 'placeholder' => __('City', 'invoicing'), |
|
1662 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1663 | + )); |
|
1664 | 1664 | ?> |
1665 | 1665 | </p> |
1666 | 1666 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1667 | - <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> |
|
1668 | - <?php echo wpinv_html_select( array( |
|
1667 | + <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> |
|
1668 | + <?php echo wpinv_html_select(array( |
|
1669 | 1669 | 'options' => wpinv_get_country_list(), |
1670 | 1670 | 'name' => 'wpinv_country', |
1671 | 1671 | 'id' => 'wpinv_country', |
@@ -1673,16 +1673,16 @@ discard block |
||
1673 | 1673 | 'show_option_all' => false, |
1674 | 1674 | 'show_option_none' => false, |
1675 | 1675 | 'class' => 'wpi-input form-control', |
1676 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1677 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1678 | - ) ); ?> |
|
1676 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1677 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1678 | + )); ?> |
|
1679 | 1679 | </p> |
1680 | 1680 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1681 | - <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> |
|
1681 | + <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> |
|
1682 | 1682 | <?php |
1683 | - $states = wpinv_get_country_states( $selected_country ); |
|
1684 | - if( !empty( $states ) ) { |
|
1685 | - echo wpinv_html_select( array( |
|
1683 | + $states = wpinv_get_country_states($selected_country); |
|
1684 | + if (!empty($states)) { |
|
1685 | + echo wpinv_html_select(array( |
|
1686 | 1686 | 'options' => $states, |
1687 | 1687 | 'name' => 'wpinv_state', |
1688 | 1688 | 'id' => 'wpinv_state', |
@@ -1690,61 +1690,61 @@ discard block |
||
1690 | 1690 | 'show_option_all' => false, |
1691 | 1691 | 'show_option_none' => false, |
1692 | 1692 | 'class' => 'wpi-input form-control', |
1693 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1694 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1695 | - ) ); |
|
1693 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1694 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1695 | + )); |
|
1696 | 1696 | } else { |
1697 | - echo wpinv_html_text( array( |
|
1697 | + echo wpinv_html_text(array( |
|
1698 | 1698 | 'name' => 'wpinv_state', |
1699 | 1699 | 'value' => $billing_details['state'], |
1700 | 1700 | 'id' => 'wpinv_state', |
1701 | 1701 | 'class' => 'wpi-input form-control', |
1702 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1703 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1704 | - ) ); |
|
1702 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1703 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1704 | + )); |
|
1705 | 1705 | } |
1706 | 1706 | ?> |
1707 | 1707 | </p> |
1708 | 1708 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1709 | - <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> |
|
1709 | + <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> |
|
1710 | 1710 | <?php |
1711 | - echo wpinv_html_text( array( |
|
1711 | + echo wpinv_html_text(array( |
|
1712 | 1712 | 'name' => 'wpinv_zip', |
1713 | 1713 | 'value' => $billing_details['zip'], |
1714 | 1714 | 'id' => 'wpinv_zip', |
1715 | 1715 | 'class' => 'wpi-input form-control', |
1716 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1717 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1718 | - ) ); |
|
1716 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1717 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1718 | + )); |
|
1719 | 1719 | ?> |
1720 | 1720 | </p> |
1721 | 1721 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1722 | - <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> |
|
1722 | + <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> |
|
1723 | 1723 | <?php |
1724 | - echo wpinv_html_text( array( |
|
1724 | + echo wpinv_html_text(array( |
|
1725 | 1725 | 'id' => 'wpinv_phone', |
1726 | 1726 | 'name' => 'wpinv_phone', |
1727 | 1727 | 'value' => $billing_details['phone'], |
1728 | 1728 | 'class' => 'wpi-input form-control', |
1729 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1730 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1731 | - ) ); |
|
1729 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1730 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1731 | + )); |
|
1732 | 1732 | ?> |
1733 | 1733 | </p> |
1734 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1734 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1735 | 1735 | <div class="clearfix"></div> |
1736 | 1736 | </div> |
1737 | 1737 | </div> |
1738 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1738 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1739 | 1739 | </div> |
1740 | 1740 | <?php |
1741 | 1741 | } |
1742 | 1742 | } |
1743 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1743 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1744 | 1744 | |
1745 | 1745 | function wpinv_checkout_hidden_fields() { |
1746 | 1746 | ?> |
1747 | - <?php if ( is_user_logged_in() ) { ?> |
|
1747 | + <?php if (is_user_logged_in()) { ?> |
|
1748 | 1748 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1749 | 1749 | <?php } ?> |
1750 | 1750 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1754,9 +1754,9 @@ discard block |
||
1754 | 1754 | function wpinv_checkout_button_purchase() { |
1755 | 1755 | ob_start(); |
1756 | 1756 | ?> |
1757 | - <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' ) ?>"/> |
|
1757 | + <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') ?>"/> |
|
1758 | 1758 | <?php |
1759 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1759 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | function wpinv_checkout_total() { |
@@ -1765,116 +1765,116 @@ discard block |
||
1765 | 1765 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1766 | 1766 | <div class="panel-body"> |
1767 | 1767 | <?php |
1768 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1768 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1769 | 1769 | ?> |
1770 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1770 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1771 | 1771 | <?php |
1772 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1772 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1773 | 1773 | ?> |
1774 | 1774 | </div> |
1775 | 1775 | </div> |
1776 | 1776 | <?php |
1777 | 1777 | } |
1778 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1778 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1779 | 1779 | |
1780 | 1780 | function wpinv_checkout_accept_tandc() { |
1781 | - $page = wpinv_get_option( 'tandc_page' ); |
|
1781 | + $page = wpinv_get_option('tandc_page'); |
|
1782 | 1782 | ?> |
1783 | 1783 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
1784 | 1784 | <div class="panel-body"> |
1785 | 1785 | <?php echo wpinv_get_policy_text(); ?> |
1786 | 1786 | <?php |
1787 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
1788 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
1787 | + if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
1788 | + $terms_link = esc_url(get_permalink($page)); |
|
1789 | 1789 | ?> |
1790 | 1790 | <label class=""> |
1791 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
1791 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
1792 | 1792 | </label> |
1793 | 1793 | <?php } ?> |
1794 | 1794 | </div> |
1795 | 1795 | </div> |
1796 | 1796 | <?php |
1797 | 1797 | } |
1798 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
1798 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
1799 | 1799 | |
1800 | 1800 | function wpinv_checkout_submit() { |
1801 | 1801 | ?> |
1802 | 1802 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1803 | 1803 | <div class="panel-body text-center"> |
1804 | 1804 | <?php |
1805 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1805 | + do_action('wpinv_purchase_form_before_submit'); |
|
1806 | 1806 | wpinv_checkout_hidden_fields(); |
1807 | 1807 | echo wpinv_checkout_button_purchase(); |
1808 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1808 | + do_action('wpinv_purchase_form_after_submit'); |
|
1809 | 1809 | ?> |
1810 | 1810 | </div> |
1811 | 1811 | </div> |
1812 | 1812 | <?php |
1813 | 1813 | } |
1814 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1814 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1815 | 1815 | |
1816 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1817 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1816 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1817 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1818 | 1818 | |
1819 | - if ( empty( $invoice ) ) { |
|
1819 | + if (empty($invoice)) { |
|
1820 | 1820 | return NULL; |
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $billing_details = $invoice->get_user_info(); |
1824 | 1824 | $address_row = ''; |
1825 | - if ( $address = $billing_details['address'] ) { |
|
1826 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1825 | + if ($address = $billing_details['address']) { |
|
1826 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | $address_fields = array(); |
1830 | - if ( !empty( $billing_details['city'] ) ) { |
|
1830 | + if (!empty($billing_details['city'])) { |
|
1831 | 1831 | $address_fields[] = $billing_details['city']; |
1832 | 1832 | } |
1833 | 1833 | |
1834 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1835 | - if ( !empty( $billing_details['state'] ) ) { |
|
1836 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1834 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1835 | + if (!empty($billing_details['state'])) { |
|
1836 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | - if ( !empty( $billing_country ) ) { |
|
1840 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1839 | + if (!empty($billing_country)) { |
|
1840 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1841 | 1841 | } |
1842 | 1842 | |
1843 | - if ( !empty( $address_fields ) ) { |
|
1844 | - $address_fields = implode( ", ", $address_fields ); |
|
1843 | + if (!empty($address_fields)) { |
|
1844 | + $address_fields = implode(", ", $address_fields); |
|
1845 | 1845 | |
1846 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1846 | + if (!empty($billing_details['zip'])) { |
|
1847 | 1847 | $address_fields .= ' ' . $billing_details['zip']; |
1848 | 1848 | } |
1849 | 1849 | |
1850 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1850 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1851 | 1851 | } |
1852 | 1852 | ob_start(); |
1853 | 1853 | ?> |
1854 | 1854 | <table class="table table-bordered table-sm wpi-billing-details"> |
1855 | 1855 | <tbody> |
1856 | 1856 | <tr class="wpi-receipt-name"> |
1857 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1858 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1857 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1858 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1859 | 1859 | </tr> |
1860 | 1860 | <tr class="wpi-receipt-email"> |
1861 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1862 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1861 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1862 | + <td><?php echo $billing_details['email']; ?></td> |
|
1863 | 1863 | </tr> |
1864 | - <?php if ( $billing_details['company'] ) { ?> |
|
1864 | + <?php if ($billing_details['company']) { ?> |
|
1865 | 1865 | <tr class="wpi-receipt-company"> |
1866 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1867 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1866 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1867 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1868 | 1868 | </tr> |
1869 | 1869 | <?php } ?> |
1870 | 1870 | <tr class="wpi-receipt-address"> |
1871 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1872 | - <td><?php echo $address_row ;?></td> |
|
1871 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1872 | + <td><?php echo $address_row; ?></td> |
|
1873 | 1873 | </tr> |
1874 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1874 | + <?php if ($billing_details['phone']) { ?> |
|
1875 | 1875 | <tr class="wpi-receipt-phone"> |
1876 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1877 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1876 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1877 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1878 | 1878 | </tr> |
1879 | 1879 | <?php } ?> |
1880 | 1880 | </tbody> |
@@ -1882,74 +1882,74 @@ discard block |
||
1882 | 1882 | <?php |
1883 | 1883 | $output = ob_get_clean(); |
1884 | 1884 | |
1885 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1885 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1886 | 1886 | |
1887 | 1887 | echo $output; |
1888 | 1888 | } |
1889 | 1889 | |
1890 | -function wpinv_filter_success_page_content( $content ) { |
|
1891 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1892 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1893 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1890 | +function wpinv_filter_success_page_content($content) { |
|
1891 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1892 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1893 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1894 | 1894 | } |
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | return $content; |
1898 | 1898 | } |
1899 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1899 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1900 | 1900 | |
1901 | -function wpinv_receipt_actions( $invoice ) { |
|
1902 | - if ( !empty( $invoice ) ) { |
|
1901 | +function wpinv_receipt_actions($invoice) { |
|
1902 | + if (!empty($invoice)) { |
|
1903 | 1903 | $actions = array(); |
1904 | 1904 | |
1905 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1906 | - $actions['print'] = array( |
|
1907 | - 'url' => $invoice->get_view_url( true ), |
|
1908 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1905 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1906 | + $actions['print'] = array( |
|
1907 | + 'url' => $invoice->get_view_url(true), |
|
1908 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1909 | 1909 | 'class' => 'btn-primary', |
1910 | 1910 | ); |
1911 | 1911 | } |
1912 | 1912 | |
1913 | - if ( is_user_logged_in() ) { |
|
1913 | + if (is_user_logged_in()) { |
|
1914 | 1914 | $actions['history'] = array( |
1915 | 1915 | 'url' => wpinv_get_history_page_uri(), |
1916 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1916 | + 'name' => __('Invoice History', 'invoicing'), |
|
1917 | 1917 | 'class' => 'btn-warning', |
1918 | 1918 | ); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1921 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1922 | 1922 | |
1923 | - if ( !empty( $actions ) ) { |
|
1923 | + if (!empty($actions)) { |
|
1924 | 1924 | ?> |
1925 | 1925 | <div class="wpinv-receipt-actions text-right"> |
1926 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1927 | - <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> |
|
1926 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1927 | + <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> |
|
1928 | 1928 | <?php } ?> |
1929 | 1929 | </div> |
1930 | 1930 | <?php |
1931 | 1931 | } |
1932 | 1932 | } |
1933 | 1933 | } |
1934 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1934 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1935 | 1935 | |
1936 | -function wpinv_invoice_link( $invoice_id ) { |
|
1937 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1936 | +function wpinv_invoice_link($invoice_id) { |
|
1937 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1938 | 1938 | |
1939 | - if ( empty( $invoice ) ) { |
|
1939 | + if (empty($invoice)) { |
|
1940 | 1940 | return NULL; |
1941 | 1941 | } |
1942 | 1942 | |
1943 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1943 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1944 | 1944 | |
1945 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1945 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1949 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
1950 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
1948 | +function wpinv_invoice_subscription_details($invoice) { |
|
1949 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1950 | + $subscription = wpinv_get_subscription($invoice, true); |
|
1951 | 1951 | |
1952 | - if ( empty( $subscription ) ) { |
|
1952 | + if (empty($subscription)) { |
|
1953 | 1953 | return; |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1960,15 +1960,15 @@ discard block |
||
1960 | 1960 | $payments = $subscription->get_child_payments(); |
1961 | 1961 | ?> |
1962 | 1962 | <div class="wpinv-subscriptions-details"> |
1963 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1963 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1964 | 1964 | <table class="table"> |
1965 | 1965 | <thead> |
1966 | 1966 | <tr> |
1967 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1968 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1969 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1970 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1971 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1967 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1968 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1969 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1970 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1971 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1972 | 1972 | </tr> |
1973 | 1973 | </thead> |
1974 | 1974 | <tbody> |
@@ -1982,29 +1982,29 @@ discard block |
||
1982 | 1982 | </tbody> |
1983 | 1983 | </table> |
1984 | 1984 | </div> |
1985 | - <?php if ( !empty( $payments ) ) { ?> |
|
1985 | + <?php if (!empty($payments)) { ?> |
|
1986 | 1986 | <div class="wpinv-renewal-payments"> |
1987 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
1987 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
1988 | 1988 | <table class="table"> |
1989 | 1989 | <thead> |
1990 | 1990 | <tr> |
1991 | 1991 | <th>#</th> |
1992 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
1993 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
1994 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
1992 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
1993 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
1994 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
1995 | 1995 | </tr> |
1996 | 1996 | </thead> |
1997 | 1997 | <tbody> |
1998 | 1998 | <?php |
1999 | 1999 | $i = 1; |
2000 | - foreach ( $payments as $payment ) { |
|
2000 | + foreach ($payments as $payment) { |
|
2001 | 2001 | $invoice_id = $payment->ID; |
2002 | 2002 | ?> |
2003 | 2003 | <tr> |
2004 | - <th scope="row"><?php echo $i;?></th> |
|
2005 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2006 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2007 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2004 | + <th scope="row"><?php echo $i; ?></th> |
|
2005 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2006 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2007 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2008 | 2008 | </tr> |
2009 | 2009 | <?php $i++; } ?> |
2010 | 2010 | </tbody> |
@@ -2015,52 +2015,52 @@ discard block |
||
2015 | 2015 | } |
2016 | 2016 | } |
2017 | 2017 | |
2018 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2019 | - if ( empty( $invoice ) ) { |
|
2018 | +function wpinv_cart_total_label($label, $invoice) { |
|
2019 | + if (empty($invoice)) { |
|
2020 | 2020 | return $label; |
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | $prefix_label = ''; |
2024 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2025 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2026 | - } else if ( $invoice->is_renewal() ) { |
|
2027 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2024 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2025 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2026 | + } else if ($invoice->is_renewal()) { |
|
2027 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2028 | 2028 | } |
2029 | 2029 | |
2030 | - if ( $prefix_label != '' ) { |
|
2031 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2030 | + if ($prefix_label != '') { |
|
2031 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2032 | 2032 | } |
2033 | 2033 | |
2034 | 2034 | return $label; |
2035 | 2035 | } |
2036 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2037 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2038 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2036 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2037 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2038 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2039 | 2039 | |
2040 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2040 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2041 | 2041 | |
2042 | -function wpinv_invoice_print_description( $invoice ) { |
|
2043 | - if ( empty( $invoice ) ) { |
|
2042 | +function wpinv_invoice_print_description($invoice) { |
|
2043 | + if (empty($invoice)) { |
|
2044 | 2044 | return NULL; |
2045 | 2045 | } |
2046 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2046 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2047 | 2047 | ?> |
2048 | 2048 | <div class="row wpinv-lower"> |
2049 | 2049 | <div class="col-sm-12 wpinv-description"> |
2050 | - <?php echo wpautop( $description ); ?> |
|
2050 | + <?php echo wpautop($description); ?> |
|
2051 | 2051 | </div> |
2052 | 2052 | </div> |
2053 | 2053 | <?php |
2054 | 2054 | } |
2055 | 2055 | } |
2056 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2056 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2057 | 2057 | |
2058 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2059 | - if ( empty( $invoice ) ) { |
|
2058 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2059 | + if (empty($invoice)) { |
|
2060 | 2060 | return NULL; |
2061 | 2061 | } |
2062 | 2062 | |
2063 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2063 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2064 | 2064 | ?> |
2065 | 2065 | <div class="row wpinv-payments"> |
2066 | 2066 | <div class="col-sm-12"> |
@@ -2072,43 +2072,43 @@ discard block |
||
2072 | 2072 | } |
2073 | 2073 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2074 | 2074 | |
2075 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2076 | - if ( empty( $note ) ) { |
|
2075 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2076 | + if (empty($note)) { |
|
2077 | 2077 | return NULL; |
2078 | 2078 | } |
2079 | 2079 | |
2080 | - if ( is_int( $note ) ) { |
|
2081 | - $note = get_comment( $note ); |
|
2080 | + if (is_int($note)) { |
|
2081 | + $note = get_comment($note); |
|
2082 | 2082 | } |
2083 | 2083 | |
2084 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2084 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2085 | 2085 | return NULL; |
2086 | 2086 | } |
2087 | 2087 | |
2088 | - $note_classes = array( 'note' ); |
|
2089 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2088 | + $note_classes = array('note'); |
|
2089 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2090 | 2090 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2091 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2092 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2091 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2092 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2093 | 2093 | |
2094 | 2094 | ob_start(); |
2095 | 2095 | ?> |
2096 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2096 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2097 | 2097 | <div class="note_content"> |
2098 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2098 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2099 | 2099 | </div> |
2100 | 2100 | <p class="meta"> |
2101 | - <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> |
|
2102 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
2103 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2101 | + <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> |
|
2102 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
2103 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2104 | 2104 | <?php } ?> |
2105 | 2105 | </p> |
2106 | 2106 | </li> |
2107 | 2107 | <?php |
2108 | 2108 | $note_content = ob_get_clean(); |
2109 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2109 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2110 | 2110 | |
2111 | - if ( $echo ) { |
|
2111 | + if ($echo) { |
|
2112 | 2112 | echo $note_content; |
2113 | 2113 | } else { |
2114 | 2114 | return $note_content; |
@@ -2118,43 +2118,43 @@ discard block |
||
2118 | 2118 | function wpinv_invalid_invoice_content() { |
2119 | 2119 | global $post; |
2120 | 2120 | |
2121 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2121 | + $invoice = wpinv_get_invoice($post->ID); |
|
2122 | 2122 | |
2123 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2124 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2125 | - if ( is_user_logged_in() ) { |
|
2126 | - if ( wpinv_require_login_to_checkout() ) { |
|
2127 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2128 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2123 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2124 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2125 | + if (is_user_logged_in()) { |
|
2126 | + if (wpinv_require_login_to_checkout()) { |
|
2127 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2128 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2129 | 2129 | } |
2130 | 2130 | } |
2131 | 2131 | } else { |
2132 | - if ( wpinv_require_login_to_checkout() ) { |
|
2133 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2134 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2132 | + if (wpinv_require_login_to_checkout()) { |
|
2133 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2134 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2135 | 2135 | } |
2136 | 2136 | } |
2137 | 2137 | } |
2138 | 2138 | } else { |
2139 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2139 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2140 | 2140 | } |
2141 | 2141 | ?> |
2142 | 2142 | <div class="row wpinv-row-invalid"> |
2143 | 2143 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2144 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2144 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2145 | 2145 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2146 | 2146 | </div> |
2147 | 2147 | </div> |
2148 | 2148 | <?php |
2149 | 2149 | } |
2150 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2150 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2151 | 2151 | |
2152 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2153 | -function wpinv_force_company_name_field(){ |
|
2152 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2153 | +function wpinv_force_company_name_field() { |
|
2154 | 2154 | $invoice = wpinv_get_invoice_cart(); |
2155 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
2156 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
2157 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
2155 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
2156 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
2157 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
2158 | 2158 | ?> |
2159 | 2159 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
2160 | 2160 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2179,21 +2179,21 @@ discard block |
||
2179 | 2179 | * @return string |
2180 | 2180 | */ |
2181 | 2181 | function wpinv_get_policy_text() { |
2182 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
2182 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
2183 | 2183 | |
2184 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
2184 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
2185 | 2185 | |
2186 | - if(!$privacy_page_id){ |
|
2187 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
2186 | + if (!$privacy_page_id) { |
|
2187 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
2190 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
2191 | 2191 | |
2192 | 2192 | $find_replace = array( |
2193 | 2193 | '[wpinv_privacy_policy]' => $privacy_link, |
2194 | 2194 | ); |
2195 | 2195 | |
2196 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
2196 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
2197 | 2197 | |
2198 | 2198 | return wp_kses_post(wpautop($privacy_text)); |
2199 | 2199 | } |
2200 | 2200 | \ No newline at end of file |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function define_constants() { |
34 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
35 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
34 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
35 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | private function actions() { |
39 | 39 | /* Internationalize the text strings used. */ |
40 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
40 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
41 | 41 | |
42 | 42 | /* Perform actions on admin initialization. */ |
43 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
44 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
45 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
43 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
44 | + add_action('init', array(&$this, 'init'), 3); |
|
45 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
47 | 47 | |
48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
48 | + if (class_exists('BuddyPress')) { |
|
49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
50 | 50 | } |
51 | 51 | |
52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
53 | 53 | |
54 | - if ( is_admin() ) { |
|
55 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
56 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
54 | + if (is_admin()) { |
|
55 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
56 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
57 | 57 | } else { |
58 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
58 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
67 | 67 | */ |
68 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
68 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
69 | 69 | |
70 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
70 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function plugins_loaded() { |
74 | 74 | /* Internationalize the text strings used. */ |
75 | 75 | $this->load_textdomain(); |
76 | 76 | |
77 | - do_action( 'wpinv_loaded' ); |
|
77 | + do_action('wpinv_loaded'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,218 +82,218 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @since 1.0 |
84 | 84 | */ |
85 | - public function load_textdomain( $locale = NULL ) { |
|
86 | - if ( empty( $locale ) ) { |
|
87 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
85 | + public function load_textdomain($locale = NULL) { |
|
86 | + if (empty($locale)) { |
|
87 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
88 | 88 | } |
89 | 89 | |
90 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
90 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
91 | 91 | |
92 | - unload_textdomain( 'invoicing' ); |
|
93 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
94 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
92 | + unload_textdomain('invoicing'); |
|
93 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
94 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Define language constants. |
98 | 98 | */ |
99 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
99 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | public function includes() { |
103 | 103 | global $wpinv_options; |
104 | 104 | |
105 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
106 | 106 | $wpinv_options = wpinv_get_settings(); |
107 | 107 | |
108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
132 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
137 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php' ); |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
139 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
132 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
137 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php'); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
139 | + if (!class_exists('WPInv_EUVat')) { |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
141 | 141 | } |
142 | 142 | |
143 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
144 | - if ( !empty( $gateways ) ) { |
|
145 | - foreach ( $gateways as $gateway ) { |
|
146 | - if ( $gateway == 'manual' ) { |
|
143 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
144 | + if (!empty($gateways)) { |
|
145 | + foreach ($gateways as $gateway) { |
|
146 | + if ($gateway == 'manual') { |
|
147 | 147 | continue; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
151 | 151 | |
152 | - if ( file_exists( $gateway_file ) ) { |
|
153 | - require_once( $gateway_file ); |
|
152 | + if (file_exists($gateway_file)) { |
|
153 | + require_once($gateway_file); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
158 | 158 | |
159 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
159 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
163 | 163 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
170 | 170 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
171 | 171 | // load the user class only on the users.php page |
172 | 172 | global $pagenow; |
173 | - if($pagenow=='users.php'){ |
|
173 | + if ($pagenow == 'users.php') { |
|
174 | 174 | new WPInv_Admin_Users(); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | // include css inliner |
179 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
180 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
179 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
180 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
181 | 181 | } |
182 | 182 | |
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | public function init() { |
187 | 187 | } |
188 | 188 | |
189 | 189 | public function admin_init() { |
190 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
190 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
191 | 191 | } |
192 | 192 | |
193 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
193 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | public function activation_redirect() { |
197 | 197 | // Bail if no activation redirect |
198 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
198 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Delete the redirect transient |
203 | - delete_transient( '_wpinv_activation_redirect' ); |
|
203 | + delete_transient('_wpinv_activation_redirect'); |
|
204 | 204 | |
205 | 205 | // Bail if activating from network, or bulk |
206 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
206 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
210 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
211 | 211 | exit; |
212 | 212 | } |
213 | 213 | |
214 | 214 | public function enqueue_scripts() { |
215 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
215 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
216 | 216 | |
217 | - wp_deregister_style( 'font-awesome' ); |
|
218 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
219 | - wp_enqueue_style( 'font-awesome' ); |
|
217 | + wp_deregister_style('font-awesome'); |
|
218 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
219 | + wp_enqueue_style('font-awesome'); |
|
220 | 220 | |
221 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
222 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
221 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
222 | + wp_enqueue_style('wpinv_front_style'); |
|
223 | 223 | |
224 | 224 | // Register scripts |
225 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
226 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
225 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
226 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
227 | 227 | |
228 | 228 | $localize = array(); |
229 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
230 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
229 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
230 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
231 | 231 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
232 | 232 | $localize['currency_pos'] = wpinv_currency_position(); |
233 | 233 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
234 | 234 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
235 | 235 | $localize['decimals'] = wpinv_decimals(); |
236 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
236 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
237 | 237 | |
238 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
238 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
239 | 239 | |
240 | - wp_enqueue_script( 'jquery-blockui' ); |
|
240 | + wp_enqueue_script('jquery-blockui'); |
|
241 | 241 | $autofill_api = wpinv_get_option('address_autofill_api'); |
242 | 242 | $autofill_active = wpinv_get_option('address_autofill_active'); |
243 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
244 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
245 | - wp_dequeue_script( 'google-maps-api' ); |
|
243 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
244 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
245 | + wp_dequeue_script('google-maps-api'); |
|
246 | 246 | } |
247 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
248 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
247 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
248 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
249 | 249 | } |
250 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
251 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
250 | + wp_enqueue_script('wpinv-front-script'); |
|
251 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | public function admin_enqueue_scripts() { |
255 | 255 | global $post, $pagenow; |
256 | 256 | |
257 | 257 | $post_type = wpinv_admin_post_type(); |
258 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
259 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
258 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
259 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
260 | 260 | |
261 | - wp_deregister_style( 'font-awesome' ); |
|
262 | - wp_register_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.4.2/css/all.css', array(), '5.4.2' ); |
|
263 | - wp_register_style( 'font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.2/css/v4-shims.css', array(), '5.4.2' ); |
|
264 | - wp_enqueue_style( 'font-awesome-shim' ); |
|
265 | - wp_enqueue_style( 'font-awesome' ); |
|
261 | + wp_deregister_style('font-awesome'); |
|
262 | + wp_register_style('font-awesome', 'https://use.fontawesome.com/releases/v5.4.2/css/all.css', array(), '5.4.2'); |
|
263 | + wp_register_style('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.2/css/v4-shims.css', array(), '5.4.2'); |
|
264 | + wp_enqueue_style('font-awesome-shim'); |
|
265 | + wp_enqueue_style('font-awesome'); |
|
266 | 266 | |
267 | 267 | $jquery_ui_css = false; |
268 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
268 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
269 | 269 | $jquery_ui_css = true; |
270 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
270 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
271 | 271 | $jquery_ui_css = true; |
272 | 272 | } |
273 | - if ( $jquery_ui_css ) { |
|
274 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
275 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
273 | + if ($jquery_ui_css) { |
|
274 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
275 | + wp_enqueue_style('jquery-ui-css'); |
|
276 | 276 | } |
277 | 277 | |
278 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
279 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
278 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
279 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
280 | 280 | |
281 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
282 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
281 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
282 | + wp_enqueue_style('wpinv_admin_style'); |
|
283 | 283 | |
284 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
285 | - if ( $page == 'wpinv-subscriptions' ) { |
|
286 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
284 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
285 | + if ($page == 'wpinv-subscriptions') { |
|
286 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
290 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
289 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
290 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
291 | 291 | } |
292 | 292 | |
293 | - wp_enqueue_style( 'wp-color-picker' ); |
|
294 | - wp_enqueue_script( 'wp-color-picker' ); |
|
293 | + wp_enqueue_style('wp-color-picker'); |
|
294 | + wp_enqueue_script('wp-color-picker'); |
|
295 | 295 | |
296 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
296 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
297 | 297 | wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), WPINV_VERSION); |
298 | 298 | wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), WPINV_VERSION); |
299 | 299 | |
@@ -306,22 +306,22 @@ discard block |
||
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - if ( !wp_script_is( 'font-awesome', 'enqueued' ) ) { |
|
310 | - wp_enqueue_script( 'font-awesome' ); |
|
311 | - wp_enqueue_script( 'font-awesome-shim' ); |
|
309 | + if (!wp_script_is('font-awesome', 'enqueued')) { |
|
310 | + wp_enqueue_script('font-awesome'); |
|
311 | + wp_enqueue_script('font-awesome-shim'); |
|
312 | 312 | } |
313 | 313 | |
314 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
315 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
314 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
315 | + wp_enqueue_script('wpinv-admin-script'); |
|
316 | 316 | |
317 | 317 | $localize = array(); |
318 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
319 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
320 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
321 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
322 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
323 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
324 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
318 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
319 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
320 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
321 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
322 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
323 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
324 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
325 | 325 | $localize['tax'] = wpinv_tax_amount(); |
326 | 326 | $localize['discount'] = wpinv_discount_amount(); |
327 | 327 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -329,69 +329,69 @@ discard block |
||
329 | 329 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
330 | 330 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
331 | 331 | $localize['decimals'] = wpinv_decimals(); |
332 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
333 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
334 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
335 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
336 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
337 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
338 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
339 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
340 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
341 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
342 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
343 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
344 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
345 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
332 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
333 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
334 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
335 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
336 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
337 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
338 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
339 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
340 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
341 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
342 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
343 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
344 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
345 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
346 | 346 | |
347 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
347 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
348 | 348 | |
349 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
349 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
350 | 350 | |
351 | - if ( $page == 'wpinv-subscriptions' ) { |
|
352 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
353 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
351 | + if ($page == 'wpinv-subscriptions') { |
|
352 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
353 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - public function admin_body_class( $classes ) { |
|
357 | + public function admin_body_class($classes) { |
|
358 | 358 | global $pagenow, $post, $current_screen; |
359 | 359 | |
360 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
360 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
361 | 361 | $classes .= ' wpinv-cpt'; |
362 | 362 | } |
363 | 363 | |
364 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
364 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
365 | 365 | |
366 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
367 | - if ( $add_class ) { |
|
368 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
366 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
367 | + if ($add_class) { |
|
368 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $settings_class = array(); |
372 | - if ( $page == 'wpinv-settings' ) { |
|
373 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
374 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
372 | + if ($page == 'wpinv-settings') { |
|
373 | + if (!empty($_REQUEST['tab'])) { |
|
374 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
375 | 375 | } |
376 | 376 | |
377 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
378 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
377 | + if (!empty($_REQUEST['section'])) { |
|
378 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
379 | 379 | } |
380 | 380 | |
381 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
381 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( !empty( $settings_class ) ) { |
|
385 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
384 | + if (!empty($settings_class)) { |
|
385 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | $post_type = wpinv_admin_post_type(); |
389 | 389 | |
390 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
390 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
391 | 391 | return $classes .= ' wpinv'; |
392 | 392 | } |
393 | 393 | |
394 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
394 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
395 | 395 | $classes .= ' wpi-editable-n'; |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | } |
404 | 404 | |
405 | 405 | public function wpinv_actions() { |
406 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
407 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
406 | + if (isset($_REQUEST['wpi_action'])) { |
|
407 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - public function pre_get_posts( $wp_query ) { |
|
412 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
413 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
411 | + public function pre_get_posts($wp_query) { |
|
412 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
413 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | return $wp_query; |
417 | 417 | } |
418 | 418 | |
419 | 419 | public function bp_invoicing_init() { |
420 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
420 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | \ No newline at end of file |