| @@ -12,62 +12,62 @@ 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 | 19 | echo "<div class='row $field_type'>"; | 
| 20 | 20 | |
| 21 | -foreach ( $fields as $address_field ) { | |
| 21 | +foreach ($fields as $address_field) { | |
| 22 | 22 | |
| 23 | 23 | // Skip if it is hidden. | 
| 24 | -    if ( empty( $address_field['visible'] ) ) { | |
| 24 | +    if (empty($address_field['visible'])) { | |
| 25 | 25 | continue; | 
| 26 | 26 | } | 
| 27 | 27 | |
| 28 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); | |
| 28 | +    do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field); | |
| 29 | 29 | |
| 30 | 30 | // Prepare variables. | 
| 31 | -    if ( ! empty( $form->invoice ) ) { | |
| 31 | +    if (!empty($form->invoice)) { | |
| 32 | 32 | $user_id = $form->invoice->get_user_id(); | 
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | -    if ( empty( $user_id ) && is_user_logged_in() ) { | |
| 35 | +    if (empty($user_id) && is_user_logged_in()) { | |
| 36 | 36 | $user_id = get_current_user_id(); | 
| 37 | 37 | } | 
| 38 | 38 | |
| 39 | 39 | $field_name = $address_field['name']; | 
| 40 | 40 |      $field_name  = "{$field_type}[$field_name]"; | 
| 41 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); | |
| 42 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); | |
| 43 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); | |
| 44 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); | |
| 45 | - $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; | |
| 46 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); | |
| 47 | - | |
| 48 | - $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] ); | |
| 49 | -    if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) { | |
| 50 | - $value = call_user_func( array( $form->invoice, $method_name ) ); | |
| 41 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); | |
| 42 | +    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper"); | |
| 43 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); | |
| 44 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); | |
| 45 | + $value = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : ''; | |
| 46 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); | |
| 47 | + | |
| 48 | +    $method_name = 'get_' . str_replace('wpinv_', '', $address_field['name']); | |
| 49 | +    if (!empty($form->invoice) && is_callable(array($form->invoice, $method_name))) { | |
| 50 | + $value = call_user_func(array($form->invoice, $method_name)); | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -    if ( ! empty( $address_field['required'] ) ) { | |
| 53 | +    if (!empty($address_field['required'])) { | |
| 54 | 54 | $label .= "<span class='text-danger'> *</span>"; | 
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | 57 | // Display the country. | 
| 58 | -    if ( 'wpinv_country' == $address_field['name'] ) { | |
| 58 | +    if ('wpinv_country' == $address_field['name']) { | |
| 59 | 59 | |
| 60 | 60 | echo "<div class='form-group $wrap_class getpaid-address-field-wrapper__country'"; | 
| 61 | 61 | |
| 62 | 62 | echo aui()->select( | 
| 63 | 63 | array( | 
| 64 | 64 | 'options' => wpinv_get_country_list(), | 
| 65 | - 'name' => esc_attr( $field_name ), | |
| 66 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, | |
| 67 | - 'value' => sanitize_text_field( $country ), | |
| 65 | + 'name' => esc_attr($field_name), | |
| 66 | + 'id' => sanitize_html_class($field_name) . $uniqid, | |
| 67 | + 'value' => sanitize_text_field($country), | |
| 68 | 68 | 'placeholder' => $placeholder, | 
| 69 | - 'required' => ! empty( $address_field['required'] ), | |
| 70 | - 'label' => wp_kses_post( $label ), | |
| 69 | + 'required' => !empty($address_field['required']), | |
| 70 | + 'label' => wp_kses_post($label), | |
| 71 | 71 | 'label_type' => 'vertical', | 
| 72 | 72 | 'help_text' => $description, | 
| 73 | 73 | 'class' => 'getpaid-address-field wpinv_country', | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | ) | 
| 81 | 81 | ); | 
| 82 | 82 | |
| 83 | -        if ( wpinv_should_validate_vat_number() ) { | |
| 83 | +        if (wpinv_should_validate_vat_number()) { | |
| 84 | 84 | |
| 85 | 85 | echo aui()->input( | 
| 86 | 86 | array( | 
| @@ -89,7 +89,7 @@ discard block | ||
| 89 | 89 | 'id' => "shipping-toggle$uniqid", | 
| 90 | 90 | 'wrap_class' => "getpaid-address-field-wrapper__address-confirm mt-1 d-none", | 
| 91 | 91 | 'required' => false, | 
| 92 | - 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", | |
| 92 | +                    'label'      => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>", | |
| 93 | 93 | 'value' => 1, | 
| 94 | 94 | 'checked' => true, | 
| 95 | 95 | 'class' => 'w-auto', | 
| @@ -103,27 +103,27 @@ discard block | ||
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | // Display the state. | 
| 106 | -    else if ( 'wpinv_state' == $address_field['name'] ) { | |
| 106 | +    else if ('wpinv_state' == $address_field['name']) { | |
| 107 | 107 | |
| 108 | -        if ( empty( $value ) ) { | |
| 108 | +        if (empty($value)) { | |
| 109 | 109 | $value = wpinv_get_default_state(); | 
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | - echo getpaid_get_states_select_markup ( | |
| 112 | + echo getpaid_get_states_select_markup( | |
| 113 | 113 | $country, | 
| 114 | 114 | $value, | 
| 115 | 115 | $placeholder, | 
| 116 | 116 | $label, | 
| 117 | 117 | $description, | 
| 118 | - ! empty( $address_field['required'] ), | |
| 118 | + !empty($address_field['required']), | |
| 119 | 119 | $wrap_class, | 
| 120 | 120 | $field_name | 
| 121 | 121 | ); | 
| 122 | 122 | |
| 123 | 123 |      } else { | 
| 124 | 124 | |
| 125 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); | |
| 126 | - $key = esc_attr( str_replace( '_', '-', $key ) ); | |
| 125 | +        $key      = str_replace('wpinv_', '', $address_field['name']); | |
| 126 | +        $key      = esc_attr(str_replace('_', '-', $key)); | |
| 127 | 127 | $autocomplete = ''; | 
| 128 | 128 | $replacements = array( | 
| 129 | 129 | 'zip' => 'postal-code', | 
| @@ -136,37 +136,37 @@ discard block | ||
| 136 | 136 | ); | 
| 137 | 137 | |
| 138 | 138 | |
| 139 | -        if ( isset( $replacements[ $key ] ) ) { | |
| 139 | +        if (isset($replacements[$key])) { | |
| 140 | 140 | $autocomplete = array( | 
| 141 | -                'autocomplete' => "$field_type {$replacements[ $key ]}", | |
| 141 | +                'autocomplete' => "$field_type {$replacements[$key]}", | |
| 142 | 142 | ); | 
| 143 | 143 | } | 
| 144 | 144 | |
| 145 | 145 | $append = ''; | 
| 146 | 146 | |
| 147 | -        if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { | |
| 148 | - $valid = esc_attr__( 'Valid', 'invoicing' ); | |
| 149 | - $invalid = esc_attr__( 'Invalid', 'invoicing' ); | |
| 150 | - $validate = esc_attr__( 'Validate', 'invoicing' ); | |
| 147 | +        if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) { | |
| 148 | +            $valid    = esc_attr__('Valid', 'invoicing'); | |
| 149 | +            $invalid  = esc_attr__('Invalid', 'invoicing'); | |
| 150 | +            $validate = esc_attr__('Validate', 'invoicing'); | |
| 151 | 151 | $append = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; | 
| 152 | 152 | } | 
| 153 | 153 | |
| 154 | -        if ( 'billing' === $field_type ) { | |
| 155 | - $description .= '<div class="getpaid-error-' . sanitize_html_class( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; | |
| 154 | +        if ('billing' === $field_type) { | |
| 155 | + $description .= '<div class="getpaid-error-' . sanitize_html_class($field_name) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; | |
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | 158 | echo aui()->input( | 
| 159 | 159 | array( | 
| 160 | - 'name' => esc_attr( $field_name ), | |
| 161 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, | |
| 162 | - 'required' => ! empty( $address_field['required'] ), | |
| 160 | + 'name' => esc_attr($field_name), | |
| 161 | + 'id' => sanitize_html_class($field_name) . $uniqid, | |
| 162 | + 'required' => !empty($address_field['required']), | |
| 163 | 163 | 'placeholder' => $placeholder, | 
| 164 | - 'label' => wp_kses_post( $label ), | |
| 164 | + 'label' => wp_kses_post($label), | |
| 165 | 165 | 'label_type' => 'vertical', | 
| 166 | 166 | 'help_text' => $description, | 
| 167 | 167 | 'type' => 'text', | 
| 168 | - 'value' => sanitize_text_field( $value ), | |
| 169 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), | |
| 168 | + 'value' => sanitize_text_field($value), | |
| 169 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), | |
| 170 | 170 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", | 
| 171 | 171 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, | 
| 172 | 172 | 'extra_attributes' => $autocomplete, | 
| @@ -176,7 +176,7 @@ discard block | ||
| 176 | 176 | |
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); | |
| 179 | +    do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field); | |
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 | echo "</div>"; | 
| @@ -7,10 +7,10 @@ discard block | ||
| 7 | 7 | * @version 1.0.19 | 
| 8 | 8 | */ | 
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; | |
| 10 | +defined('ABSPATH') || exit; | |
| 11 | 11 | |
| 12 | -$invoice = new WPInv_Invoice( $invoice ); | |
| 13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); | |
| 12 | +$invoice = new WPInv_Invoice($invoice); | |
| 13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); | |
| 14 | 14 | $phone = $invoice->get_phone(); | 
| 15 | 15 | $email = $invoice->get_email(); | 
| 16 | 16 | $vat_number = $invoice->get_vat_number(); | 
| @@ -22,47 +22,47 @@ discard block | ||
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | <div class="invoice-billing-address-label col-2"> | 
| 25 | - <strong><?php _e( 'To:', 'invoicing' ) ?></strong> | |
| 25 | +                <strong><?php _e('To:', 'invoicing') ?></strong> | |
| 26 | 26 | </div> | 
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | <div class="invoice-billing-address-value col-10"> | 
| 30 | 30 | |
| 31 | - <?php do_action( 'getpaid_billing_address_top' ); ?> | |
| 31 | +                <?php do_action('getpaid_billing_address_top'); ?> | |
| 32 | 32 | |
| 33 | - <?php if ( ! empty( $address_row ) ) : ?> | |
| 33 | + <?php if (!empty($address_row)) : ?> | |
| 34 | 34 | <div class="billing-address"> | 
| 35 | 35 | <?php echo $address_row; ?> | 
| 36 | 36 | </div> | 
| 37 | 37 | <?php endif; ?> | 
| 38 | 38 | |
| 39 | 39 | |
| 40 | - <?php if ( ! empty( $phone ) ) : ?> | |
| 40 | + <?php if (!empty($phone)) : ?> | |
| 41 | 41 | <div class="billing-phone"> | 
| 42 | - <?php echo wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> | |
| 42 | +                        <?php echo wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)); ?> | |
| 43 | 43 | </div> | 
| 44 | 44 | <?php endif; ?> | 
| 45 | 45 | |
| 46 | 46 | |
| 47 | - <?php if ( ! empty( $email ) ) : ?> | |
| 47 | + <?php if (!empty($email)) : ?> | |
| 48 | 48 | <div class="billing-email"> | 
| 49 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?> | |
| 49 | +                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?> | |
| 50 | 50 | </div> | 
| 51 | 51 | <?php endif; ?> | 
| 52 | 52 | |
| 53 | - <?php if ( ! empty( $vat_number ) ) : ?> | |
| 53 | + <?php if (!empty($vat_number)) : ?> | |
| 54 | 54 | <div class="vat-number"> | 
| 55 | - <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) ); ?> | |
| 55 | +                        <?php echo wp_sprintf(__('Vat Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?> | |
| 56 | 56 | </div> | 
| 57 | 57 | <?php endif; ?> | 
| 58 | 58 | |
| 59 | - <?php if ( ! empty( $company_id ) ) : ?> | |
| 59 | + <?php if (!empty($company_id)) : ?> | |
| 60 | 60 | <div class="company-id"> | 
| 61 | - <?php echo wp_sprintf( __( 'Company ID: %s', 'invoicing' ), sanitize_text_field( $company_id ) ); ?> | |
| 61 | +                        <?php echo wp_sprintf(__('Company ID: %s', 'invoicing'), sanitize_text_field($company_id)); ?> | |
| 62 | 62 | </div> | 
| 63 | 63 | <?php endif; ?> | 
| 64 | 64 | |
| 65 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> | |
| 65 | +                <?php do_action('getpaid_billing_address_bottom'); ?> | |
| 66 | 66 | |
| 67 | 67 | </div> | 
| 68 | 68 | |