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