@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, watermark, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,155 +228,155 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
298 | - $args = array( 'nopaging' => true ); |
|
297 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
298 | + $args = array('nopaging' => true); |
|
299 | 299 | |
300 | - if ( ! empty( $status ) ) |
|
300 | + if (!empty($status)) |
|
301 | 301 | $args['post_status'] = $status; |
302 | 302 | |
303 | - $discounts = wpinv_get_discounts( $args ); |
|
303 | + $discounts = wpinv_get_discounts($args); |
|
304 | 304 | $options = array(); |
305 | 305 | |
306 | - if ( $discounts ) { |
|
307 | - foreach ( $discounts as $discount ) { |
|
308 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
306 | + if ($discounts) { |
|
307 | + foreach ($discounts as $discount) { |
|
308 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
309 | 309 | } |
310 | 310 | } else { |
311 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
311 | + $options[0] = __('No discounts found', 'invoicing'); |
|
312 | 312 | } |
313 | 313 | |
314 | - $output = wpinv_html_select( array( |
|
314 | + $output = wpinv_html_select(array( |
|
315 | 315 | 'name' => $name, |
316 | 316 | 'selected' => $selected, |
317 | 317 | 'options' => $options, |
318 | 318 | 'show_option_all' => false, |
319 | 319 | 'show_option_none' => false, |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | |
322 | 322 | return $output; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
326 | - $current = date( 'Y' ); |
|
327 | - $start_year = $current - absint( $years_before ); |
|
328 | - $end_year = $current + absint( $years_after ); |
|
329 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
325 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
326 | + $current = date('Y'); |
|
327 | + $start_year = $current - absint($years_before); |
|
328 | + $end_year = $current + absint($years_after); |
|
329 | + $selected = empty($selected) ? date('Y') : $selected; |
|
330 | 330 | $options = array(); |
331 | 331 | |
332 | - while ( $start_year <= $end_year ) { |
|
333 | - $options[ absint( $start_year ) ] = $start_year; |
|
332 | + while ($start_year <= $end_year) { |
|
333 | + $options[absint($start_year)] = $start_year; |
|
334 | 334 | $start_year++; |
335 | 335 | } |
336 | 336 | |
337 | - $output = wpinv_html_select( array( |
|
337 | + $output = wpinv_html_select(array( |
|
338 | 338 | 'name' => $name, |
339 | 339 | 'selected' => $selected, |
340 | 340 | 'options' => $options, |
341 | 341 | 'show_option_all' => false, |
342 | 342 | 'show_option_none' => false |
343 | - ) ); |
|
343 | + )); |
|
344 | 344 | |
345 | 345 | return $output; |
346 | 346 | } |
347 | 347 | |
348 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
348 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
349 | 349 | |
350 | 350 | $options = array( |
351 | - '1' => __( 'January', 'invoicing' ), |
|
352 | - '2' => __( 'February', 'invoicing' ), |
|
353 | - '3' => __( 'March', 'invoicing' ), |
|
354 | - '4' => __( 'April', 'invoicing' ), |
|
355 | - '5' => __( 'May', 'invoicing' ), |
|
356 | - '6' => __( 'June', 'invoicing' ), |
|
357 | - '7' => __( 'July', 'invoicing' ), |
|
358 | - '8' => __( 'August', 'invoicing' ), |
|
359 | - '9' => __( 'September', 'invoicing' ), |
|
360 | - '10' => __( 'October', 'invoicing' ), |
|
361 | - '11' => __( 'November', 'invoicing' ), |
|
362 | - '12' => __( 'December', 'invoicing' ), |
|
351 | + '1' => __('January', 'invoicing'), |
|
352 | + '2' => __('February', 'invoicing'), |
|
353 | + '3' => __('March', 'invoicing'), |
|
354 | + '4' => __('April', 'invoicing'), |
|
355 | + '5' => __('May', 'invoicing'), |
|
356 | + '6' => __('June', 'invoicing'), |
|
357 | + '7' => __('July', 'invoicing'), |
|
358 | + '8' => __('August', 'invoicing'), |
|
359 | + '9' => __('September', 'invoicing'), |
|
360 | + '10' => __('October', 'invoicing'), |
|
361 | + '11' => __('November', 'invoicing'), |
|
362 | + '12' => __('December', 'invoicing'), |
|
363 | 363 | ); |
364 | 364 | |
365 | 365 | // If no month is selected, default to the current month |
366 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
366 | + $selected = empty($selected) ? date('n') : $selected; |
|
367 | 367 | |
368 | - $output = wpinv_html_select( array( |
|
368 | + $output = wpinv_html_select(array( |
|
369 | 369 | 'name' => $name, |
370 | 370 | 'selected' => $selected, |
371 | 371 | 'options' => $options, |
372 | 372 | 'show_option_all' => false, |
373 | 373 | 'show_option_none' => false |
374 | - ) ); |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | return $output; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_html_select( $args = array() ) { |
|
379 | +function wpinv_html_select($args = array()) { |
|
380 | 380 | $defaults = array( |
381 | 381 | 'options' => array(), |
382 | 382 | 'name' => null, |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | 'selected' => 0, |
386 | 386 | 'placeholder' => null, |
387 | 387 | 'multiple' => false, |
388 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
389 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
388 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
389 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
390 | 390 | 'data' => array(), |
391 | 391 | 'onchange' => null, |
392 | 392 | 'required' => false, |
@@ -394,74 +394,74 @@ discard block |
||
394 | 394 | 'readonly' => false, |
395 | 395 | ); |
396 | 396 | |
397 | - $args = wp_parse_args( $args, $defaults ); |
|
397 | + $args = wp_parse_args($args, $defaults); |
|
398 | 398 | |
399 | 399 | $data_elements = ''; |
400 | - foreach ( $args['data'] as $key => $value ) { |
|
401 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
400 | + foreach ($args['data'] as $key => $value) { |
|
401 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
402 | 402 | } |
403 | 403 | |
404 | - if( $args['multiple'] ) { |
|
404 | + if ($args['multiple']) { |
|
405 | 405 | $multiple = ' MULTIPLE'; |
406 | 406 | } else { |
407 | 407 | $multiple = ''; |
408 | 408 | } |
409 | 409 | |
410 | - if( $args['placeholder'] ) { |
|
410 | + if ($args['placeholder']) { |
|
411 | 411 | $placeholder = $args['placeholder']; |
412 | 412 | } else { |
413 | 413 | $placeholder = ''; |
414 | 414 | } |
415 | 415 | |
416 | 416 | $options = ''; |
417 | - if( !empty( $args['onchange'] ) ) { |
|
418 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
417 | + if (!empty($args['onchange'])) { |
|
418 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
419 | 419 | } |
420 | 420 | |
421 | - if( !empty( $args['required'] ) ) { |
|
421 | + if (!empty($args['required'])) { |
|
422 | 422 | $options .= ' required="required"'; |
423 | 423 | } |
424 | 424 | |
425 | - if( !empty( $args['disabled'] ) ) { |
|
425 | + if (!empty($args['disabled'])) { |
|
426 | 426 | $options .= ' disabled'; |
427 | 427 | } |
428 | 428 | |
429 | - if( !empty( $args['readonly'] ) ) { |
|
429 | + if (!empty($args['readonly'])) { |
|
430 | 430 | $options .= ' readonly'; |
431 | 431 | } |
432 | 432 | |
433 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
434 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
433 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
434 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
435 | 435 | |
436 | - if ( $args['show_option_all'] ) { |
|
437 | - if( $args['multiple'] ) { |
|
438 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
436 | + if ($args['show_option_all']) { |
|
437 | + if ($args['multiple']) { |
|
438 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
439 | 439 | } else { |
440 | - $selected = selected( $args['selected'], 0, false ); |
|
440 | + $selected = selected($args['selected'], 0, false); |
|
441 | 441 | } |
442 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
442 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
443 | 443 | } |
444 | 444 | |
445 | - if ( !empty( $args['options'] ) ) { |
|
445 | + if (!empty($args['options'])) { |
|
446 | 446 | |
447 | - if ( $args['show_option_none'] ) { |
|
448 | - if( $args['multiple'] ) { |
|
449 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
447 | + if ($args['show_option_none']) { |
|
448 | + if ($args['multiple']) { |
|
449 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
450 | 450 | } else { |
451 | - $selected = selected( $args['selected'] === "", true, false ); |
|
451 | + $selected = selected($args['selected'] === "", true, false); |
|
452 | 452 | } |
453 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
453 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
454 | 454 | } |
455 | 455 | |
456 | - foreach( $args['options'] as $key => $option ) { |
|
456 | + foreach ($args['options'] as $key => $option) { |
|
457 | 457 | |
458 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
459 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
458 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
459 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
460 | 460 | } else { |
461 | - $selected = selected( $args['selected'], $key, false ); |
|
461 | + $selected = selected($args['selected'], $key, false); |
|
462 | 462 | } |
463 | 463 | |
464 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
464 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | return $output; |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_item_dropdown( $args = array() ) { |
|
473 | +function wpinv_item_dropdown($args = array()) { |
|
474 | 474 | $defaults = array( |
475 | 475 | 'name' => 'wpi_item', |
476 | 476 | 'id' => 'wpi_item', |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | 'multiple' => false, |
479 | 479 | 'selected' => 0, |
480 | 480 | 'number' => 100, |
481 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
482 | - 'data' => array( 'search-type' => 'item' ), |
|
481 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
482 | + 'data' => array('search-type' => 'item'), |
|
483 | 483 | 'show_option_all' => false, |
484 | 484 | 'show_option_none' => false, |
485 | 485 | 'show_recurring' => false, |
486 | 486 | ); |
487 | 487 | |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | |
490 | 490 | $item_args = array( |
491 | 491 | 'post_type' => 'wpi_item', |
@@ -494,44 +494,44 @@ discard block |
||
494 | 494 | 'posts_per_page' => $args['number'] |
495 | 495 | ); |
496 | 496 | |
497 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
497 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
498 | 498 | |
499 | - $items = get_posts( $item_args ); |
|
499 | + $items = get_posts($item_args); |
|
500 | 500 | $options = array(); |
501 | - if ( $items ) { |
|
502 | - foreach ( $items as $item ) { |
|
503 | - $title = esc_html( $item->post_title ); |
|
501 | + if ($items) { |
|
502 | + foreach ($items as $item) { |
|
503 | + $title = esc_html($item->post_title); |
|
504 | 504 | |
505 | - if ( !empty( $args['show_recurring'] ) ) { |
|
506 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
505 | + if (!empty($args['show_recurring'])) { |
|
506 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
507 | 507 | } |
508 | 508 | |
509 | - $options[ absint( $item->ID ) ] = $title; |
|
509 | + $options[absint($item->ID)] = $title; |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
513 | 513 | // This ensures that any selected items are included in the drop down |
514 | - if( is_array( $args['selected'] ) ) { |
|
515 | - foreach( $args['selected'] as $item ) { |
|
516 | - if( ! in_array( $item, $options ) ) { |
|
517 | - $title = get_the_title( $item ); |
|
518 | - if ( !empty( $args['show_recurring'] ) ) { |
|
519 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
514 | + if (is_array($args['selected'])) { |
|
515 | + foreach ($args['selected'] as $item) { |
|
516 | + if (!in_array($item, $options)) { |
|
517 | + $title = get_the_title($item); |
|
518 | + if (!empty($args['show_recurring'])) { |
|
519 | + $title .= wpinv_get_item_suffix($item, false); |
|
520 | 520 | } |
521 | 521 | $options[$item] = $title; |
522 | 522 | } |
523 | 523 | } |
524 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
525 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
526 | - $title = get_the_title( $args['selected'] ); |
|
527 | - if ( !empty( $args['show_recurring'] ) ) { |
|
528 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
524 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
525 | + if (!in_array($args['selected'], $options)) { |
|
526 | + $title = get_the_title($args['selected']); |
|
527 | + if (!empty($args['show_recurring'])) { |
|
528 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
529 | 529 | } |
530 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
530 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - $output = wpinv_html_select( array( |
|
534 | + $output = wpinv_html_select(array( |
|
535 | 535 | 'name' => $args['name'], |
536 | 536 | 'selected' => $args['selected'], |
537 | 537 | 'id' => $args['id'], |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | 'show_option_all' => $args['show_option_all'], |
543 | 543 | 'show_option_none' => $args['show_option_none'], |
544 | 544 | 'data' => $args['data'], |
545 | - ) ); |
|
545 | + )); |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
@@ -562,16 +562,16 @@ discard block |
||
562 | 562 | ); |
563 | 563 | |
564 | 564 | $options = array(); |
565 | - if ( $items ) { |
|
566 | - foreach ( $items as $item ) { |
|
567 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
565 | + if ($items) { |
|
566 | + foreach ($items as $item) { |
|
567 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | return $options; |
572 | 572 | } |
573 | 573 | |
574 | -function wpinv_html_checkbox( $args = array() ) { |
|
574 | +function wpinv_html_checkbox($args = array()) { |
|
575 | 575 | $defaults = array( |
576 | 576 | 'name' => null, |
577 | 577 | 'current' => null, |
@@ -582,17 +582,17 @@ discard block |
||
582 | 582 | ) |
583 | 583 | ); |
584 | 584 | |
585 | - $args = wp_parse_args( $args, $defaults ); |
|
585 | + $args = wp_parse_args($args, $defaults); |
|
586 | 586 | |
587 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
587 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
588 | 588 | $options = ''; |
589 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
589 | + if (!empty($args['options']['disabled'])) { |
|
590 | 590 | $options .= ' disabled="disabled"'; |
591 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
591 | + } elseif (!empty($args['options']['readonly'])) { |
|
592 | 592 | $options .= ' readonly'; |
593 | 593 | } |
594 | 594 | |
595 | - $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 ) . ' />'; |
|
595 | + $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) . ' />'; |
|
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
@@ -600,30 +600,30 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Displays a hidden field. |
602 | 602 | */ |
603 | -function getpaid_hidden_field( $name, $value ) { |
|
604 | - $name = sanitize_text_field( $name ); |
|
605 | - $value = esc_attr( $value ); |
|
603 | +function getpaid_hidden_field($name, $value) { |
|
604 | + $name = sanitize_text_field($name); |
|
605 | + $value = esc_attr($value); |
|
606 | 606 | |
607 | 607 | echo "<input type='hidden' name='$name' value='$value' />"; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_text( $args = array() ) { |
|
610 | +function wpinv_html_text($args = array()) { |
|
611 | 611 | // Backwards compatibility |
612 | - if ( func_num_args() > 1 ) { |
|
612 | + if (func_num_args() > 1) { |
|
613 | 613 | $args = func_get_args(); |
614 | 614 | |
615 | 615 | $name = $args[0]; |
616 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
617 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
618 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
616 | + $value = isset($args[1]) ? $args[1] : ''; |
|
617 | + $label = isset($args[2]) ? $args[2] : ''; |
|
618 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $defaults = array( |
622 | 622 | 'id' => '', |
623 | - 'name' => isset( $name ) ? $name : 'text', |
|
624 | - 'value' => isset( $value ) ? $value : null, |
|
625 | - 'label' => isset( $label ) ? $label : null, |
|
626 | - 'desc' => isset( $desc ) ? $desc : null, |
|
623 | + 'name' => isset($name) ? $name : 'text', |
|
624 | + 'value' => isset($value) ? $value : null, |
|
625 | + 'label' => isset($label) ? $label : null, |
|
626 | + 'desc' => isset($desc) ? $desc : null, |
|
627 | 627 | 'placeholder' => '', |
628 | 628 | 'class' => 'regular-text', |
629 | 629 | 'disabled' => false, |
@@ -633,51 +633,51 @@ discard block |
||
633 | 633 | 'data' => false |
634 | 634 | ); |
635 | 635 | |
636 | - $args = wp_parse_args( $args, $defaults ); |
|
636 | + $args = wp_parse_args($args, $defaults); |
|
637 | 637 | |
638 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
638 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
639 | 639 | $options = ''; |
640 | - if( $args['required'] ) { |
|
640 | + if ($args['required']) { |
|
641 | 641 | $options .= ' required="required"'; |
642 | 642 | } |
643 | - if( $args['readonly'] ) { |
|
643 | + if ($args['readonly']) { |
|
644 | 644 | $options .= ' readonly'; |
645 | 645 | } |
646 | - if( $args['readonly'] ) { |
|
646 | + if ($args['readonly']) { |
|
647 | 647 | $options .= ' readonly'; |
648 | 648 | } |
649 | 649 | |
650 | 650 | $data = ''; |
651 | - if ( !empty( $args['data'] ) ) { |
|
652 | - foreach ( $args['data'] as $key => $value ) { |
|
653 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
651 | + if (!empty($args['data'])) { |
|
652 | + foreach ($args['data'] as $key => $value) { |
|
653 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
658 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
659 | - if ( ! empty( $args['desc'] ) ) { |
|
660 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
657 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
658 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
659 | + if (!empty($args['desc'])) { |
|
660 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
661 | 661 | } |
662 | 662 | |
663 | - $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 ) . '/>'; |
|
663 | + $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) . '/>'; |
|
664 | 664 | |
665 | 665 | $output .= '</span>'; |
666 | 666 | |
667 | 667 | return $output; |
668 | 668 | } |
669 | 669 | |
670 | -function wpinv_html_date_field( $args = array() ) { |
|
671 | - if( empty( $args['class'] ) ) { |
|
670 | +function wpinv_html_date_field($args = array()) { |
|
671 | + if (empty($args['class'])) { |
|
672 | 672 | $args['class'] = 'wpiDatepicker'; |
673 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
673 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
674 | 674 | $args['class'] .= ' wpiDatepicker'; |
675 | 675 | } |
676 | 676 | |
677 | - return wpinv_html_text( $args ); |
|
677 | + return wpinv_html_text($args); |
|
678 | 678 | } |
679 | 679 | |
680 | -function wpinv_html_textarea( $args = array() ) { |
|
680 | +function wpinv_html_textarea($args = array()) { |
|
681 | 681 | $defaults = array( |
682 | 682 | 'name' => 'textarea', |
683 | 683 | 'value' => null, |
@@ -688,31 +688,31 @@ discard block |
||
688 | 688 | 'placeholder' => '', |
689 | 689 | ); |
690 | 690 | |
691 | - $args = wp_parse_args( $args, $defaults ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | 692 | |
693 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
693 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
694 | 694 | $disabled = ''; |
695 | - if( $args['disabled'] ) { |
|
695 | + if ($args['disabled']) { |
|
696 | 696 | $disabled = ' disabled="disabled"'; |
697 | 697 | } |
698 | 698 | |
699 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
700 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
701 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
699 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
700 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
701 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
702 | 702 | |
703 | - if ( ! empty( $args['desc'] ) ) { |
|
704 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
703 | + if (!empty($args['desc'])) { |
|
704 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
705 | 705 | } |
706 | 706 | $output .= '</span>'; |
707 | 707 | |
708 | 708 | return $output; |
709 | 709 | } |
710 | 710 | |
711 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
711 | +function wpinv_html_ajax_user_search($args = array()) { |
|
712 | 712 | $defaults = array( |
713 | 713 | 'name' => 'user_id', |
714 | 714 | 'value' => null, |
715 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
715 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
716 | 716 | 'label' => null, |
717 | 717 | 'desc' => null, |
718 | 718 | 'class' => '', |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | 'data' => false |
722 | 722 | ); |
723 | 723 | |
724 | - $args = wp_parse_args( $args, $defaults ); |
|
724 | + $args = wp_parse_args($args, $defaults); |
|
725 | 725 | |
726 | 726 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
727 | 727 | |
728 | 728 | $output = '<span class="wpinv_user_search_wrap">'; |
729 | - $output .= wpinv_html_text( $args ); |
|
730 | - $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>'; |
|
729 | + $output .= wpinv_html_text($args); |
|
730 | + $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>'; |
|
731 | 731 | $output .= '</span>'; |
732 | 732 | |
733 | 733 | return $output; |
@@ -743,20 +743,20 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @param string $template the template that is currently being used. |
745 | 745 | */ |
746 | -function wpinv_template( $template ) { |
|
746 | +function wpinv_template($template) { |
|
747 | 747 | global $post; |
748 | 748 | |
749 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
749 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
750 | 750 | |
751 | 751 | // If the user can view this invoice, display it. |
752 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
752 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
753 | 753 | |
754 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
754 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
755 | 755 | |
756 | 756 | // Else display an error message. |
757 | 757 | } else { |
758 | 758 | |
759 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
759 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
@@ -764,46 +764,46 @@ discard block |
||
764 | 764 | |
765 | 765 | return $template; |
766 | 766 | } |
767 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
767 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
768 | 768 | |
769 | 769 | function wpinv_get_business_address() { |
770 | 770 | $business_address = wpinv_store_address(); |
771 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
771 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
772 | 772 | |
773 | 773 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
774 | 774 | |
775 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
775 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Displays the company address. |
780 | 780 | */ |
781 | 781 | function wpinv_display_from_address() { |
782 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
782 | + wpinv_get_template('invoice/company-address.php'); |
|
783 | 783 | } |
784 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
784 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
785 | 785 | |
786 | -function wpinv_watermark( $id = 0 ) { |
|
787 | - $output = wpinv_get_watermark( $id ); |
|
788 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
786 | +function wpinv_watermark($id = 0) { |
|
787 | + $output = wpinv_get_watermark($id); |
|
788 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
789 | 789 | } |
790 | 790 | |
791 | -function wpinv_get_watermark( $id ) { |
|
792 | - if ( !$id > 0 ) { |
|
791 | +function wpinv_get_watermark($id) { |
|
792 | + if (!$id > 0) { |
|
793 | 793 | return NULL; |
794 | 794 | } |
795 | 795 | |
796 | - $invoice = wpinv_get_invoice( $id ); |
|
796 | + $invoice = wpinv_get_invoice($id); |
|
797 | 797 | |
798 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
799 | - if ( $invoice->is_paid() ) { |
|
800 | - return __( 'Paid', 'invoicing' ); |
|
798 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
799 | + if ($invoice->is_paid()) { |
|
800 | + return __('Paid', 'invoicing'); |
|
801 | 801 | } |
802 | - if ( $invoice->is_refunded() ) { |
|
803 | - return __( 'Refunded', 'invoicing' ); |
|
802 | + if ($invoice->is_refunded()) { |
|
803 | + return __('Refunded', 'invoicing'); |
|
804 | 804 | } |
805 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
806 | - return __( 'Cancelled', 'invoicing' ); |
|
805 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
806 | + return __('Cancelled', 'invoicing'); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | |
@@ -813,140 +813,140 @@ discard block |
||
813 | 813 | /** |
814 | 814 | * @deprecated |
815 | 815 | */ |
816 | -function wpinv_display_invoice_details( $invoice ) { |
|
817 | - return getpaid_invoice_meta( $invoice ); |
|
816 | +function wpinv_display_invoice_details($invoice) { |
|
817 | + return getpaid_invoice_meta($invoice); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
821 | 821 | * Displays invoice meta. |
822 | 822 | */ |
823 | -function getpaid_invoice_meta( $invoice ) { |
|
823 | +function getpaid_invoice_meta($invoice) { |
|
824 | 824 | |
825 | - $invoice = new WPInv_Invoice( $invoice ); |
|
825 | + $invoice = new WPInv_Invoice($invoice); |
|
826 | 826 | |
827 | 827 | // Ensure that we have an invoice. |
828 | - if ( 0 == $invoice->get_id() ) { |
|
828 | + if (0 == $invoice->get_id()) { |
|
829 | 829 | return; |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Load the invoice meta. |
833 | - $meta = array( |
|
833 | + $meta = array( |
|
834 | 834 | |
835 | 835 | 'number' => array( |
836 | 836 | 'label' => sprintf( |
837 | - __( '%s Number', 'invoicing' ), |
|
838 | - ucfirst( $invoice->get_type() ) |
|
837 | + __('%s Number', 'invoicing'), |
|
838 | + ucfirst($invoice->get_type()) |
|
839 | 839 | ), |
840 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
840 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
841 | 841 | ), |
842 | 842 | |
843 | 843 | 'status' => array( |
844 | 844 | 'label' => sprintf( |
845 | - __( '%s Status', 'invoicing' ), |
|
846 | - ucfirst( $invoice->get_type() ) |
|
845 | + __('%s Status', 'invoicing'), |
|
846 | + ucfirst($invoice->get_type()) |
|
847 | 847 | ), |
848 | 848 | 'value' => $invoice->get_status_label_html(), |
849 | 849 | ), |
850 | 850 | |
851 | 851 | 'date' => array( |
852 | 852 | 'label' => sprintf( |
853 | - __( '%s Date', 'invoicing' ), |
|
854 | - ucfirst( $invoice->get_type() ) |
|
853 | + __('%s Date', 'invoicing'), |
|
854 | + ucfirst($invoice->get_type()) |
|
855 | 855 | ), |
856 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
856 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
857 | 857 | ), |
858 | 858 | |
859 | 859 | 'date_paid' => array( |
860 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
861 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
860 | + 'label' => __('Paid On', 'invoicing'), |
|
861 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
862 | 862 | ), |
863 | 863 | |
864 | 864 | 'gateway' => array( |
865 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
866 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
865 | + 'label' => __('Payment Method', 'invoicing'), |
|
866 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
867 | 867 | ), |
868 | 868 | |
869 | 869 | 'transaction_id' => array( |
870 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
871 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
870 | + 'label' => __('Transaction ID', 'invoicing'), |
|
871 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
872 | 872 | ), |
873 | 873 | |
874 | 874 | 'due_date' => array( |
875 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
876 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
875 | + 'label' => __('Due Date', 'invoicing'), |
|
876 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
877 | 877 | ), |
878 | 878 | |
879 | 879 | 'vat_number' => array( |
880 | 880 | 'label' => sprintf( |
881 | - __( '%s Number', 'invoicing' ), |
|
881 | + __('%s Number', 'invoicing'), |
|
882 | 882 | getpaid_tax()->get_vat_name() |
883 | 883 | ), |
884 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
884 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
885 | 885 | ), |
886 | 886 | |
887 | 887 | ); |
888 | 888 | |
889 | 889 | // If it is not paid, remove the date of payment. |
890 | - if ( ! $invoice->is_paid() ) { |
|
891 | - unset( $meta[ 'date_paid' ] ); |
|
892 | - unset( $meta[ 'transaction_id' ] ); |
|
890 | + if (!$invoice->is_paid()) { |
|
891 | + unset($meta['date_paid']); |
|
892 | + unset($meta['transaction_id']); |
|
893 | 893 | } |
894 | 894 | |
895 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
896 | - unset( $meta[ 'gateway' ] ); |
|
895 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
896 | + unset($meta['gateway']); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | // Only display the due date if due dates are enabled. |
900 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
901 | - unset( $meta[ 'due_date' ] ); |
|
900 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
901 | + unset($meta['due_date']); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | // Only display the vat number if taxes are enabled. |
905 | - if ( ! wpinv_use_taxes() ) { |
|
906 | - unset( $meta[ 'vat_number' ] ); |
|
905 | + if (!wpinv_use_taxes()) { |
|
906 | + unset($meta['vat_number']); |
|
907 | 907 | } |
908 | 908 | |
909 | - if ( $invoice->is_recurring() ) { |
|
909 | + if ($invoice->is_recurring()) { |
|
910 | 910 | |
911 | 911 | // Link to the parent invoice. |
912 | - if ( $invoice->is_renewal() ) { |
|
912 | + if ($invoice->is_renewal()) { |
|
913 | 913 | |
914 | - $meta[ 'parent' ] = array( |
|
914 | + $meta['parent'] = array( |
|
915 | 915 | |
916 | 916 | 'label' => sprintf( |
917 | - __( 'Parent %s', 'invoicing' ), |
|
918 | - ucfirst( $invoice->get_type() ) |
|
917 | + __('Parent %s', 'invoicing'), |
|
918 | + ucfirst($invoice->get_type()) |
|
919 | 919 | ), |
920 | 920 | |
921 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
921 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
922 | 922 | |
923 | 923 | ); |
924 | 924 | |
925 | 925 | } |
926 | 926 | |
927 | - $subscription = wpinv_get_subscription( $invoice ); |
|
927 | + $subscription = wpinv_get_subscription($invoice); |
|
928 | 928 | |
929 | - if ( ! empty ( $subscription ) ) { |
|
929 | + if (!empty ($subscription)) { |
|
930 | 930 | |
931 | 931 | // Display the renewal date. |
932 | - if ( $subscription->is_active() && 'cancelled' != $subscription->status ) { |
|
932 | + if ($subscription->is_active() && 'cancelled' != $subscription->status) { |
|
933 | 933 | |
934 | - $meta[ 'renewal_date' ] = array( |
|
934 | + $meta['renewal_date'] = array( |
|
935 | 935 | |
936 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
937 | - 'value' => getpaid_format_date( $subscription->expiration ), |
|
936 | + 'label' => __('Renews On', 'invoicing'), |
|
937 | + 'value' => getpaid_format_date($subscription->expiration), |
|
938 | 938 | |
939 | 939 | ); |
940 | 940 | |
941 | 941 | } |
942 | 942 | |
943 | - if ( $invoice->is_parent() ) { |
|
943 | + if ($invoice->is_parent()) { |
|
944 | 944 | |
945 | 945 | // Display the recurring amount. |
946 | - $meta[ 'recurring_total' ] = array( |
|
946 | + $meta['recurring_total'] = array( |
|
947 | 947 | |
948 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
949 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ), |
|
948 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
949 | + 'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()), |
|
950 | 950 | |
951 | 951 | ); |
952 | 952 | |
@@ -956,20 +956,20 @@ discard block |
||
956 | 956 | } |
957 | 957 | |
958 | 958 | // Add the invoice total to the meta. |
959 | - $meta[ 'invoice_total' ] = array( |
|
959 | + $meta['invoice_total'] = array( |
|
960 | 960 | |
961 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
962 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
961 | + 'label' => __('Total Amount', 'invoicing'), |
|
962 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
963 | 963 | |
964 | 964 | ); |
965 | 965 | |
966 | 966 | // Provide a way for third party plugins to filter the meta. |
967 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
967 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
968 | 968 | |
969 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
969 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
970 | 970 | |
971 | 971 | } |
972 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
972 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
973 | 973 | |
974 | 974 | /** |
975 | 975 | * Retrieves the address markup to use on Invoices. |
@@ -981,29 +981,29 @@ discard block |
||
981 | 981 | * @param string $separator How to separate address lines. |
982 | 982 | * @return string |
983 | 983 | */ |
984 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
984 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
985 | 985 | |
986 | 986 | // Retrieve the address markup... |
987 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
988 | - $format = wpinv_get_full_address_format( $country ); |
|
987 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
988 | + $format = wpinv_get_full_address_format($country); |
|
989 | 989 | |
990 | 990 | // ... and the replacements. |
991 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
991 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
992 | 992 | |
993 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
993 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
994 | 994 | |
995 | 995 | // Remove unavailable tags. |
996 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
996 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
997 | 997 | |
998 | 998 | // Clean up white space. |
999 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1000 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
999 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
1000 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
1001 | 1001 | |
1002 | 1002 | // Break newlines apart and remove empty lines/trim commas and white space. |
1003 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1003 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
1004 | 1004 | |
1005 | 1005 | // Add html breaks. |
1006 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1006 | + $formatted_address = implode($separator, $formatted_address); |
|
1007 | 1007 | |
1008 | 1008 | // We're done! |
1009 | 1009 | return $formatted_address; |
@@ -1015,88 +1015,88 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @param WPInv_Invoice $invoice |
1017 | 1017 | */ |
1018 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
1019 | - if ( ! empty( $invoice ) ) { |
|
1020 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
1018 | +function wpinv_display_to_address($invoice = 0) { |
|
1019 | + if (!empty($invoice)) { |
|
1020 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
1023 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
1024 | 1024 | |
1025 | 1025 | |
1026 | 1026 | /** |
1027 | 1027 | * Displays invoice line items. |
1028 | 1028 | */ |
1029 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
1029 | +function wpinv_display_line_items($invoice_id = 0) { |
|
1030 | 1030 | |
1031 | 1031 | // Prepare the invoice. |
1032 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1032 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1033 | 1033 | |
1034 | 1034 | // Abort if there is no invoice. |
1035 | - if ( 0 == $invoice->get_id() ) { |
|
1035 | + if (0 == $invoice->get_id()) { |
|
1036 | 1036 | return; |
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | // Line item columns. |
1040 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
1041 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
1040 | + $columns = getpaid_invoice_item_columns($invoice); |
|
1041 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
1042 | 1042 | |
1043 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
1043 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
1044 | 1044 | } |
1045 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
1045 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
1046 | 1046 | |
1047 | 1047 | /** |
1048 | 1048 | * Displays invoice notices on invoices. |
1049 | 1049 | */ |
1050 | 1050 | function wpinv_display_invoice_notice() { |
1051 | 1051 | |
1052 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
1053 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
1052 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
1053 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
1054 | 1054 | |
1055 | - if ( empty( $label ) && empty( $notice ) ) { |
|
1055 | + if (empty($label) && empty($notice)) { |
|
1056 | 1056 | return; |
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
1060 | 1060 | |
1061 | - if ( ! empty( $label ) ) { |
|
1062 | - $label = sanitize_text_field( $label ); |
|
1061 | + if (!empty($label)) { |
|
1062 | + $label = sanitize_text_field($label); |
|
1063 | 1063 | echo "<h5>$label</h5>"; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - if ( ! empty( $notice ) ) { |
|
1067 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
1066 | + if (!empty($notice)) { |
|
1067 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | echo '</div>'; |
1071 | 1071 | } |
1072 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
1072 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
1073 | 1073 | |
1074 | 1074 | /** |
1075 | 1075 | * @param WPInv_Invoice $invoice |
1076 | 1076 | */ |
1077 | -function wpinv_display_invoice_notes( $invoice ) { |
|
1077 | +function wpinv_display_invoice_notes($invoice) { |
|
1078 | 1078 | |
1079 | 1079 | // Retrieve the notes. |
1080 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
1080 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
1081 | 1081 | |
1082 | 1082 | // Abort if we have non. |
1083 | - if ( empty( $notes ) ) { |
|
1083 | + if (empty($notes)) { |
|
1084 | 1084 | return; |
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | // Echo the note. |
1088 | 1088 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
1089 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
1089 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
1090 | 1090 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
1091 | 1091 | |
1092 | - foreach( $notes as $note ) { |
|
1093 | - wpinv_get_invoice_note_line_item( $note ); |
|
1092 | + foreach ($notes as $note) { |
|
1093 | + wpinv_get_invoice_note_line_item($note); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | echo '</ul>'; |
1097 | 1097 | echo '</div>'; |
1098 | 1098 | } |
1099 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
1099 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
1100 | 1100 | |
1101 | 1101 | /** |
1102 | 1102 | * Loads scripts on our invoice templates. |
@@ -1104,32 +1104,32 @@ discard block |
||
1104 | 1104 | function wpinv_display_style() { |
1105 | 1105 | |
1106 | 1106 | // Make sure that all scripts have been loaded. |
1107 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
1108 | - do_action( 'wp_enqueue_scripts' ); |
|
1107 | + if (!did_action('wp_enqueue_scripts')) { |
|
1108 | + do_action('wp_enqueue_scripts'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // Register the invoices style. |
1112 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
1112 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
1113 | 1113 | |
1114 | 1114 | // Load required styles |
1115 | - wp_print_styles( 'open-sans' ); |
|
1116 | - wp_print_styles( 'wpinv-single-style' ); |
|
1117 | - wp_print_styles( 'ayecode-ui' ); |
|
1115 | + wp_print_styles('open-sans'); |
|
1116 | + wp_print_styles('wpinv-single-style'); |
|
1117 | + wp_print_styles('ayecode-ui'); |
|
1118 | 1118 | |
1119 | 1119 | // Maybe load custom css. |
1120 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
1120 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
1121 | 1121 | |
1122 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
1123 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1124 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1122 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1123 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1124 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1125 | 1125 | echo '<style type="text/css">'; |
1126 | 1126 | echo $custom_css; |
1127 | 1127 | echo '</style>'; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | } |
1131 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1132 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1131 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1132 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1133 | 1133 | |
1134 | 1134 | |
1135 | 1135 | /** |
@@ -1141,41 +1141,41 @@ discard block |
||
1141 | 1141 | // Retrieve the current invoice. |
1142 | 1142 | $invoice_id = getpaid_get_current_invoice_id(); |
1143 | 1143 | |
1144 | - if ( empty( $invoice_id ) ) { |
|
1144 | + if (empty($invoice_id)) { |
|
1145 | 1145 | |
1146 | 1146 | return aui()->alert( |
1147 | 1147 | array( |
1148 | 1148 | 'type' => 'warning', |
1149 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1149 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1150 | 1150 | ) |
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | // Can the user view this invoice? |
1156 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1156 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1157 | 1157 | |
1158 | 1158 | return aui()->alert( |
1159 | 1159 | array( |
1160 | 1160 | 'type' => 'warning', |
1161 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1161 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1162 | 1162 | ) |
1163 | 1163 | ); |
1164 | 1164 | |
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | // Ensure that it is not yet paid for. |
1168 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1168 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1169 | 1169 | |
1170 | 1170 | // Maybe mark it as viewed. |
1171 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1171 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1172 | 1172 | |
1173 | - if ( $invoice->is_paid() ) { |
|
1173 | + if ($invoice->is_paid()) { |
|
1174 | 1174 | |
1175 | 1175 | return aui()->alert( |
1176 | 1176 | array( |
1177 | 1177 | 'type' => 'success', |
1178 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1178 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1179 | 1179 | ) |
1180 | 1180 | ); |
1181 | 1181 | |
@@ -1185,14 +1185,14 @@ discard block |
||
1185 | 1185 | $wpi_checkout_id = $invoice_id; |
1186 | 1186 | |
1187 | 1187 | // We'll display this invoice via the default form. |
1188 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1188 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1189 | 1189 | |
1190 | - if ( 0 == $form->get_id() ) { |
|
1190 | + if (0 == $form->get_id()) { |
|
1191 | 1191 | |
1192 | 1192 | return aui()->alert( |
1193 | 1193 | array( |
1194 | 1194 | 'type' => 'warning', |
1195 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1195 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1196 | 1196 | ) |
1197 | 1197 | ); |
1198 | 1198 | |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | // Set the invoice. |
1202 | 1202 | $form->invoice = $invoice; |
1203 | - $form->set_items( $invoice->get_items() ); |
|
1203 | + $form->set_items($invoice->get_items()); |
|
1204 | 1204 | |
1205 | 1205 | // Generate the html. |
1206 | 1206 | return $form->get_html(); |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_empty_cart_message() { |
1211 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1211 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1225,38 +1225,38 @@ discard block |
||
1225 | 1225 | ) |
1226 | 1226 | ); |
1227 | 1227 | } |
1228 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1228 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1229 | 1229 | |
1230 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1231 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1230 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1231 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1232 | 1232 | |
1233 | - if ( empty( $invoice ) ) { |
|
1233 | + if (empty($invoice)) { |
|
1234 | 1234 | return NULL; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | $billing_details = $invoice->get_user_info(); |
1238 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
1238 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
1239 | 1239 | |
1240 | 1240 | ob_start(); |
1241 | 1241 | ?> |
1242 | 1242 | <table class="table table-bordered table-sm wpi-billing-details"> |
1243 | 1243 | <tbody> |
1244 | 1244 | <tr class="wpi-receipt-name"> |
1245 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1246 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1245 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1246 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1247 | 1247 | </tr> |
1248 | 1248 | <tr class="wpi-receipt-email"> |
1249 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1250 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1249 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1250 | + <td><?php echo $billing_details['email']; ?></td> |
|
1251 | 1251 | </tr> |
1252 | 1252 | <tr class="wpi-receipt-address"> |
1253 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1254 | - <td><?php echo $address_row ;?></td> |
|
1253 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1254 | + <td><?php echo $address_row; ?></td> |
|
1255 | 1255 | </tr> |
1256 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1256 | + <?php if ($billing_details['phone']) { ?> |
|
1257 | 1257 | <tr class="wpi-receipt-phone"> |
1258 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1259 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1258 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1259 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1260 | 1260 | </tr> |
1261 | 1261 | <?php } ?> |
1262 | 1262 | </tbody> |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | <?php |
1265 | 1265 | $output = ob_get_clean(); |
1266 | 1266 | |
1267 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1267 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1268 | 1268 | |
1269 | 1269 | echo $output; |
1270 | 1270 | } |
@@ -1272,88 +1272,88 @@ discard block |
||
1272 | 1272 | /** |
1273 | 1273 | * Filters the receipt page. |
1274 | 1274 | */ |
1275 | -function wpinv_filter_success_page_content( $content ) { |
|
1275 | +function wpinv_filter_success_page_content($content) { |
|
1276 | 1276 | |
1277 | 1277 | // Ensure this is our page. |
1278 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1278 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1279 | 1279 | |
1280 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1281 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1280 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1281 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1282 | 1282 | |
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | return $content; |
1286 | 1286 | } |
1287 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1287 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1288 | 1288 | |
1289 | -function wpinv_invoice_link( $invoice_id ) { |
|
1290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1289 | +function wpinv_invoice_link($invoice_id) { |
|
1290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1291 | 1291 | |
1292 | - if ( empty( $invoice ) ) { |
|
1292 | + if (empty($invoice)) { |
|
1293 | 1293 | return NULL; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1296 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1297 | 1297 | |
1298 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1298 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
1302 | - if ( empty( $invoice ) ) { |
|
1301 | +function wpinv_cart_total_label($label, $invoice) { |
|
1302 | + if (empty($invoice)) { |
|
1303 | 1303 | return $label; |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | $prefix_label = ''; |
1307 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
1308 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
1309 | - } else if ( $invoice->is_renewal() ) { |
|
1310 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
1307 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
1308 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
1309 | + } else if ($invoice->is_renewal()) { |
|
1310 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | - if ( $prefix_label != '' ) { |
|
1314 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1313 | + if ($prefix_label != '') { |
|
1314 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | return $label; |
1318 | 1318 | } |
1319 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1320 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1321 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
1319 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1320 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1321 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
1322 | 1322 | |
1323 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1324 | - if ( empty( $note ) ) { |
|
1323 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1324 | + if (empty($note)) { |
|
1325 | 1325 | return NULL; |
1326 | 1326 | } |
1327 | 1327 | |
1328 | - if ( is_int( $note ) ) { |
|
1329 | - $note = get_comment( $note ); |
|
1328 | + if (is_int($note)) { |
|
1329 | + $note = get_comment($note); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1332 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1333 | 1333 | return NULL; |
1334 | 1334 | } |
1335 | 1335 | |
1336 | - $note_classes = array( 'note' ); |
|
1337 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1336 | + $note_classes = array('note'); |
|
1337 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1338 | 1338 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1339 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1340 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1339 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1340 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1341 | 1341 | |
1342 | 1342 | ob_start(); |
1343 | 1343 | ?> |
1344 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
1344 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
1345 | 1345 | <div class="note_content bg-light border position-relative p-4"> |
1346 | 1346 | |
1347 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
1347 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
1348 | 1348 | |
1349 | - <?php if ( ! is_admin() ) : ?> |
|
1349 | + <?php if (!is_admin()) : ?> |
|
1350 | 1350 | <em class="meta position-absolute form-text"> |
1351 | 1351 | <?php |
1352 | 1352 | printf( |
1353 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1353 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1354 | 1354 | $note->comment_author, |
1355 | - getpaid_format_date_value( $note->comment_date ), |
|
1356 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1355 | + getpaid_format_date_value($note->comment_date), |
|
1356 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1357 | 1357 | ); |
1358 | 1358 | ?> |
1359 | 1359 | </em> |
@@ -1361,21 +1361,21 @@ discard block |
||
1361 | 1361 | |
1362 | 1362 | </div> |
1363 | 1363 | |
1364 | - <?php if ( is_admin() ) : ?> |
|
1364 | + <?php if (is_admin()) : ?> |
|
1365 | 1365 | |
1366 | 1366 | <p class="meta px-4 py-2"> |
1367 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1367 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1368 | 1368 | <?php |
1369 | 1369 | printf( |
1370 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1370 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1371 | 1371 | $note->comment_author, |
1372 | - getpaid_format_date_value( $note->comment_date ), |
|
1373 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1372 | + getpaid_format_date_value($note->comment_date), |
|
1373 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1374 | 1374 | ); |
1375 | 1375 | ?> |
1376 | 1376 | </abbr> |
1377 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1378 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1377 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1378 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1379 | 1379 | <?php } ?> |
1380 | 1380 | </p> |
1381 | 1381 | |
@@ -1384,9 +1384,9 @@ discard block |
||
1384 | 1384 | </li> |
1385 | 1385 | <?php |
1386 | 1386 | $note_content = ob_get_clean(); |
1387 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1387 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1388 | 1388 | |
1389 | - if ( $echo ) { |
|
1389 | + if ($echo) { |
|
1390 | 1390 | echo $note_content; |
1391 | 1391 | } else { |
1392 | 1392 | return $note_content; |
@@ -1396,36 +1396,36 @@ discard block |
||
1396 | 1396 | function wpinv_invalid_invoice_content() { |
1397 | 1397 | global $post; |
1398 | 1398 | |
1399 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
1399 | + $invoice = wpinv_get_invoice($post->ID); |
|
1400 | 1400 | |
1401 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
1402 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
1403 | - if ( is_user_logged_in() ) { |
|
1404 | - if ( wpinv_require_login_to_checkout() ) { |
|
1405 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1406 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
1401 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
1402 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
1403 | + if (is_user_logged_in()) { |
|
1404 | + if (wpinv_require_login_to_checkout()) { |
|
1405 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1406 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | } else { |
1410 | - if ( wpinv_require_login_to_checkout() ) { |
|
1411 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1412 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
1410 | + if (wpinv_require_login_to_checkout()) { |
|
1411 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1412 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
1413 | 1413 | } |
1414 | 1414 | } |
1415 | 1415 | } |
1416 | 1416 | } else { |
1417 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
1417 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
1418 | 1418 | } |
1419 | 1419 | ?> |
1420 | 1420 | <div class="row wpinv-row-invalid"> |
1421 | 1421 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
1422 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
1422 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
1423 | 1423 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
1424 | 1424 | </div> |
1425 | 1425 | </div> |
1426 | 1426 | <?php |
1427 | 1427 | } |
1428 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
1428 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
1429 | 1429 | |
1430 | 1430 | /** |
1431 | 1431 | * Function to get privacy policy text. |
@@ -1434,21 +1434,21 @@ discard block |
||
1434 | 1434 | * @return string |
1435 | 1435 | */ |
1436 | 1436 | function wpinv_get_policy_text() { |
1437 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1437 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1438 | 1438 | |
1439 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1439 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1440 | 1440 | |
1441 | - if(!$privacy_page_id){ |
|
1442 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1441 | + if (!$privacy_page_id) { |
|
1442 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1445 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1446 | 1446 | |
1447 | 1447 | $find_replace = array( |
1448 | 1448 | '[wpinv_privacy_policy]' => $privacy_link, |
1449 | 1449 | ); |
1450 | 1450 | |
1451 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1451 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1452 | 1452 | |
1453 | 1453 | return wp_kses_post(wpautop($privacy_text)); |
1454 | 1454 | } |
@@ -1456,21 +1456,21 @@ discard block |
||
1456 | 1456 | function wpinv_oxygen_fix_conflict() { |
1457 | 1457 | global $ct_ignore_post_types; |
1458 | 1458 | |
1459 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1459 | + if (!is_array($ct_ignore_post_types)) { |
|
1460 | 1460 | $ct_ignore_post_types = array(); |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
1463 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
1464 | 1464 | |
1465 | - foreach ( $post_types as $post_type ) { |
|
1465 | + foreach ($post_types as $post_type) { |
|
1466 | 1466 | $ct_ignore_post_types[] = $post_type; |
1467 | 1467 | |
1468 | 1468 | // Ignore post type |
1469 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1469 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1473 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1472 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1473 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @param GetPaid_Payment_Form $form |
1480 | 1480 | */ |
1481 | -function getpaid_display_payment_form( $form ) { |
|
1481 | +function getpaid_display_payment_form($form) { |
|
1482 | 1482 | |
1483 | - if ( is_numeric( $form ) ) { |
|
1484 | - $form = new GetPaid_Payment_Form( $form ); |
|
1483 | + if (is_numeric($form)) { |
|
1484 | + $form = new GetPaid_Payment_Form($form); |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | $form->display(); |
@@ -1491,16 +1491,16 @@ discard block |
||
1491 | 1491 | /** |
1492 | 1492 | * Helper function to display a item payment form on the frontend. |
1493 | 1493 | */ |
1494 | -function getpaid_display_item_payment_form( $items ) { |
|
1494 | +function getpaid_display_item_payment_form($items) { |
|
1495 | 1495 | |
1496 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1497 | - $form->set_items( $items ); |
|
1496 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1497 | + $form->set_items($items); |
|
1498 | 1498 | |
1499 | - if ( 0 == count( $form->get_items() ) ) { |
|
1499 | + if (0 == count($form->get_items())) { |
|
1500 | 1500 | echo aui()->alert( |
1501 | 1501 | array( |
1502 | 1502 | 'type' => 'warning', |
1503 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1503 | + 'content' => __('No published items found', 'invoicing'), |
|
1504 | 1504 | ) |
1505 | 1505 | ); |
1506 | 1506 | return; |
@@ -1512,75 +1512,75 @@ discard block |
||
1512 | 1512 | /** |
1513 | 1513 | * Helper function to display an invoice payment form on the frontend. |
1514 | 1514 | */ |
1515 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1515 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1516 | 1516 | global $invoicing; |
1517 | 1517 | |
1518 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1518 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1519 | 1519 | |
1520 | - if ( empty( $invoice ) ) { |
|
1520 | + if (empty($invoice)) { |
|
1521 | 1521 | return aui()->alert( |
1522 | 1522 | array( |
1523 | 1523 | 'type' => 'warning', |
1524 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1524 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1525 | 1525 | ) |
1526 | 1526 | ); |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - if ( $invoice->is_paid() ) { |
|
1529 | + if ($invoice->is_paid()) { |
|
1530 | 1530 | return aui()->alert( |
1531 | 1531 | array( |
1532 | 1532 | 'type' => 'warning', |
1533 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1533 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1534 | 1534 | ) |
1535 | 1535 | ); |
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | // Get the form elements and items. |
1539 | - $form = wpinv_get_default_payment_form(); |
|
1540 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
1541 | - $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
1539 | + $form = wpinv_get_default_payment_form(); |
|
1540 | + $elements = $invoicing->form_elements->get_form_elements($form); |
|
1541 | + $items = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice); |
|
1542 | 1542 | |
1543 | 1543 | ob_start(); |
1544 | 1544 | echo "<form class='wpinv_payment_form'>"; |
1545 | - do_action( 'wpinv_payment_form_top' ); |
|
1545 | + do_action('wpinv_payment_form_top'); |
|
1546 | 1546 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
1547 | 1547 | echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>"; |
1548 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
1549 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
1548 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
1549 | + wp_nonce_field('vat_validation', '_wpi_nonce'); |
|
1550 | 1550 | |
1551 | - foreach ( $elements as $element ) { |
|
1552 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
1553 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
1551 | + foreach ($elements as $element) { |
|
1552 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form); |
|
1553 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form); |
|
1554 | 1554 | } |
1555 | 1555 | |
1556 | 1556 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
1557 | - do_action( 'wpinv_payment_form_bottom' ); |
|
1557 | + do_action('wpinv_payment_form_bottom'); |
|
1558 | 1558 | echo '</form>'; |
1559 | 1559 | |
1560 | 1560 | $content = ob_get_clean(); |
1561 | - return str_replace( 'sr-only', '', $content ); |
|
1561 | + return str_replace('sr-only', '', $content); |
|
1562 | 1562 | } |
1563 | 1563 | |
1564 | 1564 | /** |
1565 | 1565 | * Helper function to convert item string to array. |
1566 | 1566 | */ |
1567 | -function getpaid_convert_items_to_array( $items ) { |
|
1568 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1567 | +function getpaid_convert_items_to_array($items) { |
|
1568 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1569 | 1569 | $prepared = array(); |
1570 | 1570 | |
1571 | - foreach ( $items as $item ) { |
|
1572 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1571 | + foreach ($items as $item) { |
|
1572 | + $data = array_map('trim', explode('|', $item)); |
|
1573 | 1573 | |
1574 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1574 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1575 | 1575 | continue; |
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | $quantity = 1; |
1579 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1579 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1580 | 1580 | $quantity = (int) $data[1]; |
1581 | 1581 | } |
1582 | 1582 | |
1583 | - $prepared[ $data[0] ] = $quantity; |
|
1583 | + $prepared[$data[0]] = $quantity; |
|
1584 | 1584 | |
1585 | 1585 | } |
1586 | 1586 | |
@@ -1590,13 +1590,13 @@ discard block |
||
1590 | 1590 | /** |
1591 | 1591 | * Helper function to convert item array to string. |
1592 | 1592 | */ |
1593 | -function getpaid_convert_items_to_string( $items ) { |
|
1593 | +function getpaid_convert_items_to_string($items) { |
|
1594 | 1594 | $prepared = array(); |
1595 | 1595 | |
1596 | - foreach ( $items as $item => $quantity ) { |
|
1596 | + foreach ($items as $item => $quantity) { |
|
1597 | 1597 | $prepared[] = "$item|$quantity"; |
1598 | 1598 | } |
1599 | - return implode( ',', $prepared ); |
|
1599 | + return implode(',', $prepared); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | /** |
@@ -1604,22 +1604,22 @@ discard block |
||
1604 | 1604 | * |
1605 | 1605 | * Provide a label and one of $form, $items or $invoice. |
1606 | 1606 | */ |
1607 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1608 | - $label = sanitize_text_field( $label ); |
|
1607 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1608 | + $label = sanitize_text_field($label); |
|
1609 | 1609 | $nonce = wp_create_nonce('getpaid_ajax_form'); |
1610 | 1610 | |
1611 | - if ( ! empty( $form ) ) { |
|
1612 | - $form = esc_attr( $form ); |
|
1611 | + if (!empty($form)) { |
|
1612 | + $form = esc_attr($form); |
|
1613 | 1613 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
1614 | 1614 | } |
1615 | 1615 | |
1616 | - if ( ! empty( $items ) ) { |
|
1617 | - $items = esc_attr( $items ); |
|
1616 | + if (!empty($items)) { |
|
1617 | + $items = esc_attr($items); |
|
1618 | 1618 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
1619 | 1619 | } |
1620 | 1620 | |
1621 | - if ( ! empty( $invoice ) ) { |
|
1622 | - $invoice = esc_attr( $invoice ); |
|
1621 | + if (!empty($invoice)) { |
|
1622 | + $invoice = esc_attr($invoice); |
|
1623 | 1623 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; |
1624 | 1624 | } |
1625 | 1625 | |
@@ -1630,17 +1630,17 @@ discard block |
||
1630 | 1630 | * |
1631 | 1631 | * @param WPInv_Invoice $invoice |
1632 | 1632 | */ |
1633 | -function getpaid_the_invoice_description( $invoice ) { |
|
1633 | +function getpaid_the_invoice_description($invoice) { |
|
1634 | 1634 | $description = $invoice->get_description(); |
1635 | 1635 | |
1636 | - if ( empty( $description ) ) { |
|
1636 | + if (empty($description)) { |
|
1637 | 1637 | return; |
1638 | 1638 | } |
1639 | 1639 | |
1640 | - $description = wp_kses_post( $description ); |
|
1640 | + $description = wp_kses_post($description); |
|
1641 | 1641 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
1642 | 1642 | } |
1643 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1643 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1644 | 1644 | |
1645 | 1645 | /** |
1646 | 1646 | * Render element on a form. |
@@ -1648,60 +1648,60 @@ discard block |
||
1648 | 1648 | * @param array $element |
1649 | 1649 | * @param GetPaid_Payment_Form $form |
1650 | 1650 | */ |
1651 | -function getpaid_payment_form_element( $element, $form ) { |
|
1651 | +function getpaid_payment_form_element($element, $form) { |
|
1652 | 1652 | |
1653 | 1653 | // Set up the args. |
1654 | - $element_type = trim( $element['type'] ); |
|
1654 | + $element_type = trim($element['type']); |
|
1655 | 1655 | $element['form'] = $form; |
1656 | - extract( $element ); |
|
1656 | + extract($element); |
|
1657 | 1657 | |
1658 | 1658 | // Try to locate the appropriate template. |
1659 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1659 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1660 | 1660 | |
1661 | 1661 | // Abort if this is not our element. |
1662 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1662 | + if (empty($located) || !file_exists($located)) { |
|
1663 | 1663 | return; |
1664 | 1664 | } |
1665 | 1665 | |
1666 | 1666 | // Generate the class and id of the element. |
1667 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1668 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1667 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1668 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1669 | 1669 | |
1670 | 1670 | // Echo the opening wrapper. |
1671 | 1671 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1672 | 1672 | |
1673 | 1673 | // Fires before displaying a given element type's content. |
1674 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1674 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1675 | 1675 | |
1676 | 1676 | // Include the template for the element. |
1677 | 1677 | include $located; |
1678 | 1678 | |
1679 | 1679 | // Fires after displaying a given element type's content. |
1680 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1680 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1681 | 1681 | |
1682 | 1682 | // Echo the closing wrapper. |
1683 | 1683 | echo '</div>'; |
1684 | 1684 | } |
1685 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1685 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1686 | 1686 | |
1687 | 1687 | /** |
1688 | 1688 | * Render an element's edit page. |
1689 | 1689 | * |
1690 | 1690 | * @param WP_Post $post |
1691 | 1691 | */ |
1692 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1692 | +function getpaid_payment_form_edit_element_template($post) { |
|
1693 | 1693 | |
1694 | 1694 | // Retrieve all elements. |
1695 | - $all_elements = wp_list_pluck( getpaid()->form_elements->get_elements(), 'type' ); |
|
1695 | + $all_elements = wp_list_pluck(getpaid()->form_elements->get_elements(), 'type'); |
|
1696 | 1696 | |
1697 | - foreach ( $all_elements as $element ) { |
|
1697 | + foreach ($all_elements as $element) { |
|
1698 | 1698 | |
1699 | 1699 | // Try to locate the appropriate template. |
1700 | - $element = sanitize_key( $element ); |
|
1701 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1700 | + $element = sanitize_key($element); |
|
1701 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1702 | 1702 | |
1703 | 1703 | // Continue if this is not our element. |
1704 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1704 | + if (empty($located) || !file_exists($located)) { |
|
1705 | 1705 | continue; |
1706 | 1706 | } |
1707 | 1707 | |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | } |
1715 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1715 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1716 | 1716 | |
1717 | 1717 | /** |
1718 | 1718 | * Shows a list of gateways that support recurring payments. |
@@ -1720,17 +1720,17 @@ discard block |
||
1720 | 1720 | function wpinv_get_recurring_gateways_text() { |
1721 | 1721 | $gateways = array(); |
1722 | 1722 | |
1723 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1724 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1725 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1723 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1724 | + if (wpinv_gateway_support_subscription($key)) { |
|
1725 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | |
1729 | - if ( empty( $gateways ) ) { |
|
1730 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1729 | + if (empty($gateways)) { |
|
1730 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1733 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1734 | 1734 | |
1735 | 1735 | } |
1736 | 1736 | |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | * @return GetPaid_Template |
1741 | 1741 | */ |
1742 | 1742 | function getpaid_template() { |
1743 | - return getpaid()->get( 'template' ); |
|
1743 | + return getpaid()->get('template'); |
|
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | /** |
@@ -1749,23 +1749,23 @@ discard block |
||
1749 | 1749 | * @param array args |
1750 | 1750 | * @return string |
1751 | 1751 | */ |
1752 | -function getpaid_paginate_links( $args ) { |
|
1752 | +function getpaid_paginate_links($args) { |
|
1753 | 1753 | |
1754 | 1754 | $args['type'] = 'array'; |
1755 | 1755 | $args['mid_size'] = 1; |
1756 | - $pages = paginate_links( $args ); |
|
1756 | + $pages = paginate_links($args); |
|
1757 | 1757 | |
1758 | - if ( ! is_array( $pages ) ) { |
|
1758 | + if (!is_array($pages)) { |
|
1759 | 1759 | return ''; |
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | $_pages = array(); |
1763 | - foreach ( $pages as $page ) { |
|
1764 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
1763 | + foreach ($pages as $page) { |
|
1764 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
1768 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
1768 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
1769 | 1769 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
1770 | 1770 | |
1771 | 1771 | return $links; |