@@ -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,8 +227,8 @@ 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 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
230 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
232 | 232 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
233 | 233 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
234 | 234 | ) |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array |
243 | 243 | */ |
244 | 244 | function wpinv_get_registered_settings() { |
245 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | // General filter |
292 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
292 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
293 | 293 | |
294 | - // Key specific filter. |
|
295 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
294 | + // Key specific filter. |
|
295 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $new_rates as $rate ) { |
350 | 350 | |
351 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
352 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
353 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
354 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
355 | - $rate['global'] = empty( $rate['state'] ); |
|
356 | - $tax_rates[] = $rate; |
|
351 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
352 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
353 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
354 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
355 | + $rate['global'] = empty( $rate['state'] ); |
|
356 | + $tax_rates[] = $rate; |
|
357 | 357 | |
358 | - } |
|
358 | + } |
|
359 | 359 | |
360 | 360 | update_option( 'wpinv_tax_rates', $tax_rates ); |
361 | 361 | |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | $tabs['general'] = __( 'General', 'invoicing' ); |
374 | 374 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
375 | 375 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
376 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
376 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
377 | 377 | |
378 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
379 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
380 | - } |
|
378 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
379 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
380 | + } |
|
381 | 381 | |
382 | 382 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
383 | 383 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | ) ), |
416 | 416 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
417 | 417 | 'main' => __( 'Tax Settings', 'invoicing' ), |
418 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
419 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
418 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
419 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
420 | 420 | ) ), |
421 | 421 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
422 | 422 | 'main' => __( 'Email Settings', 'invoicing' ), |
423 | - ) ), |
|
423 | + ) ), |
|
424 | 424 | |
425 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
425 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
426 | 426 | |
427 | 427 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
428 | 428 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -442,51 +442,51 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
445 | - $pages_options = array(); |
|
445 | + $pages_options = array(); |
|
446 | 446 | |
447 | - if( $default_label !== NULL && $default_label !== false ) { |
|
448 | - $pages_options = array( '' => $default_label ); // Blank option |
|
449 | - } |
|
447 | + if( $default_label !== NULL && $default_label !== false ) { |
|
448 | + $pages_options = array( '' => $default_label ); // Blank option |
|
449 | + } |
|
450 | 450 | |
451 | - $pages = get_pages(); |
|
452 | - if ( $pages ) { |
|
453 | - foreach ( $pages as $page ) { |
|
454 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
451 | + $pages = get_pages(); |
|
452 | + if ( $pages ) { |
|
453 | + foreach ( $pages as $page ) { |
|
454 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
455 | 455 | $pages_options[ $page->ID ] = $title; |
456 | - } |
|
457 | - } |
|
456 | + } |
|
457 | + } |
|
458 | 458 | |
459 | - return $pages_options; |
|
459 | + return $pages_options; |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | function wpinv_header_callback( $args ) { |
463 | - if ( !empty( $args['desc'] ) ) { |
|
463 | + if ( !empty( $args['desc'] ) ) { |
|
464 | 464 | echo $args['desc']; |
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | 468 | function wpinv_hidden_callback( $args ) { |
469 | - global $wpinv_options; |
|
470 | - |
|
471 | - if ( isset( $args['set_value'] ) ) { |
|
472 | - $value = $args['set_value']; |
|
473 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
474 | - $value = $wpinv_options[ $args['id'] ]; |
|
475 | - } else { |
|
476 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
477 | - } |
|
478 | - |
|
479 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
480 | - $args['readonly'] = true; |
|
481 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | - $name = ''; |
|
483 | - } else { |
|
484 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
485 | - } |
|
486 | - |
|
487 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
469 | + global $wpinv_options; |
|
470 | + |
|
471 | + if ( isset( $args['set_value'] ) ) { |
|
472 | + $value = $args['set_value']; |
|
473 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
474 | + $value = $wpinv_options[ $args['id'] ]; |
|
475 | + } else { |
|
476 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
477 | + } |
|
478 | + |
|
479 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
480 | + $args['readonly'] = true; |
|
481 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | + $name = ''; |
|
483 | + } else { |
|
484 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
485 | + } |
|
486 | + |
|
487 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
488 | 488 | |
489 | - echo $html; |
|
489 | + echo $html; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -494,12 +494,12 @@ discard block |
||
494 | 494 | */ |
495 | 495 | function wpinv_checkbox_callback( $args ) { |
496 | 496 | |
497 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
498 | - $std = wpinv_get_option( $args['id'], $std ); |
|
499 | - $id = esc_attr( $args['id'] ); |
|
497 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
498 | + $std = wpinv_get_option( $args['id'], $std ); |
|
499 | + $id = esc_attr( $args['id'] ); |
|
500 | 500 | |
501 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
502 | - ?> |
|
501 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
502 | + ?> |
|
503 | 503 | <fieldset> |
504 | 504 | <label> |
505 | 505 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -511,77 +511,77 @@ discard block |
||
511 | 511 | |
512 | 512 | function wpinv_multicheck_callback( $args ) { |
513 | 513 | |
514 | - global $wpinv_options; |
|
514 | + global $wpinv_options; |
|
515 | 515 | |
516 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
517 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
516 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
517 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | 518 | |
519 | - if ( ! empty( $args['options'] ) ) { |
|
519 | + if ( ! empty( $args['options'] ) ) { |
|
520 | 520 | |
521 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
522 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
521 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
522 | + $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
523 | 523 | |
524 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
524 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
525 | 525 | foreach( $args['options'] as $key => $option ): |
526 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
527 | - if ( in_array( $sanitize_key, $value ) ) { |
|
528 | - $enabled = $sanitize_key; |
|
529 | - } else { |
|
530 | - $enabled = NULL; |
|
531 | - } |
|
532 | - 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 ) . '/> '; |
|
533 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | - endforeach; |
|
535 | - echo '</div>'; |
|
536 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
537 | - } |
|
526 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
527 | + if ( in_array( $sanitize_key, $value ) ) { |
|
528 | + $enabled = $sanitize_key; |
|
529 | + } else { |
|
530 | + $enabled = NULL; |
|
531 | + } |
|
532 | + 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 ) . '/> '; |
|
533 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
534 | + endforeach; |
|
535 | + echo '</div>'; |
|
536 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
537 | + } |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | function wpinv_payment_icons_callback( $args ) { |
541 | - global $wpinv_options; |
|
541 | + global $wpinv_options; |
|
542 | 542 | |
543 | 543 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
544 | 544 | |
545 | - if ( ! empty( $args['options'] ) ) { |
|
546 | - foreach( $args['options'] as $key => $option ) { |
|
545 | + if ( ! empty( $args['options'] ) ) { |
|
546 | + foreach( $args['options'] as $key => $option ) { |
|
547 | 547 | $sanitize_key = wpinv_sanitize_key( $key ); |
548 | 548 | |
549 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
550 | - $enabled = $option; |
|
551 | - } else { |
|
552 | - $enabled = NULL; |
|
553 | - } |
|
554 | - |
|
555 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
556 | - |
|
557 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
558 | - |
|
559 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
560 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | - } else { |
|
562 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
563 | - |
|
564 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
565 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | - } else { |
|
567 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
568 | - $content_dir = WP_CONTENT_DIR; |
|
569 | - |
|
570 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
571 | - // Replaces backslashes with forward slashes for Windows systems |
|
572 | - $image = wp_normalize_path( $image ); |
|
573 | - $content_dir = wp_normalize_path( $content_dir ); |
|
574 | - } |
|
575 | - |
|
576 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
577 | - } |
|
578 | - |
|
579 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
580 | - } |
|
581 | - echo $option . '</label>'; |
|
582 | - } |
|
583 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
584 | - } |
|
549 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
550 | + $enabled = $option; |
|
551 | + } else { |
|
552 | + $enabled = NULL; |
|
553 | + } |
|
554 | + |
|
555 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
556 | + |
|
557 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
558 | + |
|
559 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
560 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | + } else { |
|
562 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
563 | + |
|
564 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
565 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
566 | + } else { |
|
567 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
568 | + $content_dir = WP_CONTENT_DIR; |
|
569 | + |
|
570 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
571 | + // Replaces backslashes with forward slashes for Windows systems |
|
572 | + $image = wp_normalize_path( $image ); |
|
573 | + $content_dir = wp_normalize_path( $content_dir ); |
|
574 | + } |
|
575 | + |
|
576 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
577 | + } |
|
578 | + |
|
579 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
580 | + } |
|
581 | + echo $option . '</label>'; |
|
582 | + } |
|
583 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
584 | + } |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | */ |
590 | 590 | function wpinv_radio_callback( $args ) { |
591 | 591 | |
592 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
593 | - $std = wpinv_get_option( $args['id'], $std ); |
|
594 | - ?> |
|
592 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
593 | + $std = wpinv_get_option( $args['id'], $std ); |
|
594 | + ?> |
|
595 | 595 | <fieldset> |
596 | 596 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
597 | 597 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | </ul> |
606 | 606 | </fieldset> |
607 | 607 | <?php |
608 | - getpaid_settings_description_callback( $args ); |
|
608 | + getpaid_settings_description_callback( $args ); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -613,50 +613,50 @@ discard block |
||
613 | 613 | */ |
614 | 614 | function getpaid_settings_description_callback( $args ) { |
615 | 615 | |
616 | - if ( ! empty( $args['desc'] ) ) { |
|
617 | - $description = wp_kses_post( $args['desc'] ); |
|
618 | - echo "<p class='description'>$description</p>"; |
|
619 | - } |
|
616 | + if ( ! empty( $args['desc'] ) ) { |
|
617 | + $description = wp_kses_post( $args['desc'] ); |
|
618 | + echo "<p class='description'>$description</p>"; |
|
619 | + } |
|
620 | 620 | |
621 | 621 | } |
622 | 622 | |
623 | 623 | function wpinv_gateways_callback( $args ) { |
624 | 624 | |
625 | - $gateways = wpinv_get_option( 'gateways', array( 'manual' => 1 ) ); |
|
625 | + $gateways = wpinv_get_option( 'gateways', array( 'manual' => 1 ) ); |
|
626 | 626 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
627 | 627 | |
628 | - foreach ( $args['options'] as $key => $option ) : |
|
629 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
628 | + foreach ( $args['options'] as $key => $option ) : |
|
629 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
630 | 630 | |
631 | 631 | if ( is_array( $gateways ) && isset( $gateways[ $key ] ) ) |
632 | - $enabled = '1'; |
|
633 | - else |
|
634 | - $enabled = null; |
|
632 | + $enabled = '1'; |
|
633 | + else |
|
634 | + $enabled = null; |
|
635 | 635 | |
636 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
637 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
638 | - endforeach; |
|
636 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
637 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
638 | + endforeach; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | function wpinv_gateway_select_callback($args) { |
642 | - global $wpinv_options; |
|
642 | + global $wpinv_options; |
|
643 | 643 | |
644 | 644 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
645 | 645 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
647 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
650 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
649 | + foreach ( $args['options'] as $key => $option ) : |
|
650 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
651 | 651 | $selected = selected( $key, $args['selected'], false ); |
652 | 652 | } else { |
653 | 653 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
654 | 654 | } |
655 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
656 | - endforeach; |
|
655 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
656 | + endforeach; |
|
657 | 657 | |
658 | - echo '</select>'; |
|
659 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
658 | + echo '</select>'; |
|
659 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -667,29 +667,29 @@ discard block |
||
667 | 667 | */ |
668 | 668 | function wpinv_settings_attrs_helper( $args ) { |
669 | 669 | |
670 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | - $id = esc_attr( $args['id'] ); |
|
672 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
670 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | + $id = esc_attr( $args['id'] ); |
|
672 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
673 | 673 | |
674 | - if ( ! empty( $args['faux'] ) ) { |
|
675 | - $args['readonly'] = true; |
|
676 | - $name = ''; |
|
677 | - } else { |
|
678 | - $value = wpinv_get_option( $args['id'], $value ); |
|
679 | - $name = "wpinv_settings[$id]"; |
|
680 | - } |
|
674 | + if ( ! empty( $args['faux'] ) ) { |
|
675 | + $args['readonly'] = true; |
|
676 | + $name = ''; |
|
677 | + } else { |
|
678 | + $value = wpinv_get_option( $args['id'], $value ); |
|
679 | + $name = "wpinv_settings[$id]"; |
|
680 | + } |
|
681 | 681 | |
682 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
683 | - $class = esc_attr( $args['class'] ); |
|
684 | - $style = esc_attr( $args['style'] ); |
|
685 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
682 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
683 | + $class = esc_attr( $args['class'] ); |
|
684 | + $style = esc_attr( $args['style'] ); |
|
685 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
686 | 686 | |
687 | - $onchange = ''; |
|
687 | + $onchange = ''; |
|
688 | 688 | if ( ! empty( $args['onchange'] ) ) { |
689 | 689 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
690 | - } |
|
690 | + } |
|
691 | 691 | |
692 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
692 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | */ |
698 | 698 | function wpinv_text_callback( $args ) { |
699 | 699 | |
700 | - $desc = wp_kses_post( $args['desc'] ); |
|
701 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
702 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
700 | + $desc = wp_kses_post( $args['desc'] ); |
|
701 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
702 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
703 | 703 | |
704 | - ?> |
|
704 | + ?> |
|
705 | 705 | <label style="width: 100%;"> |
706 | 706 | <input type="text" <?php echo $attr; ?>> |
707 | 707 | <?php echo $desc; ?> |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | */ |
716 | 716 | function wpinv_number_callback( $args ) { |
717 | 717 | |
718 | - $desc = wp_kses_post( $args['desc'] ); |
|
719 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
720 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
721 | - $max = intval( $args['max'] ); |
|
722 | - $min = intval( $args['min'] ); |
|
723 | - $step = floatval( $args['step'] ); |
|
718 | + $desc = wp_kses_post( $args['desc'] ); |
|
719 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
720 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
721 | + $max = intval( $args['max'] ); |
|
722 | + $min = intval( $args['min'] ); |
|
723 | + $step = floatval( $args['step'] ); |
|
724 | 724 | |
725 | - ?> |
|
725 | + ?> |
|
726 | 726 | <label style="width: 100%;"> |
727 | 727 | <input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>> |
728 | 728 | <?php echo $desc; ?> |
@@ -732,48 +732,48 @@ discard block |
||
732 | 732 | } |
733 | 733 | |
734 | 734 | function wpinv_textarea_callback( $args ) { |
735 | - global $wpinv_options; |
|
735 | + global $wpinv_options; |
|
736 | 736 | |
737 | 737 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
738 | 738 | |
739 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
740 | - $value = $wpinv_options[ $args['id'] ]; |
|
741 | - } else { |
|
742 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
743 | - } |
|
739 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
740 | + $value = $wpinv_options[ $args['id'] ]; |
|
741 | + } else { |
|
742 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
743 | + } |
|
744 | 744 | |
745 | 745 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
746 | 746 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
747 | 747 | |
748 | - $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>'; |
|
749 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
748 | + $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>'; |
|
749 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
750 | 750 | |
751 | - echo $html; |
|
751 | + echo $html; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | function wpinv_password_callback( $args ) { |
755 | - global $wpinv_options; |
|
755 | + global $wpinv_options; |
|
756 | 756 | |
757 | 757 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
758 | 758 | |
759 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
760 | - $value = $wpinv_options[ $args['id'] ]; |
|
761 | - } else { |
|
762 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
763 | - } |
|
759 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
760 | + $value = $wpinv_options[ $args['id'] ]; |
|
761 | + } else { |
|
762 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
763 | + } |
|
764 | 764 | |
765 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
766 | - $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 ) . '"/>'; |
|
767 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
765 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
766 | + $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 ) . '"/>'; |
|
767 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
768 | 768 | |
769 | - echo $html; |
|
769 | + echo $html; |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | function wpinv_missing_callback($args) { |
773 | - printf( |
|
774 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
775 | - '<strong>' . $args['id'] . '</strong>' |
|
776 | - ); |
|
773 | + printf( |
|
774 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
775 | + '<strong>' . $args['id'] . '</strong>' |
|
776 | + ); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | */ |
782 | 782 | function wpinv_select_callback( $args ) { |
783 | 783 | |
784 | - $desc = wp_kses_post( $args['desc'] ); |
|
785 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
786 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
787 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
788 | - $value = wpinv_get_option( $args['id'], $value ); |
|
784 | + $desc = wp_kses_post( $args['desc'] ); |
|
785 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
786 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
787 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
788 | + $value = wpinv_get_option( $args['id'], $value ); |
|
789 | 789 | |
790 | - ?> |
|
790 | + ?> |
|
791 | 791 | <label style="width: 100%;"> |
792 | 792 | <select <?php echo $attr; ?>> |
793 | 793 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -801,123 +801,123 @@ discard block |
||
801 | 801 | } |
802 | 802 | |
803 | 803 | function wpinv_color_select_callback( $args ) { |
804 | - global $wpinv_options; |
|
804 | + global $wpinv_options; |
|
805 | 805 | |
806 | 806 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
807 | 807 | |
808 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
809 | - $value = $wpinv_options[ $args['id'] ]; |
|
810 | - } else { |
|
811 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
812 | - } |
|
808 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
809 | + $value = $wpinv_options[ $args['id'] ]; |
|
810 | + } else { |
|
811 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
812 | + } |
|
813 | 813 | |
814 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
814 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
815 | 815 | |
816 | - foreach ( $args['options'] as $option => $color ) { |
|
817 | - $selected = selected( $option, $value, false ); |
|
818 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
819 | - } |
|
816 | + foreach ( $args['options'] as $option => $color ) { |
|
817 | + $selected = selected( $option, $value, false ); |
|
818 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
819 | + } |
|
820 | 820 | |
821 | - $html .= '</select>'; |
|
822 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
821 | + $html .= '</select>'; |
|
822 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
823 | 823 | |
824 | - echo $html; |
|
824 | + echo $html; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | function wpinv_rich_editor_callback( $args ) { |
828 | - global $wpinv_options, $wp_version; |
|
828 | + global $wpinv_options, $wp_version; |
|
829 | 829 | |
830 | 830 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
831 | 831 | |
832 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
833 | - $value = $wpinv_options[ $args['id'] ]; |
|
832 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
833 | + $value = $wpinv_options[ $args['id'] ]; |
|
834 | 834 | |
835 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
836 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
837 | - } |
|
838 | - } else { |
|
839 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
840 | - } |
|
835 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
836 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
837 | + } |
|
838 | + } else { |
|
839 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
840 | + } |
|
841 | 841 | |
842 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
842 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
843 | 843 | |
844 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
845 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
846 | - ob_start(); |
|
847 | - 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 ) ); |
|
848 | - $html .= ob_get_clean(); |
|
849 | - } else { |
|
850 | - $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>'; |
|
851 | - } |
|
844 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
845 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
846 | + ob_start(); |
|
847 | + 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 ) ); |
|
848 | + $html .= ob_get_clean(); |
|
849 | + } else { |
|
850 | + $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>'; |
|
851 | + } |
|
852 | 852 | |
853 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
854 | 854 | |
855 | - echo $html; |
|
855 | + echo $html; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | function wpinv_upload_callback( $args ) { |
859 | - global $wpinv_options; |
|
859 | + global $wpinv_options; |
|
860 | 860 | |
861 | 861 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
862 | 862 | |
863 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
864 | - $value = $wpinv_options[$args['id']]; |
|
865 | - } else { |
|
866 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
867 | - } |
|
863 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
864 | + $value = $wpinv_options[$args['id']]; |
|
865 | + } else { |
|
866 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
867 | + } |
|
868 | 868 | |
869 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
870 | - $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 ) ) . '"/>'; |
|
871 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
872 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
869 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
870 | + $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 ) ) . '"/>'; |
|
871 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
872 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
873 | 873 | |
874 | - echo $html; |
|
874 | + echo $html; |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | function wpinv_color_callback( $args ) { |
878 | - global $wpinv_options; |
|
878 | + global $wpinv_options; |
|
879 | 879 | |
880 | 880 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
881 | 881 | |
882 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
883 | - $value = $wpinv_options[ $args['id'] ]; |
|
884 | - } else { |
|
885 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
886 | - } |
|
882 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
883 | + $value = $wpinv_options[ $args['id'] ]; |
|
884 | + } else { |
|
885 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
886 | + } |
|
887 | 887 | |
888 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
888 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
889 | 889 | |
890 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
891 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
890 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
891 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | 892 | |
893 | - echo $html; |
|
893 | + echo $html; |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | function wpinv_country_states_callback($args) { |
897 | - global $wpinv_options; |
|
897 | + global $wpinv_options; |
|
898 | 898 | |
899 | 899 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
900 | 900 | |
901 | - if ( isset( $args['placeholder'] ) ) { |
|
902 | - $placeholder = $args['placeholder']; |
|
903 | - } else { |
|
904 | - $placeholder = ''; |
|
905 | - } |
|
901 | + if ( isset( $args['placeholder'] ) ) { |
|
902 | + $placeholder = $args['placeholder']; |
|
903 | + } else { |
|
904 | + $placeholder = ''; |
|
905 | + } |
|
906 | 906 | |
907 | - $states = wpinv_get_country_states(); |
|
907 | + $states = wpinv_get_country_states(); |
|
908 | 908 | |
909 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
910 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
909 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
910 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
911 | 911 | |
912 | - foreach ( $states as $option => $name ) { |
|
913 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
914 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
915 | - } |
|
912 | + foreach ( $states as $option => $name ) { |
|
913 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
914 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
915 | + } |
|
916 | 916 | |
917 | - $html .= '</select>'; |
|
918 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
917 | + $html .= '</select>'; |
|
918 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
919 | 919 | |
920 | - echo $html; |
|
920 | + echo $html; |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | */ |
926 | 926 | function wpinv_tax_rates_callback() { |
927 | 927 | |
928 | - ?> |
|
928 | + ?> |
|
929 | 929 | </td> |
930 | 930 | </tr> |
931 | 931 | <tr class="bsui"> |
@@ -940,17 +940,17 @@ discard block |
||
940 | 940 | * Displays a tax rate' edit row. |
941 | 941 | */ |
942 | 942 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
943 | - ob_start(); |
|
943 | + ob_start(); |
|
944 | 944 | |
945 | - $key = sanitize_key( $key ); |
|
946 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
947 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
945 | + $key = sanitize_key( $key ); |
|
946 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
947 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
948 | 948 | |
949 | - if ( $echo ) { |
|
950 | - echo ob_get_clean(); |
|
951 | - } else { |
|
952 | - return ob_get_clean(); |
|
953 | - } |
|
949 | + if ( $echo ) { |
|
950 | + echo ob_get_clean(); |
|
951 | + } else { |
|
952 | + return ob_get_clean(); |
|
953 | + } |
|
954 | 954 | |
955 | 955 | } |
956 | 956 | |
@@ -977,14 +977,14 @@ discard block |
||
977 | 977 | </td> |
978 | 978 | <td> |
979 | 979 | <a href="<?php |
980 | - echo esc_url( |
|
981 | - wp_nonce_url( |
|
982 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
983 | - 'getpaid-nonce', |
|
984 | - 'getpaid-nonce' |
|
985 | - ) |
|
986 | - ); |
|
987 | - ?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a> |
|
980 | + echo esc_url( |
|
981 | + wp_nonce_url( |
|
982 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
983 | + 'getpaid-nonce', |
|
984 | + 'getpaid-nonce' |
|
985 | + ) |
|
986 | + ); |
|
987 | + ?>" class="button button-primary"><?php _e('Run', 'geodirectory');?></a> |
|
988 | 988 | </td> |
989 | 989 | </tr> |
990 | 990 | <?php do_action( 'wpinv_tools_row' ); ?> |
@@ -996,19 +996,19 @@ discard block |
||
996 | 996 | } |
997 | 997 | |
998 | 998 | function wpinv_descriptive_text_callback( $args ) { |
999 | - echo wp_kses_post( $args['desc'] ); |
|
999 | + echo wp_kses_post( $args['desc'] ); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | function wpinv_raw_html_callback( $args ) { |
1003 | - echo $args['desc']; |
|
1003 | + echo $args['desc']; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | function wpinv_hook_callback( $args ) { |
1007 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1007 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | function wpinv_set_settings_cap() { |
1011 | - return wpinv_get_capability(); |
|
1011 | + return wpinv_get_capability(); |
|
1012 | 1012 | } |
1013 | 1013 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1014 | 1014 |
@@ -14,74 +14,74 @@ discard block |
||
14 | 14 | class GetPaid_Admin { |
15 | 15 | |
16 | 16 | /** |
17 | - * Local path to this plugins admin directory |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $admin_path; |
|
22 | - |
|
23 | - /** |
|
24 | - * Web path to this plugins admin directory |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $admin_url; |
|
17 | + * Local path to this plugins admin directory |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $admin_path; |
|
22 | + |
|
23 | + /** |
|
24 | + * Web path to this plugins admin directory |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $admin_url; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Reports components. |
|
32 | - * |
|
33 | - * @var GetPaid_Reports |
|
34 | - */ |
|
30 | + /** |
|
31 | + * Reports components. |
|
32 | + * |
|
33 | + * @var GetPaid_Reports |
|
34 | + */ |
|
35 | 35 | public $reports; |
36 | 36 | |
37 | 37 | /** |
38 | - * Class constructor. |
|
39 | - */ |
|
40 | - public function __construct(){ |
|
38 | + * Class constructor. |
|
39 | + */ |
|
40 | + public function __construct(){ |
|
41 | 41 | |
42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ ); |
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | - $this->reports = new GetPaid_Reports(); |
|
43 | + $this->admin_url = plugins_url( '/', __FILE__ ); |
|
44 | + $this->reports = new GetPaid_Reports(); |
|
45 | 45 | |
46 | 46 | if ( is_admin() ) { |
47 | - $this->init_admin_hooks(); |
|
47 | + $this->init_admin_hooks(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | - * Init action and filter hooks |
|
54 | - * |
|
55 | - */ |
|
56 | - private function init_admin_hooks() { |
|
53 | + * Init action and filter hooks |
|
54 | + * |
|
55 | + */ |
|
56 | + private function init_admin_hooks() { |
|
57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
65 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
66 | 66 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
67 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
68 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
69 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
67 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
68 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
69 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | - * Register admin scripts |
|
75 | - * |
|
76 | - */ |
|
77 | - public function enqeue_scripts() { |
|
74 | + * Register admin scripts |
|
75 | + * |
|
76 | + */ |
|
77 | + public function enqeue_scripts() { |
|
78 | 78 | global $current_screen, $pagenow; |
79 | 79 | |
80 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
81 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
80 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
81 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
82 | 82 | |
83 | 83 | if ( ! empty( $current_screen->post_type ) ) { |
84 | - $page = $current_screen->post_type; |
|
84 | + $page = $current_screen->post_type; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // General styles. |
@@ -104,54 +104,54 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Payment form scripts. |
107 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
107 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
108 | 108 | $this->load_payment_form_scripts(); |
109 | 109 | } |
110 | 110 | |
111 | - if ( $page == 'wpinv-subscriptions' ) { |
|
112 | - wp_enqueue_script( 'postbox' ); |
|
113 | - } |
|
111 | + if ( $page == 'wpinv-subscriptions' ) { |
|
112 | + wp_enqueue_script( 'postbox' ); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | - * Returns admin js translations. |
|
119 | - * |
|
120 | - */ |
|
121 | - protected function get_admin_i18() { |
|
118 | + * Returns admin js translations. |
|
119 | + * |
|
120 | + */ |
|
121 | + protected function get_admin_i18() { |
|
122 | 122 | global $post; |
123 | 123 | |
124 | - $date_range = array( |
|
125 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
126 | - ); |
|
124 | + $date_range = array( |
|
125 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
126 | + ); |
|
127 | 127 | |
128 | - if ( $date_range['period'] == 'custom' ) { |
|
128 | + if ( $date_range['period'] == 'custom' ) { |
|
129 | 129 | |
130 | - if ( isset( $_GET['from'] ) ) { |
|
131 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
132 | - } |
|
130 | + if ( isset( $_GET['from'] ) ) { |
|
131 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
132 | + } |
|
133 | 133 | |
134 | - if ( isset( $_GET['to'] ) ) { |
|
135 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
136 | - } |
|
134 | + if ( isset( $_GET['to'] ) ) { |
|
135 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
136 | + } |
|
137 | 137 | |
138 | - } |
|
138 | + } |
|
139 | 139 | |
140 | 140 | $i18n = array( |
141 | 141 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
142 | 142 | 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
143 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
144 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
145 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
146 | - 'date_range' => $date_range, |
|
143 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
144 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
145 | + 'rest_root' => esc_url_raw( rest_url() ), |
|
146 | + 'date_range' => $date_range, |
|
147 | 147 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
148 | 148 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
149 | 149 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
150 | 150 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
151 | 151 | 'tax' => wpinv_tax_amount(), |
152 | 152 | 'discount' => 0, |
153 | - 'currency_symbol' => wpinv_currency_symbol(), |
|
154 | - 'currency' => wpinv_get_currency(), |
|
153 | + 'currency_symbol' => wpinv_currency_symbol(), |
|
154 | + 'currency' => wpinv_get_currency(), |
|
155 | 155 | 'currency_pos' => wpinv_currency_position(), |
156 | 156 | 'thousand_sep' => wpinv_thousands_separator(), |
157 | 157 | 'decimal_sep' => wpinv_decimal_separator(), |
@@ -174,112 +174,112 @@ discard block |
||
174 | 174 | 'searching' => __( 'Searching', 'invoicing' ), |
175 | 175 | ); |
176 | 176 | |
177 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
177 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
178 | 178 | |
179 | - $invoice = new WPInv_Invoice( $post ); |
|
180 | - $i18n['save_invoice'] = sprintf( |
|
181 | - __( 'Save %s', 'invoicing' ), |
|
182 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
183 | - ); |
|
179 | + $invoice = new WPInv_Invoice( $post ); |
|
180 | + $i18n['save_invoice'] = sprintf( |
|
181 | + __( 'Save %s', 'invoicing' ), |
|
182 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
183 | + ); |
|
184 | 184 | |
185 | - $i18n['invoice_description'] = sprintf( |
|
186 | - __( '%s Description', 'invoicing' ), |
|
187 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
188 | - ); |
|
185 | + $i18n['invoice_description'] = sprintf( |
|
186 | + __( '%s Description', 'invoicing' ), |
|
187 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
188 | + ); |
|
189 | 189 | |
190 | - } |
|
191 | - return $i18n; |
|
192 | - } |
|
190 | + } |
|
191 | + return $i18n; |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * Change the admin footer text on GetPaid admin pages. |
|
196 | - * |
|
197 | - * @since 2.0.0 |
|
198 | - * @param string $footer_text |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function admin_footer_text( $footer_text ) { |
|
202 | - global $current_screen; |
|
194 | + /** |
|
195 | + * Change the admin footer text on GetPaid admin pages. |
|
196 | + * |
|
197 | + * @since 2.0.0 |
|
198 | + * @param string $footer_text |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function admin_footer_text( $footer_text ) { |
|
202 | + global $current_screen; |
|
203 | 203 | |
204 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
204 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
205 | 205 | |
206 | 206 | if ( ! empty( $current_screen->post_type ) ) { |
207 | - $page = $current_screen->post_type; |
|
207 | + $page = $current_screen->post_type; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | // General styles. |
211 | 211 | if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
212 | 212 | |
213 | - // Change the footer text |
|
214 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
215 | - |
|
216 | - $rating_url = esc_url( |
|
217 | - wp_nonce_url( |
|
218 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
219 | - 'getpaid-nonce', |
|
220 | - 'getpaid-nonce' |
|
221 | - ) |
|
222 | - ); |
|
223 | - |
|
224 | - $footer_text = sprintf( |
|
225 | - /* translators: %s: five stars */ |
|
226 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
227 | - "<a href='$rating_url'>★★★★★</a>" |
|
228 | - ); |
|
229 | - |
|
230 | - } else { |
|
231 | - |
|
232 | - $footer_text = sprintf( |
|
233 | - /* translators: %s: GetPaid */ |
|
234 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
235 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
236 | - ); |
|
237 | - |
|
238 | - } |
|
239 | - |
|
240 | - } |
|
241 | - |
|
242 | - return $footer_text; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Redirects to wp.org to rate the plugin. |
|
247 | - * |
|
248 | - * @since 2.0.0 |
|
249 | - */ |
|
250 | - public function redirect_to_wordpress_rating_page() { |
|
251 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
252 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
253 | - exit; |
|
254 | - } |
|
213 | + // Change the footer text |
|
214 | + if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
215 | + |
|
216 | + $rating_url = esc_url( |
|
217 | + wp_nonce_url( |
|
218 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
219 | + 'getpaid-nonce', |
|
220 | + 'getpaid-nonce' |
|
221 | + ) |
|
222 | + ); |
|
223 | + |
|
224 | + $footer_text = sprintf( |
|
225 | + /* translators: %s: five stars */ |
|
226 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
227 | + "<a href='$rating_url'>★★★★★</a>" |
|
228 | + ); |
|
229 | + |
|
230 | + } else { |
|
231 | + |
|
232 | + $footer_text = sprintf( |
|
233 | + /* translators: %s: GetPaid */ |
|
234 | + __( 'Thank you for using %s!', 'invoicing' ), |
|
235 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
|
236 | + ); |
|
237 | + |
|
238 | + } |
|
239 | + |
|
240 | + } |
|
241 | + |
|
242 | + return $footer_text; |
|
243 | + } |
|
255 | 244 | |
256 | 245 | /** |
257 | - * Loads payment form js. |
|
258 | - * |
|
259 | - */ |
|
260 | - protected function load_payment_form_scripts() { |
|
246 | + * Redirects to wp.org to rate the plugin. |
|
247 | + * |
|
248 | + * @since 2.0.0 |
|
249 | + */ |
|
250 | + public function redirect_to_wordpress_rating_page() { |
|
251 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
252 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
253 | + exit; |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Loads payment form js. |
|
258 | + * |
|
259 | + */ |
|
260 | + protected function load_payment_form_scripts() { |
|
261 | 261 | global $post; |
262 | 262 | |
263 | 263 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
264 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
265 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
264 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
265 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
266 | 266 | |
267 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
268 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
267 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
268 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
269 | 269 | |
270 | - wp_localize_script( |
|
270 | + wp_localize_script( |
|
271 | 271 | 'wpinv-admin-payment-form-script', |
272 | 272 | 'wpinvPaymentFormAdmin', |
273 | 273 | array( |
274 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
275 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
276 | - 'currency' => wpinv_currency_symbol(), |
|
277 | - 'position' => wpinv_currency_position(), |
|
278 | - 'decimals' => (int) wpinv_decimals(), |
|
279 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
280 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
281 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
282 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
274 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
275 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
276 | + 'currency' => wpinv_currency_symbol(), |
|
277 | + 'position' => wpinv_currency_position(), |
|
278 | + 'decimals' => (int) wpinv_decimals(), |
|
279 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
280 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
281 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
282 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
283 | 283 | ) |
284 | 284 | ); |
285 | 285 | |
@@ -288,20 +288,20 @@ discard block |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | - * Add our classes to admin pages. |
|
291 | + * Add our classes to admin pages. |
|
292 | 292 | * |
293 | 293 | * @param string $classes |
294 | 294 | * @return string |
295 | - * |
|
296 | - */ |
|
295 | + * |
|
296 | + */ |
|
297 | 297 | public function admin_body_class( $classes ) { |
298 | - global $pagenow, $post, $current_screen; |
|
298 | + global $pagenow, $post, $current_screen; |
|
299 | 299 | |
300 | 300 | |
301 | 301 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
302 | 302 | |
303 | 303 | if ( ! empty( $current_screen->post_type ) ) { |
304 | - $page = $current_screen->post_type; |
|
304 | + $page = $current_screen->post_type; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -310,59 +310,59 @@ discard block |
||
310 | 310 | |
311 | 311 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
312 | 312 | $classes .= ' wpinv-cpt wpinv'; |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
315 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
316 | 316 | $classes .= ' getpaid-is-invoice-cpt'; |
317 | 317 | } |
318 | 318 | |
319 | - return $classes; |
|
319 | + return $classes; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
323 | - * Maybe show the AyeCode Connect Notice. |
|
324 | - */ |
|
325 | - public function init_ayecode_connect_helper(){ |
|
323 | + * Maybe show the AyeCode Connect Notice. |
|
324 | + */ |
|
325 | + public function init_ayecode_connect_helper(){ |
|
326 | 326 | |
327 | 327 | new AyeCode_Connect_Helper( |
328 | 328 | array( |
329 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
330 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
331 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
332 | - 'connect_button' => __("Connect Site","invoicing"), |
|
333 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
334 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
335 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
329 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
330 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
331 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
332 | + 'connect_button' => __("Connect Site","invoicing"), |
|
333 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
334 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
335 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
336 | 336 | ), |
337 | 337 | array( 'wpi-addons' ) |
338 | 338 | ); |
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | - /** |
|
343 | - * Redirect users to settings on activation. |
|
344 | - * |
|
345 | - * @return void |
|
346 | - */ |
|
347 | - public function activation_redirect() { |
|
342 | + /** |
|
343 | + * Redirect users to settings on activation. |
|
344 | + * |
|
345 | + * @return void |
|
346 | + */ |
|
347 | + public function activation_redirect() { |
|
348 | 348 | |
349 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
349 | + $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
350 | 350 | |
351 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
352 | - return; |
|
353 | - } |
|
351 | + if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
352 | + return; |
|
353 | + } |
|
354 | 354 | |
355 | - // Bail if activating from network, or bulk |
|
356 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
357 | - return; |
|
358 | - } |
|
355 | + // Bail if activating from network, or bulk |
|
356 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
357 | + return; |
|
358 | + } |
|
359 | 359 | |
360 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
360 | + update_option( 'wpinv_redirected_to_settings', 1 ); |
|
361 | 361 | |
362 | 362 | wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
363 | 363 | exit; |
364 | 364 | |
365 | - } |
|
365 | + } |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Fires an admin action after verifying that a user can fire them. |
@@ -376,192 +376,192 @@ discard block |
||
376 | 376 | |
377 | 377 | } |
378 | 378 | |
379 | - /** |
|
379 | + /** |
|
380 | 380 | * Sends a payment reminder to a customer. |
381 | - * |
|
382 | - * @param array $args |
|
381 | + * |
|
382 | + * @param array $args |
|
383 | 383 | */ |
384 | 384 | public function send_customer_invoice( $args ) { |
385 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
385 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
386 | 386 | |
387 | - if ( $sent ) { |
|
388 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
389 | - } else { |
|
390 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
391 | - } |
|
387 | + if ( $sent ) { |
|
388 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
389 | + } else { |
|
390 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
391 | + } |
|
392 | 392 | |
393 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
394 | - exit; |
|
395 | - } |
|
393 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
394 | + exit; |
|
395 | + } |
|
396 | 396 | |
397 | - /** |
|
397 | + /** |
|
398 | 398 | * Sends a payment reminder to a customer. |
399 | - * |
|
400 | - * @param array $args |
|
399 | + * |
|
400 | + * @param array $args |
|
401 | 401 | */ |
402 | 402 | public function send_customer_payment_reminder( $args ) { |
403 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
403 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
404 | 404 | |
405 | - if ( $sent ) { |
|
406 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
407 | - } else { |
|
408 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
409 | - } |
|
405 | + if ( $sent ) { |
|
406 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
407 | + } else { |
|
408 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
409 | + } |
|
410 | 410 | |
411 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
412 | - exit; |
|
413 | - } |
|
411 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
412 | + exit; |
|
413 | + } |
|
414 | 414 | |
415 | - /** |
|
415 | + /** |
|
416 | 416 | * Resets tax rates. |
417 | - * |
|
417 | + * |
|
418 | 418 | */ |
419 | 419 | public function admin_reset_tax_rates() { |
420 | 420 | |
421 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
422 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
423 | - exit; |
|
421 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
422 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
423 | + exit; |
|
424 | 424 | |
425 | - } |
|
425 | + } |
|
426 | 426 | |
427 | - /** |
|
427 | + /** |
|
428 | 428 | * Resets admin pages. |
429 | - * |
|
429 | + * |
|
430 | 430 | */ |
431 | 431 | public function admin_create_missing_pages() { |
432 | - $installer = new GetPaid_Installer(); |
|
433 | - $installer->create_pages(); |
|
434 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
435 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
436 | - exit; |
|
437 | - } |
|
432 | + $installer = new GetPaid_Installer(); |
|
433 | + $installer->create_pages(); |
|
434 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
435 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
436 | + exit; |
|
437 | + } |
|
438 | 438 | |
439 | 439 | /** |
440 | - * Returns an array of admin notices. |
|
441 | - * |
|
442 | - * @since 1.0.19 |
|
440 | + * Returns an array of admin notices. |
|
441 | + * |
|
442 | + * @since 1.0.19 |
|
443 | 443 | * @return array |
444 | - */ |
|
445 | - public function get_notices() { |
|
446 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
444 | + */ |
|
445 | + public function get_notices() { |
|
446 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
447 | 447 | return is_array( $notices ) ? $notices : array(); |
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Clears all admin notices |
|
452 | - * |
|
453 | - * @access public |
|
454 | - * @since 1.0.19 |
|
455 | - */ |
|
456 | - public function clear_notices() { |
|
457 | - delete_option( 'wpinv_admin_notices' ); |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Saves a new admin notice |
|
462 | - * |
|
463 | - * @access public |
|
464 | - * @since 1.0.19 |
|
465 | - */ |
|
466 | - public function save_notice( $type, $message ) { |
|
467 | - $notices = $this->get_notices(); |
|
468 | - |
|
469 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
470 | - $notices[ $type ] = array(); |
|
471 | - } |
|
472 | - |
|
473 | - $notices[ $type ][] = $message; |
|
474 | - |
|
475 | - update_option( 'wpinv_admin_notices', $notices ); |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Displays a success notice |
|
480 | - * |
|
481 | - * @param string $msg The message to qeue. |
|
482 | - * @access public |
|
483 | - * @since 1.0.19 |
|
484 | - */ |
|
485 | - public function show_success( $msg ) { |
|
486 | - $this->save_notice( 'success', $msg ); |
|
487 | - } |
|
488 | - |
|
489 | - /** |
|
490 | - * Displays a error notice |
|
491 | - * |
|
492 | - * @access public |
|
493 | - * @param string $msg The message to qeue. |
|
494 | - * @since 1.0.19 |
|
495 | - */ |
|
496 | - public function show_error( $msg ) { |
|
497 | - $this->save_notice( 'error', $msg ); |
|
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * Displays a warning notice |
|
502 | - * |
|
503 | - * @access public |
|
504 | - * @param string $msg The message to qeue. |
|
505 | - * @since 1.0.19 |
|
506 | - */ |
|
507 | - public function show_warning( $msg ) { |
|
508 | - $this->save_notice( 'warning', $msg ); |
|
509 | - } |
|
510 | - |
|
511 | - /** |
|
512 | - * Displays a info notice |
|
513 | - * |
|
514 | - * @access public |
|
515 | - * @param string $msg The message to qeue. |
|
516 | - * @since 1.0.19 |
|
517 | - */ |
|
518 | - public function show_info( $msg ) { |
|
519 | - $this->save_notice( 'info', $msg ); |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Show notices |
|
524 | - * |
|
525 | - * @access public |
|
526 | - * @since 1.0.19 |
|
527 | - */ |
|
528 | - public function show_notices() { |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Clears all admin notices |
|
452 | + * |
|
453 | + * @access public |
|
454 | + * @since 1.0.19 |
|
455 | + */ |
|
456 | + public function clear_notices() { |
|
457 | + delete_option( 'wpinv_admin_notices' ); |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * Saves a new admin notice |
|
462 | + * |
|
463 | + * @access public |
|
464 | + * @since 1.0.19 |
|
465 | + */ |
|
466 | + public function save_notice( $type, $message ) { |
|
467 | + $notices = $this->get_notices(); |
|
468 | + |
|
469 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
470 | + $notices[ $type ] = array(); |
|
471 | + } |
|
472 | + |
|
473 | + $notices[ $type ][] = $message; |
|
474 | + |
|
475 | + update_option( 'wpinv_admin_notices', $notices ); |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Displays a success notice |
|
480 | + * |
|
481 | + * @param string $msg The message to qeue. |
|
482 | + * @access public |
|
483 | + * @since 1.0.19 |
|
484 | + */ |
|
485 | + public function show_success( $msg ) { |
|
486 | + $this->save_notice( 'success', $msg ); |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Displays a error notice |
|
491 | + * |
|
492 | + * @access public |
|
493 | + * @param string $msg The message to qeue. |
|
494 | + * @since 1.0.19 |
|
495 | + */ |
|
496 | + public function show_error( $msg ) { |
|
497 | + $this->save_notice( 'error', $msg ); |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * Displays a warning notice |
|
502 | + * |
|
503 | + * @access public |
|
504 | + * @param string $msg The message to qeue. |
|
505 | + * @since 1.0.19 |
|
506 | + */ |
|
507 | + public function show_warning( $msg ) { |
|
508 | + $this->save_notice( 'warning', $msg ); |
|
509 | + } |
|
510 | + |
|
511 | + /** |
|
512 | + * Displays a info notice |
|
513 | + * |
|
514 | + * @access public |
|
515 | + * @param string $msg The message to qeue. |
|
516 | + * @since 1.0.19 |
|
517 | + */ |
|
518 | + public function show_info( $msg ) { |
|
519 | + $this->save_notice( 'info', $msg ); |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Show notices |
|
524 | + * |
|
525 | + * @access public |
|
526 | + * @since 1.0.19 |
|
527 | + */ |
|
528 | + public function show_notices() { |
|
529 | 529 | |
530 | 530 | $notices = $this->get_notices(); |
531 | 531 | $this->clear_notices(); |
532 | 532 | |
533 | - foreach ( $notices as $type => $messages ) { |
|
533 | + foreach ( $notices as $type => $messages ) { |
|
534 | 534 | |
535 | - if ( ! is_array( $messages ) ) { |
|
536 | - continue; |
|
537 | - } |
|
535 | + if ( ! is_array( $messages ) ) { |
|
536 | + continue; |
|
537 | + } |
|
538 | 538 | |
539 | 539 | $type = sanitize_key( $type ); |
540 | - foreach ( $messages as $message ) { |
|
540 | + foreach ( $messages as $message ) { |
|
541 | 541 | $message = wp_kses_post( $message ); |
542 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
542 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | } |
546 | 546 | |
547 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
548 | - |
|
549 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
550 | - $url = esc_url( |
|
551 | - wp_nonce_url( |
|
552 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
553 | - 'getpaid-nonce', |
|
554 | - 'getpaid-nonce' |
|
555 | - ) |
|
556 | - ); |
|
557 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
558 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
559 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
560 | - break; |
|
561 | - } |
|
562 | - |
|
563 | - } |
|
564 | - |
|
565 | - } |
|
547 | + foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
548 | + |
|
549 | + if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
550 | + $url = esc_url( |
|
551 | + wp_nonce_url( |
|
552 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
553 | + 'getpaid-nonce', |
|
554 | + 'getpaid-nonce' |
|
555 | + ) |
|
556 | + ); |
|
557 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
558 | + $message2 = __( 'Generate Pages', 'invoicing' ); |
|
559 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
|
560 | + break; |
|
561 | + } |
|
562 | + |
|
563 | + } |
|
564 | + |
|
565 | + } |
|
566 | 566 | |
567 | 567 | } |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | |
20 | 20 | // Define constants. |
21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
26 | - define( 'WPINV_VERSION', '2.0.2' ); |
|
26 | + define( 'WPINV_VERSION', '2.0.2' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
46 | - return $GLOBALS['invoicing']; |
|
46 | + return $GLOBALS['invoicing']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |