@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
198 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
199 | 199 | |
200 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
201 | - $tip = wpinv_clean( $option['desc'] ); |
|
202 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
203 | - unset( $option['desc'] ); |
|
204 | - } |
|
200 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
201 | + $tip = wpinv_clean( $option['desc'] ); |
|
202 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
203 | + unset( $option['desc'] ); |
|
204 | + } |
|
205 | 205 | |
206 | 206 | // Loop through all tabs. |
207 | 207 | add_settings_field( |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
229 | 229 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
230 | 230 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
231 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
232 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
233 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
231 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
232 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
233 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
234 | 234 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
235 | 235 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
236 | 236 | ) |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return array |
245 | 245 | */ |
246 | 246 | function wpinv_get_registered_settings() { |
247 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
247 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function wpinv_settings_sanitize( $input = array() ) { |
265 | 265 | |
266 | - $wpinv_options = wpinv_get_options(); |
|
267 | - $raw_referrer = wp_get_raw_referer(); |
|
266 | + $wpinv_options = wpinv_get_options(); |
|
267 | + $raw_referrer = wp_get_raw_referer(); |
|
268 | 268 | |
269 | 269 | if ( empty( $raw_referrer ) ) { |
270 | - return array_merge( $wpinv_options, $input ); |
|
270 | + return array_merge( $wpinv_options, $input ); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | wp_parse_str( $raw_referrer, $referrer ); |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | // General filter |
295 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
295 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
296 | 296 | |
297 | - // Key specific filter. |
|
298 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
297 | + // Key specific filter. |
|
298 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | |
339 | 339 | foreach ( $new_rates as $rate ) { |
340 | 340 | |
341 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | - $rate['global'] = empty( $rate['state'] ); |
|
346 | - $tax_rates[] = $rate; |
|
341 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | + $rate['global'] = empty( $rate['state'] ); |
|
346 | + $tax_rates[] = $rate; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | 350 | update_option( 'wpinv_tax_rates', $tax_rates ); |
351 | 351 | |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | $tabs['general'] = __( 'General', 'invoicing' ); |
359 | 359 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
360 | 360 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
361 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
361 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
362 | 362 | |
363 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
364 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
365 | - } |
|
363 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
364 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
365 | + } |
|
366 | 366 | |
367 | 367 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
368 | 368 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | ) ), |
402 | 402 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
403 | 403 | 'main' => __( 'Tax Settings', 'invoicing' ), |
404 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
405 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
404 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
405 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
406 | 406 | ) ), |
407 | 407 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
408 | 408 | 'main' => __( 'Email Settings', 'invoicing' ), |
409 | - ) ), |
|
409 | + ) ), |
|
410 | 410 | |
411 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
411 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
412 | 412 | |
413 | 413 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
414 | 414 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -428,48 +428,48 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
431 | - $pages_options = array(); |
|
431 | + $pages_options = array(); |
|
432 | 432 | |
433 | - if( $default_label !== NULL && $default_label !== false ) { |
|
434 | - $pages_options = array( '' => $default_label ); // Blank option |
|
435 | - } |
|
433 | + if( $default_label !== NULL && $default_label !== false ) { |
|
434 | + $pages_options = array( '' => $default_label ); // Blank option |
|
435 | + } |
|
436 | 436 | |
437 | - $pages = get_pages(); |
|
438 | - if ( $pages ) { |
|
439 | - foreach ( $pages as $page ) { |
|
440 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
437 | + $pages = get_pages(); |
|
438 | + if ( $pages ) { |
|
439 | + foreach ( $pages as $page ) { |
|
440 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
441 | 441 | $pages_options[ $page->ID ] = $title; |
442 | - } |
|
443 | - } |
|
442 | + } |
|
443 | + } |
|
444 | 444 | |
445 | - return $pages_options; |
|
445 | + return $pages_options; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | function wpinv_header_callback( $args ) { |
449 | - if ( !empty( $args['desc'] ) ) { |
|
449 | + if ( !empty( $args['desc'] ) ) { |
|
450 | 450 | echo $args['desc']; |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | function wpinv_hidden_callback( $args ) { |
455 | 455 | |
456 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
457 | - $value = wpinv_get_option( $args['id'], $std ); |
|
456 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
457 | + $value = wpinv_get_option( $args['id'], $std ); |
|
458 | 458 | |
459 | - if ( isset( $args['set_value'] ) ) { |
|
460 | - $value = $args['set_value']; |
|
461 | - } |
|
459 | + if ( isset( $args['set_value'] ) ) { |
|
460 | + $value = $args['set_value']; |
|
461 | + } |
|
462 | 462 | |
463 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
464 | - $args['readonly'] = true; |
|
465 | - $name = ''; |
|
466 | - } else { |
|
467 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
468 | - } |
|
463 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
464 | + $args['readonly'] = true; |
|
465 | + $name = ''; |
|
466 | + } else { |
|
467 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
468 | + } |
|
469 | 469 | |
470 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
470 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
471 | 471 | |
472 | - echo $html; |
|
472 | + echo $html; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -477,12 +477,12 @@ discard block |
||
477 | 477 | */ |
478 | 478 | function wpinv_checkbox_callback( $args ) { |
479 | 479 | |
480 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | - $std = wpinv_get_option( $args['id'], $std ); |
|
482 | - $id = esc_attr( $args['id'] ); |
|
480 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | + $std = wpinv_get_option( $args['id'], $std ); |
|
482 | + $id = esc_attr( $args['id'] ); |
|
483 | 483 | |
484 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
485 | - ?> |
|
484 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
485 | + ?> |
|
486 | 486 | <fieldset> |
487 | 487 | <label> |
488 | 488 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -494,75 +494,75 @@ discard block |
||
494 | 494 | |
495 | 495 | function wpinv_multicheck_callback( $args ) { |
496 | 496 | |
497 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
498 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
497 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
498 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
499 | 499 | |
500 | - if ( ! empty( $args['options'] ) ) { |
|
500 | + if ( ! empty( $args['options'] ) ) { |
|
501 | 501 | |
502 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
503 | - $value = wpinv_get_option( $args['id'], $std ); |
|
502 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
503 | + $value = wpinv_get_option( $args['id'], $std ); |
|
504 | 504 | |
505 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
505 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
506 | 506 | foreach( $args['options'] as $key => $option ): |
507 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
508 | - if ( in_array( $sanitize_key, $value ) ) { |
|
509 | - $enabled = $sanitize_key; |
|
510 | - } else { |
|
511 | - $enabled = NULL; |
|
512 | - } |
|
513 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
514 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
515 | - endforeach; |
|
516 | - echo '</div>'; |
|
517 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
518 | - } |
|
507 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
508 | + if ( in_array( $sanitize_key, $value ) ) { |
|
509 | + $enabled = $sanitize_key; |
|
510 | + } else { |
|
511 | + $enabled = NULL; |
|
512 | + } |
|
513 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
514 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
515 | + endforeach; |
|
516 | + echo '</div>'; |
|
517 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
518 | + } |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | function wpinv_payment_icons_callback( $args ) { |
522 | 522 | |
523 | 523 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
524 | - $value = wpinv_get_option( $args['id'], false); |
|
524 | + $value = wpinv_get_option( $args['id'], false); |
|
525 | 525 | |
526 | - if ( ! empty( $args['options'] ) ) { |
|
527 | - foreach( $args['options'] as $key => $option ) { |
|
526 | + if ( ! empty( $args['options'] ) ) { |
|
527 | + foreach( $args['options'] as $key => $option ) { |
|
528 | 528 | $sanitize_key = wpinv_sanitize_key( $key ); |
529 | 529 | |
530 | - if( empty( $value ) ) { |
|
531 | - $enabled = $option; |
|
532 | - } else { |
|
533 | - $enabled = NULL; |
|
534 | - } |
|
535 | - |
|
536 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
537 | - |
|
538 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
539 | - |
|
540 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
541 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
542 | - } else { |
|
543 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
544 | - |
|
545 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
546 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
547 | - } else { |
|
548 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
549 | - $content_dir = WP_CONTENT_DIR; |
|
550 | - |
|
551 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
552 | - // Replaces backslashes with forward slashes for Windows systems |
|
553 | - $image = wp_normalize_path( $image ); |
|
554 | - $content_dir = wp_normalize_path( $content_dir ); |
|
555 | - } |
|
556 | - |
|
557 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
558 | - } |
|
559 | - |
|
560 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | - } |
|
562 | - echo $option . '</label>'; |
|
563 | - } |
|
564 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
565 | - } |
|
530 | + if( empty( $value ) ) { |
|
531 | + $enabled = $option; |
|
532 | + } else { |
|
533 | + $enabled = NULL; |
|
534 | + } |
|
535 | + |
|
536 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
537 | + |
|
538 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
539 | + |
|
540 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
541 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
542 | + } else { |
|
543 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
544 | + |
|
545 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
546 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
547 | + } else { |
|
548 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
549 | + $content_dir = WP_CONTENT_DIR; |
|
550 | + |
|
551 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
552 | + // Replaces backslashes with forward slashes for Windows systems |
|
553 | + $image = wp_normalize_path( $image ); |
|
554 | + $content_dir = wp_normalize_path( $content_dir ); |
|
555 | + } |
|
556 | + |
|
557 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
558 | + } |
|
559 | + |
|
560 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + } |
|
562 | + echo $option . '</label>'; |
|
563 | + } |
|
564 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
565 | + } |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | */ |
571 | 571 | function wpinv_radio_callback( $args ) { |
572 | 572 | |
573 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
574 | - $std = wpinv_get_option( $args['id'], $std ); |
|
575 | - ?> |
|
573 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
574 | + $std = wpinv_get_option( $args['id'], $std ); |
|
575 | + ?> |
|
576 | 576 | <fieldset> |
577 | 577 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
578 | 578 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | </ul> |
587 | 587 | </fieldset> |
588 | 588 | <?php |
589 | - getpaid_settings_description_callback( $args ); |
|
589 | + getpaid_settings_description_callback( $args ); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -594,10 +594,10 @@ discard block |
||
594 | 594 | */ |
595 | 595 | function getpaid_settings_description_callback( $args ) { |
596 | 596 | |
597 | - if ( ! empty( $args['desc'] ) ) { |
|
598 | - $description = wp_kses_post( $args['desc'] ); |
|
599 | - echo "<p class='description'>$description</p>"; |
|
600 | - } |
|
597 | + if ( ! empty( $args['desc'] ) ) { |
|
598 | + $description = wp_kses_post( $args['desc'] ); |
|
599 | + echo "<p class='description'>$description</p>"; |
|
600 | + } |
|
601 | 601 | |
602 | 602 | } |
603 | 603 | |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | */ |
607 | 607 | function wpinv_gateways_callback() { |
608 | 608 | |
609 | - ?> |
|
609 | + ?> |
|
610 | 610 | </td> |
611 | 611 | </tr> |
612 | 612 | <tr class="bsui"> |
@@ -620,22 +620,22 @@ discard block |
||
620 | 620 | |
621 | 621 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
622 | 622 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
623 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
624 | - $value = wpinv_get_option( $args['id'], $std ); |
|
623 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
624 | + $value = wpinv_get_option( $args['id'], $std ); |
|
625 | 625 | |
626 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
626 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
627 | 627 | |
628 | - foreach ( $args['options'] as $key => $option ) : |
|
629 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
628 | + foreach ( $args['options'] as $key => $option ) : |
|
629 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
630 | 630 | $selected = selected( $key, $args['selected'], false ); |
631 | 631 | } else { |
632 | 632 | $selected = selected( $key, $value, false ); |
633 | 633 | } |
634 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
635 | - endforeach; |
|
634 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
635 | + endforeach; |
|
636 | 636 | |
637 | - echo '</select>'; |
|
638 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
637 | + echo '</select>'; |
|
638 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
@@ -646,29 +646,29 @@ discard block |
||
646 | 646 | */ |
647 | 647 | function wpinv_settings_attrs_helper( $args ) { |
648 | 648 | |
649 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
650 | - $id = esc_attr( $args['id'] ); |
|
651 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
649 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
650 | + $id = esc_attr( $args['id'] ); |
|
651 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
652 | 652 | |
653 | - if ( ! empty( $args['faux'] ) ) { |
|
654 | - $args['readonly'] = true; |
|
655 | - $name = ''; |
|
656 | - } else { |
|
657 | - $value = wpinv_get_option( $args['id'], $value ); |
|
658 | - $name = "wpinv_settings[$id]"; |
|
659 | - } |
|
653 | + if ( ! empty( $args['faux'] ) ) { |
|
654 | + $args['readonly'] = true; |
|
655 | + $name = ''; |
|
656 | + } else { |
|
657 | + $value = wpinv_get_option( $args['id'], $value ); |
|
658 | + $name = "wpinv_settings[$id]"; |
|
659 | + } |
|
660 | 660 | |
661 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
662 | - $class = esc_attr( $args['class'] ); |
|
663 | - $style = esc_attr( $args['style'] ); |
|
664 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
661 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
662 | + $class = esc_attr( $args['class'] ); |
|
663 | + $style = esc_attr( $args['style'] ); |
|
664 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
665 | 665 | |
666 | - $onchange = ''; |
|
666 | + $onchange = ''; |
|
667 | 667 | if ( ! empty( $args['onchange'] ) ) { |
668 | 668 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
669 | - } |
|
669 | + } |
|
670 | 670 | |
671 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
671 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | /** |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | */ |
677 | 677 | function wpinv_text_callback( $args ) { |
678 | 678 | |
679 | - $desc = wp_kses_post( $args['desc'] ); |
|
680 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
681 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
679 | + $desc = wp_kses_post( $args['desc'] ); |
|
680 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
681 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
682 | 682 | |
683 | - ?> |
|
683 | + ?> |
|
684 | 684 | <label style="width: 100%;"> |
685 | 685 | <input type="text" <?php echo $attr; ?>> |
686 | 686 | <?php echo $desc; ?> |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | */ |
695 | 695 | function wpinv_number_callback( $args ) { |
696 | 696 | |
697 | - $desc = wp_kses_post( $args['desc'] ); |
|
698 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
699 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
700 | - $max = intval( $args['max'] ); |
|
701 | - $min = intval( $args['min'] ); |
|
702 | - $step = floatval( $args['step'] ); |
|
697 | + $desc = wp_kses_post( $args['desc'] ); |
|
698 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
699 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
700 | + $max = intval( $args['max'] ); |
|
701 | + $min = intval( $args['min'] ); |
|
702 | + $step = floatval( $args['step'] ); |
|
703 | 703 | |
704 | - ?> |
|
704 | + ?> |
|
705 | 705 | <label style="width: 100%;"> |
706 | 706 | <input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>> |
707 | 707 | <?php echo $desc; ?> |
@@ -713,36 +713,36 @@ discard block |
||
713 | 713 | function wpinv_textarea_callback( $args ) { |
714 | 714 | |
715 | 715 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
716 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
717 | - $value = wpinv_get_option( $args['id'], $std ); |
|
716 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
717 | + $value = wpinv_get_option( $args['id'], $std ); |
|
718 | 718 | |
719 | 719 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
720 | 720 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
721 | 721 | |
722 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
723 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
722 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
723 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
724 | 724 | |
725 | - echo $html; |
|
725 | + echo $html; |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | function wpinv_password_callback( $args ) { |
729 | 729 | |
730 | 730 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
731 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
732 | - $value = wpinv_get_option( $args['id'], $std ); |
|
731 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
732 | + $value = wpinv_get_option( $args['id'], $std ); |
|
733 | 733 | |
734 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
735 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
736 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
734 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
735 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
736 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
737 | 737 | |
738 | - echo $html; |
|
738 | + echo $html; |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | function wpinv_missing_callback($args) { |
742 | - printf( |
|
743 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
744 | - '<strong>' . $args['id'] . '</strong>' |
|
745 | - ); |
|
742 | + printf( |
|
743 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
744 | + '<strong>' . $args['id'] . '</strong>' |
|
745 | + ); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | */ |
751 | 751 | function wpinv_select_callback( $args ) { |
752 | 752 | |
753 | - $desc = wp_kses_post( $args['desc'] ); |
|
754 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
755 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
756 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
757 | - $value = wpinv_get_option( $args['id'], $value ); |
|
758 | - $rand = uniqid( 'random_id' ); |
|
753 | + $desc = wp_kses_post( $args['desc'] ); |
|
754 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
755 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
756 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
757 | + $value = wpinv_get_option( $args['id'], $value ); |
|
758 | + $rand = uniqid( 'random_id' ); |
|
759 | 759 | |
760 | - ?> |
|
760 | + ?> |
|
761 | 761 | <label style="width: 100%;"> |
762 | 762 | <select <?php echo $attr; ?>> |
763 | 763 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -790,104 +790,104 @@ discard block |
||
790 | 790 | function wpinv_color_select_callback( $args ) { |
791 | 791 | |
792 | 792 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
793 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
794 | - $value = wpinv_get_option( $args['id'], $std ); |
|
793 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
794 | + $value = wpinv_get_option( $args['id'], $std ); |
|
795 | 795 | |
796 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
796 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
797 | 797 | |
798 | - foreach ( $args['options'] as $option => $color ) { |
|
799 | - $selected = selected( $option, $value, false ); |
|
800 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
801 | - } |
|
798 | + foreach ( $args['options'] as $option => $color ) { |
|
799 | + $selected = selected( $option, $value, false ); |
|
800 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
801 | + } |
|
802 | 802 | |
803 | - $html .= '</select>'; |
|
804 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
803 | + $html .= '</select>'; |
|
804 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
805 | 805 | |
806 | - echo $html; |
|
806 | + echo $html; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | function wpinv_rich_editor_callback( $args ) { |
810 | - global $wp_version; |
|
810 | + global $wp_version; |
|
811 | 811 | |
812 | 812 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
813 | 813 | |
814 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
815 | - $value = wpinv_get_option( $args['id'], $std ); |
|
814 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
815 | + $value = wpinv_get_option( $args['id'], $std ); |
|
816 | 816 | |
817 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
818 | - $value = $std; |
|
819 | - } |
|
817 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
818 | + $value = $std; |
|
819 | + } |
|
820 | 820 | |
821 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
821 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
822 | 822 | |
823 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
824 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
825 | - ob_start(); |
|
826 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
827 | - $html .= ob_get_clean(); |
|
828 | - } else { |
|
829 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
830 | - } |
|
823 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
824 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
825 | + ob_start(); |
|
826 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
827 | + $html .= ob_get_clean(); |
|
828 | + } else { |
|
829 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
830 | + } |
|
831 | 831 | |
832 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
832 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
833 | 833 | |
834 | - echo $html; |
|
834 | + echo $html; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | function wpinv_upload_callback( $args ) { |
838 | 838 | |
839 | 839 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
840 | 840 | |
841 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
842 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
842 | + $value = wpinv_get_option( $args['id'], $std ); |
|
843 | 843 | |
844 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
845 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
846 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
847 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
844 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
845 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
846 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
847 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
848 | 848 | |
849 | - echo $html; |
|
849 | + echo $html; |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | function wpinv_color_callback( $args ) { |
853 | 853 | |
854 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
855 | - $value = wpinv_get_option( $args['id'], $std ); |
|
854 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
855 | + $value = wpinv_get_option( $args['id'], $std ); |
|
856 | 856 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
857 | 857 | |
858 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
859 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
858 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
859 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
860 | 860 | |
861 | - echo $html; |
|
861 | + echo $html; |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | function wpinv_country_states_callback($args) { |
865 | 865 | |
866 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
867 | - $value = wpinv_get_option( $args['id'], $std ); |
|
866 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
867 | + $value = wpinv_get_option( $args['id'], $std ); |
|
868 | 868 | |
869 | 869 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
870 | 870 | |
871 | - if ( isset( $args['placeholder'] ) ) { |
|
872 | - $placeholder = $args['placeholder']; |
|
873 | - } else { |
|
874 | - $placeholder = ''; |
|
875 | - } |
|
871 | + if ( isset( $args['placeholder'] ) ) { |
|
872 | + $placeholder = $args['placeholder']; |
|
873 | + } else { |
|
874 | + $placeholder = ''; |
|
875 | + } |
|
876 | 876 | |
877 | - $states = wpinv_get_country_states(); |
|
877 | + $states = wpinv_get_country_states(); |
|
878 | 878 | |
879 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
880 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
879 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
880 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
881 | 881 | |
882 | - foreach ( $states as $option => $name ) { |
|
883 | - $selected = selected( $option, $value, false ); |
|
884 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
885 | - } |
|
882 | + foreach ( $states as $option => $name ) { |
|
883 | + $selected = selected( $option, $value, false ); |
|
884 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
885 | + } |
|
886 | 886 | |
887 | - $html .= '</select>'; |
|
888 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
887 | + $html .= '</select>'; |
|
888 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
889 | 889 | |
890 | - echo $html; |
|
890 | + echo $html; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | /** |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | */ |
896 | 896 | function wpinv_tax_rates_callback() { |
897 | 897 | |
898 | - ?> |
|
898 | + ?> |
|
899 | 899 | </td> |
900 | 900 | </tr> |
901 | 901 | <tr class="bsui"> |
@@ -910,17 +910,17 @@ discard block |
||
910 | 910 | * Displays a tax rate' edit row. |
911 | 911 | */ |
912 | 912 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
913 | - ob_start(); |
|
913 | + ob_start(); |
|
914 | 914 | |
915 | - $key = sanitize_key( $key ); |
|
916 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
917 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
915 | + $key = sanitize_key( $key ); |
|
916 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
917 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
918 | 918 | |
919 | - if ( $echo ) { |
|
920 | - echo ob_get_clean(); |
|
921 | - } else { |
|
922 | - return ob_get_clean(); |
|
923 | - } |
|
919 | + if ( $echo ) { |
|
920 | + echo ob_get_clean(); |
|
921 | + } else { |
|
922 | + return ob_get_clean(); |
|
923 | + } |
|
924 | 924 | |
925 | 925 | } |
926 | 926 | |
@@ -948,14 +948,14 @@ discard block |
||
948 | 948 | </td> |
949 | 949 | <td> |
950 | 950 | <a href="<?php |
951 | - echo esc_url( |
|
952 | - wp_nonce_url( |
|
953 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
954 | - 'getpaid-nonce', |
|
955 | - 'getpaid-nonce' |
|
956 | - ) |
|
957 | - ); |
|
958 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
951 | + echo esc_url( |
|
952 | + wp_nonce_url( |
|
953 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
954 | + 'getpaid-nonce', |
|
955 | + 'getpaid-nonce' |
|
956 | + ) |
|
957 | + ); |
|
958 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
959 | 959 | </td> |
960 | 960 | </tr> |
961 | 961 | <tr> |
@@ -965,14 +965,14 @@ discard block |
||
965 | 965 | </td> |
966 | 966 | <td> |
967 | 967 | <a href="<?php |
968 | - echo esc_url( |
|
969 | - wp_nonce_url( |
|
970 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
971 | - 'getpaid-nonce', |
|
972 | - 'getpaid-nonce' |
|
973 | - ) |
|
974 | - ); |
|
975 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
968 | + echo esc_url( |
|
969 | + wp_nonce_url( |
|
970 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
971 | + 'getpaid-nonce', |
|
972 | + 'getpaid-nonce' |
|
973 | + ) |
|
974 | + ); |
|
975 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
976 | 976 | </td> |
977 | 977 | </tr> |
978 | 978 | <tr> |
@@ -982,14 +982,14 @@ discard block |
||
982 | 982 | </td> |
983 | 983 | <td> |
984 | 984 | <a href="<?php |
985 | - echo esc_url( |
|
986 | - wp_nonce_url( |
|
987 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
988 | - 'getpaid-nonce', |
|
989 | - 'getpaid-nonce' |
|
990 | - ) |
|
991 | - ); |
|
992 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
985 | + echo esc_url( |
|
986 | + wp_nonce_url( |
|
987 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
988 | + 'getpaid-nonce', |
|
989 | + 'getpaid-nonce' |
|
990 | + ) |
|
991 | + ); |
|
992 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
993 | 993 | </td> |
994 | 994 | </tr> |
995 | 995 | |
@@ -1000,14 +1000,14 @@ discard block |
||
1000 | 1000 | </td> |
1001 | 1001 | <td> |
1002 | 1002 | <a href="<?php |
1003 | - echo esc_url( |
|
1004 | - wp_nonce_url( |
|
1005 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1006 | - 'getpaid-nonce', |
|
1007 | - 'getpaid-nonce' |
|
1008 | - ) |
|
1009 | - ); |
|
1010 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1003 | + echo esc_url( |
|
1004 | + wp_nonce_url( |
|
1005 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1006 | + 'getpaid-nonce', |
|
1007 | + 'getpaid-nonce' |
|
1008 | + ) |
|
1009 | + ); |
|
1010 | + ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1011 | 1011 | </td> |
1012 | 1012 | </tr> |
1013 | 1013 | |
@@ -1021,19 +1021,19 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | |
1023 | 1023 | function wpinv_descriptive_text_callback( $args ) { |
1024 | - echo wp_kses_post( $args['desc'] ); |
|
1024 | + echo wp_kses_post( $args['desc'] ); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | function wpinv_raw_html_callback( $args ) { |
1028 | - echo $args['desc']; |
|
1028 | + echo $args['desc']; |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | function wpinv_hook_callback( $args ) { |
1032 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1032 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | function wpinv_set_settings_cap() { |
1036 | - return wpinv_get_capability(); |
|
1036 | + return wpinv_get_capability(); |
|
1037 | 1037 | } |
1038 | 1038 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1039 | 1039 | |
@@ -1057,15 +1057,15 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
1059 | 1059 | |
1060 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1061 | - $link = sprintf( |
|
1062 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1063 | - $url, |
|
1064 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1065 | - ); |
|
1060 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1061 | + $link = sprintf( |
|
1062 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1063 | + $url, |
|
1064 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1065 | + ); |
|
1066 | 1066 | |
1067 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1067 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1068 | 1068 | |
1069 | - return "$description $link"; |
|
1069 | + return "$description $link"; |
|
1070 | 1070 | |
1071 | 1071 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( empty( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (empty($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,49 +190,49 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
198 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
199 | 199 | |
200 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
201 | - $tip = wpinv_clean( $option['desc'] ); |
|
200 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
201 | + $tip = wpinv_clean($option['desc']); |
|
202 | 202 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
203 | - unset( $option['desc'] ); |
|
203 | + unset($option['desc']); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // Loop through all tabs. |
207 | 207 | add_settings_field( |
208 | 208 | 'wpinv_settings[' . $option['id'] . ']', |
209 | 209 | $name, |
210 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
210 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
211 | 211 | $section, |
212 | 212 | $section, |
213 | 213 | array( |
214 | 214 | 'section' => $section, |
215 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
216 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
215 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
216 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
217 | 217 | 'name' => $name, |
218 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
219 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
220 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
221 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
222 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
223 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
224 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
225 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
226 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
227 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
228 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
229 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
230 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
231 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
232 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
233 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
234 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
235 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
218 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
219 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
220 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
221 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
222 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
223 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
224 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
225 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
226 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
227 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
228 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
229 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
230 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
231 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
232 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
233 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
234 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
235 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
236 | 236 | ) |
237 | 237 | ); |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return array |
245 | 245 | */ |
246 | 246 | function wpinv_get_registered_settings() { |
247 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
247 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return array |
254 | 254 | */ |
255 | 255 | function getpaid_get_integration_settings() { |
256 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
256 | + return apply_filters('getpaid_integration_settings', array()); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -261,122 +261,122 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return array |
263 | 263 | */ |
264 | -function wpinv_settings_sanitize( $input = array() ) { |
|
264 | +function wpinv_settings_sanitize($input = array()) { |
|
265 | 265 | |
266 | 266 | $wpinv_options = wpinv_get_options(); |
267 | 267 | $raw_referrer = wp_get_raw_referer(); |
268 | 268 | |
269 | - if ( empty( $raw_referrer ) ) { |
|
270 | - return array_merge( $wpinv_options, $input ); |
|
269 | + if (empty($raw_referrer)) { |
|
270 | + return array_merge($wpinv_options, $input); |
|
271 | 271 | } |
272 | 272 | |
273 | - wp_parse_str( $raw_referrer, $referrer ); |
|
273 | + wp_parse_str($raw_referrer, $referrer); |
|
274 | 274 | |
275 | 275 | $settings = wpinv_get_registered_settings(); |
276 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
277 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
276 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
277 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
278 | 278 | |
279 | 279 | $input = $input ? $input : array(); |
280 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
281 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
280 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
281 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
282 | 282 | |
283 | 283 | // Loop through each setting being saved and pass it through a sanitization filter |
284 | - foreach ( $input as $key => $value ) { |
|
284 | + foreach ($input as $key => $value) { |
|
285 | 285 | |
286 | 286 | // Get the setting type (checkbox, select, etc) |
287 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
287 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
288 | 288 | |
289 | - if ( $type ) { |
|
289 | + if ($type) { |
|
290 | 290 | // Field type specific filter |
291 | - $input[$key] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
291 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // General filter |
295 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
295 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
296 | 296 | |
297 | 297 | // Key specific filter. |
298 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
298 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Loop through the whitelist and unset any that are empty for the tab being saved |
302 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
303 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
302 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
303 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
304 | 304 | |
305 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
305 | + $found_settings = array_merge($main_settings, $section_settings); |
|
306 | 306 | |
307 | - if ( ! empty( $found_settings ) ) { |
|
308 | - foreach ( $found_settings as $key => $value ) { |
|
307 | + if (!empty($found_settings)) { |
|
308 | + foreach ($found_settings as $key => $value) { |
|
309 | 309 | |
310 | 310 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
311 | - if ( is_numeric( $key ) ) { |
|
311 | + if (is_numeric($key)) { |
|
312 | 312 | $key = $value['id']; |
313 | 313 | } |
314 | 314 | |
315 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
316 | - unset( $wpinv_options[ $key ] ); |
|
315 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
316 | + unset($wpinv_options[$key]); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | 321 | // Merge our new settings with the existing |
322 | - $output = array_merge( $wpinv_options, $input ); |
|
322 | + $output = array_merge($wpinv_options, $input); |
|
323 | 323 | |
324 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
324 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
325 | 325 | |
326 | 326 | return $output; |
327 | 327 | } |
328 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
329 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
328 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
329 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
330 | 330 | |
331 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
332 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
331 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
332 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
333 | 333 | return $input; |
334 | 334 | } |
335 | 335 | |
336 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
336 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
337 | 337 | $tax_rates = array(); |
338 | 338 | |
339 | - foreach ( $new_rates as $rate ) { |
|
339 | + foreach ($new_rates as $rate) { |
|
340 | 340 | |
341 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | - $rate['global'] = empty( $rate['state'] ); |
|
341 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
342 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
343 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
344 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
345 | + $rate['global'] = empty($rate['state']); |
|
346 | 346 | $tax_rates[] = $rate; |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
350 | + update_option('wpinv_tax_rates', $tax_rates); |
|
351 | 351 | |
352 | 352 | return $input; |
353 | 353 | } |
354 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
354 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
355 | 355 | |
356 | 356 | function wpinv_get_settings_tabs() { |
357 | 357 | $tabs = array(); |
358 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
359 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
360 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
361 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
358 | + $tabs['general'] = __('General', 'invoicing'); |
|
359 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
360 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
361 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
362 | 362 | |
363 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
364 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
363 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
364 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
365 | 365 | } |
366 | 366 | |
367 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
368 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
369 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
367 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
368 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
369 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
370 | 370 | |
371 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
371 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
374 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
375 | 375 | $tabs = false; |
376 | 376 | $sections = wpinv_get_registered_settings_sections(); |
377 | 377 | |
378 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
379 | - $tabs = $sections[ $tab ]; |
|
378 | + if ($tab && !empty($sections[$tab])) { |
|
379 | + $tabs = $sections[$tab]; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | return $tabs; |
@@ -385,89 +385,89 @@ discard block |
||
385 | 385 | function wpinv_get_registered_settings_sections() { |
386 | 386 | static $sections = false; |
387 | 387 | |
388 | - if ( false !== $sections ) { |
|
388 | + if (false !== $sections) { |
|
389 | 389 | return $sections; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $sections = array( |
393 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
394 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
395 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
396 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
397 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
398 | - ) ), |
|
399 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
400 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
401 | - ) ), |
|
402 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
403 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
404 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
405 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
406 | - ) ), |
|
407 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
408 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
409 | - ) ), |
|
410 | - |
|
411 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
412 | - |
|
413 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
414 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
415 | - ) ), |
|
416 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
417 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
418 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
419 | - ) ), |
|
420 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
421 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
422 | - ) ), |
|
393 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
394 | + 'main' => __('General Settings', 'invoicing'), |
|
395 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
396 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
397 | + 'labels' => __('Label Texts', 'invoicing'), |
|
398 | + )), |
|
399 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
400 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
401 | + )), |
|
402 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
403 | + 'main' => __('Tax Settings', 'invoicing'), |
|
404 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
405 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
406 | + )), |
|
407 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
408 | + 'main' => __('Email Settings', 'invoicing'), |
|
409 | + )), |
|
410 | + |
|
411 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
412 | + |
|
413 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
414 | + 'main' => __('Privacy policy', 'invoicing'), |
|
415 | + )), |
|
416 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
417 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
418 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
419 | + )), |
|
420 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
421 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
422 | + )), |
|
423 | 423 | ); |
424 | 424 | |
425 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
425 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
426 | 426 | |
427 | 427 | return $sections; |
428 | 428 | } |
429 | 429 | |
430 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
430 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
431 | 431 | $pages_options = array(); |
432 | 432 | |
433 | - if( $default_label !== NULL && $default_label !== false ) { |
|
434 | - $pages_options = array( '' => $default_label ); // Blank option |
|
433 | + if ($default_label !== NULL && $default_label !== false) { |
|
434 | + $pages_options = array('' => $default_label); // Blank option |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | $pages = get_pages(); |
438 | - if ( $pages ) { |
|
439 | - foreach ( $pages as $page ) { |
|
438 | + if ($pages) { |
|
439 | + foreach ($pages as $page) { |
|
440 | 440 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
441 | - $pages_options[ $page->ID ] = $title; |
|
441 | + $pages_options[$page->ID] = $title; |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | return $pages_options; |
446 | 446 | } |
447 | 447 | |
448 | -function wpinv_header_callback( $args ) { |
|
449 | - if ( !empty( $args['desc'] ) ) { |
|
448 | +function wpinv_header_callback($args) { |
|
449 | + if (!empty($args['desc'])) { |
|
450 | 450 | echo $args['desc']; |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | -function wpinv_hidden_callback( $args ) { |
|
454 | +function wpinv_hidden_callback($args) { |
|
455 | 455 | |
456 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
457 | - $value = wpinv_get_option( $args['id'], $std ); |
|
456 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
457 | + $value = wpinv_get_option($args['id'], $std); |
|
458 | 458 | |
459 | - if ( isset( $args['set_value'] ) ) { |
|
459 | + if (isset($args['set_value'])) { |
|
460 | 460 | $value = $args['set_value']; |
461 | 461 | } |
462 | 462 | |
463 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
463 | + if (isset($args['faux']) && true === $args['faux']) { |
|
464 | 464 | $args['readonly'] = true; |
465 | - $name = ''; |
|
465 | + $name = ''; |
|
466 | 466 | } else { |
467 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
467 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
468 | 468 | } |
469 | 469 | |
470 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
470 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
471 | 471 | |
472 | 472 | echo $html; |
473 | 473 | } |
@@ -475,59 +475,59 @@ discard block |
||
475 | 475 | /** |
476 | 476 | * Displays a checkbox settings callback. |
477 | 477 | */ |
478 | -function wpinv_checkbox_callback( $args ) { |
|
478 | +function wpinv_checkbox_callback($args) { |
|
479 | 479 | |
480 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | - $std = wpinv_get_option( $args['id'], $std ); |
|
482 | - $id = esc_attr( $args['id'] ); |
|
480 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
481 | + $std = wpinv_get_option($args['id'], $std); |
|
482 | + $id = esc_attr($args['id']); |
|
483 | 483 | |
484 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
484 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
485 | 485 | ?> |
486 | 486 | <fieldset> |
487 | 487 | <label> |
488 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
489 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
488 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
489 | + <?php echo wp_kses_post($args['desc']); ?> |
|
490 | 490 | </label> |
491 | 491 | </fieldset> |
492 | 492 | <?php |
493 | 493 | } |
494 | 494 | |
495 | -function wpinv_multicheck_callback( $args ) { |
|
495 | +function wpinv_multicheck_callback($args) { |
|
496 | 496 | |
497 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
498 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
497 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
498 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
499 | 499 | |
500 | - if ( ! empty( $args['options'] ) ) { |
|
500 | + if (!empty($args['options'])) { |
|
501 | 501 | |
502 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
503 | - $value = wpinv_get_option( $args['id'], $std ); |
|
502 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
503 | + $value = wpinv_get_option($args['id'], $std); |
|
504 | 504 | |
505 | 505 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
506 | - foreach( $args['options'] as $key => $option ): |
|
507 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
508 | - if ( in_array( $sanitize_key, $value ) ) { |
|
506 | + foreach ($args['options'] as $key => $option): |
|
507 | + $sanitize_key = wpinv_sanitize_key($key); |
|
508 | + if (in_array($sanitize_key, $value)) { |
|
509 | 509 | $enabled = $sanitize_key; |
510 | 510 | } else { |
511 | 511 | $enabled = NULL; |
512 | 512 | } |
513 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
514 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
513 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
514 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
515 | 515 | endforeach; |
516 | 516 | echo '</div>'; |
517 | 517 | echo '<p class="description">' . $args['desc'] . '</p>'; |
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | -function wpinv_payment_icons_callback( $args ) { |
|
521 | +function wpinv_payment_icons_callback($args) { |
|
522 | 522 | |
523 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
524 | - $value = wpinv_get_option( $args['id'], false); |
|
523 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
524 | + $value = wpinv_get_option($args['id'], false); |
|
525 | 525 | |
526 | - if ( ! empty( $args['options'] ) ) { |
|
527 | - foreach( $args['options'] as $key => $option ) { |
|
528 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
526 | + if (!empty($args['options'])) { |
|
527 | + foreach ($args['options'] as $key => $option) { |
|
528 | + $sanitize_key = wpinv_sanitize_key($key); |
|
529 | 529 | |
530 | - if( empty( $value ) ) { |
|
530 | + if (empty($value)) { |
|
531 | 531 | $enabled = $option; |
532 | 532 | } else { |
533 | 533 | $enabled = NULL; |
@@ -535,67 +535,67 @@ discard block |
||
535 | 535 | |
536 | 536 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
537 | 537 | |
538 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
538 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
539 | 539 | |
540 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
541 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
540 | + if (wpinv_string_is_image_url($key)) { |
|
541 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
542 | 542 | } else { |
543 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
543 | + $card = strtolower(str_replace(' ', '', $option)); |
|
544 | 544 | |
545 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
546 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
545 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
546 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
547 | 547 | } else { |
548 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
548 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
549 | 549 | $content_dir = WP_CONTENT_DIR; |
550 | 550 | |
551 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
551 | + if (function_exists('wp_normalize_path')) { |
|
552 | 552 | // Replaces backslashes with forward slashes for Windows systems |
553 | - $image = wp_normalize_path( $image ); |
|
554 | - $content_dir = wp_normalize_path( $content_dir ); |
|
553 | + $image = wp_normalize_path($image); |
|
554 | + $content_dir = wp_normalize_path($content_dir); |
|
555 | 555 | } |
556 | 556 | |
557 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
557 | + $image = str_replace($content_dir, content_url(), $image); |
|
558 | 558 | } |
559 | 559 | |
560 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
560 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | 561 | } |
562 | 562 | echo $option . '</label>'; |
563 | 563 | } |
564 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
564 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
569 | 569 | * Displays a radio settings field. |
570 | 570 | */ |
571 | -function wpinv_radio_callback( $args ) { |
|
571 | +function wpinv_radio_callback($args) { |
|
572 | 572 | |
573 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
574 | - $std = wpinv_get_option( $args['id'], $std ); |
|
573 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
574 | + $std = wpinv_get_option($args['id'], $std); |
|
575 | 575 | ?> |
576 | 576 | <fieldset> |
577 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
578 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
577 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
578 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
579 | 579 | <li> |
580 | 580 | <label> |
581 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
582 | - <?php echo wp_kses_post( $option ); ?> |
|
581 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
582 | + <?php echo wp_kses_post($option); ?> |
|
583 | 583 | </label> |
584 | 584 | </li> |
585 | 585 | <?php endforeach; ?> |
586 | 586 | </ul> |
587 | 587 | </fieldset> |
588 | 588 | <?php |
589 | - getpaid_settings_description_callback( $args ); |
|
589 | + getpaid_settings_description_callback($args); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
593 | 593 | * Displays a description if available. |
594 | 594 | */ |
595 | -function getpaid_settings_description_callback( $args ) { |
|
595 | +function getpaid_settings_description_callback($args) { |
|
596 | 596 | |
597 | - if ( ! empty( $args['desc'] ) ) { |
|
598 | - $description = wp_kses_post( $args['desc'] ); |
|
597 | + if (!empty($args['desc'])) { |
|
598 | + $description = wp_kses_post($args['desc']); |
|
599 | 599 | echo "<p class='description'>$description</p>"; |
600 | 600 | } |
601 | 601 | |
@@ -611,31 +611,31 @@ discard block |
||
611 | 611 | </tr> |
612 | 612 | <tr class="bsui"> |
613 | 613 | <td colspan="2" class="p-0"> |
614 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
614 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
615 | 615 | |
616 | 616 | <?php |
617 | 617 | } |
618 | 618 | |
619 | 619 | function wpinv_gateway_select_callback($args) { |
620 | 620 | |
621 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
622 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
623 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
624 | - $value = wpinv_get_option( $args['id'], $std ); |
|
621 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
622 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
623 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
624 | + $value = wpinv_get_option($args['id'], $std); |
|
625 | 625 | |
626 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
626 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
627 | 627 | |
628 | - foreach ( $args['options'] as $key => $option ) : |
|
629 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
630 | - $selected = selected( $key, $args['selected'], false ); |
|
628 | + foreach ($args['options'] as $key => $option) : |
|
629 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
630 | + $selected = selected($key, $args['selected'], false); |
|
631 | 631 | } else { |
632 | - $selected = selected( $key, $value, false ); |
|
632 | + $selected = selected($key, $value, false); |
|
633 | 633 | } |
634 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
634 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
635 | 635 | endforeach; |
636 | 636 | |
637 | 637 | echo '</select>'; |
638 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
638 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
@@ -644,28 +644,28 @@ discard block |
||
644 | 644 | * @param array $args |
645 | 645 | * @return string |
646 | 646 | */ |
647 | -function wpinv_settings_attrs_helper( $args ) { |
|
647 | +function wpinv_settings_attrs_helper($args) { |
|
648 | 648 | |
649 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
650 | - $id = esc_attr( $args['id'] ); |
|
651 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
649 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
650 | + $id = esc_attr($args['id']); |
|
651 | + $placeholder = esc_attr($args['placeholder']); |
|
652 | 652 | |
653 | - if ( ! empty( $args['faux'] ) ) { |
|
653 | + if (!empty($args['faux'])) { |
|
654 | 654 | $args['readonly'] = true; |
655 | 655 | $name = ''; |
656 | 656 | } else { |
657 | - $value = wpinv_get_option( $args['id'], $value ); |
|
657 | + $value = wpinv_get_option($args['id'], $value); |
|
658 | 658 | $name = "wpinv_settings[$id]"; |
659 | 659 | } |
660 | 660 | |
661 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
662 | - $class = esc_attr( $args['class'] ); |
|
663 | - $style = esc_attr( $args['style'] ); |
|
664 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
661 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
662 | + $class = esc_attr($args['class']); |
|
663 | + $style = esc_attr($args['style']); |
|
664 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
665 | 665 | |
666 | 666 | $onchange = ''; |
667 | - if ( ! empty( $args['onchange'] ) ) { |
|
668 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
667 | + if (!empty($args['onchange'])) { |
|
668 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | /** |
675 | 675 | * Displays a text input settings callback. |
676 | 676 | */ |
677 | -function wpinv_text_callback( $args ) { |
|
677 | +function wpinv_text_callback($args) { |
|
678 | 678 | |
679 | - $desc = wp_kses_post( $args['desc'] ); |
|
680 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
681 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
679 | + $desc = wp_kses_post($args['desc']); |
|
680 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
681 | + $attr = wpinv_settings_attrs_helper($args); |
|
682 | 682 | |
683 | 683 | ?> |
684 | 684 | <label style="width: 100%;"> |
@@ -692,14 +692,14 @@ discard block |
||
692 | 692 | /** |
693 | 693 | * Displays a number input settings callback. |
694 | 694 | */ |
695 | -function wpinv_number_callback( $args ) { |
|
695 | +function wpinv_number_callback($args) { |
|
696 | 696 | |
697 | - $desc = wp_kses_post( $args['desc'] ); |
|
698 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
699 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
700 | - $max = intval( $args['max'] ); |
|
701 | - $min = intval( $args['min'] ); |
|
702 | - $step = floatval( $args['step'] ); |
|
697 | + $desc = wp_kses_post($args['desc']); |
|
698 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
699 | + $attr = wpinv_settings_attrs_helper($args); |
|
700 | + $max = intval($args['max']); |
|
701 | + $min = intval($args['min']); |
|
702 | + $step = floatval($args['step']); |
|
703 | 703 | |
704 | 704 | ?> |
705 | 705 | <label style="width: 100%;"> |
@@ -710,37 +710,37 @@ discard block |
||
710 | 710 | |
711 | 711 | } |
712 | 712 | |
713 | -function wpinv_textarea_callback( $args ) { |
|
713 | +function wpinv_textarea_callback($args) { |
|
714 | 714 | |
715 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
716 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
717 | - $value = wpinv_get_option( $args['id'], $std ); |
|
715 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
716 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
717 | + $value = wpinv_get_option($args['id'], $std); |
|
718 | 718 | |
719 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
720 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
719 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
720 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
721 | 721 | |
722 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
723 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
722 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
723 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
724 | 724 | |
725 | 725 | echo $html; |
726 | 726 | } |
727 | 727 | |
728 | -function wpinv_password_callback( $args ) { |
|
728 | +function wpinv_password_callback($args) { |
|
729 | 729 | |
730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
731 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
732 | - $value = wpinv_get_option( $args['id'], $std ); |
|
730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
731 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
732 | + $value = wpinv_get_option($args['id'], $std); |
|
733 | 733 | |
734 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
735 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
736 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
734 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
735 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
736 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
737 | 737 | |
738 | 738 | echo $html; |
739 | 739 | } |
740 | 740 | |
741 | 741 | function wpinv_missing_callback($args) { |
742 | 742 | printf( |
743 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
743 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
744 | 744 | '<strong>' . $args['id'] . '</strong>' |
745 | 745 | ); |
746 | 746 | } |
@@ -748,35 +748,35 @@ discard block |
||
748 | 748 | /** |
749 | 749 | * Displays a number input settings callback. |
750 | 750 | */ |
751 | -function wpinv_select_callback( $args ) { |
|
751 | +function wpinv_select_callback($args) { |
|
752 | 752 | |
753 | - $desc = wp_kses_post( $args['desc'] ); |
|
754 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
755 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
756 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
757 | - $value = wpinv_get_option( $args['id'], $value ); |
|
758 | - $rand = uniqid( 'random_id' ); |
|
753 | + $desc = wp_kses_post($args['desc']); |
|
754 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
755 | + $attr = wpinv_settings_attrs_helper($args); |
|
756 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
757 | + $value = wpinv_get_option($args['id'], $value); |
|
758 | + $rand = uniqid('random_id'); |
|
759 | 759 | |
760 | 760 | ?> |
761 | 761 | <label style="width: 100%;"> |
762 | 762 | <select <?php echo $attr; ?>> |
763 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
764 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
765 | - <?php endforeach;?> |
|
763 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
764 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
765 | + <?php endforeach; ?> |
|
766 | 766 | </select> |
767 | 767 | |
768 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
769 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a> |
|
768 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
769 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a> |
|
770 | 770 | <?php endif; ?> |
771 | 771 | |
772 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
773 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a> |
|
772 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
773 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a> |
|
774 | 774 | <div id='<?php echo $rand; ?>' style='display:none;'> |
775 | 775 | <div> |
776 | - <h3><?php _e( 'Original Content', 'invoicing' ) ?></h3> |
|
777 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
778 | - <h3><?php _e( 'Current Content', 'invoicing' ) ?></h3> |
|
779 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
776 | + <h3><?php _e('Original Content', 'invoicing') ?></h3> |
|
777 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
778 | + <h3><?php _e('Current Content', 'invoicing') ?></h3> |
|
779 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
780 | 780 | </div> |
781 | 781 | </div> |
782 | 782 | <?php endif; ?> |
@@ -787,88 +787,88 @@ discard block |
||
787 | 787 | |
788 | 788 | } |
789 | 789 | |
790 | -function wpinv_color_select_callback( $args ) { |
|
790 | +function wpinv_color_select_callback($args) { |
|
791 | 791 | |
792 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
793 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
794 | - $value = wpinv_get_option( $args['id'], $std ); |
|
792 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
793 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
794 | + $value = wpinv_get_option($args['id'], $std); |
|
795 | 795 | |
796 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
796 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
797 | 797 | |
798 | - foreach ( $args['options'] as $option => $color ) { |
|
799 | - $selected = selected( $option, $value, false ); |
|
800 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
798 | + foreach ($args['options'] as $option => $color) { |
|
799 | + $selected = selected($option, $value, false); |
|
800 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | $html .= '</select>'; |
804 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
804 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
805 | 805 | |
806 | 806 | echo $html; |
807 | 807 | } |
808 | 808 | |
809 | -function wpinv_rich_editor_callback( $args ) { |
|
809 | +function wpinv_rich_editor_callback($args) { |
|
810 | 810 | global $wp_version; |
811 | 811 | |
812 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
812 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
813 | 813 | |
814 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
815 | - $value = wpinv_get_option( $args['id'], $std ); |
|
814 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
815 | + $value = wpinv_get_option($args['id'], $std); |
|
816 | 816 | |
817 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
817 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
818 | 818 | $value = $std; |
819 | 819 | } |
820 | 820 | |
821 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
821 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
822 | 822 | |
823 | 823 | $html = '<div class="getpaid-settings-editor-input">'; |
824 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
824 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
825 | 825 | ob_start(); |
826 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
826 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
827 | 827 | $html .= ob_get_clean(); |
828 | 828 | } else { |
829 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
829 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
830 | 830 | } |
831 | 831 | |
832 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
832 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
833 | 833 | |
834 | 834 | echo $html; |
835 | 835 | } |
836 | 836 | |
837 | -function wpinv_upload_callback( $args ) { |
|
837 | +function wpinv_upload_callback($args) { |
|
838 | 838 | |
839 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
839 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
840 | 840 | |
841 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
842 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
842 | + $value = wpinv_get_option($args['id'], $std); |
|
843 | 843 | |
844 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
845 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
846 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
847 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
844 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
845 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
846 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
847 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
848 | 848 | |
849 | 849 | echo $html; |
850 | 850 | } |
851 | 851 | |
852 | -function wpinv_color_callback( $args ) { |
|
852 | +function wpinv_color_callback($args) { |
|
853 | 853 | |
854 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
855 | - $value = wpinv_get_option( $args['id'], $std ); |
|
856 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
854 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
855 | + $value = wpinv_get_option($args['id'], $std); |
|
856 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
857 | 857 | |
858 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
859 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
858 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
859 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
860 | 860 | |
861 | 861 | echo $html; |
862 | 862 | } |
863 | 863 | |
864 | 864 | function wpinv_country_states_callback($args) { |
865 | 865 | |
866 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
867 | - $value = wpinv_get_option( $args['id'], $std ); |
|
866 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
867 | + $value = wpinv_get_option($args['id'], $std); |
|
868 | 868 | |
869 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
869 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
870 | 870 | |
871 | - if ( isset( $args['placeholder'] ) ) { |
|
871 | + if (isset($args['placeholder'])) { |
|
872 | 872 | $placeholder = $args['placeholder']; |
873 | 873 | } else { |
874 | 874 | $placeholder = ''; |
@@ -876,16 +876,16 @@ discard block |
||
876 | 876 | |
877 | 877 | $states = wpinv_get_country_states(); |
878 | 878 | |
879 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
880 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
879 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
880 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
881 | 881 | |
882 | - foreach ( $states as $option => $name ) { |
|
883 | - $selected = selected( $option, $value, false ); |
|
884 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
882 | + foreach ($states as $option => $name) { |
|
883 | + $selected = selected($option, $value, false); |
|
884 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | $html .= '</select>'; |
888 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
888 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
889 | 889 | |
890 | 890 | echo $html; |
891 | 891 | } |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | </tr> |
901 | 901 | <tr class="bsui"> |
902 | 902 | <td colspan="2" class="p-0"> |
903 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
903 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
904 | 904 | |
905 | 905 | <?php |
906 | 906 | |
@@ -909,14 +909,14 @@ discard block |
||
909 | 909 | /** |
910 | 910 | * Displays a tax rate' edit row. |
911 | 911 | */ |
912 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
912 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
913 | 913 | ob_start(); |
914 | 914 | |
915 | - $key = sanitize_key( $key ); |
|
916 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
917 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
915 | + $key = sanitize_key($key); |
|
916 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
917 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
918 | 918 | |
919 | - if ( $echo ) { |
|
919 | + if ($echo) { |
|
920 | 920 | echo ob_get_clean(); |
921 | 921 | } else { |
922 | 922 | return ob_get_clean(); |
@@ -929,124 +929,124 @@ discard block |
||
929 | 929 | ob_start(); ?> |
930 | 930 | </td><tr> |
931 | 931 | <td colspan="2" class="wpinv_tools_tdbox"> |
932 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
933 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
932 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
933 | + <?php do_action('wpinv_tools_before'); ?> |
|
934 | 934 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
935 | 935 | <thead> |
936 | 936 | <tr> |
937 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
938 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
939 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
937 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
938 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
939 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
940 | 940 | </tr> |
941 | 941 | </thead> |
942 | 942 | |
943 | 943 | <tbody> |
944 | 944 | <tr> |
945 | - <td><?php _e( 'Check Pages', 'invoicing' );?></td> |
|
945 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
946 | 946 | <td> |
947 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
947 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
948 | 948 | </td> |
949 | 949 | <td> |
950 | 950 | <a href="<?php |
951 | 951 | echo esc_url( |
952 | 952 | wp_nonce_url( |
953 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
953 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
954 | 954 | 'getpaid-nonce', |
955 | 955 | 'getpaid-nonce' |
956 | 956 | ) |
957 | 957 | ); |
958 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
958 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
959 | 959 | </td> |
960 | 960 | </tr> |
961 | 961 | <tr> |
962 | - <td><?php _e( 'Create Database Tables', 'invoicing' );?></td> |
|
962 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
963 | 963 | <td> |
964 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
964 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
965 | 965 | </td> |
966 | 966 | <td> |
967 | 967 | <a href="<?php |
968 | 968 | echo esc_url( |
969 | 969 | wp_nonce_url( |
970 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
970 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
971 | 971 | 'getpaid-nonce', |
972 | 972 | 'getpaid-nonce' |
973 | 973 | ) |
974 | 974 | ); |
975 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
975 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
976 | 976 | </td> |
977 | 977 | </tr> |
978 | 978 | <tr> |
979 | - <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td> |
|
979 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
980 | 980 | <td> |
981 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
981 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
982 | 982 | </td> |
983 | 983 | <td> |
984 | 984 | <a href="<?php |
985 | 985 | echo esc_url( |
986 | 986 | wp_nonce_url( |
987 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
987 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
988 | 988 | 'getpaid-nonce', |
989 | 989 | 'getpaid-nonce' |
990 | 990 | ) |
991 | 991 | ); |
992 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
992 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
993 | 993 | </td> |
994 | 994 | </tr> |
995 | 995 | |
996 | 996 | <tr> |
997 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td> |
|
997 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
998 | 998 | <td> |
999 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
999 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1000 | 1000 | </td> |
1001 | 1001 | <td> |
1002 | 1002 | <a href="<?php |
1003 | 1003 | echo esc_url( |
1004 | 1004 | wp_nonce_url( |
1005 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1005 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1006 | 1006 | 'getpaid-nonce', |
1007 | 1007 | 'getpaid-nonce' |
1008 | 1008 | ) |
1009 | 1009 | ); |
1010 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1010 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1011 | 1011 | </td> |
1012 | 1012 | </tr> |
1013 | 1013 | |
1014 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1014 | + <?php do_action('wpinv_tools_row'); ?> |
|
1015 | 1015 | </tbody> |
1016 | 1016 | </table> |
1017 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1017 | + <?php do_action('wpinv_tools_after'); ?> |
|
1018 | 1018 | <?php |
1019 | 1019 | echo ob_get_clean(); |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | |
1023 | -function wpinv_descriptive_text_callback( $args ) { |
|
1024 | - echo wp_kses_post( $args['desc'] ); |
|
1023 | +function wpinv_descriptive_text_callback($args) { |
|
1024 | + echo wp_kses_post($args['desc']); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | -function wpinv_raw_html_callback( $args ) { |
|
1027 | +function wpinv_raw_html_callback($args) { |
|
1028 | 1028 | echo $args['desc']; |
1029 | 1029 | } |
1030 | 1030 | |
1031 | -function wpinv_hook_callback( $args ) { |
|
1032 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1031 | +function wpinv_hook_callback($args) { |
|
1032 | + do_action('wpinv_' . $args['id'], $args); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | function wpinv_set_settings_cap() { |
1036 | 1036 | return wpinv_get_capability(); |
1037 | 1037 | } |
1038 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1038 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1039 | 1039 | |
1040 | 1040 | |
1041 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1042 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1043 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1041 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1042 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1043 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1044 | 1044 | |
1045 | - if ( $old != $new ) { |
|
1046 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1045 | + if ($old != $new) { |
|
1046 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1049 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1050 | 1050 | |
1051 | 1051 | /** |
1052 | 1052 | * Returns the merge tags help text. |
@@ -1055,16 +1055,16 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @return string |
1057 | 1057 | */ |
1058 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1058 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1059 | 1059 | |
1060 | 1060 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1061 | 1061 | $link = sprintf( |
1062 | 1062 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1063 | 1063 | $url, |
1064 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1064 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1065 | 1065 | ); |
1066 | 1066 | |
1067 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1067 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1068 | 1068 | |
1069 | 1069 | return "$description $link"; |
1070 | 1070 |