@@ -7,109 +7,109 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', 'invoicing/' ); |
|
22 | + return apply_filters('wpinv_template_path', 'invoicing/'); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_post_class( $classes, $class, $post_id ) { |
|
25 | +function wpinv_post_class($classes, $class, $post_id) { |
|
26 | 26 | global $pagenow, $typenow; |
27 | 27 | |
28 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' ) { |
|
28 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && get_post_meta($post_id, '_wpinv_type', true) == 'package') { |
|
29 | 29 | $classes[] = 'wpi-gd-package'; |
30 | 30 | } |
31 | 31 | return $classes; |
32 | 32 | } |
33 | -add_filter( 'post_class', 'wpinv_post_class', 10, 3 ); |
|
33 | +add_filter('post_class', 'wpinv_post_class', 10, 3); |
|
34 | 34 | |
35 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
36 | - if ( empty( $invoice ) ) { |
|
35 | +function wpinv_display_invoice_top_bar($invoice) { |
|
36 | + if (empty($invoice)) { |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | <div class="row wpinv-top-bar no-print"> |
41 | 41 | <div class="container"> |
42 | 42 | <div class="col-xs-6"> |
43 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
43 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
44 | 44 | </div> |
45 | 45 | <div class="col-xs-6 text-right"> |
46 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
46 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | <?php |
51 | 51 | } |
52 | 52 | |
53 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
54 | - if ( empty( $invoice ) ) { |
|
53 | +function wpinv_invoice_display_left_actions($invoice) { |
|
54 | + if (empty($invoice)) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if($invoice->post_type == 'wpi_invoice'){ |
|
58 | + if ($invoice->post_type == 'wpi_invoice') { |
|
59 | 59 | |
60 | 60 | $user_id = (int)$invoice->get_user_id(); |
61 | 61 | $current_user_id = (int)get_current_user_id(); |
62 | 62 | |
63 | - if ( $user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment() ) { |
|
63 | + if ($user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment()) { |
|
64 | 64 | ?> |
65 | - <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> |
|
65 | + <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> |
|
66 | 66 | <?php |
67 | 67 | } |
68 | 68 | } |
69 | 69 | do_action('wpinv_invoice_display_left_actions', $invoice); |
70 | 70 | } |
71 | 71 | |
72 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
73 | - if ( empty( $invoice ) ) return; //Exit if invoice is not set. |
|
72 | +function wpinv_invoice_display_right_actions($invoice) { |
|
73 | + if (empty($invoice)) return; //Exit if invoice is not set. |
|
74 | 74 | |
75 | - if($invoice->post_type == 'wpi_invoice'){ |
|
75 | + if ($invoice->post_type == 'wpi_invoice') { |
|
76 | 76 | $user_id = (int)$invoice->get_user_id(); |
77 | 77 | $current_user_id = (int)get_current_user_id(); |
78 | 78 | |
79 | - if ( $user_id > 0 && $user_id == $current_user_id ) { |
|
79 | + if ($user_id > 0 && $user_id == $current_user_id) { |
|
80 | 80 | ?> |
81 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
82 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
81 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
82 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
83 | 83 | <?php } |
84 | 84 | } |
85 | 85 | do_action('wpinv_invoice_display_right_actions', $invoice); |
86 | 86 | } |
87 | 87 | |
88 | -function wpinv_before_invoice_content( $content ) { |
|
88 | +function wpinv_before_invoice_content($content) { |
|
89 | 89 | global $post; |
90 | 90 | |
91 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
91 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
92 | 92 | ob_start(); |
93 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
93 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
94 | 94 | $content = ob_get_clean() . $content; |
95 | 95 | } |
96 | 96 | |
97 | 97 | return $content; |
98 | 98 | } |
99 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
99 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
100 | 100 | |
101 | -function wpinv_after_invoice_content( $content ) { |
|
101 | +function wpinv_after_invoice_content($content) { |
|
102 | 102 | global $post; |
103 | 103 | |
104 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
104 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
105 | 105 | ob_start(); |
106 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
106 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
107 | 107 | $content .= ob_get_clean(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | return $content; |
111 | 111 | } |
112 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
112 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
113 | 113 | |
114 | 114 | function wpinv_get_templates_dir() { |
115 | 115 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -119,105 +119,105 @@ discard block |
||
119 | 119 | return WPINV_PLUGIN_URL . 'templates'; |
120 | 120 | } |
121 | 121 | |
122 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
123 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
124 | - extract( $args ); |
|
122 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
123 | + if (!empty($args) && is_array($args)) { |
|
124 | + extract($args); |
|
125 | 125 | } |
126 | 126 | |
127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
127 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
128 | 128 | // Allow 3rd party plugin filter template file from their plugin. |
129 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
129 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
130 | 130 | |
131 | - if ( ! file_exists( $located ) ) { |
|
132 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
131 | + if (!file_exists($located)) { |
|
132 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
136 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
137 | 137 | |
138 | - include( $located ); |
|
138 | + include($located); |
|
139 | 139 | |
140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
140 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
141 | 141 | } |
142 | 142 | |
143 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
144 | 144 | ob_start(); |
145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
145 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
146 | 146 | return ob_get_clean(); |
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
150 | - if ( ! $template_path ) { |
|
149 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
150 | + if (!$template_path) { |
|
151 | 151 | $template_path = wpinv_template_path(); |
152 | 152 | } |
153 | 153 | |
154 | - if ( ! $default_path ) { |
|
154 | + if (!$default_path) { |
|
155 | 155 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Look within passed path within the theme - this is priority. |
159 | 159 | $template = locate_template( |
160 | 160 | array( |
161 | - trailingslashit( $template_path ) . $template_name, |
|
161 | + trailingslashit($template_path) . $template_name, |
|
162 | 162 | $template_name |
163 | 163 | ) |
164 | 164 | ); |
165 | 165 | |
166 | 166 | // Get default templates/ |
167 | - if ( !$template && $default_path ) { |
|
168 | - $template = trailingslashit( $default_path ) . $template_name; |
|
167 | + if (!$template && $default_path) { |
|
168 | + $template = trailingslashit($default_path) . $template_name; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Return what we found. |
172 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
172 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
173 | 173 | } |
174 | 174 | |
175 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
175 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
176 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
177 | 177 | |
178 | 178 | // Setup possible parts |
179 | 179 | $templates = array(); |
180 | - if ( isset( $name ) ) |
|
180 | + if (isset($name)) |
|
181 | 181 | $templates[] = $slug . '-' . $name . '.php'; |
182 | 182 | $templates[] = $slug . '.php'; |
183 | 183 | |
184 | 184 | // Allow template parts to be filtered |
185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
185 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
186 | 186 | |
187 | 187 | // Return the part that is found |
188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
188 | + return wpinv_locate_tmpl($templates, $load, false); |
|
189 | 189 | } |
190 | 190 | |
191 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
191 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
192 | 192 | // No file found yet |
193 | 193 | $located = false; |
194 | 194 | |
195 | 195 | // Try to find a template file |
196 | - foreach ( (array)$template_names as $template_name ) { |
|
196 | + foreach ((array)$template_names as $template_name) { |
|
197 | 197 | |
198 | 198 | // Continue if template is empty |
199 | - if ( empty( $template_name ) ) |
|
199 | + if (empty($template_name)) |
|
200 | 200 | continue; |
201 | 201 | |
202 | 202 | // Trim off any slashes from the template name |
203 | - $template_name = ltrim( $template_name, '/' ); |
|
203 | + $template_name = ltrim($template_name, '/'); |
|
204 | 204 | |
205 | 205 | // try locating this template file by looping through the template paths |
206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
206 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
207 | 207 | |
208 | - if( file_exists( $template_path . $template_name ) ) { |
|
208 | + if (file_exists($template_path . $template_name)) { |
|
209 | 209 | $located = $template_path . $template_name; |
210 | 210 | break; |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - if( !empty( $located ) ) { |
|
214 | + if (!empty($located)) { |
|
215 | 215 | break; |
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
220 | - load_template( $located, $require_once ); |
|
219 | + if ((true == $load) && !empty($located)) |
|
220 | + load_template($located, $require_once); |
|
221 | 221 | |
222 | 222 | return $located; |
223 | 223 | } |
@@ -226,143 +226,143 @@ discard block |
||
226 | 226 | $template_dir = wpinv_get_theme_template_dir_name(); |
227 | 227 | |
228 | 228 | $file_paths = array( |
229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
229 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
230 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
231 | 231 | 100 => wpinv_get_templates_dir() |
232 | 232 | ); |
233 | 233 | |
234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
234 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
235 | 235 | |
236 | 236 | // sort the file paths based on priority |
237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
237 | + ksort($file_paths, SORT_NUMERIC); |
|
238 | 238 | |
239 | - return array_map( 'trailingslashit', $file_paths ); |
|
239 | + return array_map('trailingslashit', $file_paths); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | function wpinv_get_theme_template_dir_name() { |
243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
243 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | function wpinv_checkout_meta_tags() { |
247 | 247 | |
248 | 248 | $pages = array(); |
249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
249 | + $pages[] = wpinv_get_option('success_page'); |
|
250 | + $pages[] = wpinv_get_option('failure_page'); |
|
251 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
252 | 252 | |
253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
253 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | 257 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
258 | 258 | } |
259 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
259 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
260 | 260 | |
261 | -function wpinv_add_body_classes( $class ) { |
|
261 | +function wpinv_add_body_classes($class) { |
|
262 | 262 | $classes = (array)$class; |
263 | 263 | |
264 | - if( wpinv_is_checkout() ) { |
|
264 | + if (wpinv_is_checkout()) { |
|
265 | 265 | $classes[] = 'wpinv-checkout'; |
266 | 266 | $classes[] = 'wpinv-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if( wpinv_is_success_page() ) { |
|
269 | + if (wpinv_is_success_page()) { |
|
270 | 270 | $classes[] = 'wpinv-success'; |
271 | 271 | $classes[] = 'wpinv-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if( wpinv_is_failed_transaction_page() ) { |
|
274 | + if (wpinv_is_failed_transaction_page()) { |
|
275 | 275 | $classes[] = 'wpinv-failed-transaction'; |
276 | 276 | $classes[] = 'wpinv-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if( wpinv_is_invoice_history_page() ) { |
|
279 | + if (wpinv_is_invoice_history_page()) { |
|
280 | 280 | $classes[] = 'wpinv-history'; |
281 | 281 | $classes[] = 'wpinv-page'; |
282 | 282 | } |
283 | 283 | |
284 | - if( wpinv_is_test_mode() ) { |
|
284 | + if (wpinv_is_test_mode()) { |
|
285 | 285 | $classes[] = 'wpinv-test-mode'; |
286 | 286 | $classes[] = 'wpinv-page'; |
287 | 287 | } |
288 | 288 | |
289 | - return array_unique( $classes ); |
|
289 | + return array_unique($classes); |
|
290 | 290 | } |
291 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
291 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
292 | 292 | |
293 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
294 | - $args = array( 'nopaging' => true ); |
|
293 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
294 | + $args = array('nopaging' => true); |
|
295 | 295 | |
296 | - if ( ! empty( $status ) ) |
|
296 | + if (!empty($status)) |
|
297 | 297 | $args['post_status'] = $status; |
298 | 298 | |
299 | - $discounts = wpinv_get_discounts( $args ); |
|
299 | + $discounts = wpinv_get_discounts($args); |
|
300 | 300 | $options = array(); |
301 | 301 | |
302 | - if ( $discounts ) { |
|
303 | - foreach ( $discounts as $discount ) { |
|
304 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
302 | + if ($discounts) { |
|
303 | + foreach ($discounts as $discount) { |
|
304 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
305 | 305 | } |
306 | 306 | } else { |
307 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
307 | + $options[0] = __('No discounts found', 'invoicing'); |
|
308 | 308 | } |
309 | 309 | |
310 | - $output = wpinv_html_select( array( |
|
310 | + $output = wpinv_html_select(array( |
|
311 | 311 | 'name' => $name, |
312 | 312 | 'selected' => $selected, |
313 | 313 | 'options' => $options, |
314 | 314 | 'show_option_all' => false, |
315 | 315 | 'show_option_none' => false, |
316 | - ) ); |
|
316 | + )); |
|
317 | 317 | |
318 | 318 | return $output; |
319 | 319 | } |
320 | 320 | |
321 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
322 | - $current = date( 'Y' ); |
|
323 | - $start_year = $current - absint( $years_before ); |
|
324 | - $end_year = $current + absint( $years_after ); |
|
325 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
321 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
322 | + $current = date('Y'); |
|
323 | + $start_year = $current - absint($years_before); |
|
324 | + $end_year = $current + absint($years_after); |
|
325 | + $selected = empty($selected) ? date('Y') : $selected; |
|
326 | 326 | $options = array(); |
327 | 327 | |
328 | - while ( $start_year <= $end_year ) { |
|
329 | - $options[ absint( $start_year ) ] = $start_year; |
|
328 | + while ($start_year <= $end_year) { |
|
329 | + $options[absint($start_year)] = $start_year; |
|
330 | 330 | $start_year++; |
331 | 331 | } |
332 | 332 | |
333 | - $output = wpinv_html_select( array( |
|
333 | + $output = wpinv_html_select(array( |
|
334 | 334 | 'name' => $name, |
335 | 335 | 'selected' => $selected, |
336 | 336 | 'options' => $options, |
337 | 337 | 'show_option_all' => false, |
338 | 338 | 'show_option_none' => false |
339 | - ) ); |
|
339 | + )); |
|
340 | 340 | |
341 | 341 | return $output; |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
344 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
345 | 345 | $month = 1; |
346 | 346 | $options = array(); |
347 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
347 | + $selected = empty($selected) ? date('n') : $selected; |
|
348 | 348 | |
349 | - while ( $month <= 12 ) { |
|
350 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
349 | + while ($month <= 12) { |
|
350 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
351 | 351 | $month++; |
352 | 352 | } |
353 | 353 | |
354 | - $output = wpinv_html_select( array( |
|
354 | + $output = wpinv_html_select(array( |
|
355 | 355 | 'name' => $name, |
356 | 356 | 'selected' => $selected, |
357 | 357 | 'options' => $options, |
358 | 358 | 'show_option_all' => false, |
359 | 359 | 'show_option_none' => false |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | |
362 | 362 | return $output; |
363 | 363 | } |
364 | 364 | |
365 | -function wpinv_html_select( $args = array() ) { |
|
365 | +function wpinv_html_select($args = array()) { |
|
366 | 366 | $defaults = array( |
367 | 367 | 'options' => array(), |
368 | 368 | 'name' => null, |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | 'chosen' => false, |
373 | 373 | 'placeholder' => null, |
374 | 374 | 'multiple' => false, |
375 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
376 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
375 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
376 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
377 | 377 | 'data' => array(), |
378 | 378 | 'onchange' => null, |
379 | 379 | 'required' => false, |
@@ -381,78 +381,78 @@ discard block |
||
381 | 381 | 'readonly' => false, |
382 | 382 | ); |
383 | 383 | |
384 | - $args = wp_parse_args( $args, $defaults ); |
|
384 | + $args = wp_parse_args($args, $defaults); |
|
385 | 385 | |
386 | 386 | $data_elements = ''; |
387 | - foreach ( $args['data'] as $key => $value ) { |
|
388 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
387 | + foreach ($args['data'] as $key => $value) { |
|
388 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
389 | 389 | } |
390 | 390 | |
391 | - if( $args['multiple'] ) { |
|
391 | + if ($args['multiple']) { |
|
392 | 392 | $multiple = ' MULTIPLE'; |
393 | 393 | } else { |
394 | 394 | $multiple = ''; |
395 | 395 | } |
396 | 396 | |
397 | - if( $args['chosen'] ) { |
|
397 | + if ($args['chosen']) { |
|
398 | 398 | $args['class'] .= ' wpinv-select-chosen'; |
399 | 399 | } |
400 | 400 | |
401 | - if( $args['placeholder'] ) { |
|
401 | + if ($args['placeholder']) { |
|
402 | 402 | $placeholder = $args['placeholder']; |
403 | 403 | } else { |
404 | 404 | $placeholder = ''; |
405 | 405 | } |
406 | 406 | |
407 | 407 | $options = ''; |
408 | - if( !empty( $args['onchange'] ) ) { |
|
409 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
408 | + if (!empty($args['onchange'])) { |
|
409 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
410 | 410 | } |
411 | 411 | |
412 | - if( !empty( $args['required'] ) ) { |
|
412 | + if (!empty($args['required'])) { |
|
413 | 413 | $options .= ' required="required"'; |
414 | 414 | } |
415 | 415 | |
416 | - if( !empty( $args['disabled'] ) ) { |
|
416 | + if (!empty($args['disabled'])) { |
|
417 | 417 | $options .= ' disabled'; |
418 | 418 | } |
419 | 419 | |
420 | - if( !empty( $args['readonly'] ) ) { |
|
420 | + if (!empty($args['readonly'])) { |
|
421 | 421 | $options .= ' readonly'; |
422 | 422 | } |
423 | 423 | |
424 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
425 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
424 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
425 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
426 | 426 | |
427 | - if ( $args['show_option_all'] ) { |
|
428 | - if( $args['multiple'] ) { |
|
429 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
427 | + if ($args['show_option_all']) { |
|
428 | + if ($args['multiple']) { |
|
429 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
430 | 430 | } else { |
431 | - $selected = selected( $args['selected'], 0, false ); |
|
431 | + $selected = selected($args['selected'], 0, false); |
|
432 | 432 | } |
433 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
433 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
434 | 434 | } |
435 | 435 | |
436 | - if ( !empty( $args['options'] ) ) { |
|
436 | + if (!empty($args['options'])) { |
|
437 | 437 | |
438 | - if ( $args['show_option_none'] ) { |
|
439 | - if( $args['multiple'] ) { |
|
440 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
438 | + if ($args['show_option_none']) { |
|
439 | + if ($args['multiple']) { |
|
440 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
441 | 441 | } else { |
442 | - $selected = selected( $args['selected'] === "", true, false ); |
|
442 | + $selected = selected($args['selected'] === "", true, false); |
|
443 | 443 | } |
444 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
444 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
445 | 445 | } |
446 | 446 | |
447 | - foreach( $args['options'] as $key => $option ) { |
|
447 | + foreach ($args['options'] as $key => $option) { |
|
448 | 448 | |
449 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
450 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
449 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
450 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
451 | 451 | } else { |
452 | - $selected = selected( $args['selected'], $key, false ); |
|
452 | + $selected = selected($args['selected'], $key, false); |
|
453 | 453 | } |
454 | 454 | |
455 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
455 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | return $output; |
462 | 462 | } |
463 | 463 | |
464 | -function wpinv_item_dropdown( $args = array() ) { |
|
464 | +function wpinv_item_dropdown($args = array()) { |
|
465 | 465 | $defaults = array( |
466 | 466 | 'name' => 'wpi_item', |
467 | 467 | 'id' => 'wpi_item', |
@@ -470,15 +470,15 @@ discard block |
||
470 | 470 | 'selected' => 0, |
471 | 471 | 'chosen' => false, |
472 | 472 | 'number' => 100, |
473 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
474 | - 'data' => array( 'search-type' => 'item' ), |
|
473 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
474 | + 'data' => array('search-type' => 'item'), |
|
475 | 475 | 'show_option_all' => false, |
476 | 476 | 'show_option_none' => false, |
477 | 477 | 'with_packages' => true, |
478 | 478 | 'show_recurring' => false, |
479 | 479 | ); |
480 | 480 | |
481 | - $args = wp_parse_args( $args, $defaults ); |
|
481 | + $args = wp_parse_args($args, $defaults); |
|
482 | 482 | |
483 | 483 | $item_args = array( |
484 | 484 | 'post_type' => 'wpi_item', |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | 'posts_per_page' => $args['number'] |
488 | 488 | ); |
489 | 489 | |
490 | - if ( !$args['with_packages'] ) { |
|
490 | + if (!$args['with_packages']) { |
|
491 | 491 | $item_args['meta_query'] = array( |
492 | 492 | array( |
493 | 493 | 'key' => '_wpinv_type', |
@@ -497,42 +497,42 @@ discard block |
||
497 | 497 | ); |
498 | 498 | } |
499 | 499 | |
500 | - $items = get_posts( $item_args ); |
|
500 | + $items = get_posts($item_args); |
|
501 | 501 | $options = array(); |
502 | - if ( $items ) { |
|
503 | - foreach ( $items as $item ) { |
|
504 | - $title = esc_html( $item->post_title ); |
|
502 | + if ($items) { |
|
503 | + foreach ($items as $item) { |
|
504 | + $title = esc_html($item->post_title); |
|
505 | 505 | |
506 | - if ( !empty( $args['show_recurring'] ) ) { |
|
507 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
506 | + if (!empty($args['show_recurring'])) { |
|
507 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
508 | 508 | } |
509 | 509 | |
510 | - $options[ absint( $item->ID ) ] = $title; |
|
510 | + $options[absint($item->ID)] = $title; |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | // This ensures that any selected items are included in the drop down |
515 | - if( is_array( $args['selected'] ) ) { |
|
516 | - foreach( $args['selected'] as $item ) { |
|
517 | - if( ! in_array( $item, $options ) ) { |
|
518 | - $title = get_the_title( $item ); |
|
519 | - if ( !empty( $args['show_recurring'] ) ) { |
|
520 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
515 | + if (is_array($args['selected'])) { |
|
516 | + foreach ($args['selected'] as $item) { |
|
517 | + if (!in_array($item, $options)) { |
|
518 | + $title = get_the_title($item); |
|
519 | + if (!empty($args['show_recurring'])) { |
|
520 | + $title .= wpinv_get_item_suffix($item, false); |
|
521 | 521 | } |
522 | 522 | $options[$item] = $title; |
523 | 523 | } |
524 | 524 | } |
525 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
526 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
527 | - $title = get_the_title( $args['selected'] ); |
|
528 | - if ( !empty( $args['show_recurring'] ) ) { |
|
529 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
525 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
526 | + if (!in_array($args['selected'], $options)) { |
|
527 | + $title = get_the_title($args['selected']); |
|
528 | + if (!empty($args['show_recurring'])) { |
|
529 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
530 | 530 | } |
531 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
531 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | |
535 | - $output = wpinv_html_select( array( |
|
535 | + $output = wpinv_html_select(array( |
|
536 | 536 | 'name' => $args['name'], |
537 | 537 | 'selected' => $args['selected'], |
538 | 538 | 'id' => $args['id'], |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | 'show_option_all' => $args['show_option_all'], |
545 | 545 | 'show_option_none' => $args['show_option_none'], |
546 | 546 | 'data' => $args['data'], |
547 | - ) ); |
|
547 | + )); |
|
548 | 548 | |
549 | 549 | return $output; |
550 | 550 | } |
551 | 551 | |
552 | -function wpinv_html_checkbox( $args = array() ) { |
|
552 | +function wpinv_html_checkbox($args = array()) { |
|
553 | 553 | $defaults = array( |
554 | 554 | 'name' => null, |
555 | 555 | 'current' => null, |
@@ -560,38 +560,38 @@ discard block |
||
560 | 560 | ) |
561 | 561 | ); |
562 | 562 | |
563 | - $args = wp_parse_args( $args, $defaults ); |
|
563 | + $args = wp_parse_args($args, $defaults); |
|
564 | 564 | |
565 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
565 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
566 | 566 | $options = ''; |
567 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
567 | + if (!empty($args['options']['disabled'])) { |
|
568 | 568 | $options .= ' disabled="disabled"'; |
569 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
569 | + } elseif (!empty($args['options']['readonly'])) { |
|
570 | 570 | $options .= ' readonly'; |
571 | 571 | } |
572 | 572 | |
573 | - $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 ) . ' />'; |
|
573 | + $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) . ' />'; |
|
574 | 574 | |
575 | 575 | return $output; |
576 | 576 | } |
577 | 577 | |
578 | -function wpinv_html_text( $args = array() ) { |
|
578 | +function wpinv_html_text($args = array()) { |
|
579 | 579 | // Backwards compatibility |
580 | - if ( func_num_args() > 1 ) { |
|
580 | + if (func_num_args() > 1) { |
|
581 | 581 | $args = func_get_args(); |
582 | 582 | |
583 | 583 | $name = $args[0]; |
584 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
585 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
586 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
584 | + $value = isset($args[1]) ? $args[1] : ''; |
|
585 | + $label = isset($args[2]) ? $args[2] : ''; |
|
586 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $defaults = array( |
590 | 590 | 'id' => '', |
591 | - 'name' => isset( $name ) ? $name : 'text', |
|
592 | - 'value' => isset( $value ) ? $value : null, |
|
593 | - 'label' => isset( $label ) ? $label : null, |
|
594 | - 'desc' => isset( $desc ) ? $desc : null, |
|
591 | + 'name' => isset($name) ? $name : 'text', |
|
592 | + 'value' => isset($value) ? $value : null, |
|
593 | + 'label' => isset($label) ? $label : null, |
|
594 | + 'desc' => isset($desc) ? $desc : null, |
|
595 | 595 | 'placeholder' => '', |
596 | 596 | 'class' => 'regular-text', |
597 | 597 | 'disabled' => false, |
@@ -601,51 +601,51 @@ discard block |
||
601 | 601 | 'data' => false |
602 | 602 | ); |
603 | 603 | |
604 | - $args = wp_parse_args( $args, $defaults ); |
|
604 | + $args = wp_parse_args($args, $defaults); |
|
605 | 605 | |
606 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
606 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
607 | 607 | $options = ''; |
608 | - if( $args['required'] ) { |
|
608 | + if ($args['required']) { |
|
609 | 609 | $options .= ' required="required"'; |
610 | 610 | } |
611 | - if( $args['readonly'] ) { |
|
611 | + if ($args['readonly']) { |
|
612 | 612 | $options .= ' readonly'; |
613 | 613 | } |
614 | - if( $args['readonly'] ) { |
|
614 | + if ($args['readonly']) { |
|
615 | 615 | $options .= ' readonly'; |
616 | 616 | } |
617 | 617 | |
618 | 618 | $data = ''; |
619 | - if ( !empty( $args['data'] ) ) { |
|
620 | - foreach ( $args['data'] as $key => $value ) { |
|
621 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
619 | + if (!empty($args['data'])) { |
|
620 | + foreach ($args['data'] as $key => $value) { |
|
621 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
625 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
626 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
627 | - if ( ! empty( $args['desc'] ) ) { |
|
628 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
625 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
626 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
627 | + if (!empty($args['desc'])) { |
|
628 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
629 | 629 | } |
630 | 630 | |
631 | - $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 ) . '/>'; |
|
631 | + $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) . '/>'; |
|
632 | 632 | |
633 | 633 | $output .= '</span>'; |
634 | 634 | |
635 | 635 | return $output; |
636 | 636 | } |
637 | 637 | |
638 | -function wpinv_html_date_field( $args = array() ) { |
|
639 | - if( empty( $args['class'] ) ) { |
|
638 | +function wpinv_html_date_field($args = array()) { |
|
639 | + if (empty($args['class'])) { |
|
640 | 640 | $args['class'] = 'wpiDatepicker'; |
641 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
641 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
642 | 642 | $args['class'] .= ' wpiDatepicker'; |
643 | 643 | } |
644 | 644 | |
645 | - return wpinv_html_text( $args ); |
|
645 | + return wpinv_html_text($args); |
|
646 | 646 | } |
647 | 647 | |
648 | -function wpinv_html_textarea( $args = array() ) { |
|
648 | +function wpinv_html_textarea($args = array()) { |
|
649 | 649 | $defaults = array( |
650 | 650 | 'name' => 'textarea', |
651 | 651 | 'value' => null, |
@@ -655,31 +655,31 @@ discard block |
||
655 | 655 | 'disabled' => false |
656 | 656 | ); |
657 | 657 | |
658 | - $args = wp_parse_args( $args, $defaults ); |
|
658 | + $args = wp_parse_args($args, $defaults); |
|
659 | 659 | |
660 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
660 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
661 | 661 | $disabled = ''; |
662 | - if( $args['disabled'] ) { |
|
662 | + if ($args['disabled']) { |
|
663 | 663 | $disabled = ' disabled="disabled"'; |
664 | 664 | } |
665 | 665 | |
666 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
667 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
668 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
666 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
667 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
668 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
669 | 669 | |
670 | - if ( ! empty( $args['desc'] ) ) { |
|
671 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
670 | + if (!empty($args['desc'])) { |
|
671 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
672 | 672 | } |
673 | 673 | $output .= '</span>'; |
674 | 674 | |
675 | 675 | return $output; |
676 | 676 | } |
677 | 677 | |
678 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
678 | +function wpinv_html_ajax_user_search($args = array()) { |
|
679 | 679 | $defaults = array( |
680 | 680 | 'name' => 'user_id', |
681 | 681 | 'value' => null, |
682 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
682 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
683 | 683 | 'label' => null, |
684 | 684 | 'desc' => null, |
685 | 685 | 'class' => '', |
@@ -688,13 +688,13 @@ discard block |
||
688 | 688 | 'data' => false |
689 | 689 | ); |
690 | 690 | |
691 | - $args = wp_parse_args( $args, $defaults ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | 692 | |
693 | 693 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
694 | 694 | |
695 | 695 | $output = '<span class="wpinv_user_search_wrap">'; |
696 | - $output .= wpinv_html_text( $args ); |
|
697 | - $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>'; |
|
696 | + $output .= wpinv_html_text($args); |
|
697 | + $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>'; |
|
698 | 698 | $output .= '</span>'; |
699 | 699 | |
700 | 700 | return $output; |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | function wpinv_ip_geolocation() { |
704 | 704 | global $wpinv_euvat; |
705 | 705 | |
706 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
706 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
707 | 707 | $content = ''; |
708 | 708 | $iso = ''; |
709 | 709 | $country = ''; |
@@ -714,69 +714,69 @@ discard block |
||
714 | 714 | $credit = ''; |
715 | 715 | $address = ''; |
716 | 716 | |
717 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
717 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
718 | 718 | try { |
719 | 719 | $iso = $geoip2_city->country->isoCode; |
720 | 720 | $country = $geoip2_city->country->name; |
721 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
721 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
722 | 722 | $city = $geoip2_city->city->name; |
723 | 723 | $longitude = $geoip2_city->location->longitude; |
724 | 724 | $latitude = $geoip2_city->location->latitude; |
725 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
726 | - } catch( Exception $e ) { } |
|
725 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
726 | + } catch (Exception $e) { } |
|
727 | 727 | } |
728 | 728 | |
729 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
729 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
730 | 730 | try { |
731 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
731 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
732 | 732 | |
733 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
733 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
734 | 734 | $iso = $load_xml->geoplugin_countryCode; |
735 | 735 | $country = $load_xml->geoplugin_countryName; |
736 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
737 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
736 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
737 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
738 | 738 | $longitude = $load_xml->geoplugin_longitude; |
739 | 739 | $latitude = $load_xml->geoplugin_latitude; |
740 | 740 | $credit = $load_xml->geoplugin_credit; |
741 | - $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; |
|
741 | + $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; |
|
742 | 742 | } |
743 | - } catch( Exception $e ) { } |
|
743 | + } catch (Exception $e) { } |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( $iso && $longitude && $latitude ) { |
|
747 | - if ( $city ) { |
|
746 | + if ($iso && $longitude && $latitude) { |
|
747 | + if ($city) { |
|
748 | 748 | $address .= $city . ', '; |
749 | 749 | } |
750 | 750 | |
751 | - if ( $region ) { |
|
751 | + if ($region) { |
|
752 | 752 | $address .= $region . ', '; |
753 | 753 | } |
754 | 754 | |
755 | 755 | $address .= $country . ' (' . $iso . ')'; |
756 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
757 | - $content .= '<p>'. $credit . '</p>'; |
|
756 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
757 | + $content .= '<p>' . $credit . '</p>'; |
|
758 | 758 | } else { |
759 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
759 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
760 | 760 | } |
761 | 761 | ?> |
762 | 762 | <!DOCTYPE html> |
763 | -<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> |
|
763 | +<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> |
|
764 | 764 | <body> |
765 | - <?php if ( $latitude && $latitude ) { ?> |
|
765 | + <?php if ($latitude && $latitude) { ?> |
|
766 | 766 | <div id="map"></div> |
767 | 767 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
768 | 768 | <script type="text/javascript"> |
769 | 769 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
770 | 770 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
771 | 771 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
772 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
772 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
773 | 773 | |
774 | 774 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
775 | 775 | |
776 | 776 | var marker = new L.Marker(latlng); |
777 | 777 | map.addLayer(marker); |
778 | 778 | |
779 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
779 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
780 | 780 | </script> |
781 | 781 | <?php } ?> |
782 | 782 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -784,31 +784,31 @@ discard block |
||
784 | 784 | <?php |
785 | 785 | exit; |
786 | 786 | } |
787 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
788 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
787 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
788 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
789 | 789 | |
790 | 790 | // Set up the template for the invoice. |
791 | -function wpinv_template( $template ) { |
|
791 | +function wpinv_template($template) { |
|
792 | 792 | global $post, $wp_query; |
793 | 793 | |
794 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
795 | - if ( wpinv_user_can_print_invoice( $post->ID ) ) { |
|
796 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
794 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
795 | + if (wpinv_user_can_print_invoice($post->ID)) { |
|
796 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
797 | 797 | } else { |
798 | - if ( !is_user_logged_in() && !empty( $_REQUEST['_wpipay'] ) && $invoice = wpinv_get_invoice( $post->ID ) ) { |
|
798 | + if (!is_user_logged_in() && !empty($_REQUEST['_wpipay']) && $invoice = wpinv_get_invoice($post->ID)) { |
|
799 | 799 | $user_id = $invoice->get_user_id(); |
800 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
800 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
801 | 801 | |
802 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key() ) ) { // valid invoice link |
|
803 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
802 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key())) { // valid invoice link |
|
803 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
804 | 804 | |
805 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
805 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
806 | 806 | wpinv_die(); |
807 | 807 | } |
808 | 808 | } |
809 | - $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
809 | + $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
810 | 810 | |
811 | - wp_redirect( $redirect_to ); |
|
811 | + wp_redirect($redirect_to); |
|
812 | 812 | wpinv_die(); |
813 | 813 | } |
814 | 814 | } |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | |
819 | 819 | function wpinv_get_business_address() { |
820 | 820 | $business_address = wpinv_store_address(); |
821 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
821 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
822 | 822 | |
823 | 823 | /* |
824 | 824 | $default_country = wpinv_get_default_country(); |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | |
843 | 843 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
844 | 844 | |
845 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
845 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | function wpinv_display_from_address() { |
@@ -852,185 +852,185 @@ discard block |
||
852 | 852 | if (empty($from_name)) { |
853 | 853 | $from_name = wpinv_get_business_name(); |
854 | 854 | } |
855 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
855 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
856 | 856 | <div class="wrapper col-xs-10"> |
857 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
858 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
859 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
857 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
858 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
859 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
860 | 860 | <?php } ?> |
861 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
862 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s' ), $email_from );?></div> |
|
861 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
862 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s'), $email_from); ?></div> |
|
863 | 863 | <?php } ?> |
864 | 864 | </div> |
865 | 865 | <?php |
866 | 866 | } |
867 | 867 | |
868 | -function wpinv_watermark( $id = 0 ) { |
|
869 | - $output = wpinv_get_watermark( $id ); |
|
868 | +function wpinv_watermark($id = 0) { |
|
869 | + $output = wpinv_get_watermark($id); |
|
870 | 870 | |
871 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
871 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
872 | 872 | } |
873 | 873 | |
874 | -function wpinv_get_watermark( $id ) { |
|
875 | - if ( !$id > 0 ) { |
|
874 | +function wpinv_get_watermark($id) { |
|
875 | + if (!$id > 0) { |
|
876 | 876 | return NULL; |
877 | 877 | } |
878 | - $invoice = wpinv_get_invoice( $id ); |
|
878 | + $invoice = wpinv_get_invoice($id); |
|
879 | 879 | |
880 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
881 | - if ( $invoice->is_paid() ) { |
|
882 | - return __( 'Paid', 'invoicing' ); |
|
880 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
881 | + if ($invoice->is_paid()) { |
|
882 | + return __('Paid', 'invoicing'); |
|
883 | 883 | } |
884 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
885 | - return __( 'Cancelled', 'invoicing' ); |
|
884 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
885 | + return __('Cancelled', 'invoicing'); |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | 889 | return NULL; |
890 | 890 | } |
891 | 891 | |
892 | -function wpinv_display_invoice_details( $invoice ) { |
|
892 | +function wpinv_display_invoice_details($invoice) { |
|
893 | 893 | global $wpinv_euvat; |
894 | 894 | |
895 | 895 | $invoice_id = $invoice->ID; |
896 | 896 | $vat_name = $wpinv_euvat->get_vat_name(); |
897 | 897 | $use_taxes = wpinv_use_taxes(); |
898 | 898 | |
899 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
899 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
900 | 900 | |
901 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
902 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
901 | + if ($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
902 | + elseif ($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
903 | 903 | ?> |
904 | 904 | <table class="table table-bordered table-sm"> |
905 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
905 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
906 | 906 | <tr class="wpi-row-number"> |
907 | - <th><?php echo sprintf(__( '%s Number', 'invoicing' ), $type); ?></th> |
|
908 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
907 | + <th><?php echo sprintf(__('%s Number', 'invoicing'), $type); ?></th> |
|
908 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
909 | 909 | </tr> |
910 | 910 | <?php } ?> |
911 | 911 | <tr class="wpi-row-status"> |
912 | - <th><?php echo wp_sprintf(__( '%s Status', 'invoicing' ), $type); ?></th> |
|
913 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
912 | + <th><?php echo wp_sprintf(__('%s Status', 'invoicing'), $type); ?></th> |
|
913 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
914 | 914 | </tr> |
915 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
915 | + <?php if ($invoice->is_renewal()) { ?> |
|
916 | 916 | <tr class="wpi-row-parent"> |
917 | - <th><?php echo wp_sprintf(__( 'Parent %s', 'invoicing' ), $type); ?></th> |
|
918 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
917 | + <th><?php echo wp_sprintf(__('Parent %s', 'invoicing'), $type); ?></th> |
|
918 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
919 | 919 | </tr> |
920 | 920 | <?php } ?> |
921 | 921 | <tr class="wpi-row-gateway"> |
922 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
923 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
922 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
923 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
924 | 924 | </tr> |
925 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
925 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
926 | 926 | <tr class="wpi-row-date"> |
927 | - <th><?php echo wp_sprintf(__( '%s Date', 'invoicing' ), $type); ?></th> |
|
927 | + <th><?php echo wp_sprintf(__('%s Date', 'invoicing'), $type); ?></th> |
|
928 | 928 | <td><?php echo $invoice_date; ?></td> |
929 | 929 | </tr> |
930 | 930 | <?php } ?> |
931 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
931 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
932 | 932 | <tr class="wpi-row-date"> |
933 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
933 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
934 | 934 | <td><?php echo $due_date; ?></td> |
935 | 935 | </tr> |
936 | 936 | <?php } ?> |
937 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
937 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
938 | 938 | <tr class="wpi-row-ovatno"> |
939 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
939 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
940 | 940 | <td><?php echo $owner_vat_number; ?></td> |
941 | 941 | </tr> |
942 | 942 | <?php } ?> |
943 | - <?php if ( $use_taxes && $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
943 | + <?php if ($use_taxes && $user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
944 | 944 | <tr class="wpi-row-uvatno"> |
945 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
945 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
946 | 946 | <td><?php echo $user_vat_number; ?></td> |
947 | 947 | </tr> |
948 | 948 | <?php } ?> |
949 | 949 | <tr class="table-active tr-total wpi-row-total"> |
950 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
951 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
950 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
951 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
952 | 952 | </tr> |
953 | 953 | </table> |
954 | 954 | <?php |
955 | 955 | } |
956 | 956 | |
957 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
958 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
957 | +function wpinv_display_to_address($invoice_id = 0) { |
|
958 | + $invoice = wpinv_get_invoice($invoice_id); |
|
959 | 959 | |
960 | - if ( empty( $invoice ) ) { |
|
960 | + if (empty($invoice)) { |
|
961 | 961 | return NULL; |
962 | 962 | } |
963 | 963 | |
964 | 964 | $billing_details = $invoice->get_user_info(); |
965 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
965 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
966 | 966 | $output .= '<div class="wrapper col-xs-10">'; |
967 | 967 | |
968 | 968 | ob_start(); |
969 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
969 | + do_action('wpinv_display_to_address_top', $invoice); |
|
970 | 970 | $output .= ob_get_clean(); |
971 | 971 | |
972 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
973 | - if ( $company = $billing_details['company'] ) { |
|
974 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
972 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
973 | + if ($company = $billing_details['company']) { |
|
974 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
975 | 975 | } |
976 | 976 | $address_row = ''; |
977 | - if ( $address = $billing_details['address'] ) { |
|
978 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
977 | + if ($address = $billing_details['address']) { |
|
978 | + $address_row .= wpautop(wp_kses_post($address)); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | $address_fields = array(); |
982 | - if ( !empty( $billing_details['city'] ) ) { |
|
982 | + if (!empty($billing_details['city'])) { |
|
983 | 983 | $address_fields[] = $billing_details['city']; |
984 | 984 | } |
985 | 985 | |
986 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
987 | - if ( !empty( $billing_details['state'] ) ) { |
|
988 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
986 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
987 | + if (!empty($billing_details['state'])) { |
|
988 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
989 | 989 | } |
990 | 990 | |
991 | - if ( !empty( $billing_country ) ) { |
|
992 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
991 | + if (!empty($billing_country)) { |
|
992 | + $address_fields[] = wpinv_country_name($billing_country); |
|
993 | 993 | } |
994 | 994 | |
995 | - if ( !empty( $address_fields ) ) { |
|
996 | - $address_fields = implode( ", ", $address_fields ); |
|
995 | + if (!empty($address_fields)) { |
|
996 | + $address_fields = implode(", ", $address_fields); |
|
997 | 997 | |
998 | - if ( !empty( $billing_details['zip'] ) ) { |
|
998 | + if (!empty($billing_details['zip'])) { |
|
999 | 999 | $address_fields .= ' ' . $billing_details['zip']; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1002 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | - if ( $address_row ) { |
|
1005 | + if ($address_row) { |
|
1006 | 1006 | $output .= '<div class="address">' . $address_row . '</div>'; |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if ( $phone = $invoice->get_phone() ) { |
|
1010 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s' ), esc_html( $phone ) ) . '</div>'; |
|
1009 | + if ($phone = $invoice->get_phone()) { |
|
1010 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s'), esc_html($phone)) . '</div>'; |
|
1011 | 1011 | } |
1012 | - if ( $email = $invoice->get_email() ) { |
|
1013 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' ), esc_html( $email ) ) . '</div>'; |
|
1012 | + if ($email = $invoice->get_email()) { |
|
1013 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s'), esc_html($email)) . '</div>'; |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | ob_start(); |
1017 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
1017 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
1018 | 1018 | $output .= ob_get_clean(); |
1019 | 1019 | |
1020 | 1020 | $output .= '</div>'; |
1021 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
1021 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
1022 | 1022 | |
1023 | 1023 | echo $output; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1026 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1027 | 1027 | global $wpinv_euvat, $ajax_cart_details; |
1028 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1028 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1029 | 1029 | $quantities_enabled = wpinv_item_quantities_enabled(); |
1030 | 1030 | $use_taxes = wpinv_use_taxes(); |
1031 | 1031 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
1032 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
1033 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
1032 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
1033 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
1034 | 1034 | |
1035 | 1035 | $cart_details = $invoice->get_cart_details(); |
1036 | 1036 | $ajax_cart_details = $cart_details; |
@@ -1039,68 +1039,68 @@ discard block |
||
1039 | 1039 | <table class="table table-sm table-bordered table-responsive"> |
1040 | 1040 | <thead> |
1041 | 1041 | <tr> |
1042 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1043 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1042 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1043 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1044 | 1044 | <?php if ($quantities_enabled) { ?> |
1045 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1045 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1046 | 1046 | <?php } ?> |
1047 | 1047 | <?php if ($use_taxes && !$zero_tax) { ?> |
1048 | 1048 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1049 | 1049 | <?php } ?> |
1050 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1050 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1051 | 1051 | </tr> |
1052 | 1052 | </thead> |
1053 | 1053 | <tbody> |
1054 | 1054 | <?php |
1055 | - if ( !empty( $cart_details ) ) { |
|
1056 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1055 | + if (!empty($cart_details)) { |
|
1056 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1057 | 1057 | |
1058 | 1058 | $count = 0; |
1059 | 1059 | $cols = 3; |
1060 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1061 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1062 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1063 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1064 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1060 | + foreach ($cart_details as $key => $cart_item) { |
|
1061 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1062 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1063 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1064 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1065 | 1065 | |
1066 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1066 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1067 | 1067 | $summary = ''; |
1068 | 1068 | $cols = 3; |
1069 | - if ( !empty($item) ) { |
|
1069 | + if (!empty($item)) { |
|
1070 | 1070 | $item_name = $item->get_name(); |
1071 | 1071 | $summary = $item->get_summary(); |
1072 | 1072 | } |
1073 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1073 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1074 | 1074 | |
1075 | 1075 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1076 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1077 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_custom_singular_name(), $post_link ); |
|
1076 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1077 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_custom_singular_name(), $post_link); |
|
1078 | 1078 | } |
1079 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1079 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1080 | 1080 | |
1081 | 1081 | $item_tax = ''; |
1082 | 1082 | $tax_rate = ''; |
1083 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1084 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1085 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1086 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1083 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1084 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1085 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1086 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1087 | 1087 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | $line_item_tax = $item_tax . $tax_rate; |
1091 | 1091 | |
1092 | - if ( $line_item_tax === '' ) { |
|
1092 | + if ($line_item_tax === '') { |
|
1093 | 1093 | $line_item_tax = 0; // Zero tax |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1097 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1098 | - if ( $summary !== '' ) { |
|
1099 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1096 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1097 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1098 | + if ($summary !== '') { |
|
1099 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1100 | 1100 | } |
1101 | 1101 | $line_item .= '</td>'; |
1102 | 1102 | |
1103 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1103 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1104 | 1104 | if ($quantities_enabled) { |
1105 | 1105 | $cols++; |
1106 | 1106 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1109,55 +1109,55 @@ discard block |
||
1109 | 1109 | $cols++; |
1110 | 1110 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1111 | 1111 | } |
1112 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1112 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1113 | 1113 | $line_item .= '</tr>'; |
1114 | 1114 | |
1115 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1115 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1116 | 1116 | |
1117 | 1117 | $count++; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1120 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1121 | 1121 | ?> |
1122 | 1122 | <tr class="row-sub-total row_odd"> |
1123 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1124 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1123 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1124 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1125 | 1125 | </tr> |
1126 | 1126 | <?php |
1127 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1127 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1128 | 1128 | |
1129 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1130 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1129 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1130 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1131 | 1131 | ?> |
1132 | 1132 | <tr class="row-discount"> |
1133 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1134 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1133 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1134 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1135 | 1135 | </tr> |
1136 | 1136 | <?php |
1137 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1137 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | - if ( $use_taxes ) { |
|
1141 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1140 | + if ($use_taxes) { |
|
1141 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1142 | 1142 | ?> |
1143 | 1143 | <tr class="row-tax"> |
1144 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1145 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1144 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1145 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1146 | 1146 | </tr> |
1147 | 1147 | <?php |
1148 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1148 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1151 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1152 | 1152 | ?> |
1153 | 1153 | <tr class="table-active row-total"> |
1154 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1155 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1154 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1155 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1156 | 1156 | </tr> |
1157 | 1157 | <?php |
1158 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1158 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1159 | 1159 | |
1160 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1160 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1161 | 1161 | } |
1162 | 1162 | ?> |
1163 | 1163 | </tbody> |
@@ -1166,35 +1166,35 @@ discard block |
||
1166 | 1166 | echo ob_get_clean(); |
1167 | 1167 | } |
1168 | 1168 | |
1169 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1169 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1170 | 1170 | $use_taxes = wpinv_use_taxes(); |
1171 | 1171 | |
1172 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1172 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1173 | 1173 | ?> |
1174 | 1174 | <table class="table table-sm table-bordered table-responsive"> |
1175 | 1175 | <tbody> |
1176 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1176 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1177 | 1177 | <tr class="row-sub-total"> |
1178 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1179 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1178 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1179 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1180 | 1180 | </tr> |
1181 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1182 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1181 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1182 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1183 | 1183 | <tr class="row-discount"> |
1184 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1185 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1184 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1185 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1186 | 1186 | </tr> |
1187 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1187 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1188 | 1188 | <?php } ?> |
1189 | - <?php if ( $use_taxes ) { ?> |
|
1189 | + <?php if ($use_taxes) { ?> |
|
1190 | 1190 | <tr class="row-tax"> |
1191 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1192 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1191 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1192 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1193 | 1193 | </tr> |
1194 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1194 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1195 | 1195 | <?php } ?> |
1196 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1197 | - <?php foreach ( $fees as $fee ) { ?> |
|
1196 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1197 | + <?php foreach ($fees as $fee) { ?> |
|
1198 | 1198 | <tr class="row-fee"> |
1199 | 1199 | <td class="rate"><?php echo $fee['label']; ?></td> |
1200 | 1200 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1202,72 +1202,72 @@ discard block |
||
1202 | 1202 | <?php } ?> |
1203 | 1203 | <?php } ?> |
1204 | 1204 | <tr class="table-active row-total"> |
1205 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1206 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1205 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1206 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1207 | 1207 | </tr> |
1208 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1208 | + <?php do_action('wpinv_after_totals'); ?> |
|
1209 | 1209 | </tbody> |
1210 | 1210 | |
1211 | 1211 | </table> |
1212 | 1212 | |
1213 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1213 | + <?php do_action('wpinv_after_totals_table'); |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1217 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1216 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1217 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1218 | 1218 | |
1219 | 1219 | ob_start(); |
1220 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1221 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() ) { |
|
1220 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1221 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid()) { |
|
1222 | 1222 | ?> |
1223 | 1223 | <div class="wpi-payment-info"> |
1224 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1225 | - <?php if ( $gateway_title ) { ?> |
|
1226 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1224 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1225 | + <?php if ($gateway_title) { ?> |
|
1226 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1227 | 1227 | <?php } ?> |
1228 | 1228 | </div> |
1229 | 1229 | <?php |
1230 | 1230 | } |
1231 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1231 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1232 | 1232 | $outout = ob_get_clean(); |
1233 | 1233 | |
1234 | - if ( $echo ) { |
|
1234 | + if ($echo) { |
|
1235 | 1235 | echo $outout; |
1236 | 1236 | } else { |
1237 | 1237 | return $outout; |
1238 | 1238 | } |
1239 | 1239 | } |
1240 | 1240 | |
1241 | -function wpinv_display_style( $invoice ) { |
|
1242 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1241 | +function wpinv_display_style($invoice) { |
|
1242 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1243 | 1243 | |
1244 | - wp_print_styles( 'open-sans' ); |
|
1245 | - wp_print_styles( 'wpinv-single-style' ); |
|
1244 | + wp_print_styles('open-sans'); |
|
1245 | + wp_print_styles('wpinv-single-style'); |
|
1246 | 1246 | } |
1247 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1247 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1248 | 1248 | |
1249 | 1249 | function wpinv_checkout_billing_details() { |
1250 | 1250 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1251 | 1251 | if (empty($invoice_id)) { |
1252 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1252 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1253 | 1253 | return null; |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1256 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1257 | 1257 | if (empty($invoice)) { |
1258 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1258 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1259 | 1259 | return null; |
1260 | 1260 | } |
1261 | 1261 | $user_id = $invoice->get_user_id(); |
1262 | 1262 | $user_info = $invoice->get_user_info(); |
1263 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1263 | + $address_info = wpinv_get_user_address($user_id); |
|
1264 | 1264 | |
1265 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1265 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1266 | 1266 | $user_info['first_name'] = $user_info['first_name']; |
1267 | 1267 | $user_info['last_name'] = $user_info['last_name']; |
1268 | 1268 | } |
1269 | 1269 | |
1270 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1270 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1271 | 1271 | $user_info['country'] = $address_info['country']; |
1272 | 1272 | $user_info['state'] = $address_info['state']; |
1273 | 1273 | $user_info['city'] = $address_info['city']; |
@@ -1283,103 +1283,103 @@ discard block |
||
1283 | 1283 | 'address' |
1284 | 1284 | ); |
1285 | 1285 | |
1286 | - foreach ( $address_fields as $field ) { |
|
1287 | - if ( empty( $user_info[$field] ) ) { |
|
1286 | + foreach ($address_fields as $field) { |
|
1287 | + if (empty($user_info[$field])) { |
|
1288 | 1288 | $user_info[$field] = $address_info[$field]; |
1289 | 1289 | } |
1290 | 1290 | } |
1291 | 1291 | |
1292 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1292 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | function wpinv_admin_get_line_items($invoice = array()) { |
1296 | 1296 | $item_quantities = wpinv_item_quantities_enabled(); |
1297 | 1297 | $use_taxes = wpinv_use_taxes(); |
1298 | 1298 | |
1299 | - if ( empty( $invoice ) ) { |
|
1299 | + if (empty($invoice)) { |
|
1300 | 1300 | return NULL; |
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | $cart_items = $invoice->get_cart_details(); |
1304 | - if ( empty( $cart_items ) ) { |
|
1304 | + if (empty($cart_items)) { |
|
1305 | 1305 | return NULL; |
1306 | 1306 | } |
1307 | 1307 | ob_start(); |
1308 | 1308 | |
1309 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1309 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1310 | 1310 | |
1311 | 1311 | $count = 0; |
1312 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1312 | + foreach ($cart_items as $key => $cart_item) { |
|
1313 | 1313 | $item_id = $cart_item['id']; |
1314 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1314 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1315 | 1315 | |
1316 | 1316 | if (empty($wpi_item)) { |
1317 | 1317 | continue; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
1321 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1322 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
1320 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
1321 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1322 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
1323 | 1323 | $can_remove = true; |
1324 | 1324 | |
1325 | 1325 | $summary = ''; |
1326 | 1326 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
1327 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
1328 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_custom_singular_name(), $post_link ); |
|
1327 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
1328 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_custom_singular_name(), $post_link); |
|
1329 | 1329 | } |
1330 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
1330 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
1331 | 1331 | |
1332 | 1332 | $item_tax = ''; |
1333 | 1333 | $tax_rate = ''; |
1334 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1335 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
1336 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1337 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1334 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1335 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
1336 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1337 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1338 | 1338 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1339 | 1339 | } |
1340 | 1340 | $line_item_tax = $item_tax . $tax_rate; |
1341 | 1341 | |
1342 | - if ( $line_item_tax === '' ) { |
|
1342 | + if ($line_item_tax === '') { |
|
1343 | 1343 | $line_item_tax = 0; // Zero tax |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1346 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1347 | 1347 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1348 | - $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 ); |
|
1349 | - if ( $summary !== '' ) { |
|
1350 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1348 | + $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); |
|
1349 | + if ($summary !== '') { |
|
1350 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1351 | 1351 | } |
1352 | 1352 | $line_item .= '</td>'; |
1353 | 1353 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1354 | 1354 | |
1355 | - if ( $item_quantities ) { |
|
1356 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1355 | + if ($item_quantities) { |
|
1356 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1357 | 1357 | $can_remove = false; |
1358 | 1358 | } |
1359 | 1359 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1360 | 1360 | } else { |
1361 | - if ( count( $cart_items ) == 1 ) { |
|
1361 | + if (count($cart_items) == 1) { |
|
1362 | 1362 | $can_remove = false; |
1363 | 1363 | } |
1364 | 1364 | } |
1365 | 1365 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1366 | 1366 | |
1367 | - if ( $use_taxes ) { |
|
1367 | + if ($use_taxes) { |
|
1368 | 1368 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1369 | 1369 | } |
1370 | 1370 | $line_item .= '<td class="action">'; |
1371 | - if ( !$invoice->is_paid() && $can_remove ) { |
|
1371 | + if (!$invoice->is_paid() && $can_remove) { |
|
1372 | 1372 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1373 | 1373 | } |
1374 | 1374 | $line_item .= '</td>'; |
1375 | 1375 | $line_item .= '</tr>'; |
1376 | 1376 | |
1377 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1377 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1378 | 1378 | |
1379 | 1379 | $count++; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1382 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1383 | 1383 | |
1384 | 1384 | return ob_get_clean(); |
1385 | 1385 | } |
@@ -1390,35 +1390,35 @@ discard block |
||
1390 | 1390 | // Set current invoice id. |
1391 | 1391 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1392 | 1392 | |
1393 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1393 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1394 | 1394 | |
1395 | 1395 | ob_start(); |
1396 | 1396 | echo '<div id="wpinv_checkout_wrap">'; |
1397 | 1397 | |
1398 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1398 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1399 | 1399 | ?> |
1400 | 1400 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1401 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1401 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1402 | 1402 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1403 | 1403 | <?php |
1404 | - do_action( 'wpinv_checkout_form_top' ); |
|
1405 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1406 | - do_action( 'wpinv_checkout_cart' ); |
|
1407 | - do_action( 'wpinv_payment_mode_select' ); |
|
1408 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1404 | + do_action('wpinv_checkout_form_top'); |
|
1405 | + do_action('wpinv_checkout_billing_info'); |
|
1406 | + do_action('wpinv_checkout_cart'); |
|
1407 | + do_action('wpinv_payment_mode_select'); |
|
1408 | + do_action('wpinv_checkout_form_bottom') |
|
1409 | 1409 | ?> |
1410 | 1410 | </form> |
1411 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1411 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1412 | 1412 | </div><!--end #wpinv_checkout_form_wrap--> |
1413 | 1413 | <?php |
1414 | 1414 | } else { |
1415 | - do_action( 'wpinv_cart_empty' ); |
|
1415 | + do_action('wpinv_cart_empty'); |
|
1416 | 1416 | } |
1417 | 1417 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1418 | 1418 | return ob_get_clean(); |
1419 | 1419 | } |
1420 | 1420 | |
1421 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1421 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1422 | 1422 | global $ajax_cart_details; |
1423 | 1423 | $ajax_cart_details = $cart_details; |
1424 | 1424 | /* |
@@ -1433,25 +1433,25 @@ discard block |
||
1433 | 1433 | } |
1434 | 1434 | */ |
1435 | 1435 | ob_start(); |
1436 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1436 | + do_action('wpinv_before_checkout_cart'); |
|
1437 | 1437 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1438 | 1438 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1439 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1439 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1440 | 1440 | echo '</div>'; |
1441 | 1441 | echo '</div>'; |
1442 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1442 | + do_action('wpinv_after_checkout_cart'); |
|
1443 | 1443 | $content = ob_get_clean(); |
1444 | 1444 | |
1445 | - if ( $echo ) { |
|
1445 | + if ($echo) { |
|
1446 | 1446 | echo $content; |
1447 | 1447 | } else { |
1448 | 1448 | return $content; |
1449 | 1449 | } |
1450 | 1450 | } |
1451 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1451 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1452 | 1452 | |
1453 | 1453 | function wpinv_empty_cart_message() { |
1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1454 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | /** |
@@ -1463,91 +1463,91 @@ discard block |
||
1463 | 1463 | function wpinv_empty_checkout_cart() { |
1464 | 1464 | echo wpinv_empty_cart_message(); |
1465 | 1465 | } |
1466 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1466 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1467 | 1467 | |
1468 | 1468 | function wpinv_save_cart_button() { |
1469 | - if ( wpinv_is_cart_saving_disabled() ) |
|
1469 | + if (wpinv_is_cart_saving_disabled()) |
|
1470 | 1470 | return; |
1471 | 1471 | ?> |
1472 | - <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> |
|
1472 | + <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> |
|
1473 | 1473 | <?php |
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | function wpinv_update_cart_button() { |
1477 | - if ( !wpinv_item_quantities_enabled() ) |
|
1477 | + if (!wpinv_item_quantities_enabled()) |
|
1478 | 1478 | return; |
1479 | 1479 | ?> |
1480 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1480 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1481 | 1481 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1482 | 1482 | <?php |
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | function wpinv_checkout_cart_columns() { |
1486 | 1486 | $default = 3; |
1487 | - if ( wpinv_item_quantities_enabled() ) { |
|
1487 | + if (wpinv_item_quantities_enabled()) { |
|
1488 | 1488 | $default++; |
1489 | 1489 | } |
1490 | 1490 | |
1491 | - if ( wpinv_use_taxes() ) { |
|
1491 | + if (wpinv_use_taxes()) { |
|
1492 | 1492 | $default++; |
1493 | 1493 | } |
1494 | 1494 | |
1495 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1495 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | function wpinv_display_cart_messages() { |
1499 | 1499 | global $wpi_session; |
1500 | 1500 | |
1501 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1501 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1502 | 1502 | |
1503 | - if ( $messages ) { |
|
1504 | - foreach ( $messages as $message_id => $message ) { |
|
1503 | + if ($messages) { |
|
1504 | + foreach ($messages as $message_id => $message) { |
|
1505 | 1505 | // Try and detect what type of message this is |
1506 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1506 | + if (strpos(strtolower($message), 'error')) { |
|
1507 | 1507 | $type = 'error'; |
1508 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1508 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1509 | 1509 | $type = 'success'; |
1510 | 1510 | } else { |
1511 | 1511 | $type = 'info'; |
1512 | 1512 | } |
1513 | 1513 | |
1514 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1514 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1515 | 1515 | |
1516 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1516 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1517 | 1517 | // Loop message codes and display messages |
1518 | 1518 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1519 | 1519 | echo '</div>'; |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // Remove all of the cart saving messages |
1523 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1523 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1524 | 1524 | } |
1525 | 1525 | } |
1526 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1526 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1527 | 1527 | |
1528 | 1528 | function wpinv_discount_field() { |
1529 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1529 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1530 | 1530 | return; // Only show before a payment method has been selected if ajax is disabled |
1531 | 1531 | } |
1532 | 1532 | |
1533 | - if ( !wpinv_is_checkout() ) { |
|
1533 | + if (!wpinv_is_checkout()) { |
|
1534 | 1534 | return; |
1535 | 1535 | } |
1536 | 1536 | |
1537 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1537 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1538 | 1538 | ?> |
1539 | 1539 | <div id="wpinv-discount-field" class="panel panel-default"> |
1540 | 1540 | <div class="panel-body"> |
1541 | 1541 | <p> |
1542 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1543 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1542 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1543 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1544 | 1544 | </p> |
1545 | 1545 | <div class="form-group row"> |
1546 | 1546 | <div class="col-sm-4"> |
1547 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1547 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1548 | 1548 | </div> |
1549 | 1549 | <div class="col-sm-3"> |
1550 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1550 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1551 | 1551 | </div> |
1552 | 1552 | <div style="clear:both"></div> |
1553 | 1553 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1560,10 +1560,10 @@ discard block |
||
1560 | 1560 | <?php |
1561 | 1561 | } |
1562 | 1562 | } |
1563 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1563 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1564 | 1564 | |
1565 | 1565 | function wpinv_agree_to_terms_js() { |
1566 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1566 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1567 | 1567 | ?> |
1568 | 1568 | <script type="text/javascript"> |
1569 | 1569 | jQuery(document).ready(function($){ |
@@ -1578,126 +1578,126 @@ discard block |
||
1578 | 1578 | <?php |
1579 | 1579 | } |
1580 | 1580 | } |
1581 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1581 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1582 | 1582 | |
1583 | 1583 | function wpinv_payment_mode_select() { |
1584 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1585 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1584 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1585 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1586 | 1586 | $page_URL = wpinv_get_current_page_url(); |
1587 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1587 | + $invoice = wpinv_get_invoice(0, true); |
|
1588 | 1588 | |
1589 | 1589 | do_action('wpinv_payment_mode_top'); |
1590 | 1590 | $invoice_id = (int)$invoice->ID; |
1591 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1591 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1592 | 1592 | ?> |
1593 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;"' : '' ); ?>> |
|
1594 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1593 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;"' : ''); ?>> |
|
1594 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1595 | 1595 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1596 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1596 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1597 | 1597 | <div class="panel-body list-group wpi-payment_methods"> |
1598 | 1598 | <?php |
1599 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1599 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1600 | 1600 | |
1601 | - if(!empty($gateways)){ |
|
1602 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1603 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1604 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1605 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1601 | + if (!empty($gateways)) { |
|
1602 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1603 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1604 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1605 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1606 | 1606 | ?> |
1607 | 1607 | <div class="list-group-item"> |
1608 | 1608 | <div class="radio"> |
1609 | - <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> |
|
1609 | + <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> |
|
1610 | 1610 | </div> |
1611 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1612 | - <?php if ( !empty( $description ) ) { ?> |
|
1613 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
1611 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1612 | + <?php if (!empty($description)) { ?> |
|
1613 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
1614 | 1614 | <?php } ?> |
1615 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1615 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1616 | 1616 | </div> |
1617 | 1617 | </div> |
1618 | 1618 | <?php |
1619 | 1619 | } |
1620 | - }else{ |
|
1621 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
1620 | + } else { |
|
1621 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1624 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1625 | 1625 | ?> |
1626 | 1626 | </div> |
1627 | 1627 | </div> |
1628 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1628 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1629 | 1629 | </div> |
1630 | 1630 | <?php |
1631 | 1631 | do_action('wpinv_payment_mode_bottom'); |
1632 | 1632 | } |
1633 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1633 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1634 | 1634 | |
1635 | 1635 | function wpinv_checkout_billing_info() { |
1636 | - if ( wpinv_is_checkout() ) { |
|
1636 | + if (wpinv_is_checkout()) { |
|
1637 | 1637 | $logged_in = is_user_logged_in(); |
1638 | 1638 | $billing_details = wpinv_checkout_billing_details(); |
1639 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1639 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1640 | 1640 | ?> |
1641 | 1641 | <div id="wpinv-fields" class="clearfix"> |
1642 | 1642 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1643 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1643 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1644 | 1644 | <div id="wpinv-fields-box" class="panel-body"> |
1645 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1645 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1646 | 1646 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1647 | - <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> |
|
1647 | + <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> |
|
1648 | 1648 | <?php |
1649 | - echo wpinv_html_text( array( |
|
1649 | + echo wpinv_html_text(array( |
|
1650 | 1650 | 'id' => 'wpinv_first_name', |
1651 | 1651 | 'name' => 'wpinv_first_name', |
1652 | 1652 | 'value' => $billing_details['first_name'], |
1653 | 1653 | 'class' => 'wpi-input form-control', |
1654 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1655 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1656 | - ) ); |
|
1654 | + 'placeholder' => __('First name', 'invoicing'), |
|
1655 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1656 | + )); |
|
1657 | 1657 | ?> |
1658 | 1658 | </p> |
1659 | 1659 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1660 | - <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> |
|
1660 | + <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> |
|
1661 | 1661 | <?php |
1662 | - echo wpinv_html_text( array( |
|
1662 | + echo wpinv_html_text(array( |
|
1663 | 1663 | 'id' => 'wpinv_last_name', |
1664 | 1664 | 'name' => 'wpinv_last_name', |
1665 | 1665 | 'value' => $billing_details['last_name'], |
1666 | 1666 | 'class' => 'wpi-input form-control', |
1667 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1668 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1669 | - ) ); |
|
1667 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1668 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1669 | + )); |
|
1670 | 1670 | ?> |
1671 | 1671 | </p> |
1672 | 1672 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1673 | - <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> |
|
1673 | + <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> |
|
1674 | 1674 | <?php |
1675 | - echo wpinv_html_text( array( |
|
1675 | + echo wpinv_html_text(array( |
|
1676 | 1676 | 'id' => 'wpinv_address', |
1677 | 1677 | 'name' => 'wpinv_address', |
1678 | 1678 | 'value' => $billing_details['address'], |
1679 | 1679 | 'class' => 'wpi-input form-control', |
1680 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1681 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1682 | - ) ); |
|
1680 | + 'placeholder' => __('Address', 'invoicing'), |
|
1681 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1682 | + )); |
|
1683 | 1683 | ?> |
1684 | 1684 | </p> |
1685 | 1685 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1686 | - <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> |
|
1686 | + <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> |
|
1687 | 1687 | <?php |
1688 | - echo wpinv_html_text( array( |
|
1688 | + echo wpinv_html_text(array( |
|
1689 | 1689 | 'id' => 'wpinv_city', |
1690 | 1690 | 'name' => 'wpinv_city', |
1691 | 1691 | 'value' => $billing_details['city'], |
1692 | 1692 | 'class' => 'wpi-input form-control', |
1693 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1694 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1695 | - ) ); |
|
1693 | + 'placeholder' => __('City', 'invoicing'), |
|
1694 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1695 | + )); |
|
1696 | 1696 | ?> |
1697 | 1697 | </p> |
1698 | 1698 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1699 | - <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> |
|
1700 | - <?php echo wpinv_html_select( array( |
|
1699 | + <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> |
|
1700 | + <?php echo wpinv_html_select(array( |
|
1701 | 1701 | 'options' => wpinv_get_country_list(), |
1702 | 1702 | 'name' => 'wpinv_country', |
1703 | 1703 | 'id' => 'wpinv_country', |
@@ -1705,16 +1705,16 @@ discard block |
||
1705 | 1705 | 'show_option_all' => false, |
1706 | 1706 | 'show_option_none' => false, |
1707 | 1707 | 'class' => 'wpi-input form-control', |
1708 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1709 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1710 | - ) ); ?> |
|
1708 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1709 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1710 | + )); ?> |
|
1711 | 1711 | </p> |
1712 | 1712 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1713 | - <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> |
|
1713 | + <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> |
|
1714 | 1714 | <?php |
1715 | - $states = wpinv_get_country_states( $selected_country ); |
|
1716 | - if( !empty( $states ) ) { |
|
1717 | - echo wpinv_html_select( array( |
|
1715 | + $states = wpinv_get_country_states($selected_country); |
|
1716 | + if (!empty($states)) { |
|
1717 | + echo wpinv_html_select(array( |
|
1718 | 1718 | 'options' => $states, |
1719 | 1719 | 'name' => 'wpinv_state', |
1720 | 1720 | 'id' => 'wpinv_state', |
@@ -1722,61 +1722,61 @@ discard block |
||
1722 | 1722 | 'show_option_all' => false, |
1723 | 1723 | 'show_option_none' => false, |
1724 | 1724 | 'class' => 'wpi-input form-control', |
1725 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1726 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1727 | - ) ); |
|
1725 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1726 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1727 | + )); |
|
1728 | 1728 | } else { |
1729 | - echo wpinv_html_text( array( |
|
1729 | + echo wpinv_html_text(array( |
|
1730 | 1730 | 'name' => 'wpinv_state', |
1731 | 1731 | 'value' => $billing_details['state'], |
1732 | 1732 | 'id' => 'wpinv_state', |
1733 | 1733 | 'class' => 'wpi-input form-control', |
1734 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1735 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1736 | - ) ); |
|
1734 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1735 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1736 | + )); |
|
1737 | 1737 | } |
1738 | 1738 | ?> |
1739 | 1739 | </p> |
1740 | 1740 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1741 | - <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> |
|
1741 | + <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> |
|
1742 | 1742 | <?php |
1743 | - echo wpinv_html_text( array( |
|
1743 | + echo wpinv_html_text(array( |
|
1744 | 1744 | 'name' => 'wpinv_zip', |
1745 | 1745 | 'value' => $billing_details['zip'], |
1746 | 1746 | 'id' => 'wpinv_zip', |
1747 | 1747 | 'class' => 'wpi-input form-control', |
1748 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1749 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1750 | - ) ); |
|
1748 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1749 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1750 | + )); |
|
1751 | 1751 | ?> |
1752 | 1752 | </p> |
1753 | 1753 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1754 | - <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> |
|
1754 | + <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> |
|
1755 | 1755 | <?php |
1756 | - echo wpinv_html_text( array( |
|
1756 | + echo wpinv_html_text(array( |
|
1757 | 1757 | 'id' => 'wpinv_phone', |
1758 | 1758 | 'name' => 'wpinv_phone', |
1759 | 1759 | 'value' => $billing_details['phone'], |
1760 | 1760 | 'class' => 'wpi-input form-control', |
1761 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1762 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1763 | - ) ); |
|
1761 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1762 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1763 | + )); |
|
1764 | 1764 | ?> |
1765 | 1765 | </p> |
1766 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1766 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1767 | 1767 | <div class="clearfix"></div> |
1768 | 1768 | </div> |
1769 | 1769 | </div> |
1770 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1770 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1771 | 1771 | </div> |
1772 | 1772 | <?php |
1773 | 1773 | } |
1774 | 1774 | } |
1775 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1775 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1776 | 1776 | |
1777 | 1777 | function wpinv_checkout_hidden_fields() { |
1778 | 1778 | ?> |
1779 | - <?php if ( is_user_logged_in() ) { ?> |
|
1779 | + <?php if (is_user_logged_in()) { ?> |
|
1780 | 1780 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1781 | 1781 | <?php } ?> |
1782 | 1782 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1786,9 +1786,9 @@ discard block |
||
1786 | 1786 | function wpinv_checkout_button_purchase() { |
1787 | 1787 | ob_start(); |
1788 | 1788 | ?> |
1789 | - <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' ) ?>"/> |
|
1789 | + <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') ?>"/> |
|
1790 | 1790 | <?php |
1791 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1791 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1792 | 1792 | } |
1793 | 1793 | |
1794 | 1794 | function wpinv_checkout_total() { |
@@ -1797,96 +1797,96 @@ discard block |
||
1797 | 1797 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1798 | 1798 | <div class="panel-body"> |
1799 | 1799 | <?php |
1800 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1800 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1801 | 1801 | ?> |
1802 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1802 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1803 | 1803 | <?php |
1804 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1804 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1805 | 1805 | ?> |
1806 | 1806 | </div> |
1807 | 1807 | </div> |
1808 | 1808 | <?php |
1809 | 1809 | } |
1810 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1810 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1811 | 1811 | |
1812 | 1812 | function wpinv_checkout_submit() { |
1813 | 1813 | ?> |
1814 | 1814 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1815 | 1815 | <div class="panel-body text-center"> |
1816 | 1816 | <?php |
1817 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1817 | + do_action('wpinv_purchase_form_before_submit'); |
|
1818 | 1818 | wpinv_checkout_hidden_fields(); |
1819 | 1819 | echo wpinv_checkout_button_purchase(); |
1820 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1820 | + do_action('wpinv_purchase_form_after_submit'); |
|
1821 | 1821 | ?> |
1822 | 1822 | </div> |
1823 | 1823 | </div> |
1824 | 1824 | <?php |
1825 | 1825 | } |
1826 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1826 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1827 | 1827 | |
1828 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1829 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1828 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1829 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1830 | 1830 | |
1831 | - if ( empty( $invoice ) ) { |
|
1831 | + if (empty($invoice)) { |
|
1832 | 1832 | return NULL; |
1833 | 1833 | } |
1834 | 1834 | |
1835 | 1835 | $billing_details = $invoice->get_user_info(); |
1836 | 1836 | $address_row = ''; |
1837 | - if ( $address = $billing_details['address'] ) { |
|
1838 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1837 | + if ($address = $billing_details['address']) { |
|
1838 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1839 | 1839 | } |
1840 | 1840 | |
1841 | 1841 | $address_fields = array(); |
1842 | - if ( !empty( $billing_details['city'] ) ) { |
|
1842 | + if (!empty($billing_details['city'])) { |
|
1843 | 1843 | $address_fields[] = $billing_details['city']; |
1844 | 1844 | } |
1845 | 1845 | |
1846 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1847 | - if ( !empty( $billing_details['state'] ) ) { |
|
1848 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1846 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1847 | + if (!empty($billing_details['state'])) { |
|
1848 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1849 | 1849 | } |
1850 | 1850 | |
1851 | - if ( !empty( $billing_country ) ) { |
|
1852 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1851 | + if (!empty($billing_country)) { |
|
1852 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1853 | 1853 | } |
1854 | 1854 | |
1855 | - if ( !empty( $address_fields ) ) { |
|
1856 | - $address_fields = implode( ", ", $address_fields ); |
|
1855 | + if (!empty($address_fields)) { |
|
1856 | + $address_fields = implode(", ", $address_fields); |
|
1857 | 1857 | |
1858 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1858 | + if (!empty($billing_details['zip'])) { |
|
1859 | 1859 | $address_fields .= ' ' . $billing_details['zip']; |
1860 | 1860 | } |
1861 | 1861 | |
1862 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1862 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1863 | 1863 | } |
1864 | 1864 | ob_start(); |
1865 | 1865 | ?> |
1866 | 1866 | <table class="table table-bordered table-sm wpi-billing-details"> |
1867 | 1867 | <tbody> |
1868 | 1868 | <tr class="wpi-receipt-name"> |
1869 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1870 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1869 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1870 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1871 | 1871 | </tr> |
1872 | 1872 | <tr class="wpi-receipt-email"> |
1873 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1874 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1873 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1874 | + <td><?php echo $billing_details['email']; ?></td> |
|
1875 | 1875 | </tr> |
1876 | - <?php if ( $billing_details['company'] ) { ?> |
|
1876 | + <?php if ($billing_details['company']) { ?> |
|
1877 | 1877 | <tr class="wpi-receipt-company"> |
1878 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1879 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1878 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1879 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1880 | 1880 | </tr> |
1881 | 1881 | <?php } ?> |
1882 | 1882 | <tr class="wpi-receipt-address"> |
1883 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1884 | - <td><?php echo $address_row ;?></td> |
|
1883 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1884 | + <td><?php echo $address_row; ?></td> |
|
1885 | 1885 | </tr> |
1886 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1886 | + <?php if ($billing_details['phone']) { ?> |
|
1887 | 1887 | <tr class="wpi-receipt-phone"> |
1888 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1889 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1888 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1889 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1890 | 1890 | </tr> |
1891 | 1891 | <?php } ?> |
1892 | 1892 | </tbody> |
@@ -1894,98 +1894,98 @@ discard block |
||
1894 | 1894 | <?php |
1895 | 1895 | $output = ob_get_clean(); |
1896 | 1896 | |
1897 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1897 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1898 | 1898 | |
1899 | 1899 | echo $output; |
1900 | 1900 | } |
1901 | 1901 | |
1902 | -function wpinv_filter_success_page_content( $content ) { |
|
1903 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1904 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1905 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1902 | +function wpinv_filter_success_page_content($content) { |
|
1903 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1904 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1905 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1906 | 1906 | } |
1907 | 1907 | } |
1908 | 1908 | |
1909 | 1909 | return $content; |
1910 | 1910 | } |
1911 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1911 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1912 | 1912 | |
1913 | -function wpinv_receipt_actions( $invoice ) { |
|
1914 | - if ( !empty( $invoice ) ) { |
|
1913 | +function wpinv_receipt_actions($invoice) { |
|
1914 | + if (!empty($invoice)) { |
|
1915 | 1915 | $actions = array( |
1916 | 1916 | 'print' => array( |
1917 | 1917 | 'url' => $invoice->get_view_url(), |
1918 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1918 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1919 | 1919 | 'class' => 'btn-primary', |
1920 | 1920 | ), |
1921 | 1921 | 'history' => array( |
1922 | 1922 | 'url' => wpinv_get_history_page_uri(), |
1923 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1923 | + 'name' => __('Invoice History', 'invoicing'), |
|
1924 | 1924 | 'class' => 'btn-warning', |
1925 | 1925 | ) |
1926 | 1926 | ); |
1927 | 1927 | |
1928 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1928 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1929 | 1929 | |
1930 | - if ( !empty( $actions ) ) { |
|
1930 | + if (!empty($actions)) { |
|
1931 | 1931 | ?> |
1932 | 1932 | <div class="wpinv-receipt-actions text-right"> |
1933 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1934 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1933 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1934 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1935 | 1935 | <?php } ?> |
1936 | 1936 | </div> |
1937 | 1937 | <?php |
1938 | 1938 | } |
1939 | 1939 | } |
1940 | 1940 | } |
1941 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1941 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1942 | 1942 | |
1943 | -function wpinv_invoice_link( $invoice_id ) { |
|
1944 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1943 | +function wpinv_invoice_link($invoice_id) { |
|
1944 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1945 | 1945 | |
1946 | - if ( empty( $invoice ) ) { |
|
1946 | + if (empty($invoice)) { |
|
1947 | 1947 | return NULL; |
1948 | 1948 | } |
1949 | 1949 | |
1950 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1950 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1951 | 1951 | |
1952 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1952 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1956 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
1955 | +function wpinv_invoice_subscription_details($invoice) { |
|
1956 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1957 | 1957 | $total_payments = (int)$invoice->get_total_payments(); |
1958 | 1958 | $payments = $invoice->get_child_payments(); |
1959 | 1959 | |
1960 | 1960 | $subscription = $invoice->get_subscription_data(); |
1961 | 1961 | |
1962 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
1962 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
1963 | 1963 | return; |
1964 | 1964 | } |
1965 | 1965 | |
1966 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
1967 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
1966 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
1967 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
1968 | 1968 | |
1969 | 1969 | $subscription_status = $invoice->get_subscription_status(); |
1970 | 1970 | |
1971 | 1971 | $status_desc = ''; |
1972 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
1973 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
1974 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
1975 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
1972 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
1973 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
1974 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
1975 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
1976 | 1976 | } |
1977 | 1977 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
1978 | 1978 | ?> |
1979 | 1979 | <div class="wpinv-subscriptions-details"> |
1980 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1980 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1981 | 1981 | <table class="table"> |
1982 | 1982 | <thead> |
1983 | 1983 | <tr> |
1984 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1985 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1986 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
1987 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
1988 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1984 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1985 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1986 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
1987 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
1988 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
1989 | 1989 | </tr> |
1990 | 1990 | </thead> |
1991 | 1991 | <tbody> |
@@ -1994,32 +1994,32 @@ discard block |
||
1994 | 1994 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
1995 | 1995 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
1996 | 1996 | <td class="text-center"><?php echo $times_billed; ?></td> |
1997 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
1997 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
1998 | 1998 | <?php echo $status_desc; ?> |
1999 | 1999 | </td> |
2000 | 2000 | </tr> |
2001 | 2001 | </tbody> |
2002 | 2002 | </table> |
2003 | 2003 | </div> |
2004 | - <?php if ( !empty( $payments ) ) { ?> |
|
2004 | + <?php if (!empty($payments)) { ?> |
|
2005 | 2005 | <div class="wpinv-renewal-payments"> |
2006 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
2006 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
2007 | 2007 | <table class="table"> |
2008 | 2008 | <thead> |
2009 | 2009 | <tr> |
2010 | 2010 | <th>#</th> |
2011 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
2012 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2013 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
2011 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
2012 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2013 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2014 | 2014 | </tr> |
2015 | 2015 | </thead> |
2016 | 2016 | <tbody> |
2017 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
2017 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
2018 | 2018 | <tr> |
2019 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
2020 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2021 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2022 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2019 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
2020 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2021 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2022 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2023 | 2023 | </tr> |
2024 | 2024 | <?php } ?> |
2025 | 2025 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2031,52 +2031,52 @@ discard block |
||
2031 | 2031 | } |
2032 | 2032 | } |
2033 | 2033 | |
2034 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2035 | - if ( empty( $invoice ) ) { |
|
2034 | +function wpinv_cart_total_label($label, $invoice) { |
|
2035 | + if (empty($invoice)) { |
|
2036 | 2036 | return $label; |
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | $prefix_label = ''; |
2040 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2041 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2042 | - } else if ( $invoice->is_renewal() ) { |
|
2043 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2040 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2041 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2042 | + } else if ($invoice->is_renewal()) { |
|
2043 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2044 | 2044 | } |
2045 | 2045 | |
2046 | - if ( $prefix_label != '' ) { |
|
2047 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2046 | + if ($prefix_label != '') { |
|
2047 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | return $label; |
2051 | 2051 | } |
2052 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2053 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2054 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2052 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2053 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2054 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2055 | 2055 | |
2056 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2056 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2057 | 2057 | |
2058 | -function wpinv_invoice_print_description( $invoice ) { |
|
2059 | - if ( empty( $invoice ) ) { |
|
2058 | +function wpinv_invoice_print_description($invoice) { |
|
2059 | + if (empty($invoice)) { |
|
2060 | 2060 | return NULL; |
2061 | 2061 | } |
2062 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2062 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2063 | 2063 | ?> |
2064 | 2064 | <div class="row wpinv-lower"> |
2065 | 2065 | <div class="col-sm-12 wpinv-description"> |
2066 | - <?php echo wpautop( $description ); ?> |
|
2066 | + <?php echo wpautop($description); ?> |
|
2067 | 2067 | </div> |
2068 | 2068 | </div> |
2069 | 2069 | <?php |
2070 | 2070 | } |
2071 | 2071 | } |
2072 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2072 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2073 | 2073 | |
2074 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2075 | - if ( empty( $invoice ) ) { |
|
2074 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2075 | + if (empty($invoice)) { |
|
2076 | 2076 | return NULL; |
2077 | 2077 | } |
2078 | 2078 | |
2079 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2079 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2080 | 2080 | ?> |
2081 | 2081 | <div class="row wpinv-payments"> |
2082 | 2082 | <div class="col-sm-12"> |
@@ -2088,43 +2088,43 @@ discard block |
||
2088 | 2088 | } |
2089 | 2089 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2090 | 2090 | |
2091 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2092 | - if ( empty( $note ) ) { |
|
2091 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2092 | + if (empty($note)) { |
|
2093 | 2093 | return NULL; |
2094 | 2094 | } |
2095 | 2095 | |
2096 | - if ( is_int( $note ) ) { |
|
2097 | - $note = get_comment( $note ); |
|
2096 | + if (is_int($note)) { |
|
2097 | + $note = get_comment($note); |
|
2098 | 2098 | } |
2099 | 2099 | |
2100 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2100 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2101 | 2101 | return NULL; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | - $note_classes = array( 'note' ); |
|
2105 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2106 | - $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : ''; |
|
2107 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2108 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2104 | + $note_classes = array('note'); |
|
2105 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2106 | + $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : ''; |
|
2107 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2108 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2109 | 2109 | |
2110 | 2110 | ob_start(); |
2111 | 2111 | ?> |
2112 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2112 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2113 | 2113 | <div class="note_content"> |
2114 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2114 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2115 | 2115 | </div> |
2116 | 2116 | <p class="meta"> |
2117 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2118 | - <?php if($note->comment_author !== 'System') {?> |
|
2119 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2117 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2118 | + <?php if ($note->comment_author !== 'System') {?> |
|
2119 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2120 | 2120 | <?php } ?> |
2121 | 2121 | </p> |
2122 | 2122 | </li> |
2123 | 2123 | <?php |
2124 | 2124 | $note_content = ob_get_clean(); |
2125 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2125 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2126 | 2126 | |
2127 | - if ( $echo ) { |
|
2127 | + if ($echo) { |
|
2128 | 2128 | echo $note_content; |
2129 | 2129 | } else { |
2130 | 2130 | return $note_content; |
@@ -140,6 +140,9 @@ discard block |
||
140 | 140 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
141 | 141 | } |
142 | 142 | |
143 | +/** |
|
144 | + * @param string $template_name |
|
145 | + */ |
|
143 | 146 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
144 | 147 | ob_start(); |
145 | 148 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -172,6 +175,9 @@ discard block |
||
172 | 175 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
173 | 176 | } |
174 | 177 | |
178 | +/** |
|
179 | + * @param string $slug |
|
180 | + */ |
|
175 | 181 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
176 | 182 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
177 | 183 | |
@@ -871,6 +877,9 @@ discard block |
||
871 | 877 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
872 | 878 | } |
873 | 879 | |
880 | +/** |
|
881 | + * @param integer $id |
|
882 | + */ |
|
874 | 883 | function wpinv_get_watermark( $id ) { |
875 | 884 | if ( !$id > 0 ) { |
876 | 885 | return NULL; |
@@ -21,6 +21,9 @@ |
||
21 | 21 | add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
22 | 22 | } |
23 | 23 | |
24 | + /** |
|
25 | + * @param string[] $function |
|
26 | + */ |
|
24 | 27 | public static function shortcode_wrapper( |
25 | 28 | $function, |
26 | 29 | $atts = array(), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
15 | 15 | ); |
16 | 16 | |
17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
17 | + foreach ($shortcodes as $shortcode => $function) { |
|
18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
19 | 19 | } |
20 | 20 | |
21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function shortcode_wrapper( |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | ) { |
33 | 33 | ob_start(); |
34 | 34 | |
35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
36 | - call_user_func( $function, $atts ); |
|
37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
36 | + call_user_func($function, $atts); |
|
37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
38 | 38 | |
39 | 39 | return ob_get_clean(); |
40 | 40 | } |
41 | 41 | |
42 | - public static function checkout( $atts = array(), $content = null ) { |
|
43 | - return wpinv_checkout_form( $atts, $content ); |
|
42 | + public static function checkout($atts = array(), $content = null) { |
|
43 | + return wpinv_checkout_form($atts, $content); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function messages( $atts, $content = null ) { |
|
46 | + public static function messages($atts, $content = null) { |
|
47 | 47 | ob_start(); |
48 | 48 | wpinv_print_errors(); |
49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
50 | 50 | } |
51 | 51 | |
52 | - public static function history( $atts, $content = null ) { |
|
53 | - return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts ); |
|
52 | + public static function history($atts, $content = null) { |
|
53 | + return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param array $atts |
60 | 60 | */ |
61 | - public static function history_output( $atts ) { |
|
62 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
63 | - wpinv_get_template_part( 'wpinv-invoice-history', $atts ); |
|
64 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
61 | + public static function history_output($atts) { |
|
62 | + do_action('wpinv_before_user_invoice_history'); |
|
63 | + wpinv_get_template_part('wpinv-invoice-history', $atts); |
|
64 | + do_action('wpinv_after_user_invoice_history'); |
|
65 | 65 | } |
66 | 66 | |
67 | - public static function receipt( $atts, $content = null ) { |
|
68 | - return wpinv_payment_receipt( $atts, $content ); |
|
67 | + public static function receipt($atts, $content = null) { |
|
68 | + return wpinv_payment_receipt($atts, $content); |
|
69 | 69 | } |
70 | 70 | } |
@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
7 | +function wpinv_get_option($key = '', $default = false) { |
|
8 | 8 | global $wpinv_options; |
9 | 9 | |
10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
12 | 12 | |
13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
14 | 14 | } |
15 | 15 | |
16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
16 | +function wpinv_update_option($key = '', $value = false) { |
|
17 | 17 | // If no key, exit |
18 | - if ( empty( $key ) ) { |
|
18 | + if (empty($key)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - if ( empty( $value ) ) { |
|
23 | - $remove_option = wpinv_delete_option( $key ); |
|
22 | + if (empty($value)) { |
|
23 | + $remove_option = wpinv_delete_option($key); |
|
24 | 24 | return $remove_option; |
25 | 25 | } |
26 | 26 | |
27 | 27 | // First let's grab the current settings |
28 | - $options = get_option( 'wpinv_settings' ); |
|
28 | + $options = get_option('wpinv_settings'); |
|
29 | 29 | |
30 | 30 | // Let other plugin alter the value |
31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
32 | 32 | |
33 | 33 | // Next let's try to update the value |
34 | - $options[ $key ] = $value; |
|
35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
34 | + $options[$key] = $value; |
|
35 | + $did_update = update_option('wpinv_settings', $options); |
|
36 | 36 | |
37 | 37 | // If it's updated, let's update the global variable |
38 | - if ( $did_update ) { |
|
38 | + if ($did_update) { |
|
39 | 39 | global $wpinv_options; |
40 | - $wpinv_options[ $key ] = $value; |
|
40 | + $wpinv_options[$key] = $value; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $did_update; |
44 | 44 | } |
45 | 45 | |
46 | -function wpinv_delete_option( $key = '' ) { |
|
46 | +function wpinv_delete_option($key = '') { |
|
47 | 47 | // If no key, exit |
48 | - if ( empty( $key ) ) { |
|
48 | + if (empty($key)) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // First let's grab the current settings |
53 | - $options = get_option( 'wpinv_settings' ); |
|
53 | + $options = get_option('wpinv_settings'); |
|
54 | 54 | |
55 | 55 | // Next let's try to update the value |
56 | - if( isset( $options[ $key ] ) ) { |
|
57 | - unset( $options[ $key ] ); |
|
56 | + if (isset($options[$key])) { |
|
57 | + unset($options[$key]); |
|
58 | 58 | } |
59 | 59 | |
60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
60 | + $did_update = update_option('wpinv_settings', $options); |
|
61 | 61 | |
62 | 62 | // If it updated, let's update the global variable |
63 | - if ( $did_update ){ |
|
63 | + if ($did_update) { |
|
64 | 64 | global $wpinv_options; |
65 | 65 | $wpinv_options = $options; |
66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_get_settings() { |
72 | - $settings = get_option( 'wpinv_settings' ); |
|
72 | + $settings = get_option('wpinv_settings'); |
|
73 | 73 | |
74 | - if ( empty( $settings ) ) { |
|
74 | + if (empty($settings)) { |
|
75 | 75 | // Update old settings with new single option |
76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
82 | 82 | |
83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
84 | 84 | |
85 | - update_option( 'wpinv_settings', $settings ); |
|
85 | + update_option('wpinv_settings', $settings); |
|
86 | 86 | |
87 | 87 | } |
88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
88 | + return apply_filters('wpinv_get_settings', $settings); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_register_settings() { |
92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
93 | - add_option( 'wpinv_settings' ); |
|
92 | + if (false == get_option('wpinv_settings')) { |
|
93 | + add_option('wpinv_settings'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $register_settings = wpinv_get_registered_settings(); |
97 | 97 | |
98 | - foreach ( $register_settings as $tab => $sections ) { |
|
99 | - foreach ( $sections as $section => $settings) { |
|
98 | + foreach ($register_settings as $tab => $sections) { |
|
99 | + foreach ($sections as $section => $settings) { |
|
100 | 100 | // Check for backwards compatibility |
101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
103 | 103 | $section = 'main'; |
104 | 104 | $settings = $sections; |
105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
112 | 112 | ); |
113 | 113 | |
114 | - foreach ( $settings as $option ) { |
|
114 | + foreach ($settings as $option) { |
|
115 | 115 | // For backwards compatibility |
116 | - if ( empty( $option['id'] ) ) { |
|
116 | + if (empty($option['id'])) { |
|
117 | 117 | continue; |
118 | 118 | } |
119 | 119 | |
120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
121 | 121 | |
122 | 122 | add_settings_field( |
123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
124 | 124 | $name, |
125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
128 | 128 | array( |
129 | 129 | 'section' => $section, |
130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | } |
@@ -154,21 +154,21 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Creates our settings in the options table |
157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
158 | 158 | } |
159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
160 | 160 | |
161 | 161 | function wpinv_get_registered_settings() { |
162 | - $pages = wpinv_get_pages( true ); |
|
162 | + $pages = wpinv_get_pages(true); |
|
163 | 163 | |
164 | 164 | $due_payment_options = array(); |
165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
166 | + for ($i = 1; $i <= 30; $i++) { |
|
167 | 167 | $due_payment_options[$i] = $i; |
168 | 168 | } |
169 | 169 | |
170 | 170 | $invoice_number_padd_options = array(); |
171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
171 | + for ($i = 0; $i <= 20; $i++) { |
|
172 | 172 | $invoice_number_padd_options[$i] = $i; |
173 | 173 | } |
174 | 174 | |
@@ -177,141 +177,141 @@ discard block |
||
177 | 177 | $alert_wrapper_start = '<p style="color: #F00">'; |
178 | 178 | $alert_wrapper_close = '</p>'; |
179 | 179 | $wpinv_settings = array( |
180 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
180 | + 'general' => apply_filters('wpinv_settings_general', |
|
181 | 181 | array( |
182 | 182 | 'main' => array( |
183 | 183 | 'location_settings' => array( |
184 | 184 | 'id' => 'location_settings', |
185 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
185 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
186 | 186 | 'desc' => '', |
187 | 187 | 'type' => 'header', |
188 | 188 | ), |
189 | 189 | 'default_country' => array( |
190 | 190 | 'id' => 'default_country', |
191 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
192 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
191 | + 'name' => __('Default Country', 'invoicing'), |
|
192 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
193 | 193 | 'type' => 'select', |
194 | 194 | 'options' => wpinv_get_country_list(), |
195 | 195 | 'std' => 'GB', |
196 | 196 | 'chosen' => true, |
197 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
197 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
198 | 198 | ), |
199 | 199 | 'default_state' => array( |
200 | 200 | 'id' => 'default_state', |
201 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
202 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
201 | + 'name' => __('Default State / Province', 'invoicing'), |
|
202 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
203 | 203 | 'type' => 'country_states', |
204 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
204 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | 'store_name' => array( |
207 | 207 | 'id' => 'store_name', |
208 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
209 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
208 | + 'name' => __('Store Name', 'invoicing'), |
|
209 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
210 | 210 | 'std' => get_option('blogname'), |
211 | 211 | 'type' => 'text', |
212 | 212 | ), |
213 | 213 | 'logo' => array( |
214 | 214 | 'id' => 'logo', |
215 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
216 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
215 | + 'name' => __('Logo URL', 'invoicing'), |
|
216 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
217 | 217 | 'type' => 'text', |
218 | 218 | ), |
219 | 219 | 'store_address' => array( |
220 | 220 | 'id' => 'store_address', |
221 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
222 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
221 | + 'name' => __('Store Address', 'invoicing'), |
|
222 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
223 | 223 | 'type' => 'textarea', |
224 | 224 | ), |
225 | 225 | 'page_settings' => array( |
226 | 226 | 'id' => 'page_settings', |
227 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
227 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
228 | 228 | 'desc' => '', |
229 | 229 | 'type' => 'header', |
230 | 230 | ), |
231 | 231 | 'checkout_page' => array( |
232 | 232 | 'id' => 'checkout_page', |
233 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
234 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
233 | + 'name' => __('Checkout Page', 'invoicing'), |
|
234 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
235 | 235 | 'type' => 'select', |
236 | 236 | 'options' => $pages, |
237 | 237 | 'chosen' => true, |
238 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
238 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
239 | 239 | ), |
240 | 240 | 'success_page' => array( |
241 | 241 | 'id' => 'success_page', |
242 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
243 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
242 | + 'name' => __('Success Page', 'invoicing'), |
|
243 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
244 | 244 | 'type' => 'select', |
245 | 245 | 'options' => $pages, |
246 | 246 | 'chosen' => true, |
247 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
247 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
248 | 248 | ), |
249 | 249 | 'failure_page' => array( |
250 | 250 | 'id' => 'failure_page', |
251 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
252 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
251 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
252 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
253 | 253 | 'type' => 'select', |
254 | 254 | 'options' => $pages, |
255 | 255 | 'chosen' => true, |
256 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
256 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
257 | 257 | ), |
258 | 258 | 'invoice_history_page' => array( |
259 | 259 | 'id' => 'invoice_history_page', |
260 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
261 | - 'desc' => __( 'This page shows an invoice history for the current user', 'invoicing' ), |
|
260 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
261 | + 'desc' => __('This page shows an invoice history for the current user', 'invoicing'), |
|
262 | 262 | 'type' => 'select', |
263 | 263 | 'options' => $pages, |
264 | 264 | 'chosen' => true, |
265 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
265 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
266 | 266 | ) |
267 | 267 | ), |
268 | 268 | 'currency_section' => array( |
269 | 269 | 'currency_settings' => array( |
270 | 270 | 'id' => 'currency_settings', |
271 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
271 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
272 | 272 | 'desc' => '', |
273 | 273 | 'type' => 'header', |
274 | 274 | ), |
275 | 275 | 'currency' => array( |
276 | 276 | 'id' => 'currency', |
277 | - 'name' => __( 'Currency', 'invoicing' ), |
|
278 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
277 | + 'name' => __('Currency', 'invoicing'), |
|
278 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
279 | 279 | 'type' => 'select', |
280 | 280 | 'options' => wpinv_get_currencies(), |
281 | 281 | 'chosen' => true, |
282 | 282 | ), |
283 | 283 | 'currency_position' => array( |
284 | 284 | 'id' => 'currency_position', |
285 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
286 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
285 | + 'name' => __('Currency Position', 'invoicing'), |
|
286 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
287 | 287 | 'type' => 'select', |
288 | 288 | 'options' => array( |
289 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
290 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
291 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
292 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
289 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
290 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
291 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
292 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
293 | 293 | ) |
294 | 294 | ), |
295 | 295 | 'thousands_separator' => array( |
296 | 296 | 'id' => 'thousands_separator', |
297 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
298 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
297 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
298 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
299 | 299 | 'type' => 'text', |
300 | 300 | 'size' => 'small', |
301 | 301 | 'std' => ',', |
302 | 302 | ), |
303 | 303 | 'decimal_separator' => array( |
304 | 304 | 'id' => 'decimal_separator', |
305 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
306 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
305 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
306 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
307 | 307 | 'type' => 'text', |
308 | 308 | 'size' => 'small', |
309 | 309 | 'std' => '.', |
310 | 310 | ), |
311 | 311 | 'decimals' => array( |
312 | 312 | 'id' => 'decimals', |
313 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
314 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
313 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
314 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
315 | 315 | 'type' => 'number', |
316 | 316 | 'size' => 'small', |
317 | 317 | 'std' => '2', |
@@ -323,29 +323,29 @@ discard block |
||
323 | 323 | 'labels' => array( |
324 | 324 | 'labels' => array( |
325 | 325 | 'id' => 'labels_settings', |
326 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
326 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
327 | 327 | 'desc' => '', |
328 | 328 | 'type' => 'header', |
329 | 329 | ), |
330 | 330 | 'vat_name' => array( |
331 | 331 | 'id' => 'vat_name', |
332 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
333 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
332 | + 'name' => __('VAT Name', 'invoicing'), |
|
333 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
334 | 334 | 'type' => 'text', |
335 | 335 | 'size' => 'regular', |
336 | 336 | 'std' => 'VAT' |
337 | 337 | ), |
338 | 338 | 'vat_invoice_notice_label' => array( |
339 | 339 | 'id' => 'vat_invoice_notice_label', |
340 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
341 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
340 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
341 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
342 | 342 | 'type' => 'text', |
343 | 343 | 'size' => 'regular', |
344 | 344 | ), |
345 | 345 | 'vat_invoice_notice' => array( |
346 | 346 | 'id' => 'vat_invoice_notice', |
347 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
348 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
347 | + 'name' => __('Invoice notice', 'invoicing'), |
|
348 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
349 | 349 | 'type' => 'text', |
350 | 350 | 'size' => 'regular', |
351 | 351 | ) |
@@ -357,22 +357,22 @@ discard block |
||
357 | 357 | 'main' => array( |
358 | 358 | 'gateway_settings' => array( |
359 | 359 | 'id' => 'api_header', |
360 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
360 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
361 | 361 | 'desc' => '', |
362 | 362 | 'type' => 'header', |
363 | 363 | ), |
364 | 364 | 'gateways' => array( |
365 | 365 | 'id' => 'gateways', |
366 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
367 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
366 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
367 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
368 | 368 | 'type' => 'gateways', |
369 | 369 | 'std' => array('manual'=>1), |
370 | 370 | 'options' => wpinv_get_payment_gateways(), |
371 | 371 | ), |
372 | 372 | 'default_gateway' => array( |
373 | 373 | 'id' => 'default_gateway', |
374 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
375 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
374 | + 'name' => __('Default Gateway', 'invoicing'), |
|
375 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
376 | 376 | 'type' => 'gateway_select', |
377 | 377 | 'std' => 'manual', |
378 | 378 | 'options' => wpinv_get_payment_gateways(), |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | 'main' => array( |
387 | 387 | 'tax_settings' => array( |
388 | 388 | 'id' => 'tax_settings', |
389 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
389 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
390 | 390 | 'type' => 'header', |
391 | 391 | ), |
392 | 392 | 'enable_taxes' => array( |
393 | 393 | 'id' => 'enable_taxes', |
394 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
395 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
394 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
395 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
396 | 396 | 'type' => 'checkbox', |
397 | 397 | ), |
398 | 398 | 'tax_rate' => array( |
399 | 399 | 'id' => 'tax_rate', |
400 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
401 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
400 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
401 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
402 | 402 | 'type' => 'number', |
403 | 403 | 'size' => 'small', |
404 | 404 | 'min' => '0', |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | 'rates' => array( |
411 | 411 | 'tax_rates' => array( |
412 | 412 | 'id' => 'tax_rates', |
413 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
414 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
413 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
414 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
415 | 415 | 'type' => 'tax_rates', |
416 | 416 | ), |
417 | 417 | ) |
@@ -423,62 +423,62 @@ discard block |
||
423 | 423 | 'main' => array( |
424 | 424 | 'email_settings_header' => array( |
425 | 425 | 'id' => 'email_settings_header', |
426 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
426 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
427 | 427 | 'type' => 'header', |
428 | 428 | ), |
429 | 429 | 'email_from_name' => array( |
430 | 430 | 'id' => 'email_from_name', |
431 | - 'name' => __( 'From Name', 'invoicing' ), |
|
432 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
433 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
431 | + 'name' => __('From Name', 'invoicing'), |
|
432 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
433 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
434 | 434 | 'type' => 'text', |
435 | 435 | ), |
436 | 436 | 'email_from' => array( |
437 | 437 | 'id' => 'email_from', |
438 | - 'name' => __( 'From Email', 'invoicing' ), |
|
439 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
440 | - 'std' => get_option( 'admin_email' ), |
|
438 | + 'name' => __('From Email', 'invoicing'), |
|
439 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
440 | + 'std' => get_option('admin_email'), |
|
441 | 441 | 'type' => 'text', |
442 | 442 | ), |
443 | 443 | 'overdue_settings_header' => array( |
444 | 444 | 'id' => 'overdue_settings_header', |
445 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
445 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
446 | 446 | 'type' => 'header', |
447 | 447 | ), |
448 | 448 | 'overdue_active' => array( |
449 | 449 | 'id' => 'overdue_active', |
450 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
451 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
450 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
451 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
452 | 452 | 'type' => 'checkbox', |
453 | 453 | 'std' => false, |
454 | 454 | ), |
455 | 455 | 'overdue_days' => array( |
456 | 456 | 'id' => 'overdue_days', |
457 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
458 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
457 | + 'name' => __('Default Due Date', 'invoicing'), |
|
458 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
459 | 459 | 'type' => 'select', |
460 | 460 | 'options' => $due_payment_options, |
461 | 461 | 'chosen' => true, |
462 | 462 | 'std' => 0, |
463 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
463 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
464 | 464 | ), |
465 | 465 | 'email_template_header' => array( |
466 | 466 | 'id' => 'email_template_header', |
467 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
467 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
468 | 468 | 'type' => 'header', |
469 | 469 | ), |
470 | 470 | 'email_header_image' => array( |
471 | 471 | 'id' => 'email_header_image', |
472 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
473 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
472 | + 'name' => __('Header Image', 'invoicing'), |
|
473 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
474 | 474 | 'std' => '', |
475 | 475 | 'type' => 'text', |
476 | 476 | ), |
477 | 477 | 'email_footer_text' => array( |
478 | 478 | 'id' => 'email_footer_text', |
479 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
480 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
481 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
479 | + 'name' => __('Footer Text', 'invoicing'), |
|
480 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
481 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
482 | 482 | 'type' => 'textarea', |
483 | 483 | 'class' => 'regular-text', |
484 | 484 | 'rows' => 2, |
@@ -486,29 +486,29 @@ discard block |
||
486 | 486 | ), |
487 | 487 | 'email_base_color' => array( |
488 | 488 | 'id' => 'email_base_color', |
489 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
490 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
489 | + 'name' => __('Base Color', 'invoicing'), |
|
490 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
491 | 491 | 'std' => '#557da2', |
492 | 492 | 'type' => 'color', |
493 | 493 | ), |
494 | 494 | 'email_background_color' => array( |
495 | 495 | 'id' => 'email_background_color', |
496 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
497 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
496 | + 'name' => __('Background Color', 'invoicing'), |
|
497 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
498 | 498 | 'std' => '#f5f5f5', |
499 | 499 | 'type' => 'color', |
500 | 500 | ), |
501 | 501 | 'email_body_background_color' => array( |
502 | 502 | 'id' => 'email_body_background_color', |
503 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
504 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
503 | + 'name' => __('Body Background Color', 'invoicing'), |
|
504 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
505 | 505 | 'std' => '#fdfdfd', |
506 | 506 | 'type' => 'color', |
507 | 507 | ), |
508 | 508 | 'email_text_color' => array( |
509 | 509 | 'id' => 'email_text_color', |
510 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
511 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
510 | + 'name' => __('Body Text Color', 'invoicing'), |
|
511 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
512 | 512 | 'std' => '#505050', |
513 | 513 | 'type' => 'color', |
514 | 514 | ), |
@@ -527,73 +527,73 @@ discard block |
||
527 | 527 | 'main' => array( |
528 | 528 | 'fields_settings' => array( |
529 | 529 | 'id' => 'fields_settings', |
530 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
531 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
530 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
531 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
532 | 532 | 'type' => 'header', |
533 | 533 | ), |
534 | 534 | 'fname_mandatory' => array( |
535 | 535 | 'id' => 'fname_mandatory', |
536 | - 'name' => __( 'First Name', 'invoicing' ), |
|
536 | + 'name' => __('First Name', 'invoicing'), |
|
537 | 537 | 'type' => 'checkbox', |
538 | 538 | 'std' => true, |
539 | 539 | ), |
540 | 540 | 'lname_mandatory' => array( |
541 | 541 | 'id' => 'lname_mandatory', |
542 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
542 | + 'name' => __('Last Name', 'invoicing'), |
|
543 | 543 | 'type' => 'checkbox', |
544 | 544 | 'std' => true, |
545 | 545 | ), |
546 | 546 | 'address_mandatory' => array( |
547 | 547 | 'id' => 'address_mandatory', |
548 | - 'name' => __( 'Address', 'invoicing' ), |
|
548 | + 'name' => __('Address', 'invoicing'), |
|
549 | 549 | 'type' => 'checkbox', |
550 | 550 | 'std' => true, |
551 | 551 | ), |
552 | 552 | 'city_mandatory' => array( |
553 | 553 | 'id' => 'city_mandatory', |
554 | - 'name' => __( 'City', 'invoicing' ), |
|
554 | + 'name' => __('City', 'invoicing'), |
|
555 | 555 | 'type' => 'checkbox', |
556 | 556 | 'std' => true, |
557 | 557 | ), |
558 | 558 | 'country_mandatory' => array( |
559 | 559 | 'id' => 'country_mandatory', |
560 | - 'name' => __( 'Country', 'invoicing' ), |
|
560 | + 'name' => __('Country', 'invoicing'), |
|
561 | 561 | 'type' => 'checkbox', |
562 | 562 | 'std' => true, |
563 | 563 | ), |
564 | 564 | 'state_mandatory' => array( |
565 | 565 | 'id' => 'state_mandatory', |
566 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
566 | + 'name' => __('State / Province', 'invoicing'), |
|
567 | 567 | 'type' => 'checkbox', |
568 | 568 | 'std' => true, |
569 | 569 | ), |
570 | 570 | 'zip_mandatory' => array( |
571 | 571 | 'id' => 'zip_mandatory', |
572 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
572 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
573 | 573 | 'type' => 'checkbox', |
574 | 574 | 'std' => true, |
575 | 575 | ), |
576 | 576 | 'phone_mandatory' => array( |
577 | 577 | 'id' => 'phone_mandatory', |
578 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
578 | + 'name' => __('Phone Number', 'invoicing'), |
|
579 | 579 | 'type' => 'checkbox', |
580 | 580 | 'std' => true, |
581 | 581 | ), |
582 | 582 | 'invoice_number_format_settings' => array( |
583 | 583 | 'id' => 'invoice_number_format_settings', |
584 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
584 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
585 | 585 | 'type' => 'header', |
586 | 586 | ), |
587 | 587 | 'sequential_invoice_number' => array( |
588 | 588 | 'id' => 'sequential_invoice_number', |
589 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
590 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
589 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
590 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
591 | 591 | 'type' => 'checkbox', |
592 | 592 | ), |
593 | 593 | 'invoice_sequence_start' => array( |
594 | 594 | 'id' => 'invoice_sequence_start', |
595 | - 'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ), |
|
596 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ), |
|
595 | + 'name' => __('Sequential Starting Number', 'easy-digital-downloads'), |
|
596 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'), |
|
597 | 597 | 'type' => 'number', |
598 | 598 | 'size' => 'small', |
599 | 599 | 'std' => '1', |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | ), |
602 | 602 | 'invoice_number_padd' => array( |
603 | 603 | 'id' => 'invoice_number_padd', |
604 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
605 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
604 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
605 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
606 | 606 | 'type' => 'select', |
607 | 607 | 'options' => $invoice_number_padd_options, |
608 | 608 | 'std' => 5, |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | ), |
611 | 611 | 'invoice_number_prefix' => array( |
612 | 612 | 'id' => 'invoice_number_prefix', |
613 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
614 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
613 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
614 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
615 | 615 | 'type' => 'text', |
616 | 616 | 'size' => 'regular', |
617 | 617 | 'std' => 'WPINV-', |
@@ -619,25 +619,25 @@ discard block |
||
619 | 619 | ), |
620 | 620 | 'invoice_number_postfix' => array( |
621 | 621 | 'id' => 'invoice_number_postfix', |
622 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
623 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
622 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
623 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
624 | 624 | 'type' => 'text', |
625 | 625 | 'size' => 'regular', |
626 | 626 | 'std' => '' |
627 | 627 | ), |
628 | 628 | 'guest_checkout_settings' => array( |
629 | 629 | 'id' => 'guest_checkout_settings', |
630 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
630 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
631 | 631 | 'type' => 'header', |
632 | 632 | ), |
633 | 633 | 'guest_checkout' => array( |
634 | 634 | 'type' => 'radio', |
635 | 635 | 'id' => 'guest_checkout', |
636 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
637 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing' ), |
|
636 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
637 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing'), |
|
638 | 638 | 'options' => array( |
639 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
640 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
639 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
640 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
641 | 641 | ), |
642 | 642 | 'std' => 0, |
643 | 643 | ), |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | 'main' => array( |
651 | 651 | 'tool_settings' => array( |
652 | 652 | 'id' => 'tool_settings', |
653 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
654 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
653 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
654 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
655 | 655 | 'type' => 'tools', |
656 | 656 | ), |
657 | 657 | ), |
@@ -659,135 +659,135 @@ discard block |
||
659 | 659 | ) |
660 | 660 | ); |
661 | 661 | |
662 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
662 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
663 | 663 | } |
664 | 664 | |
665 | -function wpinv_settings_sanitize( $input = array() ) { |
|
665 | +function wpinv_settings_sanitize($input = array()) { |
|
666 | 666 | global $wpinv_options; |
667 | 667 | |
668 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
668 | + if (empty($_POST['_wp_http_referer'])) { |
|
669 | 669 | return $input; |
670 | 670 | } |
671 | 671 | |
672 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
672 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
673 | 673 | |
674 | 674 | $settings = wpinv_get_registered_settings(); |
675 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
676 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
675 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
676 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
677 | 677 | |
678 | 678 | $input = $input ? $input : array(); |
679 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
680 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
679 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
680 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
681 | 681 | |
682 | 682 | // Loop through each setting being saved and pass it through a sanitization filter |
683 | - foreach ( $input as $key => $value ) { |
|
683 | + foreach ($input as $key => $value) { |
|
684 | 684 | // Get the setting type (checkbox, select, etc) |
685 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
685 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
686 | 686 | |
687 | - if ( $type ) { |
|
687 | + if ($type) { |
|
688 | 688 | // Field type specific filter |
689 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
689 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // General filter |
693 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
693 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | // Loop through the whitelist and unset any that are empty for the tab being saved |
697 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
698 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
697 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
698 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
699 | 699 | |
700 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
700 | + $found_settings = array_merge($main_settings, $section_settings); |
|
701 | 701 | |
702 | - if ( ! empty( $found_settings ) ) { |
|
703 | - foreach ( $found_settings as $key => $value ) { |
|
702 | + if (!empty($found_settings)) { |
|
703 | + foreach ($found_settings as $key => $value) { |
|
704 | 704 | |
705 | 705 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
706 | - if ( is_numeric( $key ) ) { |
|
706 | + if (is_numeric($key)) { |
|
707 | 707 | $key = $value['id']; |
708 | 708 | } |
709 | 709 | |
710 | - if ( empty( $input[ $key ] ) ) { |
|
711 | - unset( $wpinv_options[ $key ] ); |
|
710 | + if (empty($input[$key])) { |
|
711 | + unset($wpinv_options[$key]); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
716 | 716 | // Merge our new settings with the existing |
717 | - $output = array_merge( $wpinv_options, $input ); |
|
717 | + $output = array_merge($wpinv_options, $input); |
|
718 | 718 | |
719 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
719 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
720 | 720 | |
721 | 721 | return $output; |
722 | 722 | } |
723 | 723 | |
724 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
724 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
725 | 725 | global $wpinv_options, $wpi_session; |
726 | 726 | |
727 | - if ( !current_user_can( 'manage_options' ) ) { |
|
727 | + if (!current_user_can('manage_options')) { |
|
728 | 728 | return $input; |
729 | 729 | } |
730 | 730 | |
731 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
731 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
732 | 732 | // Shows an admin notice about upgrading previous order numbers |
733 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
733 | + $wpi_session->set('upgrade_sequential', '1'); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | return $input; |
737 | 737 | } |
738 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
738 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
739 | 739 | |
740 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
741 | - if( !current_user_can( 'manage_options' ) ) { |
|
740 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
741 | + if (!current_user_can('manage_options')) { |
|
742 | 742 | return $input; |
743 | 743 | } |
744 | 744 | |
745 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
745 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
746 | 746 | |
747 | 747 | $tax_rates = array(); |
748 | 748 | |
749 | - if ( !empty( $new_rates ) ) { |
|
750 | - foreach ( $new_rates as $rate ) { |
|
751 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
749 | + if (!empty($new_rates)) { |
|
750 | + foreach ($new_rates as $rate) { |
|
751 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
752 | 752 | continue; |
753 | 753 | } |
754 | 754 | |
755 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
755 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
756 | 756 | |
757 | 757 | $tax_rates[] = $rate; |
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
761 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
761 | + update_option('wpinv_tax_rates', $tax_rates); |
|
762 | 762 | |
763 | 763 | return $input; |
764 | 764 | } |
765 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
765 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
766 | 766 | |
767 | -function wpinv_sanitize_text_field( $input ) { |
|
768 | - return trim( $input ); |
|
767 | +function wpinv_sanitize_text_field($input) { |
|
768 | + return trim($input); |
|
769 | 769 | } |
770 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
770 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
771 | 771 | |
772 | 772 | function wpinv_get_settings_tabs() { |
773 | 773 | $tabs = array(); |
774 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
775 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
776 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
777 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
778 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
779 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
780 | - |
|
781 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
774 | + $tabs['general'] = __('General', 'invoicing'); |
|
775 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
776 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
777 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
778 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
779 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
780 | + |
|
781 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
782 | 782 | } |
783 | 783 | |
784 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
784 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
785 | 785 | $tabs = false; |
786 | 786 | $sections = wpinv_get_registered_settings_sections(); |
787 | 787 | |
788 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
789 | - $tabs = $sections[ $tab ]; |
|
790 | - } else if ( $tab ) { |
|
788 | + if ($tab && !empty($sections[$tab])) { |
|
789 | + $tabs = $sections[$tab]; |
|
790 | + } else if ($tab) { |
|
791 | 791 | $tabs = false; |
792 | 792 | } |
793 | 793 | |
@@ -797,135 +797,135 @@ discard block |
||
797 | 797 | function wpinv_get_registered_settings_sections() { |
798 | 798 | static $sections = false; |
799 | 799 | |
800 | - if ( false !== $sections ) { |
|
800 | + if (false !== $sections) { |
|
801 | 801 | return $sections; |
802 | 802 | } |
803 | 803 | |
804 | 804 | $sections = array( |
805 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
806 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
807 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
808 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
809 | - ) ), |
|
810 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
811 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
812 | - ) ), |
|
813 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
814 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
815 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
816 | - ) ), |
|
817 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
818 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
819 | - ) ), |
|
820 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
821 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
822 | - ) ), |
|
823 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
824 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
825 | - ) ), |
|
805 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
806 | + 'main' => __('General Settings', 'invoicing'), |
|
807 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
808 | + 'labels' => __('Label Texts', 'invoicing'), |
|
809 | + )), |
|
810 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
811 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
812 | + )), |
|
813 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
814 | + 'main' => __('Tax Settings', 'invoicing'), |
|
815 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
816 | + )), |
|
817 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
818 | + 'main' => __('Email Settings', 'invoicing'), |
|
819 | + )), |
|
820 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
821 | + 'main' => __('Misc Settings', 'invoicing'), |
|
822 | + )), |
|
823 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
824 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
825 | + )), |
|
826 | 826 | ); |
827 | 827 | |
828 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
828 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
829 | 829 | |
830 | 830 | return $sections; |
831 | 831 | } |
832 | 832 | |
833 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
833 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
834 | 834 | $pages_options = array(); |
835 | 835 | |
836 | - if( $default_label !== NULL && $default_label !== false ) { |
|
837 | - $pages_options = array( '' => $default_label ); // Blank option |
|
836 | + if ($default_label !== NULL && $default_label !== false) { |
|
837 | + $pages_options = array('' => $default_label); // Blank option |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | $pages = get_pages(); |
841 | - if ( $pages ) { |
|
842 | - foreach ( $pages as $page ) { |
|
841 | + if ($pages) { |
|
842 | + foreach ($pages as $page) { |
|
843 | 843 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
844 | - $pages_options[ $page->ID ] = $title; |
|
844 | + $pages_options[$page->ID] = $title; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
848 | 848 | return $pages_options; |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_header_callback( $args ) { |
|
852 | - if ( !empty( $args['desc'] ) ) { |
|
851 | +function wpinv_header_callback($args) { |
|
852 | + if (!empty($args['desc'])) { |
|
853 | 853 | echo $args['desc']; |
854 | 854 | } |
855 | 855 | } |
856 | 856 | |
857 | -function wpinv_hidden_callback( $args ) { |
|
857 | +function wpinv_hidden_callback($args) { |
|
858 | 858 | global $wpinv_options; |
859 | 859 | |
860 | - if ( isset( $args['set_value'] ) ) { |
|
860 | + if (isset($args['set_value'])) { |
|
861 | 861 | $value = $args['set_value']; |
862 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
863 | - $value = $wpinv_options[ $args['id'] ]; |
|
862 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
863 | + $value = $wpinv_options[$args['id']]; |
|
864 | 864 | } else { |
865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
865 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
866 | 866 | } |
867 | 867 | |
868 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
868 | + if (isset($args['faux']) && true === $args['faux']) { |
|
869 | 869 | $args['readonly'] = true; |
870 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
870 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
871 | 871 | $name = ''; |
872 | 872 | } else { |
873 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
873 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
874 | 874 | } |
875 | 875 | |
876 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
876 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
877 | 877 | |
878 | 878 | echo $html; |
879 | 879 | } |
880 | 880 | |
881 | -function wpinv_checkbox_callback( $args ) { |
|
881 | +function wpinv_checkbox_callback($args) { |
|
882 | 882 | global $wpinv_options; |
883 | 883 | |
884 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
884 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
885 | 885 | |
886 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
886 | + if (isset($args['faux']) && true === $args['faux']) { |
|
887 | 887 | $name = ''; |
888 | 888 | } else { |
889 | 889 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
890 | 890 | } |
891 | 891 | |
892 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
892 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
893 | 893 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
894 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
894 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
895 | 895 | |
896 | 896 | echo $html; |
897 | 897 | } |
898 | 898 | |
899 | -function wpinv_multicheck_callback( $args ) { |
|
899 | +function wpinv_multicheck_callback($args) { |
|
900 | 900 | global $wpinv_options; |
901 | 901 | |
902 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
902 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
903 | 903 | |
904 | - if ( ! empty( $args['options'] ) ) { |
|
905 | - foreach( $args['options'] as $key => $option ): |
|
906 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
907 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
904 | + if (!empty($args['options'])) { |
|
905 | + foreach ($args['options'] as $key => $option): |
|
906 | + $sanitize_key = wpinv_sanitize_key($key); |
|
907 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
908 | 908 | $enabled = $sanitize_key; |
909 | 909 | } else { |
910 | 910 | $enabled = NULL; |
911 | 911 | } |
912 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
913 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
912 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
913 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
914 | 914 | endforeach; |
915 | 915 | echo '<p class="description">' . $args['desc'] . '</p>'; |
916 | 916 | } |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_payment_icons_callback( $args ) { |
|
919 | +function wpinv_payment_icons_callback($args) { |
|
920 | 920 | global $wpinv_options; |
921 | 921 | |
922 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
922 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
923 | 923 | |
924 | - if ( ! empty( $args['options'] ) ) { |
|
925 | - foreach( $args['options'] as $key => $option ) { |
|
926 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
924 | + if (!empty($args['options'])) { |
|
925 | + foreach ($args['options'] as $key => $option) { |
|
926 | + $sanitize_key = wpinv_sanitize_key($key); |
|
927 | 927 | |
928 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
928 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
929 | 929 | $enabled = $option; |
930 | 930 | } else { |
931 | 931 | $enabled = NULL; |
@@ -933,196 +933,196 @@ discard block |
||
933 | 933 | |
934 | 934 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
935 | 935 | |
936 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
936 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
937 | 937 | |
938 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
939 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
938 | + if (wpinv_string_is_image_url($key)) { |
|
939 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
940 | 940 | } else { |
941 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
941 | + $card = strtolower(str_replace(' ', '', $option)); |
|
942 | 942 | |
943 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
944 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
943 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
944 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
945 | 945 | } else { |
946 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
946 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
947 | 947 | $content_dir = WP_CONTENT_DIR; |
948 | 948 | |
949 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
949 | + if (function_exists('wp_normalize_path')) { |
|
950 | 950 | // Replaces backslashes with forward slashes for Windows systems |
951 | - $image = wp_normalize_path( $image ); |
|
952 | - $content_dir = wp_normalize_path( $content_dir ); |
|
951 | + $image = wp_normalize_path($image); |
|
952 | + $content_dir = wp_normalize_path($content_dir); |
|
953 | 953 | } |
954 | 954 | |
955 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
955 | + $image = str_replace($content_dir, content_url(), $image); |
|
956 | 956 | } |
957 | 957 | |
958 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
958 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
959 | 959 | } |
960 | 960 | echo $option . '</label>'; |
961 | 961 | } |
962 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
962 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
966 | -function wpinv_radio_callback( $args ) { |
|
966 | +function wpinv_radio_callback($args) { |
|
967 | 967 | global $wpinv_options; |
968 | 968 | |
969 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
969 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
970 | 970 | |
971 | - foreach ( $args['options'] as $key => $option ) : |
|
972 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
971 | + foreach ($args['options'] as $key => $option) : |
|
972 | + $sanitize_key = wpinv_sanitize_key($key); |
|
973 | 973 | |
974 | 974 | $checked = false; |
975 | 975 | |
976 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
976 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
977 | 977 | $checked = true; |
978 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
978 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
979 | 979 | $checked = true; |
980 | 980 | |
981 | 981 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
982 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
982 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
983 | 983 | endforeach; |
984 | 984 | |
985 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
985 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_gateways_callback( $args ) { |
|
988 | +function wpinv_gateways_callback($args) { |
|
989 | 989 | global $wpinv_options; |
990 | 990 | |
991 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
991 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
992 | 992 | |
993 | - foreach ( $args['options'] as $key => $option ) : |
|
994 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
993 | + foreach ($args['options'] as $key => $option) : |
|
994 | + $sanitize_key = wpinv_sanitize_key($key); |
|
995 | 995 | |
996 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
996 | + if (isset($wpinv_options['gateways'][$key])) |
|
997 | 997 | $enabled = '1'; |
998 | 998 | else |
999 | 999 | $enabled = null; |
1000 | 1000 | |
1001 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1002 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1001 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1002 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
1003 | 1003 | endforeach; |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | function wpinv_gateway_select_callback($args) { |
1007 | 1007 | global $wpinv_options; |
1008 | 1008 | |
1009 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1009 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1010 | 1010 | |
1011 | 1011 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
1012 | 1012 | |
1013 | - foreach ( $args['options'] as $key => $option ) : |
|
1014 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1015 | - $selected = selected( $key, $args['selected'], false ); |
|
1013 | + foreach ($args['options'] as $key => $option) : |
|
1014 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1015 | + $selected = selected($key, $args['selected'], false); |
|
1016 | 1016 | } else { |
1017 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
1017 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
1018 | 1018 | } |
1019 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1019 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
1020 | 1020 | endforeach; |
1021 | 1021 | |
1022 | 1022 | echo '</select>'; |
1023 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1023 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | -function wpinv_text_callback( $args ) { |
|
1026 | +function wpinv_text_callback($args) { |
|
1027 | 1027 | global $wpinv_options; |
1028 | 1028 | |
1029 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1029 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1030 | 1030 | |
1031 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1032 | - $value = $wpinv_options[ $args['id'] ]; |
|
1031 | + if (isset($wpinv_options[$args['id']])) { |
|
1032 | + $value = $wpinv_options[$args['id']]; |
|
1033 | 1033 | } else { |
1034 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1034 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1037 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1038 | 1038 | $args['readonly'] = true; |
1039 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1039 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1040 | 1040 | $name = ''; |
1041 | 1041 | } else { |
1042 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1042 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1043 | 1043 | } |
1044 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1044 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1045 | 1045 | |
1046 | 1046 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
1047 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1048 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1049 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1047 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1048 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
1049 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1050 | 1050 | |
1051 | 1051 | echo $html; |
1052 | 1052 | } |
1053 | 1053 | |
1054 | -function wpinv_number_callback( $args ) { |
|
1054 | +function wpinv_number_callback($args) { |
|
1055 | 1055 | global $wpinv_options; |
1056 | 1056 | |
1057 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1057 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1058 | 1058 | |
1059 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1060 | - $value = $wpinv_options[ $args['id'] ]; |
|
1059 | + if (isset($wpinv_options[$args['id']])) { |
|
1060 | + $value = $wpinv_options[$args['id']]; |
|
1061 | 1061 | } else { |
1062 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1062 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1065 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1066 | 1066 | $args['readonly'] = true; |
1067 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1067 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1068 | 1068 | $name = ''; |
1069 | 1069 | } else { |
1070 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1070 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1074 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1075 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1076 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1073 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
1074 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
1075 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
1076 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1077 | 1077 | |
1078 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1079 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1080 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1078 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1079 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1080 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1081 | 1081 | |
1082 | 1082 | echo $html; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | -function wpinv_textarea_callback( $args ) { |
|
1085 | +function wpinv_textarea_callback($args) { |
|
1086 | 1086 | global $wpinv_options; |
1087 | 1087 | |
1088 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1088 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1089 | 1089 | |
1090 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1091 | - $value = $wpinv_options[ $args['id'] ]; |
|
1090 | + if (isset($wpinv_options[$args['id']])) { |
|
1091 | + $value = $wpinv_options[$args['id']]; |
|
1092 | 1092 | } else { |
1093 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1093 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1097 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
1096 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1097 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
1098 | 1098 | |
1099 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1100 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1099 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1100 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1101 | 1101 | |
1102 | 1102 | echo $html; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | -function wpinv_password_callback( $args ) { |
|
1105 | +function wpinv_password_callback($args) { |
|
1106 | 1106 | global $wpinv_options; |
1107 | 1107 | |
1108 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1108 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1109 | 1109 | |
1110 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1111 | - $value = $wpinv_options[ $args['id'] ]; |
|
1110 | + if (isset($wpinv_options[$args['id']])) { |
|
1111 | + $value = $wpinv_options[$args['id']]; |
|
1112 | 1112 | } else { |
1113 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1113 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1117 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1118 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1116 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1117 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
1118 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1119 | 1119 | |
1120 | 1120 | echo $html; |
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | function wpinv_missing_callback($args) { |
1124 | 1124 | printf( |
1125 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1125 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
1126 | 1126 | '<strong>' . $args['id'] . '</strong>' |
1127 | 1127 | ); |
1128 | 1128 | } |
@@ -1130,137 +1130,137 @@ discard block |
||
1130 | 1130 | function wpinv_select_callback($args) { |
1131 | 1131 | global $wpinv_options; |
1132 | 1132 | |
1133 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1133 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1134 | 1134 | |
1135 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1136 | - $value = $wpinv_options[ $args['id'] ]; |
|
1135 | + if (isset($wpinv_options[$args['id']])) { |
|
1136 | + $value = $wpinv_options[$args['id']]; |
|
1137 | 1137 | } else { |
1138 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1138 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1141 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1142 | 1142 | $value = $args['selected']; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - if ( isset( $args['placeholder'] ) ) { |
|
1145 | + if (isset($args['placeholder'])) { |
|
1146 | 1146 | $placeholder = $args['placeholder']; |
1147 | 1147 | } else { |
1148 | 1148 | $placeholder = ''; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | - if ( isset( $args['chosen'] ) ) { |
|
1151 | + if (isset($args['chosen'])) { |
|
1152 | 1152 | $chosen = 'class="wpinv-chosen"'; |
1153 | 1153 | } else { |
1154 | 1154 | $chosen = ''; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - if( !empty( $args['onchange'] ) ) { |
|
1158 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
1157 | + if (!empty($args['onchange'])) { |
|
1158 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
1159 | 1159 | } else { |
1160 | 1160 | $onchange = ''; |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1163 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
1164 | 1164 | |
1165 | - foreach ( $args['options'] as $option => $name ) { |
|
1166 | - $selected = selected( $option, $value, false ); |
|
1167 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1165 | + foreach ($args['options'] as $option => $name) { |
|
1166 | + $selected = selected($option, $value, false); |
|
1167 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | $html .= '</select>'; |
1171 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1171 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1172 | 1172 | |
1173 | 1173 | echo $html; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | -function wpinv_color_select_callback( $args ) { |
|
1176 | +function wpinv_color_select_callback($args) { |
|
1177 | 1177 | global $wpinv_options; |
1178 | 1178 | |
1179 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1179 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1180 | 1180 | |
1181 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1182 | - $value = $wpinv_options[ $args['id'] ]; |
|
1181 | + if (isset($wpinv_options[$args['id']])) { |
|
1182 | + $value = $wpinv_options[$args['id']]; |
|
1183 | 1183 | } else { |
1184 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1184 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1187 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
1188 | 1188 | |
1189 | - foreach ( $args['options'] as $option => $color ) { |
|
1190 | - $selected = selected( $option, $value, false ); |
|
1191 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1189 | + foreach ($args['options'] as $option => $color) { |
|
1190 | + $selected = selected($option, $value, false); |
|
1191 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | $html .= '</select>'; |
1195 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1195 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1196 | 1196 | |
1197 | 1197 | echo $html; |
1198 | 1198 | } |
1199 | 1199 | |
1200 | -function wpinv_rich_editor_callback( $args ) { |
|
1200 | +function wpinv_rich_editor_callback($args) { |
|
1201 | 1201 | global $wpinv_options, $wp_version; |
1202 | 1202 | |
1203 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1203 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1204 | 1204 | |
1205 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1206 | - $value = $wpinv_options[ $args['id'] ]; |
|
1205 | + if (isset($wpinv_options[$args['id']])) { |
|
1206 | + $value = $wpinv_options[$args['id']]; |
|
1207 | 1207 | |
1208 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1209 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1208 | + if (empty($args['allow_blank']) && empty($value)) { |
|
1209 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1210 | 1210 | } |
1211 | 1211 | } else { |
1212 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1212 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1215 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
1216 | 1216 | |
1217 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1217 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
1218 | 1218 | ob_start(); |
1219 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1219 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
1220 | 1220 | $html = ob_get_clean(); |
1221 | 1221 | } else { |
1222 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1222 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1225 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1226 | 1226 | |
1227 | 1227 | echo $html; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | -function wpinv_upload_callback( $args ) { |
|
1230 | +function wpinv_upload_callback($args) { |
|
1231 | 1231 | global $wpinv_options; |
1232 | 1232 | |
1233 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1233 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1234 | 1234 | |
1235 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1235 | + if (isset($wpinv_options[$args['id']])) { |
|
1236 | 1236 | $value = $wpinv_options[$args['id']]; |
1237 | 1237 | } else { |
1238 | 1238 | $value = isset($args['std']) ? $args['std'] : ''; |
1239 | 1239 | } |
1240 | 1240 | |
1241 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1242 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1243 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1244 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1241 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1242 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1243 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
1244 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1245 | 1245 | |
1246 | 1246 | echo $html; |
1247 | 1247 | } |
1248 | 1248 | |
1249 | -function wpinv_color_callback( $args ) { |
|
1249 | +function wpinv_color_callback($args) { |
|
1250 | 1250 | global $wpinv_options; |
1251 | 1251 | |
1252 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1252 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1253 | 1253 | |
1254 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1255 | - $value = $wpinv_options[ $args['id'] ]; |
|
1254 | + if (isset($wpinv_options[$args['id']])) { |
|
1255 | + $value = $wpinv_options[$args['id']]; |
|
1256 | 1256 | } else { |
1257 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1257 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1260 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
1261 | 1261 | |
1262 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1263 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1262 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
1263 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1264 | 1264 | |
1265 | 1265 | echo $html; |
1266 | 1266 | } |
@@ -1268,9 +1268,9 @@ discard block |
||
1268 | 1268 | function wpinv_country_states_callback($args) { |
1269 | 1269 | global $wpinv_options; |
1270 | 1270 | |
1271 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1271 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1272 | 1272 | |
1273 | - if ( isset( $args['placeholder'] ) ) { |
|
1273 | + if (isset($args['placeholder'])) { |
|
1274 | 1274 | $placeholder = $args['placeholder']; |
1275 | 1275 | } else { |
1276 | 1276 | $placeholder = ''; |
@@ -1278,17 +1278,17 @@ discard block |
||
1278 | 1278 | |
1279 | 1279 | $states = wpinv_get_country_states(); |
1280 | 1280 | |
1281 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
1282 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1283 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1281 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
1282 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1283 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
1284 | 1284 | |
1285 | - foreach ( $states as $option => $name ) { |
|
1286 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1287 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1285 | + foreach ($states as $option => $name) { |
|
1286 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
1287 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | $html .= '</select>'; |
1291 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1291 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1292 | 1292 | |
1293 | 1293 | echo $html; |
1294 | 1294 | } |
@@ -1303,25 +1303,25 @@ discard block |
||
1303 | 1303 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
1304 | 1304 | <thead> |
1305 | 1305 | <tr> |
1306 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
1307 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
1308 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
1309 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
1310 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
1311 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
1306 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
1307 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
1308 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
1309 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
1310 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
1311 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
1312 | 1312 | </tr> |
1313 | 1313 | </thead> |
1314 | 1314 | <tbody> |
1315 | - <?php if( !empty( $rates ) ) : ?> |
|
1316 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
1315 | + <?php if (!empty($rates)) : ?> |
|
1316 | + <?php foreach ($rates as $key => $rate) : ?> |
|
1317 | 1317 | <?php |
1318 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
1318 | + $sanitized_key = wpinv_sanitize_key($key); |
|
1319 | 1319 | ?> |
1320 | 1320 | <tr> |
1321 | 1321 | <td class="wpinv_tax_country"> |
1322 | 1322 | <?php |
1323 | - echo wpinv_html_select( array( |
|
1324 | - 'options' => wpinv_get_country_list( true ), |
|
1323 | + echo wpinv_html_select(array( |
|
1324 | + 'options' => wpinv_get_country_list(true), |
|
1325 | 1325 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
1326 | 1326 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1327 | 1327 | 'selected' => $rate['country'], |
@@ -1329,72 +1329,72 @@ discard block |
||
1329 | 1329 | 'show_option_none' => false, |
1330 | 1330 | 'class' => 'wpinv-tax-country', |
1331 | 1331 | 'chosen' => false, |
1332 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1333 | - ) ); |
|
1332 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1333 | + )); |
|
1334 | 1334 | ?> |
1335 | 1335 | </td> |
1336 | 1336 | <td class="wpinv_tax_state"> |
1337 | 1337 | <?php |
1338 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1339 | - if( !empty( $states ) ) { |
|
1340 | - echo wpinv_html_select( array( |
|
1341 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1338 | + $states = wpinv_get_country_states($rate['country']); |
|
1339 | + if (!empty($states)) { |
|
1340 | + echo wpinv_html_select(array( |
|
1341 | + 'options' => array_merge(array('' => ''), $states), |
|
1342 | 1342 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
1343 | 1343 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1344 | 1344 | 'selected' => $rate['state'], |
1345 | 1345 | 'show_option_all' => false, |
1346 | 1346 | 'show_option_none' => false, |
1347 | 1347 | 'chosen' => false, |
1348 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1349 | - ) ); |
|
1348 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
1349 | + )); |
|
1350 | 1350 | } else { |
1351 | - echo wpinv_html_text( array( |
|
1351 | + echo wpinv_html_text(array( |
|
1352 | 1352 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
1353 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1353 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
1354 | 1354 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1355 | - ) ); |
|
1355 | + )); |
|
1356 | 1356 | } |
1357 | 1357 | ?> |
1358 | 1358 | </td> |
1359 | 1359 | <td class="wpinv_tax_global"> |
1360 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
1361 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1360 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
1361 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1362 | 1362 | </td> |
1363 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
1364 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
1365 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1363 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
1364 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
1365 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1366 | 1366 | </tr> |
1367 | 1367 | <?php endforeach; ?> |
1368 | 1368 | <?php else : ?> |
1369 | 1369 | <tr> |
1370 | 1370 | <td class="wpinv_tax_country"> |
1371 | 1371 | <?php |
1372 | - echo wpinv_html_select( array( |
|
1373 | - 'options' => wpinv_get_country_list( true ), |
|
1372 | + echo wpinv_html_select(array( |
|
1373 | + 'options' => wpinv_get_country_list(true), |
|
1374 | 1374 | 'name' => 'tax_rates[0][country]', |
1375 | 1375 | 'show_option_all' => false, |
1376 | 1376 | 'show_option_none' => false, |
1377 | 1377 | 'class' => 'wpinv-tax-country', |
1378 | 1378 | 'chosen' => false, |
1379 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1380 | - ) ); ?> |
|
1379 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1380 | + )); ?> |
|
1381 | 1381 | </td> |
1382 | 1382 | <td class="wpinv_tax_state"> |
1383 | - <?php echo wpinv_html_text( array( |
|
1383 | + <?php echo wpinv_html_text(array( |
|
1384 | 1384 | 'name' => 'tax_rates[0][state]' |
1385 | - ) ); ?> |
|
1385 | + )); ?> |
|
1386 | 1386 | </td> |
1387 | 1387 | <td class="wpinv_tax_global"> |
1388 | 1388 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
1389 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1389 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1390 | 1390 | </td> |
1391 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
1391 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
1392 | 1392 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
1393 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1393 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1394 | 1394 | </tr> |
1395 | 1395 | <?php endif; ?> |
1396 | 1396 | </tbody> |
1397 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
1397 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
1398 | 1398 | </table> |
1399 | 1399 | <?php |
1400 | 1400 | echo ob_get_clean(); |
@@ -1405,44 +1405,44 @@ discard block |
||
1405 | 1405 | ob_start(); ?> |
1406 | 1406 | </td><tr> |
1407 | 1407 | <td colspan="2" class="wpinv_tools_tdbox"> |
1408 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1409 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1408 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1409 | + <?php do_action('wpinv_tools_before'); ?> |
|
1410 | 1410 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1411 | 1411 | <thead> |
1412 | 1412 | <tr> |
1413 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1414 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1415 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1413 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1414 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1415 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1416 | 1416 | </tr> |
1417 | 1417 | </thead> |
1418 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1418 | + <?php do_action('wpinv_tools_row'); ?> |
|
1419 | 1419 | <tbody> |
1420 | 1420 | </tbody> |
1421 | 1421 | </table> |
1422 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1422 | + <?php do_action('wpinv_tools_after'); ?> |
|
1423 | 1423 | <?php |
1424 | 1424 | echo ob_get_clean(); |
1425 | 1425 | } |
1426 | 1426 | |
1427 | -function wpinv_descriptive_text_callback( $args ) { |
|
1428 | - echo wp_kses_post( $args['desc'] ); |
|
1427 | +function wpinv_descriptive_text_callback($args) { |
|
1428 | + echo wp_kses_post($args['desc']); |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | -function wpinv_hook_callback( $args ) { |
|
1432 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1431 | +function wpinv_hook_callback($args) { |
|
1432 | + do_action('wpinv_' . $args['id'], $args); |
|
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | function wpinv_set_settings_cap() { |
1436 | 1436 | return 'manage_options'; |
1437 | 1437 | } |
1438 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1438 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1439 | 1439 | |
1440 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1441 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1442 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1440 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1441 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1442 | + $value = wpinv_sanitize_amount($value, 4); |
|
1443 | 1443 | $value = $value >= 100 ? 99 : $value; |
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | return $value; |
1447 | 1447 | } |
1448 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1449 | 1448 | \ No newline at end of file |
1449 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1450 | 1450 | \ No newline at end of file |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish' ) { |
|
6 | - if ( empty( $user ) ) { |
|
5 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish') { |
|
6 | + if (empty($user)) { |
|
7 | 7 | $user = get_current_user_id(); |
8 | 8 | } |
9 | 9 | |
10 | - if ( 0 === $user ) { |
|
10 | + if (0 === $user) { |
|
11 | 11 | return false; |
12 | 12 | } |
13 | 13 | |
14 | - if ( $pagination ) { |
|
15 | - if ( get_query_var( 'paged' ) ) |
|
14 | + if ($pagination) { |
|
15 | + if (get_query_var('paged')) |
|
16 | 16 | $paged = get_query_var('paged'); |
17 | - else if ( get_query_var( 'page' ) ) |
|
18 | - $paged = get_query_var( 'page' ); |
|
17 | + else if (get_query_var('page')) |
|
18 | + $paged = get_query_var('page'); |
|
19 | 19 | else |
20 | 20 | $paged = 1; |
21 | 21 | } |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | 'post_type' => 'wpi_invoice', |
25 | 25 | 'posts_per_page' => 20, |
26 | 26 | 'paged' => null, |
27 | - 'post_status' => array( 'publish', 'pending' ), |
|
27 | + 'post_status' => array('publish', 'pending'), |
|
28 | 28 | 'user' => $user, |
29 | 29 | 'order' => 'date', |
30 | 30 | ); |
31 | 31 | |
32 | - $invoices = get_posts( $args ); |
|
32 | + $invoices = get_posts($args); |
|
33 | 33 | |
34 | 34 | // No invoices |
35 | - if ( ! $invoices ) |
|
35 | + if (!$invoices) |
|
36 | 36 | return false; |
37 | 37 | |
38 | 38 | return $invoices; |
39 | 39 | } |
40 | 40 | |
41 | -function wpinv_dropdown_users( $args = '' ) { |
|
41 | +function wpinv_dropdown_users($args = '') { |
|
42 | 42 | $defaults = array( |
43 | 43 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
44 | 44 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | 'option_none_value' => -1 |
50 | 50 | ); |
51 | 51 | |
52 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
52 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
53 | 53 | |
54 | - $r = wp_parse_args( $args, $defaults ); |
|
54 | + $r = wp_parse_args($args, $defaults); |
|
55 | 55 | |
56 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
56 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
57 | 57 | |
58 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
58 | + $fields = array('ID', 'user_login', 'user_email'); |
|
59 | 59 | |
60 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
61 | - if ( 'display_name_with_login' === $show ) { |
|
60 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
61 | + if ('display_name_with_login' === $show) { |
|
62 | 62 | $fields[] = 'display_name'; |
63 | - } else if ( 'display_name_with_email' === $show ) { |
|
63 | + } else if ('display_name_with_email' === $show) { |
|
64 | 64 | $fields[] = 'display_name'; |
65 | 65 | } else { |
66 | 66 | $fields[] = $show; |
@@ -72,99 +72,99 @@ discard block |
||
72 | 72 | $show_option_none = $r['show_option_none']; |
73 | 73 | $option_none_value = $r['option_none_value']; |
74 | 74 | |
75 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
75 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
76 | 76 | |
77 | - $users = get_users( $query_args ); |
|
77 | + $users = get_users($query_args); |
|
78 | 78 | |
79 | 79 | $output = ''; |
80 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
81 | - $name = esc_attr( $r['name'] ); |
|
82 | - if ( $r['multi'] && ! $r['id'] ) { |
|
80 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
81 | + $name = esc_attr($r['name']); |
|
82 | + if ($r['multi'] && !$r['id']) { |
|
83 | 83 | $id = ''; |
84 | 84 | } else { |
85 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
85 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
86 | 86 | } |
87 | 87 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
88 | 88 | |
89 | - if ( $show_option_all ) { |
|
89 | + if ($show_option_all) { |
|
90 | 90 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
91 | 91 | } |
92 | 92 | |
93 | - if ( $show_option_none ) { |
|
94 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
95 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
93 | + if ($show_option_none) { |
|
94 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
95 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
98 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
99 | 99 | $found_selected = false; |
100 | - $r['selected'] = (int) $r['selected']; |
|
101 | - foreach ( (array) $users as $user ) { |
|
102 | - $user->ID = (int) $user->ID; |
|
103 | - if ( $user->ID === $r['selected'] ) { |
|
100 | + $r['selected'] = (int)$r['selected']; |
|
101 | + foreach ((array)$users as $user) { |
|
102 | + $user->ID = (int)$user->ID; |
|
103 | + if ($user->ID === $r['selected']) { |
|
104 | 104 | $found_selected = true; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! $found_selected ) { |
|
109 | - $users[] = get_userdata( $r['selected'] ); |
|
108 | + if (!$found_selected) { |
|
109 | + $users[] = get_userdata($r['selected']); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - foreach ( (array) $users as $user ) { |
|
114 | - if ( 'display_name_with_login' === $show ) { |
|
113 | + foreach ((array)$users as $user) { |
|
114 | + if ('display_name_with_login' === $show) { |
|
115 | 115 | /* translators: 1: display name, 2: user_login */ |
116 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
117 | - } elseif ( 'display_name_with_email' === $show ) { |
|
116 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
117 | + } elseif ('display_name_with_email' === $show) { |
|
118 | 118 | /* translators: 1: display name, 2: user_email */ |
119 | - if ( $user->display_name == $user->user_email ) { |
|
119 | + if ($user->display_name == $user->user_email) { |
|
120 | 120 | $display = $user->display_name; |
121 | 121 | } else { |
122 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
122 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
123 | 123 | } |
124 | - } elseif ( ! empty( $user->$show ) ) { |
|
124 | + } elseif (!empty($user->$show)) { |
|
125 | 125 | $display = $user->$show; |
126 | 126 | } else { |
127 | 127 | $display = '(' . $user->user_login . ')'; |
128 | 128 | } |
129 | 129 | |
130 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
131 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
130 | + $_selected = selected($user->ID, $r['selected'], false); |
|
131 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $output .= "</select>"; |
135 | 135 | } |
136 | 136 | |
137 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
137 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
138 | 138 | |
139 | - if ( $r['echo'] ) { |
|
139 | + if ($r['echo']) { |
|
140 | 140 | echo $html; |
141 | 141 | } |
142 | 142 | return $html; |
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
146 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
147 | - wpinv_login_user( $user_id ); |
|
145 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
146 | + if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
147 | + wpinv_login_user($user_id); |
|
148 | 148 | } else { |
149 | - $redirect_to = wp_login_url( $redirect_to ); |
|
149 | + $redirect_to = wp_login_url($redirect_to); |
|
150 | 150 | } |
151 | 151 | |
152 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
152 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
153 | 153 | |
154 | - wp_redirect( $redirect_to ); |
|
154 | + wp_redirect($redirect_to); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_login_user( $user_id ) { |
|
158 | - if ( is_user_logged_in() ) { |
|
157 | +function wpinv_login_user($user_id) { |
|
158 | + if (is_user_logged_in()) { |
|
159 | 159 | return true; |
160 | 160 | } |
161 | 161 | |
162 | - $user = get_user_by( 'id', $user_id ); |
|
162 | + $user = get_user_by('id', $user_id); |
|
163 | 163 | |
164 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
165 | - wp_set_current_user( $user_id, $user->user_login ); |
|
166 | - wp_set_auth_cookie( $user_id ); |
|
167 | - do_action( 'wp_login', $user->user_login ); |
|
164 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
165 | + wp_set_current_user($user_id, $user->user_login); |
|
166 | + wp_set_auth_cookie($user_id); |
|
167 | + do_action('wp_login', $user->user_login); |
|
168 | 168 | |
169 | 169 | return true; |
170 | 170 | } |
@@ -1,6 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish' ) { |
6 | 8 | if ( empty( $user ) ) { |
@@ -12,12 +14,13 @@ discard block |
||
12 | 14 | } |
13 | 15 | |
14 | 16 | if ( $pagination ) { |
15 | - if ( get_query_var( 'paged' ) ) |
|
16 | - $paged = get_query_var('paged'); |
|
17 | - else if ( get_query_var( 'page' ) ) |
|
18 | - $paged = get_query_var( 'page' ); |
|
19 | - else |
|
20 | - $paged = 1; |
|
17 | + if ( get_query_var( 'paged' ) ) { |
|
18 | + $paged = get_query_var('paged'); |
|
19 | + } else if ( get_query_var( 'page' ) ) { |
|
20 | + $paged = get_query_var( 'page' ); |
|
21 | + } else { |
|
22 | + $paged = 1; |
|
23 | + } |
|
21 | 24 | } |
22 | 25 | |
23 | 26 | $args = array( |
@@ -32,8 +35,9 @@ discard block |
||
32 | 35 | $invoices = get_posts( $args ); |
33 | 36 | |
34 | 37 | // No invoices |
35 | - if ( ! $invoices ) |
|
36 | - return false; |
|
38 | + if ( ! $invoices ) { |
|
39 | + return false; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | return $invoices; |
39 | 43 | } |
@@ -7,44 +7,44 @@ 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 | -add_action( 'init', 'wpinv_register_post_types', 1 ); |
|
14 | +add_action('init', 'wpinv_register_post_types', 1); |
|
15 | 15 | function wpinv_register_post_types() { |
16 | 16 | $labels = array( |
17 | - 'name' => _x( 'Invoices', 'post type general name', 'invoicing' ), |
|
18 | - 'singular_name' => _x( 'Invoice', 'post type singular name', 'invoicing' ), |
|
19 | - 'menu_name' => _x( 'Invoices', 'admin menu', 'invoicing' ), |
|
20 | - 'name_admin_bar' => _x( 'Invoice', 'add new on admin bar', 'invoicing' ), |
|
21 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
22 | - 'add_new_item' => __( 'Add New Invoice', 'invoicing' ), |
|
23 | - 'new_item' => __( 'New Invoice', 'invoicing' ), |
|
24 | - 'edit_item' => __( 'Edit Invoice', 'invoicing' ), |
|
25 | - 'view_item' => __( 'View Invoice', 'invoicing' ), |
|
26 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
27 | - 'search_items' => __( 'Search Invoices', 'invoicing' ), |
|
28 | - 'parent_item_colon' => __( 'Parent Invoices:', 'invoicing' ), |
|
29 | - 'not_found' => __( 'No invoices found.', 'invoicing' ), |
|
30 | - 'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' ) |
|
17 | + 'name' => _x('Invoices', 'post type general name', 'invoicing'), |
|
18 | + 'singular_name' => _x('Invoice', 'post type singular name', 'invoicing'), |
|
19 | + 'menu_name' => _x('Invoices', 'admin menu', 'invoicing'), |
|
20 | + 'name_admin_bar' => _x('Invoice', 'add new on admin bar', 'invoicing'), |
|
21 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
22 | + 'add_new_item' => __('Add New Invoice', 'invoicing'), |
|
23 | + 'new_item' => __('New Invoice', 'invoicing'), |
|
24 | + 'edit_item' => __('Edit Invoice', 'invoicing'), |
|
25 | + 'view_item' => __('View Invoice', 'invoicing'), |
|
26 | + 'all_items' => __('Invoices', 'invoicing'), |
|
27 | + 'search_items' => __('Search Invoices', 'invoicing'), |
|
28 | + 'parent_item_colon' => __('Parent Invoices:', 'invoicing'), |
|
29 | + 'not_found' => __('No invoices found.', 'invoicing'), |
|
30 | + 'not_found_in_trash' => __('No invoices found in trash.', 'invoicing') |
|
31 | 31 | ); |
32 | - $labels = apply_filters( 'wpinv_labels', $labels ); |
|
32 | + $labels = apply_filters('wpinv_labels', $labels); |
|
33 | 33 | |
34 | 34 | $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico'; |
35 | - $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon ); |
|
35 | + $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon); |
|
36 | 36 | |
37 | 37 | $cap_type = 'wpi_invoice'; |
38 | 38 | $args = array( |
39 | 39 | 'labels' => $labels, |
40 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
40 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
41 | 41 | 'public' => true, |
42 | 42 | 'can_export' => true, |
43 | 43 | '_builtin' => false, |
44 | 44 | 'publicly_queryable' => true, |
45 | 45 | 'exclude_from_search'=> true, |
46 | 46 | 'show_ui' => true, |
47 | - 'show_in_menu' => current_user_can( 'manage_invoicing' ) ? 'wpinv' : true, |
|
47 | + 'show_in_menu' => current_user_can('manage_invoicing') ? 'wpinv' : true, |
|
48 | 48 | 'query_var' => false, |
49 | 49 | 'rewrite' => true, |
50 | 50 | 'capability_type' => 'wpi_invoice', |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | 'has_archive' => false, |
69 | 69 | 'hierarchical' => false, |
70 | 70 | 'menu_position' => null, |
71 | - 'supports' => array( 'title', 'author' ), |
|
71 | + 'supports' => array('title', 'author'), |
|
72 | 72 | 'menu_icon' => $menu_icon, |
73 | 73 | ); |
74 | 74 | |
75 | - $args = apply_filters( 'wpinv_register_post_type_invoice', $args ); |
|
75 | + $args = apply_filters('wpinv_register_post_type_invoice', $args); |
|
76 | 76 | |
77 | - register_post_type( 'wpi_invoice', $args ); |
|
77 | + register_post_type('wpi_invoice', $args); |
|
78 | 78 | |
79 | 79 | $items_labels = array( |
80 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
81 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
82 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
83 | - 'add_new' => _x( 'Add New', 'wpi_item', 'invoicing' ), |
|
84 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
85 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
86 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
87 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
88 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
89 | - 'search_items' => __( 'Search Items', 'invoicing' ), |
|
80 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
81 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
82 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
83 | + 'add_new' => _x('Add New', 'wpi_item', 'invoicing'), |
|
84 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
85 | + 'new_item' => __('New Item', 'invoicing'), |
|
86 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
87 | + 'view_item' => __('View Item', 'invoicing'), |
|
88 | + 'all_items' => __('Items', 'invoicing'), |
|
89 | + 'search_items' => __('Search Items', 'invoicing'), |
|
90 | 90 | 'parent_item_colon' => '', |
91 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
92 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
91 | + 'not_found' => __('No items found.', 'invoicing'), |
|
92 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
93 | 93 | ); |
94 | - $items_labels = apply_filters( 'wpinv_items_labels', $items_labels ); |
|
94 | + $items_labels = apply_filters('wpinv_items_labels', $items_labels); |
|
95 | 95 | |
96 | 96 | $cap_type = 'wpi_item'; |
97 | 97 | $invoice_item_args = array( |
98 | 98 | 'labels' => $items_labels, |
99 | 99 | 'public' => false, |
100 | 100 | 'show_ui' => true, |
101 | - 'show_in_menu' => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false, |
|
102 | - 'supports' => array( 'title', 'excerpt' ), |
|
101 | + 'show_in_menu' => current_user_can('manage_invoicing') ? 'wpinv' : false, |
|
102 | + 'supports' => array('title', 'excerpt'), |
|
103 | 103 | 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
104 | 104 | 'rewrite' => false, |
105 | 105 | 'query_var' => false, |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | ), |
124 | 124 | 'can_export' => true, |
125 | 125 | ); |
126 | - $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args ); |
|
126 | + $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args); |
|
127 | 127 | |
128 | - register_post_type( 'wpi_item', $invoice_item_args ); |
|
128 | + register_post_type('wpi_item', $invoice_item_args); |
|
129 | 129 | |
130 | 130 | $labels = array( |
131 | - 'name' => _x( 'Discounts', 'post type general name', 'invoicing' ), |
|
132 | - 'singular_name' => _x( 'Discount', 'post type singular name', 'invoicing' ), |
|
133 | - 'menu_name' => _x( 'Discounts', 'admin menu', 'invoicing' ), |
|
134 | - 'name_admin_bar' => _x( 'Discount', 'add new on admin bar', 'invoicing' ), |
|
135 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
136 | - 'add_new_item' => __( 'Add New Discount', 'invoicing' ), |
|
137 | - 'new_item' => __( 'New Discount', 'invoicing' ), |
|
138 | - 'edit_item' => __( 'Edit Discount', 'invoicing' ), |
|
139 | - 'view_item' => __( 'View Discount', 'invoicing' ), |
|
140 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
141 | - 'search_items' => __( 'Search Discounts', 'invoicing' ), |
|
142 | - 'parent_item_colon' => __( 'Parent Discounts:', 'invoicing' ), |
|
143 | - 'not_found' => __( 'No discounts found.', 'invoicing' ), |
|
144 | - 'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' ) |
|
131 | + 'name' => _x('Discounts', 'post type general name', 'invoicing'), |
|
132 | + 'singular_name' => _x('Discount', 'post type singular name', 'invoicing'), |
|
133 | + 'menu_name' => _x('Discounts', 'admin menu', 'invoicing'), |
|
134 | + 'name_admin_bar' => _x('Discount', 'add new on admin bar', 'invoicing'), |
|
135 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
136 | + 'add_new_item' => __('Add New Discount', 'invoicing'), |
|
137 | + 'new_item' => __('New Discount', 'invoicing'), |
|
138 | + 'edit_item' => __('Edit Discount', 'invoicing'), |
|
139 | + 'view_item' => __('View Discount', 'invoicing'), |
|
140 | + 'all_items' => __('Discounts', 'invoicing'), |
|
141 | + 'search_items' => __('Search Discounts', 'invoicing'), |
|
142 | + 'parent_item_colon' => __('Parent Discounts:', 'invoicing'), |
|
143 | + 'not_found' => __('No discounts found.', 'invoicing'), |
|
144 | + 'not_found_in_trash' => __('No discounts found in trash.', 'invoicing') |
|
145 | 145 | ); |
146 | - $labels = apply_filters( 'wpinv_discounts_labels', $labels ); |
|
146 | + $labels = apply_filters('wpinv_discounts_labels', $labels); |
|
147 | 147 | |
148 | 148 | $cap_type = 'wpi_discount'; |
149 | 149 | |
150 | 150 | $args = array( |
151 | 151 | 'labels' => $labels, |
152 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
152 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
153 | 153 | 'public' => false, |
154 | 154 | 'can_export' => true, |
155 | 155 | '_builtin' => false, |
156 | 156 | 'publicly_queryable' => false, |
157 | 157 | 'exclude_from_search'=> true, |
158 | 158 | 'show_ui' => true, |
159 | - 'show_in_menu' => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false, |
|
159 | + 'show_in_menu' => current_user_can('manage_invoicing') ? 'wpinv' : false, |
|
160 | 160 | 'query_var' => false, |
161 | 161 | 'rewrite' => false, |
162 | 162 | 'capability_type' => $cap_type, |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | ), |
180 | 180 | 'has_archive' => false, |
181 | 181 | 'hierarchical' => false, |
182 | - 'supports' => array( 'title', 'excerpt' ), |
|
182 | + 'supports' => array('title', 'excerpt'), |
|
183 | 183 | 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
184 | 184 | 'show_in_nav_menus' => false, |
185 | 185 | 'show_in_admin_bar' => true, |
@@ -187,99 +187,99 @@ discard block |
||
187 | 187 | 'menu_position' => null, |
188 | 188 | ); |
189 | 189 | |
190 | - $args = apply_filters( 'wpinv_register_post_type_discount', $args ); |
|
190 | + $args = apply_filters('wpinv_register_post_type_discount', $args); |
|
191 | 191 | |
192 | - register_post_type( 'wpi_discount', $args ); |
|
192 | + register_post_type('wpi_discount', $args); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | function wpinv_get_default_labels() { |
196 | 196 | $defaults = array( |
197 | - 'singular' => __( 'Invoice', 'invoicing' ), |
|
198 | - 'plural' => __( 'Invoices', 'invoicing' ) |
|
197 | + 'singular' => __('Invoice', 'invoicing'), |
|
198 | + 'plural' => __('Invoices', 'invoicing') |
|
199 | 199 | ); |
200 | 200 | |
201 | - return apply_filters( 'wpinv_default_invoices_name', $defaults ); |
|
201 | + return apply_filters('wpinv_default_invoices_name', $defaults); |
|
202 | 202 | } |
203 | 203 | |
204 | -function wpinv_get_label_singular( $lowercase = false ) { |
|
204 | +function wpinv_get_label_singular($lowercase = false) { |
|
205 | 205 | $defaults = wpinv_get_default_labels(); |
206 | 206 | |
207 | - return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
207 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
208 | 208 | } |
209 | 209 | |
210 | -function wpinv_get_label_plural( $lowercase = false ) { |
|
210 | +function wpinv_get_label_plural($lowercase = false) { |
|
211 | 211 | $defaults = wpinv_get_default_labels(); |
212 | 212 | |
213 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
213 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
214 | 214 | } |
215 | 215 | |
216 | -function wpinv_change_default_title( $title ) { |
|
217 | - if ( !is_admin() ) { |
|
216 | +function wpinv_change_default_title($title) { |
|
217 | + if (!is_admin()) { |
|
218 | 218 | $label = wpinv_get_label_singular(); |
219 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
219 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
220 | 220 | return $title; |
221 | 221 | } |
222 | 222 | |
223 | 223 | $screen = get_current_screen(); |
224 | 224 | |
225 | - if ( 'wpi_invoice' == $screen->post_type ) { |
|
225 | + if ('wpi_invoice' == $screen->post_type) { |
|
226 | 226 | $label = wpinv_get_label_singular(); |
227 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
227 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return $title; |
231 | 231 | } |
232 | -add_filter( 'enter_title_here', 'wpinv_change_default_title' ); |
|
232 | +add_filter('enter_title_here', 'wpinv_change_default_title'); |
|
233 | 233 | |
234 | 234 | function wpinv_register_post_status() { |
235 | - register_post_status( 'wpi-processing', array( |
|
236 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
235 | + register_post_status('wpi-processing', array( |
|
236 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
237 | 237 | 'public' => true, |
238 | 238 | 'exclude_from_search' => true, |
239 | 239 | 'show_in_admin_all_list' => true, |
240 | 240 | 'show_in_admin_status_list' => true, |
241 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
242 | - ) ); |
|
243 | - register_post_status( 'wpi-onhold', array( |
|
244 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
241 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
242 | + )); |
|
243 | + register_post_status('wpi-onhold', array( |
|
244 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
245 | 245 | 'public' => true, |
246 | 246 | 'exclude_from_search' => true, |
247 | 247 | 'show_in_admin_all_list' => true, |
248 | 248 | 'show_in_admin_status_list' => true, |
249 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
250 | - ) ); |
|
251 | - register_post_status( 'wpi-cancelled', array( |
|
252 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
249 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
250 | + )); |
|
251 | + register_post_status('wpi-cancelled', array( |
|
252 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
253 | 253 | 'public' => true, |
254 | 254 | 'exclude_from_search' => true, |
255 | 255 | 'show_in_admin_all_list' => true, |
256 | 256 | 'show_in_admin_status_list' => true, |
257 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ) ); |
|
259 | - register_post_status( 'wpi-refunded', array( |
|
260 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
257 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
258 | + )); |
|
259 | + register_post_status('wpi-refunded', array( |
|
260 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
261 | 261 | 'public' => true, |
262 | 262 | 'exclude_from_search' => true, |
263 | 263 | 'show_in_admin_all_list' => true, |
264 | 264 | 'show_in_admin_status_list' => true, |
265 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
266 | - ) ); |
|
267 | - register_post_status( 'wpi-failed', array( |
|
268 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
265 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
266 | + )); |
|
267 | + register_post_status('wpi-failed', array( |
|
268 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
269 | 269 | 'public' => true, |
270 | 270 | 'exclude_from_search' => true, |
271 | 271 | 'show_in_admin_all_list' => true, |
272 | 272 | 'show_in_admin_status_list' => true, |
273 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
274 | - ) ); |
|
275 | - register_post_status( 'wpi-renewal', array( |
|
276 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
273 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
274 | + )); |
|
275 | + register_post_status('wpi-renewal', array( |
|
276 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
277 | 277 | 'public' => true, |
278 | 278 | 'exclude_from_search' => true, |
279 | 279 | 'show_in_admin_all_list' => true, |
280 | 280 | 'show_in_admin_status_list' => true, |
281 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
282 | - ) ); |
|
281 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
282 | + )); |
|
283 | 283 | } |
284 | -add_action( 'init', 'wpinv_register_post_status', 10 ); |
|
284 | +add_action('init', 'wpinv_register_post_status', 10); |
|
285 | 285 |
@@ -1,72 +1,72 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
8 | 8 | function wpinv_add_options_link() { |
9 | 9 | global $menu; |
10 | 10 | |
11 | - if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) { |
|
11 | + if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | - $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' ); |
|
15 | + $capability = apply_filters('invoicing_capability', 'manage_invoicing'); |
|
16 | 16 | |
17 | - if ( current_user_can( 'manage_options' ) ) { |
|
18 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
17 | + if (current_user_can('manage_options')) { |
|
18 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
19 | 19 | } |
20 | 20 | |
21 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
21 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
22 | 22 | |
23 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
23 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
24 | 24 | |
25 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', 'wpinv_options_page' ); |
|
25 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', 'wpinv_options_page'); |
|
26 | 26 | } |
27 | 27 | |
28 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
28 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
29 | 29 | function wpinv_remove_admin_submenus() { |
30 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
30 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
34 | -function wpinv_discount_columns( $existing_columns ) { |
|
33 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
34 | +function wpinv_discount_columns($existing_columns) { |
|
35 | 35 | $columns = array(); |
36 | 36 | $columns['cb'] = $existing_columns['cb']; |
37 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
38 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
39 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
40 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
41 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
42 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
37 | + $columns['name'] = __('Name', 'invoicing'); |
|
38 | + $columns['code'] = __('Code', 'invoicing'); |
|
39 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
40 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
41 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
42 | + $columns['status'] = __('Status', 'invoicing'); |
|
43 | 43 | |
44 | 44 | return $columns; |
45 | 45 | } |
46 | 46 | |
47 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
48 | -function wpinv_discount_custom_column( $column ) { |
|
47 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
48 | +function wpinv_discount_custom_column($column) { |
|
49 | 49 | global $post; |
50 | 50 | |
51 | 51 | $discount = $post; |
52 | 52 | |
53 | - switch ( $column ) { |
|
53 | + switch ($column) { |
|
54 | 54 | case 'name' : |
55 | - echo get_the_title( $discount->ID ); |
|
55 | + echo get_the_title($discount->ID); |
|
56 | 56 | break; |
57 | 57 | case 'code' : |
58 | - echo wpinv_get_discount_code( $discount->ID ); |
|
58 | + echo wpinv_get_discount_code($discount->ID); |
|
59 | 59 | break; |
60 | 60 | case 'amount' : |
61 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
61 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
62 | 62 | break; |
63 | 63 | case 'usage_limit' : |
64 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
64 | + echo wpinv_get_discount_uses($discount->ID); |
|
65 | 65 | break; |
66 | 66 | case 'usage' : |
67 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
68 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
69 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
67 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
68 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
69 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
70 | 70 | } else { |
71 | 71 | $usage .= ' ∞'; |
72 | 72 | } |
@@ -74,162 +74,162 @@ discard block |
||
74 | 74 | echo $usage; |
75 | 75 | break; |
76 | 76 | case 'expiry_date' : |
77 | - if ( wpinv_get_discount_expiration( $discount->ID ) ) { |
|
78 | - $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) ); |
|
77 | + if (wpinv_get_discount_expiration($discount->ID)) { |
|
78 | + $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID))); |
|
79 | 79 | } else { |
80 | - $expiration = __( 'Never', 'invoicing' ); |
|
80 | + $expiration = __('Never', 'invoicing'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | echo $expiration; |
84 | 84 | break; |
85 | 85 | case 'description' : |
86 | - echo wp_kses_post( $post->post_excerpt ); |
|
86 | + echo wp_kses_post($post->post_excerpt); |
|
87 | 87 | break; |
88 | 88 | case 'status' : |
89 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
89 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
90 | 90 | |
91 | - echo wpinv_discount_status( $status ); |
|
91 | + echo wpinv_discount_status($status); |
|
92 | 92 | break; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
97 | -function wpinv_post_row_actions( $actions, $post ) { |
|
98 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
96 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
97 | +function wpinv_post_row_actions($actions, $post) { |
|
98 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
99 | 99 | |
100 | - if ( $post_type == 'wpi_invoice' ) { |
|
100 | + if ($post_type == 'wpi_invoice') { |
|
101 | 101 | $actions = array(); |
102 | 102 | } |
103 | 103 | |
104 | - if ( $post_type == 'wpi_discount' ) { |
|
105 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
104 | + if ($post_type == 'wpi_discount') { |
|
105 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $actions; |
109 | 109 | } |
110 | 110 | |
111 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
112 | - $row_actions = array(); |
|
113 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
114 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
111 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
112 | + $row_actions = array(); |
|
113 | + $edit_link = get_edit_post_link($discount->ID); |
|
114 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
115 | 115 | |
116 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
117 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
118 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
119 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
116 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
117 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
118 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
119 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
120 | 120 | } |
121 | 121 | |
122 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
123 | - if ( isset( $row_actions['delete'] ) ) { |
|
124 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
122 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
123 | + if (isset($row_actions['delete'])) { |
|
124 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
125 | 125 | } |
126 | 126 | } else { |
127 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
127 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
131 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
132 | 132 | |
133 | 133 | return $row_actions; |
134 | 134 | } |
135 | 135 | |
136 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
137 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
138 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
136 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
137 | +function wpinv_table_primary_column($default, $screen_id) { |
|
138 | + if ('edit-wpi_invoice' === $screen_id) { |
|
139 | 139 | return 'name'; |
140 | 140 | } |
141 | 141 | |
142 | 142 | return $default; |
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
146 | - if ( !$display ) { |
|
145 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
146 | + if (!$display) { |
|
147 | 147 | return array(); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $actions = array( |
151 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
152 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
153 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
151 | + 'activate' => __('Activate', 'invoicing'), |
|
152 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
153 | + 'delete' => __('Delete', 'invoicing'), |
|
154 | 154 | ); |
155 | 155 | $two = ''; |
156 | 156 | $which = 'top'; |
157 | 157 | echo '</div><div class="alignleft actions bulkactions">'; |
158 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
159 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
160 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
158 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
159 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
160 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
161 | 161 | |
162 | - foreach ( $actions as $name => $title ) { |
|
162 | + foreach ($actions as $name => $title) { |
|
163 | 163 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
164 | 164 | |
165 | 165 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
166 | 166 | } |
167 | 167 | echo "</select>"; |
168 | 168 | |
169 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
169 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
170 | 170 | |
171 | 171 | echo '</div><div class="alignleft actions">'; |
172 | 172 | } |
173 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
173 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
174 | 174 | |
175 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
176 | - if ( $post_type == 'wpi_discount' ) { |
|
175 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
176 | + if ($post_type == 'wpi_discount') { |
|
177 | 177 | $disable = true; |
178 | 178 | } |
179 | 179 | |
180 | 180 | return $disable; |
181 | 181 | } |
182 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
182 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
183 | 183 | |
184 | 184 | function wpinv_restrict_manage_posts() { |
185 | 185 | global $typenow; |
186 | 186 | |
187 | - if( 'wpi_discount' == $typenow ) { |
|
187 | + if ('wpi_discount' == $typenow) { |
|
188 | 188 | wpinv_discount_filters(); |
189 | 189 | } |
190 | 190 | } |
191 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
191 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
192 | 192 | |
193 | 193 | function wpinv_discount_filters() { |
194 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
194 | + echo wpinv_discount_bulk_actions(array(), true); |
|
195 | 195 | |
196 | 196 | ?> |
197 | 197 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
198 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
198 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
199 | 199 | <?php |
200 | 200 | $types = wpinv_get_discount_types(); |
201 | 201 | |
202 | - foreach ( $types as $name => $type ) { |
|
203 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
202 | + foreach ($types as $name => $type) { |
|
203 | + echo '<option value="' . esc_attr($name) . '"'; |
|
204 | 204 | |
205 | - if ( isset( $_GET['discount_type'] ) ) |
|
206 | - selected( $name, $_GET['discount_type'] ); |
|
205 | + if (isset($_GET['discount_type'])) |
|
206 | + selected($name, $_GET['discount_type']); |
|
207 | 207 | |
208 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
208 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
209 | 209 | } |
210 | 210 | ?> |
211 | 211 | </select> |
212 | 212 | <?php |
213 | 213 | } |
214 | 214 | |
215 | -function wpinv_request( $vars ) { |
|
215 | +function wpinv_request($vars) { |
|
216 | 216 | global $typenow, $wp_query, $wp_post_statuses; |
217 | 217 | |
218 | - if ( 'wpi_invoice' === $typenow ) { |
|
219 | - if ( !isset( $vars['post_status'] ) ) { |
|
218 | + if ('wpi_invoice' === $typenow) { |
|
219 | + if (!isset($vars['post_status'])) { |
|
220 | 220 | $post_statuses = wpinv_get_invoice_statuses(); |
221 | 221 | |
222 | - foreach ( $post_statuses as $status => $value ) { |
|
223 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
224 | - unset( $post_statuses[ $status ] ); |
|
222 | + foreach ($post_statuses as $status => $value) { |
|
223 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
224 | + unset($post_statuses[$status]); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
228 | + $vars['post_status'] = array_keys($post_statuses); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( isset( $vars['orderby'] ) ) { |
|
232 | - if ( 'amount' == $vars['orderby'] ) { |
|
231 | + if (isset($vars['orderby'])) { |
|
232 | + if ('amount' == $vars['orderby']) { |
|
233 | 233 | $vars = array_merge( |
234 | 234 | $vars, |
235 | 235 | array( |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | 'orderby' => 'meta_value_num' |
238 | 238 | ) |
239 | 239 | ); |
240 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
240 | + } else if ('customer' == $vars['orderby']) { |
|
241 | 241 | $vars = array_merge( |
242 | 242 | $vars, |
243 | 243 | array( |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'orderby' => 'meta_value' |
246 | 246 | ) |
247 | 247 | ); |
248 | - } else if ( 'number' == $vars['orderby'] ) { |
|
248 | + } else if ('number' == $vars['orderby']) { |
|
249 | 249 | $vars = array_merge( |
250 | 250 | $vars, |
251 | 251 | array( |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | ); |
256 | 256 | } |
257 | 257 | } |
258 | - } else if ( 'wpi_item' == $typenow ) { |
|
258 | + } else if ('wpi_item' == $typenow) { |
|
259 | 259 | // Check if 'orderby' is set to "price" |
260 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
260 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
261 | 261 | $vars = array_merge( |
262 | 262 | $vars, |
263 | 263 | array( |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | // Check if "orderby" is set to "vat_rule" |
271 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
271 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
272 | 272 | $vars = array_merge( |
273 | 273 | $vars, |
274 | 274 | array( |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | // Check if "orderby" is set to "vat_class" |
282 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
282 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
283 | 283 | $vars = array_merge( |
284 | 284 | $vars, |
285 | 285 | array( |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // Check if "orderby" is set to "type" |
293 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
293 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
294 | 294 | $vars = array_merge( |
295 | 295 | $vars, |
296 | 296 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | // Check if "orderby" is set to "recurring" |
304 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
304 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
305 | 305 | $vars = array_merge( |
306 | 306 | $vars, |
307 | 307 | array( |
@@ -311,120 +311,120 @@ discard block |
||
311 | 311 | ); |
312 | 312 | } |
313 | 313 | |
314 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
314 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
315 | 315 | // Filter vat rule type |
316 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
316 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
317 | 317 | $meta_query[] = array( |
318 | 318 | 'key' => '_wpinv_vat_rule', |
319 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
319 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
320 | 320 | 'compare' => '=' |
321 | 321 | ); |
322 | 322 | } |
323 | 323 | |
324 | 324 | // Filter vat class |
325 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
325 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
326 | 326 | $meta_query[] = array( |
327 | 327 | 'key' => '_wpinv_vat_class', |
328 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
328 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
329 | 329 | 'compare' => '=' |
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Filter item type |
334 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
334 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
335 | 335 | $meta_query[] = array( |
336 | 336 | 'key' => '_wpinv_type', |
337 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
337 | + 'value' => sanitize_text_field($_GET['type']), |
|
338 | 338 | 'compare' => '=' |
339 | 339 | ); |
340 | 340 | } |
341 | 341 | |
342 | - if ( !empty( $meta_query ) ) { |
|
342 | + if (!empty($meta_query)) { |
|
343 | 343 | $vars['meta_query'] = $meta_query; |
344 | 344 | } |
345 | - } else if ( 'wpi_discount' == $typenow ) { |
|
346 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
345 | + } else if ('wpi_discount' == $typenow) { |
|
346 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
347 | 347 | // Filter vat rule type |
348 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
348 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
349 | 349 | $meta_query[] = array( |
350 | 350 | 'key' => '_wpi_discount_type', |
351 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
351 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
352 | 352 | 'compare' => '=' |
353 | 353 | ); |
354 | 354 | } |
355 | 355 | |
356 | - if ( !empty( $meta_query ) ) { |
|
356 | + if (!empty($meta_query)) { |
|
357 | 357 | $vars['meta_query'] = $meta_query; |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | 361 | return $vars; |
362 | 362 | } |
363 | -add_filter( 'request', 'wpinv_request' ); |
|
363 | +add_filter('request', 'wpinv_request'); |
|
364 | 364 | |
365 | 365 | function wpinv_options_page() { |
366 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
366 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
367 | 367 | |
368 | - if ( $page !== 'wpinv-settings' ) { |
|
368 | + if ($page !== 'wpinv-settings') { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | 372 | $settings_tabs = wpinv_get_settings_tabs(); |
373 | 373 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
374 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
375 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
374 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
375 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
376 | 376 | $key = 'main'; |
377 | 377 | |
378 | - if ( is_array( $sections ) ) { |
|
379 | - $key = key( $sections ); |
|
378 | + if (is_array($sections)) { |
|
379 | + $key = key($sections); |
|
380 | 380 | } |
381 | 381 | |
382 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
383 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
382 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
383 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
384 | 384 | ob_start(); |
385 | 385 | ?> |
386 | 386 | <div class="wrap"> |
387 | 387 | <h1 class="nav-tab-wrapper"> |
388 | 388 | <?php |
389 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
390 | - $tab_url = add_query_arg( array( |
|
389 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
390 | + $tab_url = add_query_arg(array( |
|
391 | 391 | 'settings-updated' => false, |
392 | 392 | 'tab' => $tab_id, |
393 | - ) ); |
|
393 | + )); |
|
394 | 394 | |
395 | 395 | // Remove the section from the tabs so we always end up at the main section |
396 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
397 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
396 | + $tab_url = remove_query_arg('section', $tab_url); |
|
397 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
398 | 398 | |
399 | 399 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
400 | 400 | |
401 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
402 | - echo esc_html( $tab_name ); |
|
401 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
402 | + echo esc_html($tab_name); |
|
403 | 403 | echo '</a>'; |
404 | 404 | } |
405 | 405 | ?> |
406 | 406 | </h1> |
407 | 407 | <?php |
408 | - $number_of_sections = count( $sections ); |
|
408 | + $number_of_sections = count($sections); |
|
409 | 409 | $number = 0; |
410 | - if ( $number_of_sections > 1 ) { |
|
410 | + if ($number_of_sections > 1) { |
|
411 | 411 | echo '<div><ul class="subsubsub">'; |
412 | - foreach( $sections as $section_id => $section_name ) { |
|
412 | + foreach ($sections as $section_id => $section_name) { |
|
413 | 413 | echo '<li>'; |
414 | 414 | $number++; |
415 | - $tab_url = add_query_arg( array( |
|
415 | + $tab_url = add_query_arg(array( |
|
416 | 416 | 'settings-updated' => false, |
417 | 417 | 'tab' => $active_tab, |
418 | 418 | 'section' => $section_id |
419 | - ) ); |
|
420 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
419 | + )); |
|
420 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
421 | 421 | $class = ''; |
422 | - if ( $section == $section_id ) { |
|
422 | + if ($section == $section_id) { |
|
423 | 423 | $class = 'current'; |
424 | 424 | } |
425 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
425 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
426 | 426 | |
427 | - if ( $number != $number_of_sections ) { |
|
427 | + if ($number != $number_of_sections) { |
|
428 | 428 | echo ' | '; |
429 | 429 | } |
430 | 430 | echo '</li>'; |
@@ -436,19 +436,19 @@ discard block |
||
436 | 436 | <form method="post" action="options.php"> |
437 | 437 | <table class="form-table"> |
438 | 438 | <?php |
439 | - settings_fields( 'wpinv_settings' ); |
|
439 | + settings_fields('wpinv_settings'); |
|
440 | 440 | |
441 | - if ( 'main' === $section ) { |
|
442 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
441 | + if ('main' === $section) { |
|
442 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
443 | 443 | } |
444 | 444 | |
445 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section ); |
|
446 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section ); |
|
447 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section ); |
|
445 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section); |
|
446 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section); |
|
447 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section); |
|
448 | 448 | |
449 | 449 | // For backwards compatibility |
450 | - if ( 'main' === $section ) { |
|
451 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
450 | + if ('main' === $section) { |
|
451 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
452 | 452 | } |
453 | 453 | ?> |
454 | 454 | </table> |
@@ -461,53 +461,53 @@ discard block |
||
461 | 461 | echo $content; |
462 | 462 | } |
463 | 463 | |
464 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
464 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
465 | 465 | global $pagenow, $typenow; |
466 | 466 | |
467 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
468 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
469 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
467 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
468 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
469 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
470 | 470 | } |
471 | 471 | |
472 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
472 | + if (!wpinv_item_is_editable($post_id)) { |
|
473 | 473 | $classes[] = 'wpi-editable-n'; |
474 | 474 | } |
475 | 475 | } |
476 | 476 | return $classes; |
477 | 477 | } |
478 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
478 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
479 | 479 | |
480 | 480 | function wpinv_check_quick_edit() { |
481 | 481 | global $pagenow, $current_screen, $wpinv_item_screen; |
482 | 482 | |
483 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
484 | - if ( empty( $wpinv_item_screen ) ) { |
|
485 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
483 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
484 | + if (empty($wpinv_item_screen)) { |
|
485 | + if ($current_screen->post_type == 'wpi_item') { |
|
486 | 486 | $wpinv_item_screen = 'y'; |
487 | 487 | } else { |
488 | 488 | $wpinv_item_screen = 'n'; |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
493 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
494 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
492 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
493 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
494 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
498 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
498 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
499 | 499 | |
500 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
501 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
502 | - unset( $actions['inline hide-if-no-js'] ); |
|
500 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
501 | + if (isset($actions['inline hide-if-no-js'])) { |
|
502 | + unset($actions['inline hide-if-no-js']); |
|
503 | 503 | } |
504 | 504 | |
505 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
506 | - if ( isset( $actions['trash'] ) ) { |
|
507 | - unset( $actions['trash'] ); |
|
505 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
506 | + if (isset($actions['trash'])) { |
|
507 | + unset($actions['trash']); |
|
508 | 508 | } |
509 | - if ( isset( $actions['delete'] ) ) { |
|
510 | - unset( $actions['delete'] ); |
|
509 | + if (isset($actions['delete'])) { |
|
510 | + unset($actions['delete']); |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
@@ -524,19 +524,19 @@ discard block |
||
524 | 524 | * @param int $post_parent (default: 0) Parent for the new page |
525 | 525 | * @return int page ID |
526 | 526 | */ |
527 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
527 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
528 | 528 | global $wpdb; |
529 | 529 | |
530 | - $option_value = wpinv_get_option( $option ); |
|
530 | + $option_value = wpinv_get_option($option); |
|
531 | 531 | |
532 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
533 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
532 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
533 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
534 | 534 | // Valid page is already in place |
535 | 535 | return $page_object->ID; |
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
539 | - if(!empty($post_parent)){ |
|
539 | + if (!empty($post_parent)) { |
|
540 | 540 | $page = get_page_by_path($post_parent); |
541 | 541 | if ($page) { |
542 | 542 | $post_parent = $page->ID; |
@@ -545,40 +545,40 @@ discard block |
||
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - if ( strlen( $page_content ) > 0 ) { |
|
548 | + if (strlen($page_content) > 0) { |
|
549 | 549 | // Search for an existing page with the specified page content (typically a shortcode) |
550 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
550 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
551 | 551 | } else { |
552 | 552 | // Search for an existing page with the specified page slug |
553 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
553 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
554 | 554 | } |
555 | 555 | |
556 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
556 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
557 | 557 | |
558 | - if ( $valid_page_found ) { |
|
559 | - if ( $option ) { |
|
560 | - wpinv_update_option( $option, $valid_page_found ); |
|
558 | + if ($valid_page_found) { |
|
559 | + if ($option) { |
|
560 | + wpinv_update_option($option, $valid_page_found); |
|
561 | 561 | } |
562 | 562 | return $valid_page_found; |
563 | 563 | } |
564 | 564 | |
565 | 565 | // Search for a matching valid trashed page |
566 | - if ( strlen( $page_content ) > 0 ) { |
|
566 | + if (strlen($page_content) > 0) { |
|
567 | 567 | // Search for an existing page with the specified page content (typically a shortcode) |
568 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
568 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
569 | 569 | } else { |
570 | 570 | // Search for an existing page with the specified page slug |
571 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
571 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
572 | 572 | } |
573 | 573 | |
574 | - if ( $trashed_page_found ) { |
|
574 | + if ($trashed_page_found) { |
|
575 | 575 | $page_id = $trashed_page_found; |
576 | 576 | $page_data = array( |
577 | 577 | 'ID' => $page_id, |
578 | 578 | 'post_status' => 'publish', |
579 | 579 | 'post_parent' => $post_parent, |
580 | 580 | ); |
581 | - wp_update_post( $page_data ); |
|
581 | + wp_update_post($page_data); |
|
582 | 582 | } else { |
583 | 583 | $page_data = array( |
584 | 584 | 'post_status' => 'publish', |
@@ -590,11 +590,11 @@ discard block |
||
590 | 590 | 'post_parent' => $post_parent, |
591 | 591 | 'comment_status' => 'closed', |
592 | 592 | ); |
593 | - $page_id = wp_insert_post( $page_data ); |
|
593 | + $page_id = wp_insert_post($page_data); |
|
594 | 594 | } |
595 | 595 | |
596 | - if ( $option ) { |
|
597 | - wpinv_update_option( $option, (int)$page_id ); |
|
596 | + if ($option) { |
|
597 | + wpinv_update_option($option, (int)$page_id); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | return $page_id; |