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