@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a textarea in payment form |
| 4 | 4 | * |
@@ -7,26 +7,26 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | + $label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | + $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 16 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 15 | + if ( ! empty( $required ) ) { |
|
| 16 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -aui()->textarea( |
|
| 20 | - array( |
|
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $element_id ), |
|
| 23 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 25 | - 'label' => $label, |
|
| 26 | - 'label_type' => 'vertical', |
|
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | - 'class' => $label_class, |
|
| 29 | - 'value' => $query_value, |
|
| 30 | - ), |
|
| 31 | - true |
|
| 32 | -); |
|
| 19 | + aui()->textarea( |
|
| 20 | + array( |
|
| 21 | + 'name' => esc_attr( $id ), |
|
| 22 | + 'id' => esc_attr( $element_id ), |
|
| 23 | + 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | + 'required' => ! empty( $required ), |
|
| 25 | + 'label' => $label, |
|
| 26 | + 'label_type' => 'vertical', |
|
| 27 | + 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | + 'class' => $label_class, |
|
| 29 | + 'value' => $query_value, |
|
| 30 | + ), |
|
| 31 | + true |
|
| 32 | + ); |
|
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a select in payment form |
| 4 | 4 | * |
@@ -7,27 +7,27 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | + $label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | + $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 16 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 15 | + if ( ! empty( $required ) ) { |
|
| 16 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -aui()->select( |
|
| 20 | - array( |
|
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $element_id ), |
|
| 23 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | - 'required' => ! empty( $required ), |
|
| 25 | - 'label' => $label, |
|
| 26 | - 'label_type' => 'vertical', |
|
| 27 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | - 'options' => empty( $options ) ? array() : array_combine( $options, $options ), |
|
| 29 | - 'class' => $label_class, |
|
| 30 | - 'value' => $query_value, |
|
| 31 | - ), |
|
| 32 | - true |
|
| 33 | -); |
|
| 19 | + aui()->select( |
|
| 20 | + array( |
|
| 21 | + 'name' => esc_attr( $id ), |
|
| 22 | + 'id' => esc_attr( $element_id ), |
|
| 23 | + 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 24 | + 'required' => ! empty( $required ), |
|
| 25 | + 'label' => $label, |
|
| 26 | + 'label_type' => 'vertical', |
|
| 27 | + 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 28 | + 'options' => empty( $options ) ? array() : array_combine( $options, $options ), |
|
| 29 | + 'class' => $label_class, |
|
| 30 | + 'value' => $query_value, |
|
| 31 | + ), |
|
| 32 | + true |
|
| 33 | + ); |
|
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a heading in payment form |
| 4 | 4 | * |
@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$heading_tag = isset( $element['level'] ) ? trim( sanitize_key( $element['level'] ) ) : 'h3'; |
|
| 13 | -$text = isset( $element['text'] ) ? trim( $element['text'] ) : ''; |
|
| 12 | + $heading_tag = isset( $element['level'] ) ? trim( sanitize_key( $element['level'] ) ) : 'h3'; |
|
| 13 | + $text = isset( $element['text'] ) ? trim( $element['text'] ) : ''; |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $text ) ) { |
|
| 16 | - echo wp_kses_post( "<$heading_tag>$text</$heading_tag>" ); |
|
| 15 | + if ( ! empty( $text ) ) { |
|
| 16 | + echo wp_kses_post( "<$heading_tag>$text</$heading_tag>" ); |
|
| 17 | 17 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a payment button in payment form |
| 4 | 4 | * |
@@ -7,28 +7,28 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class ); |
|
| 13 | -$label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label ); |
|
| 14 | -$free = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free ); |
|
| 12 | + $class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class ); |
|
| 13 | + $label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label ); |
|
| 14 | + $free = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free ); |
|
| 15 | 15 | |
| 16 | -do_action( 'getpaid_before_payment_form_pay_button', $form ); |
|
| 16 | + do_action( 'getpaid_before_payment_form_pay_button', $form ); |
|
| 17 | 17 | |
| 18 | -aui()->input( |
|
| 19 | - array( |
|
| 20 | - 'name' => esc_attr( $id ), |
|
| 21 | - 'id' => esc_attr( $element_id ), |
|
| 22 | - 'value' => $label, |
|
| 23 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 24 | - 'type' => 'submit', |
|
| 25 | - 'class' => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class, |
|
| 26 | - 'extra_attributes' => array( |
|
| 27 | - 'data-free' => $free, |
|
| 28 | - 'data-pay' => $label, |
|
| 18 | + aui()->input( |
|
| 19 | + array( |
|
| 20 | + 'name' => esc_attr( $id ), |
|
| 21 | + 'id' => esc_attr( $element_id ), |
|
| 22 | + 'value' => $label, |
|
| 23 | + 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 24 | + 'type' => 'submit', |
|
| 25 | + 'class' => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class, |
|
| 26 | + 'extra_attributes' => array( |
|
| 27 | + 'data-free' => $free, |
|
| 28 | + 'data-pay' => $label, |
|
| 29 | + ), |
|
| 29 | 30 | ), |
| 30 | - ), |
|
| 31 | - true |
|
| 32 | -); |
|
| 31 | + true |
|
| 32 | + ); |
|
| 33 | 33 | |
| 34 | -do_action( 'getpaid_after_payment_form_pay_button', $form ); |
|
| 34 | + do_action( 'getpaid_after_payment_form_pay_button', $form ); |
|
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a total payable text in payment form |
| 4 | 4 | * |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -if ( empty( $text ) ) { |
|
| 13 | - $text = __( 'Total to pay:', 'invoicing' ); |
|
| 12 | + if ( empty( $text ) ) { |
|
| 13 | + $text = __( 'Total to pay:', 'invoicing' ); |
|
| 14 | 14 | } |
| 15 | -?> |
|
| 15 | + ?> |
|
| 16 | 16 | <div class="form-group mb-3 mt-4"> |
| 17 | 17 | <strong><?php echo esc_html( $text ); ?></strong> |
| 18 | 18 | <span class="getpaid-checkout-total-payable"></span> |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a file_upload input in a payment form |
| 4 | 4 | * |
@@ -7,37 +7,37 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | - |
|
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | -$id = esc_attr( $id ); |
|
| 15 | -$_id = $id . uniqid( '_' ); |
|
| 16 | -$max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num ); |
|
| 17 | -$file_types = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types; |
|
| 18 | -$all_types = getpaid_get_allowed_mime_types(); |
|
| 19 | -$types = array(); |
|
| 20 | -$_types = array(); |
|
| 21 | - |
|
| 22 | -foreach ( $file_types as $file_type ) { |
|
| 23 | - |
|
| 24 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | - $types[] = $all_types[ $file_type ]; |
|
| 26 | - $file_type = explode( '|', $file_type ); |
|
| 27 | - |
|
| 28 | - foreach ( $file_type as $type ) { |
|
| 29 | - $type = trim( $type ); |
|
| 30 | - $types[] = ".$type"; |
|
| 31 | - $_types[] = $type; |
|
| 32 | - } |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | + |
|
| 12 | + $label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | + $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | + $id = esc_attr( $id ); |
|
| 15 | + $_id = $id . uniqid( '_' ); |
|
| 16 | + $max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num ); |
|
| 17 | + $file_types = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types; |
|
| 18 | + $all_types = getpaid_get_allowed_mime_types(); |
|
| 19 | + $types = array(); |
|
| 20 | + $_types = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $file_types as $file_type ) { |
|
| 23 | + |
|
| 24 | + if ( isset( $all_types[ $file_type ] ) ) { |
|
| 25 | + $types[] = $all_types[ $file_type ]; |
|
| 26 | + $file_type = explode( '|', $file_type ); |
|
| 27 | + |
|
| 28 | + foreach ( $file_type as $type ) { |
|
| 29 | + $type = trim( $type ); |
|
| 30 | + $types[] = ".$type"; |
|
| 31 | + $_types[] = $type; |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -if ( ! empty( $required ) ) { |
|
| 37 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 36 | + if ( ! empty( $required ) ) { |
|
| 37 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -?> |
|
| 40 | + ?> |
|
| 41 | 41 | |
| 42 | 42 | <label><span v-html="form_element.label"></span></label> |
| 43 | 43 | |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | <label for="<?php echo esc_attr( $id ); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2"> |
| 49 | 49 | <div class="h5 text-dark"> |
| 50 | 50 | <?php echo esc_html( _n( 'Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing' ) ); ?> |
| 51 | - </div> |
|
| 51 | + </div> |
|
| 52 | 52 | <?php if ( ! empty( $description ) ) : ?> |
| 53 | - <small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small> |
|
| 53 | + <small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small> |
|
| 54 | 54 | <?php endif; ?> |
| 55 | 55 | </label> |
| 56 | 56 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays an address field in payment form |
| 4 | 4 | * |
@@ -12,188 +12,188 @@ discard block |
||
| 12 | 12 | * @var GetPaid_Payment_Form $form |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -defined( 'ABSPATH' ) || exit; |
|
| 15 | + defined( 'ABSPATH' ) || exit; |
|
| 16 | 16 | |
| 17 | -$field_type = sanitize_key( $field_type ); |
|
| 17 | + $field_type = sanitize_key( $field_type ); |
|
| 18 | 18 | |
| 19 | -echo "<div class='row " . esc_attr( $field_type ) . "'>"; |
|
| 19 | + echo "<div class='row " . esc_attr( $field_type ) . "'>"; |
|
| 20 | 20 | |
| 21 | -// Prepare current user. |
|
| 22 | -if ( ! empty( $form->invoice ) ) { |
|
| 23 | - $user_id = $form->invoice->get_user_id(); |
|
| 21 | + // Prepare current user. |
|
| 22 | + if ( ! empty( $form->invoice ) ) { |
|
| 23 | + $user_id = $form->invoice->get_user_id(); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -if ( empty( $user_id ) && is_user_logged_in() ) { |
|
| 27 | - $user_id = get_current_user_id(); |
|
| 26 | + if ( empty( $user_id ) && is_user_logged_in() ) { |
|
| 27 | + $user_id = get_current_user_id(); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -if ( ! empty( $user_id ) ) { |
|
| 31 | - $user = wp_get_current_user(); |
|
| 30 | + if ( ! empty( $user_id ) ) { |
|
| 31 | + $user = wp_get_current_user(); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -foreach ( $fields as $address_field ) { |
|
| 35 | - |
|
| 36 | - // Skip if it is hidden. |
|
| 37 | - if ( empty( $address_field['visible'] ) ) { |
|
| 38 | - continue; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
| 42 | - |
|
| 43 | - // Prepare variables. |
|
| 44 | - $field_name = $address_field['name']; |
|
| 45 | - $field_name = "{$field_type}[$field_name]"; |
|
| 46 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
| 47 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
| 48 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
| 49 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
| 50 | - $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; |
|
| 51 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
| 52 | - |
|
| 53 | - $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 54 | - if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) { |
|
| 55 | - $value = call_user_func( array( $form->invoice, $method_name ) ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if ( empty( $value ) && 'wpinv_first_name' === $address_field['name'] && ! empty( $user ) ) { |
|
| 59 | - $value = $user->first_name; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ( empty( $value ) && 'wpinv_last_name' === $address_field['name'] && ! empty( $user ) ) { |
|
| 63 | - $value = $user->last_name; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 67 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Display the country. |
|
| 71 | - if ( 'wpinv_country' === $address_field['name'] ) { |
|
| 72 | - |
|
| 73 | - echo "<div class='form-group mb-3 " . esc_attr( $wrap_class ) . " getpaid-address-field-wrapper__country'"; |
|
| 74 | - |
|
| 75 | - aui()->select( |
|
| 76 | - array( |
|
| 77 | - 'options' => wpinv_get_country_list(), |
|
| 78 | - 'name' => esc_attr( $field_name ), |
|
| 79 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 80 | - 'value' => esc_attr( $country ), |
|
| 81 | - 'placeholder' => $placeholder, |
|
| 82 | - 'required' => ! empty( $address_field['required'] ), |
|
| 83 | - 'label' => wp_kses_post( $label ), |
|
| 84 | - 'label_type' => 'vertical', |
|
| 85 | - 'help_text' => $description, |
|
| 86 | - 'class' => 'getpaid-address-field wpinv_country', |
|
| 87 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__country', |
|
| 88 | - 'extra_attributes' => array( |
|
| 89 | - 'autocomplete' => "$field_type country", |
|
| 90 | - 'data-ip-country' => getpaid_get_ip_country(), |
|
| 91 | - ), |
|
| 92 | - 'no_wrap' => true, |
|
| 93 | - ), |
|
| 94 | - true |
|
| 95 | - ); |
|
| 34 | + foreach ( $fields as $address_field ) { |
|
| 96 | 35 | |
| 97 | - if ( wpinv_should_validate_vat_number() ) { |
|
| 36 | + // Skip if it is hidden. |
|
| 37 | + if ( empty( $address_field['visible'] ) ) { |
|
| 38 | + continue; |
|
| 39 | + } |
|
| 98 | 40 | |
| 99 | - aui()->input( |
|
| 41 | + do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
| 42 | + |
|
| 43 | + // Prepare variables. |
|
| 44 | + $field_name = $address_field['name']; |
|
| 45 | + $field_name = "{$field_type}[$field_name]"; |
|
| 46 | + $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
| 47 | + $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
| 48 | + $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
| 49 | + $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
| 50 | + $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; |
|
| 51 | + $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
| 52 | + |
|
| 53 | + $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 54 | + if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) { |
|
| 55 | + $value = call_user_func( array( $form->invoice, $method_name ) ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if ( empty( $value ) && 'wpinv_first_name' === $address_field['name'] && ! empty( $user ) ) { |
|
| 59 | + $value = $user->first_name; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ( empty( $value ) && 'wpinv_last_name' === $address_field['name'] && ! empty( $user ) ) { |
|
| 63 | + $value = $user->last_name; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ( ! empty( $address_field['required'] ) ) { |
|
| 67 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Display the country. |
|
| 71 | + if ( 'wpinv_country' === $address_field['name'] ) { |
|
| 72 | + |
|
| 73 | + echo "<div class='form-group mb-3 " . esc_attr( $wrap_class ) . " getpaid-address-field-wrapper__country'"; |
|
| 74 | + |
|
| 75 | + aui()->select( |
|
| 100 | 76 | array( |
| 101 | - 'type' => 'checkbox', |
|
| 102 | - 'name' => 'confirm-address', |
|
| 103 | - 'id' => "shipping-toggle$uniqid", |
|
| 104 | - 'wrap_class' => 'getpaid-address-field-wrapper__address-confirm mt-1 d-none', |
|
| 105 | - 'required' => false, |
|
| 106 | - 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", |
|
| 107 | - 'value' => 1, |
|
| 108 | - 'checked' => true, |
|
| 109 | - 'class' => 'w-auto', |
|
| 77 | + 'options' => wpinv_get_country_list(), |
|
| 78 | + 'name' => esc_attr( $field_name ), |
|
| 79 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 80 | + 'value' => esc_attr( $country ), |
|
| 81 | + 'placeholder' => $placeholder, |
|
| 82 | + 'required' => ! empty( $address_field['required'] ), |
|
| 83 | + 'label' => wp_kses_post( $label ), |
|
| 84 | + 'label_type' => 'vertical', |
|
| 85 | + 'help_text' => $description, |
|
| 86 | + 'class' => 'getpaid-address-field wpinv_country', |
|
| 87 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__country', |
|
| 88 | + 'extra_attributes' => array( |
|
| 89 | + 'autocomplete' => "$field_type country", |
|
| 90 | + 'data-ip-country' => getpaid_get_ip_country(), |
|
| 91 | + ), |
|
| 92 | + 'no_wrap' => true, |
|
| 110 | 93 | ), |
| 111 | 94 | true |
| 112 | 95 | ); |
| 113 | 96 | |
| 114 | - } |
|
| 97 | + if ( wpinv_should_validate_vat_number() ) { |
|
| 115 | 98 | |
| 116 | - echo '</div>'; |
|
| 99 | + aui()->input( |
|
| 100 | + array( |
|
| 101 | + 'type' => 'checkbox', |
|
| 102 | + 'name' => 'confirm-address', |
|
| 103 | + 'id' => "shipping-toggle$uniqid", |
|
| 104 | + 'wrap_class' => 'getpaid-address-field-wrapper__address-confirm mt-1 d-none', |
|
| 105 | + 'required' => false, |
|
| 106 | + 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", |
|
| 107 | + 'value' => 1, |
|
| 108 | + 'checked' => true, |
|
| 109 | + 'class' => 'w-auto', |
|
| 110 | + ), |
|
| 111 | + true |
|
| 112 | + ); |
|
| 117 | 113 | |
| 118 | - } |
|
| 114 | + } |
|
| 119 | 115 | |
| 120 | - // Display the state. |
|
| 121 | - elseif ( 'wpinv_state' == $address_field['name'] ) { |
|
| 116 | + echo '</div>'; |
|
| 122 | 117 | |
| 123 | - if ( empty( $value ) ) { |
|
| 124 | - $value = wpinv_get_default_state(); |
|
| 125 | 118 | } |
| 126 | 119 | |
| 127 | - getpaid_get_states_select_markup( |
|
| 128 | - $country, |
|
| 129 | - $value, |
|
| 130 | - $placeholder, |
|
| 131 | - $label, |
|
| 132 | - $description, |
|
| 133 | - ! empty( $address_field['required'] ), |
|
| 134 | - $wrap_class, |
|
| 135 | - $field_name, |
|
| 136 | - true |
|
| 137 | - ); |
|
| 138 | - |
|
| 139 | - } else { |
|
| 140 | - |
|
| 141 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 142 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
| 143 | - $autocomplete = ''; |
|
| 144 | - $replacements = array( |
|
| 145 | - 'zip' => 'postal-code', |
|
| 146 | - 'first-name' => 'given-name', |
|
| 147 | - 'last-name' => 'family-name', |
|
| 148 | - 'company' => 'organization', |
|
| 149 | - 'address' => 'street-address', |
|
| 150 | - 'phone' => 'tel', |
|
| 151 | - 'city' => 'address-level2', |
|
| 152 | - ); |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - if ( isset( $replacements[ $key ] ) ) { |
|
| 156 | - $autocomplete = array( |
|
| 157 | - 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
| 120 | + // Display the state. |
|
| 121 | + elseif ( 'wpinv_state' == $address_field['name'] ) { |
|
| 122 | + |
|
| 123 | + if ( empty( $value ) ) { |
|
| 124 | + $value = wpinv_get_default_state(); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + getpaid_get_states_select_markup( |
|
| 128 | + $country, |
|
| 129 | + $value, |
|
| 130 | + $placeholder, |
|
| 131 | + $label, |
|
| 132 | + $description, |
|
| 133 | + ! empty( $address_field['required'] ), |
|
| 134 | + $wrap_class, |
|
| 135 | + $field_name, |
|
| 136 | + true |
|
| 158 | 137 | ); |
| 159 | - } |
|
| 160 | 138 | |
| 161 | - $append = ''; |
|
| 139 | + } else { |
|
| 140 | + |
|
| 141 | + $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 142 | + $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
| 143 | + $autocomplete = ''; |
|
| 144 | + $replacements = array( |
|
| 145 | + 'zip' => 'postal-code', |
|
| 146 | + 'first-name' => 'given-name', |
|
| 147 | + 'last-name' => 'family-name', |
|
| 148 | + 'company' => 'organization', |
|
| 149 | + 'address' => 'street-address', |
|
| 150 | + 'phone' => 'tel', |
|
| 151 | + 'city' => 'address-level2', |
|
| 152 | + ); |
|
| 162 | 153 | |
| 163 | - if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { |
|
| 164 | - $valid = esc_attr__( 'Valid', 'invoicing' ); |
|
| 165 | - $invalid = esc_attr__( 'Invalid', 'invoicing' ); |
|
| 166 | - $validate = esc_attr__( 'Validate', 'invoicing' ); |
|
| 167 | - $append = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; |
|
| 168 | - } |
|
| 169 | 154 | |
| 170 | - if ( 'billing' === $field_type ) { |
|
| 171 | - $description .= '<div class="getpaid-error-' . esc_attr( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
| 155 | + if ( isset( $replacements[ $key ] ) ) { |
|
| 156 | + $autocomplete = array( |
|
| 157 | + 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
| 158 | + ); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $append = ''; |
|
| 162 | + |
|
| 163 | + if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { |
|
| 164 | + $valid = esc_attr__( 'Valid', 'invoicing' ); |
|
| 165 | + $invalid = esc_attr__( 'Invalid', 'invoicing' ); |
|
| 166 | + $validate = esc_attr__( 'Validate', 'invoicing' ); |
|
| 167 | + $append = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ( 'billing' === $field_type ) { |
|
| 171 | + $description .= '<div class="getpaid-error-' . esc_attr( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + aui()->input( |
|
| 175 | + array( |
|
| 176 | + 'name' => esc_attr( $field_name ), |
|
| 177 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 178 | + 'required' => ! empty( $address_field['required'] ), |
|
| 179 | + 'placeholder' => $placeholder, |
|
| 180 | + 'label' => wp_kses_post( $label ), |
|
| 181 | + 'label_type' => 'vertical', |
|
| 182 | + 'help_text' => $description, |
|
| 183 | + 'type' => 'text', |
|
| 184 | + 'value' => apply_filters( 'getpaid_payment_form_value_' . $address_field['name'], esc_attr( $value ) ), |
|
| 185 | + 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
| 186 | + 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
|
| 187 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
|
| 188 | + 'extra_attributes' => $autocomplete, |
|
| 189 | + 'input_group_right' => $append, |
|
| 190 | + ), |
|
| 191 | + true |
|
| 192 | + ); |
|
| 193 | + |
|
| 172 | 194 | } |
| 173 | 195 | |
| 174 | - aui()->input( |
|
| 175 | - array( |
|
| 176 | - 'name' => esc_attr( $field_name ), |
|
| 177 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 178 | - 'required' => ! empty( $address_field['required'] ), |
|
| 179 | - 'placeholder' => $placeholder, |
|
| 180 | - 'label' => wp_kses_post( $label ), |
|
| 181 | - 'label_type' => 'vertical', |
|
| 182 | - 'help_text' => $description, |
|
| 183 | - 'type' => 'text', |
|
| 184 | - 'value' => apply_filters( 'getpaid_payment_form_value_' . $address_field['name'], esc_attr( $value ) ), |
|
| 185 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
| 186 | - 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
|
| 187 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
|
| 188 | - 'extra_attributes' => $autocomplete, |
|
| 189 | - 'input_group_right' => $append, |
|
| 190 | - ), |
|
| 191 | - true |
|
| 192 | - ); |
|
| 193 | - |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
| 196 | + do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | -echo '</div>'; |
|
| 199 | + echo '</div>'; |
|
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a date input in payment form |
| 4 | 4 | * |
@@ -7,64 +7,64 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | -if ( ! empty( $required ) ) { |
|
| 15 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 12 | + $label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | + $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | + if ( ! empty( $required ) ) { |
|
| 15 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -$disable_dates = array(); |
|
| 18 | + $disable_dates = array(); |
|
| 19 | 19 | |
| 20 | -if ( ! empty( $disabled_dates ) ) { |
|
| 21 | - $disabled_dates = preg_replace( '/\s+/', '', $disabled_dates ); |
|
| 22 | - $disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates ); |
|
| 23 | - $disabled_dates = array_filter( explode( ',', $disabled_dates ) ); |
|
| 20 | + if ( ! empty( $disabled_dates ) ) { |
|
| 21 | + $disabled_dates = preg_replace( '/\s+/', '', $disabled_dates ); |
|
| 22 | + $disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates ); |
|
| 23 | + $disabled_dates = array_filter( explode( ',', $disabled_dates ) ); |
|
| 24 | 24 | |
| 25 | - foreach ( $disabled_dates as $disabled_date ) { |
|
| 25 | + foreach ( $disabled_dates as $disabled_date ) { |
|
| 26 | 26 | |
| 27 | - $disabled_date = trim( $disabled_date ); |
|
| 27 | + $disabled_date = trim( $disabled_date ); |
|
| 28 | 28 | |
| 29 | - if ( false === strpos( $disabled_date, '|' ) ) { |
|
| 30 | - $disable_dates[] = $disabled_date; |
|
| 31 | - continue; |
|
| 32 | - } |
|
| 29 | + if ( false === strpos( $disabled_date, '|' ) ) { |
|
| 30 | + $disable_dates[] = $disabled_date; |
|
| 31 | + continue; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - $disabled_date = explode( '|', $disabled_date ); |
|
| 35 | - $disable_dates[] = array( |
|
| 36 | - 'from' => trim( $disabled_date[0] ), |
|
| 37 | - 'to' => trim( $disabled_date[1] ), |
|
| 38 | - ); |
|
| 34 | + $disabled_date = explode( '|', $disabled_date ); |
|
| 35 | + $disable_dates[] = array( |
|
| 36 | + 'from' => trim( $disabled_date[0] ), |
|
| 37 | + 'to' => trim( $disabled_date[1] ), |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -$options = array( |
|
| 44 | - 'data-default-date' => empty( $default_date ) ? false : $default_date, |
|
| 45 | - 'data-min-date' => empty( $min_date ) ? false : $min_date, |
|
| 46 | - 'data-max-date' => empty( $max_date ) ? false : $max_date, |
|
| 47 | - 'data-mode' => empty( $mode ) ? 'single' : $mode, |
|
| 48 | - 'data-alt-format' => get_option( 'date_format', 'F j, Y' ), |
|
| 49 | - 'data-date-format' => 'Y-m-d', |
|
| 50 | - 'data-alt-input' => 'true', |
|
| 51 | - 'data-disable_alt' => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ), |
|
| 52 | - 'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ), |
|
| 53 | -); |
|
| 43 | + $options = array( |
|
| 44 | + 'data-default-date' => empty( $default_date ) ? false : $default_date, |
|
| 45 | + 'data-min-date' => empty( $min_date ) ? false : $min_date, |
|
| 46 | + 'data-max-date' => empty( $max_date ) ? false : $max_date, |
|
| 47 | + 'data-mode' => empty( $mode ) ? 'single' : $mode, |
|
| 48 | + 'data-alt-format' => get_option( 'date_format', 'F j, Y' ), |
|
| 49 | + 'data-date-format' => 'Y-m-d', |
|
| 50 | + 'data-alt-input' => 'true', |
|
| 51 | + 'data-disable_alt' => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ), |
|
| 52 | + 'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ), |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | -aui()->input( |
|
| 56 | - array( |
|
| 57 | - 'name' => esc_attr( $id ), |
|
| 58 | - 'id' => esc_attr( $element_id ), |
|
| 59 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 60 | - 'required' => ! empty( $required ), |
|
| 61 | - 'label' => $label, |
|
| 62 | - 'label_type' => 'vertical', |
|
| 63 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 64 | - 'type' => 'datepicker', |
|
| 65 | - 'class' => $label_class . ' getpaid-init-flatpickr flatpickr-input', |
|
| 66 | - 'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ), |
|
| 67 | - 'value' => $query_value, |
|
| 68 | - ), |
|
| 69 | - true |
|
| 70 | -); |
|
| 55 | + aui()->input( |
|
| 56 | + array( |
|
| 57 | + 'name' => esc_attr( $id ), |
|
| 58 | + 'id' => esc_attr( $element_id ), |
|
| 59 | + 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 60 | + 'required' => ! empty( $required ), |
|
| 61 | + 'label' => $label, |
|
| 62 | + 'label_type' => 'vertical', |
|
| 63 | + 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 64 | + 'type' => 'datepicker', |
|
| 65 | + 'class' => $label_class . ' getpaid-init-flatpickr flatpickr-input', |
|
| 66 | + 'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ), |
|
| 67 | + 'value' => $query_value, |
|
| 68 | + ), |
|
| 69 | + true |
|
| 70 | + ); |
|
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php |
|
| 1 | + <?php |
|
| 2 | 2 | /** |
| 3 | 3 | * Displays a website input in payment form |
| 4 | 4 | * |
@@ -7,28 +7,28 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | + defined( 'ABSPATH' ) || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 12 | + $label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 13 | + $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
| 14 | 14 | |
| 15 | -if ( ! empty( $required ) ) { |
|
| 16 | - $label .= "<span class='text-danger'> *</span>"; |
|
| 15 | + if ( ! empty( $required ) ) { |
|
| 16 | + $label .= "<span class='text-danger'> *</span>"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -$current_url = ! empty( $_GET['current_url'] ) ? esc_url_raw( urldecode( $_GET['current_url'] ) ) : get_permalink(); |
|
| 20 | -aui()->input( |
|
| 21 | - array( |
|
| 22 | - 'name' => esc_attr( $id ), |
|
| 23 | - 'id' => esc_attr( $element_id ), |
|
| 24 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 25 | - 'required' => ! empty( $required ), |
|
| 26 | - 'label' => $label, |
|
| 27 | - 'label_type' => 'vertical', |
|
| 28 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 29 | - 'type' => 'url', |
|
| 30 | - 'value' => ! empty( $default_current_post ) ? $current_url : $query_value, |
|
| 31 | - 'class' => $label_class, |
|
| 32 | - ), |
|
| 33 | - true |
|
| 34 | -); |
|
| 19 | + $current_url = ! empty( $_GET['current_url'] ) ? esc_url_raw( urldecode( $_GET['current_url'] ) ) : get_permalink(); |
|
| 20 | + aui()->input( |
|
| 21 | + array( |
|
| 22 | + 'name' => esc_attr( $id ), |
|
| 23 | + 'id' => esc_attr( $element_id ), |
|
| 24 | + 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 25 | + 'required' => ! empty( $required ), |
|
| 26 | + 'label' => $label, |
|
| 27 | + 'label_type' => 'vertical', |
|
| 28 | + 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 29 | + 'type' => 'url', |
|
| 30 | + 'value' => ! empty( $default_current_post ) ? $current_url : $query_value, |
|
| 31 | + 'class' => $label_class, |
|
| 32 | + ), |
|
| 33 | + true |
|
| 34 | + ); |
|