@@ -12,75 +12,75 @@ 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 | 21 | // Prepare current user. |
| 22 | -if ( ! empty( $form->invoice ) ) { |
|
| 22 | +if (!empty($form->invoice)) { |
|
| 23 | 23 | $user_id = $form->invoice->get_user_id(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -if ( empty( $user_id ) && is_user_logged_in() ) { |
|
| 26 | +if (empty($user_id) && is_user_logged_in()) { |
|
| 27 | 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 ) { |
|
| 34 | +foreach ($fields as $address_field) { |
|
| 35 | 35 | |
| 36 | 36 | // Skip if it is hidden. |
| 37 | - if ( empty( $address_field['visible'] ) ) { |
|
| 37 | + if (empty($address_field['visible'])) { |
|
| 38 | 38 | continue; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
| 41 | + do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field); |
|
| 42 | 42 | |
| 43 | 43 | // Prepare variables. |
| 44 | 44 | $field_name = $address_field['name']; |
| 45 | 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 ) ); |
|
| 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 | 56 | } |
| 57 | 57 | |
| 58 | - if ( empty( $value ) && 'wpinv_first_name' == $address_field['name'] && ! empty( $user ) ) { |
|
| 58 | + if (empty($value) && 'wpinv_first_name' == $address_field['name'] && !empty($user)) { |
|
| 59 | 59 | $value = $user->first_name; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( empty( $value ) && 'wpinv_last_name' == $address_field['name'] && ! empty( $user ) ) { |
|
| 62 | + if (empty($value) && 'wpinv_last_name' == $address_field['name'] && !empty($user)) { |
|
| 63 | 63 | $value = $user->last_name; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( ! empty( $address_field['required'] ) ) { |
|
| 66 | + if (!empty($address_field['required'])) { |
|
| 67 | 67 | $label .= "<span class='text-danger'> *</span>"; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Display the country. |
| 71 | - if ( 'wpinv_country' == $address_field['name'] ) { |
|
| 71 | + if ('wpinv_country' == $address_field['name']) { |
|
| 72 | 72 | |
| 73 | 73 | echo "<div class='form-group $wrap_class getpaid-address-field-wrapper__country'"; |
| 74 | 74 | |
| 75 | 75 | echo aui()->select( |
| 76 | 76 | array( |
| 77 | 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 ), |
|
| 78 | + 'name' => esc_attr($field_name), |
|
| 79 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 80 | + 'value' => esc_attr($country), |
|
| 81 | 81 | 'placeholder' => $placeholder, |
| 82 | - 'required' => ! empty( $address_field['required'] ), |
|
| 83 | - 'label' => wp_kses_post( $label ), |
|
| 82 | + 'required' => !empty($address_field['required']), |
|
| 83 | + 'label' => wp_kses_post($label), |
|
| 84 | 84 | 'label_type' => 'vertical', |
| 85 | 85 | 'help_text' => $description, |
| 86 | 86 | 'class' => 'getpaid-address-field wpinv_country', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | ) |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | - if ( wpinv_should_validate_vat_number() ) { |
|
| 96 | + if (wpinv_should_validate_vat_number()) { |
|
| 97 | 97 | |
| 98 | 98 | echo aui()->input( |
| 99 | 99 | array( |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | 'id' => "shipping-toggle$uniqid", |
| 103 | 103 | 'wrap_class' => "getpaid-address-field-wrapper__address-confirm mt-1 d-none", |
| 104 | 104 | 'required' => false, |
| 105 | - 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", |
|
| 105 | + 'label' => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>", |
|
| 106 | 106 | 'value' => 1, |
| 107 | 107 | 'checked' => true, |
| 108 | 108 | 'class' => 'w-auto', |
@@ -116,27 +116,27 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Display the state. |
| 119 | - else if ( 'wpinv_state' == $address_field['name'] ) { |
|
| 119 | + else if ('wpinv_state' == $address_field['name']) { |
|
| 120 | 120 | |
| 121 | - if ( empty( $value ) ) { |
|
| 121 | + if (empty($value)) { |
|
| 122 | 122 | $value = wpinv_get_default_state(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - echo getpaid_get_states_select_markup ( |
|
| 125 | + echo getpaid_get_states_select_markup( |
|
| 126 | 126 | $country, |
| 127 | 127 | $value, |
| 128 | 128 | $placeholder, |
| 129 | 129 | $label, |
| 130 | 130 | $description, |
| 131 | - ! empty( $address_field['required'] ), |
|
| 131 | + !empty($address_field['required']), |
|
| 132 | 132 | $wrap_class, |
| 133 | 133 | $field_name |
| 134 | 134 | ); |
| 135 | 135 | |
| 136 | 136 | } else { |
| 137 | 137 | |
| 138 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
| 139 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
| 138 | + $key = str_replace('wpinv_', '', $address_field['name']); |
|
| 139 | + $key = esc_attr(str_replace('_', '-', $key)); |
|
| 140 | 140 | $autocomplete = ''; |
| 141 | 141 | $replacements = array( |
| 142 | 142 | 'zip' => 'postal-code', |
@@ -149,37 +149,37 @@ discard block |
||
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | 151 | |
| 152 | - if ( isset( $replacements[ $key ] ) ) { |
|
| 152 | + if (isset($replacements[$key])) { |
|
| 153 | 153 | $autocomplete = array( |
| 154 | - 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
| 154 | + 'autocomplete' => "$field_type {$replacements[$key]}", |
|
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $append = ''; |
| 159 | 159 | |
| 160 | - if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { |
|
| 161 | - $valid = esc_attr__( 'Valid', 'invoicing' ); |
|
| 162 | - $invalid = esc_attr__( 'Invalid', 'invoicing' ); |
|
| 163 | - $validate = esc_attr__( 'Validate', 'invoicing' ); |
|
| 160 | + if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) { |
|
| 161 | + $valid = esc_attr__('Valid', 'invoicing'); |
|
| 162 | + $invalid = esc_attr__('Invalid', 'invoicing'); |
|
| 163 | + $validate = esc_attr__('Validate', 'invoicing'); |
|
| 164 | 164 | $append = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( 'billing' === $field_type ) { |
|
| 168 | - $description .= '<div class="getpaid-error-' . sanitize_html_class( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
| 167 | + if ('billing' === $field_type) { |
|
| 168 | + $description .= '<div class="getpaid-error-' . sanitize_html_class($field_name) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | echo aui()->input( |
| 172 | 172 | array( |
| 173 | - 'name' => esc_attr( $field_name ), |
|
| 174 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 175 | - 'required' => ! empty( $address_field['required'] ), |
|
| 173 | + 'name' => esc_attr($field_name), |
|
| 174 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 175 | + 'required' => !empty($address_field['required']), |
|
| 176 | 176 | 'placeholder' => $placeholder, |
| 177 | - 'label' => wp_kses_post( $label ), |
|
| 177 | + 'label' => wp_kses_post($label), |
|
| 178 | 178 | 'label_type' => 'vertical', |
| 179 | 179 | 'help_text' => $description, |
| 180 | 180 | 'type' => 'text', |
| 181 | - 'value' => esc_attr( $value ), |
|
| 182 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
| 181 | + 'value' => esc_attr($value), |
|
| 182 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), |
|
| 183 | 183 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
| 184 | 184 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
| 185 | 185 | 'extra_attributes' => $autocomplete, |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
| 192 | + do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | echo "</div>"; |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Payment form submission refresh prices class |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
| 25 | 25 | */ |
| 26 | - public function __construct( $submission ) { |
|
| 26 | + public function __construct($submission) { |
|
| 27 | 27 | |
| 28 | 28 | $this->response = array( |
| 29 | 29 | 'submission_id' => $submission->id, |
| 30 | 30 | 'has_recurring' => $submission->has_recurring, |
| 31 | 31 | 'has_subscription_group' => $submission->has_subscription_group(), |
| 32 | 32 | 'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(), |
| 33 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
| 33 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - $this->add_totals( $submission ); |
|
| 37 | - $this->add_texts( $submission ); |
|
| 38 | - $this->add_items( $submission ); |
|
| 39 | - $this->add_fees( $submission ); |
|
| 40 | - $this->add_discounts( $submission ); |
|
| 41 | - $this->add_taxes( $submission ); |
|
| 42 | - $this->add_gateways( $submission ); |
|
| 43 | - $this->add_data( $submission ); |
|
| 36 | + $this->add_totals($submission); |
|
| 37 | + $this->add_texts($submission); |
|
| 38 | + $this->add_items($submission); |
|
| 39 | + $this->add_fees($submission); |
|
| 40 | + $this->add_discounts($submission); |
|
| 41 | + $this->add_taxes($submission); |
|
| 42 | + $this->add_gateways($submission); |
|
| 43 | + $this->add_data($submission); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -49,30 +49,30 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param GetPaid_Payment_Form_Submission $submission |
| 51 | 51 | */ |
| 52 | - public function add_totals( $submission ) { |
|
| 52 | + public function add_totals($submission) { |
|
| 53 | 53 | |
| 54 | 54 | $this->response = array_merge( |
| 55 | 55 | $this->response, |
| 56 | 56 | array( |
| 57 | 57 | |
| 58 | 58 | 'totals' => array( |
| 59 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
| 60 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
| 61 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
| 62 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
| 63 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
| 64 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
| 59 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
| 60 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
| 61 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
| 62 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
| 63 | + 'total' => $submission->format_amount($submission->get_total()), |
|
| 64 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
| 65 | 65 | ), |
| 66 | 66 | |
| 67 | 67 | 'recurring' => array( |
| 68 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
| 69 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
| 70 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
| 71 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
| 72 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
| 68 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
| 69 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
| 70 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
| 71 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
| 72 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
| 73 | 73 | ), |
| 74 | 74 | |
| 75 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
| 75 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
| 76 | 76 | 'currency' => $submission->get_currency(), |
| 77 | 77 | |
| 78 | 78 | ) |
@@ -85,53 +85,53 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param GetPaid_Payment_Form_Submission $submission |
| 87 | 87 | */ |
| 88 | - public function add_texts( $submission ) { |
|
| 88 | + public function add_texts($submission) { |
|
| 89 | 89 | |
| 90 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
| 91 | - $groups = getpaid_get_subscription_groups( $submission ); |
|
| 90 | + $payable = $submission->format_amount($submission->get_total()); |
|
| 91 | + $groups = getpaid_get_subscription_groups($submission); |
|
| 92 | 92 | |
| 93 | - if ( $submission->has_recurring && 2 > count( $groups ) ) { |
|
| 93 | + if ($submission->has_recurring && 2 > count($groups)) { |
|
| 94 | 94 | |
| 95 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
| 96 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
| 97 | - $main_item = reset( $groups ); |
|
| 95 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
| 96 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
| 97 | + $main_item = reset($groups); |
|
| 98 | 98 | |
| 99 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
| 99 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
| 100 | 100 | $payable = "$payable / $period"; |
| 101 | - } else if ( $main_item ) { |
|
| 101 | + } else if ($main_item) { |
|
| 102 | 102 | |
| 103 | - $main_item = reset( $main_item ); |
|
| 103 | + $main_item = reset($main_item); |
|
| 104 | 104 | |
| 105 | 105 | // Calculate the next renewal date. |
| 106 | - $_period = $main_item->get_recurring_period( true ); |
|
| 106 | + $_period = $main_item->get_recurring_period(true); |
|
| 107 | 107 | $_interval = $main_item->get_recurring_interval(); |
| 108 | 108 | |
| 109 | 109 | // If the subscription item has a trial period... |
| 110 | - if ( $main_item->has_free_trial() ) { |
|
| 111 | - $_period = $main_item->get_trial_period( true ); |
|
| 110 | + if ($main_item->has_free_trial()) { |
|
| 111 | + $_period = $main_item->get_trial_period(true); |
|
| 112 | 112 | $_interval = $main_item->get_trial_interval(); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $payable = sprintf( |
| 116 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
| 117 | - $submission->format_amount( $submission->get_total() ), |
|
| 118 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
| 116 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
| 117 | + $submission->format_amount($submission->get_total()), |
|
| 118 | + $submission->format_amount($submission->get_recurring_total()), |
|
| 119 | 119 | $period |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | $payable .= sprintf( |
| 123 | 123 | '<small class="text-muted form-text">%s</small>', |
| 124 | 124 | sprintf( |
| 125 | - __( 'First renewal on %s', 'invoicing' ), |
|
| 126 | - getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) ) |
|
| 125 | + __('First renewal on %s', 'invoicing'), |
|
| 126 | + getpaid_format_date(date('Y-m-d H:i:s', strtotime("+$_interval $_period", current_time('timestamp')))) |
|
| 127 | 127 | ) |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | } else { |
| 131 | 131 | $payable = sprintf( |
| 132 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
| 133 | - $submission->format_amount( $submission->get_total() ), |
|
| 134 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
| 132 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
| 133 | + $submission->format_amount($submission->get_total()), |
|
| 134 | + $submission->format_amount($submission->get_recurring_total()), |
|
| 135 | 135 | $period |
| 136 | 136 | ); |
| 137 | 137 | } |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | '.getpaid-checkout-total-payable' => $payable, |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - foreach ( $submission->get_items() as $item ) { |
|
| 145 | + foreach ($submission->get_items() as $item) { |
|
| 146 | 146 | $item_id = $item->get_id(); |
| 147 | - $initial_price = $submission->format_amount( $item->get_sub_total() - $item->item_discount ); |
|
| 148 | - $recurring_price = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount ); |
|
| 149 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
| 150 | - $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) ); |
|
| 147 | + $initial_price = $submission->format_amount($item->get_sub_total() - $item->item_discount); |
|
| 148 | + $recurring_price = $submission->format_amount($item->get_recurring_sub_total() - $item->recurring_item_discount); |
|
| 149 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
| 150 | + $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf(__('Subtotal: %s', 'invoicing'), $submission->format_amount($item->get_sub_total())); |
|
| 151 | 151 | |
| 152 | - if ( $item->get_quantity() == 1 ) { |
|
| 152 | + if ($item->get_quantity() == 1) { |
|
| 153 | 153 | $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = ''; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
| 158 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param GetPaid_Payment_Form_Submission $submission |
| 166 | 166 | */ |
| 167 | - public function add_items( $submission ) { |
|
| 167 | + public function add_items($submission) { |
|
| 168 | 168 | |
| 169 | 169 | // Add items. |
| 170 | 170 | $items = array(); |
| 171 | 171 | |
| 172 | - foreach ( $submission->get_items() as $item ) { |
|
| 172 | + foreach ($submission->get_items() as $item) { |
|
| 173 | 173 | $item_id = $item->get_id(); |
| 174 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
| 174 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $this->response = array_merge( |
| 178 | 178 | $this->response, |
| 179 | - array( 'items' => $items ) |
|
| 179 | + array('items' => $items) |
|
| 180 | 180 | ); |
| 181 | 181 | |
| 182 | 182 | } |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @param GetPaid_Payment_Form_Submission $submission |
| 188 | 188 | */ |
| 189 | - public function add_fees( $submission ) { |
|
| 189 | + public function add_fees($submission) { |
|
| 190 | 190 | |
| 191 | 191 | $fees = array(); |
| 192 | 192 | |
| 193 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
| 194 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
| 193 | + foreach ($submission->get_fees() as $name => $data) { |
|
| 194 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $this->response = array_merge( |
| 198 | 198 | $this->response, |
| 199 | - array( 'fees' => $fees ) |
|
| 199 | + array('fees' => $fees) |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | } |
@@ -206,17 +206,17 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param GetPaid_Payment_Form_Submission $submission |
| 208 | 208 | */ |
| 209 | - public function add_discounts( $submission ) { |
|
| 209 | + public function add_discounts($submission) { |
|
| 210 | 210 | |
| 211 | 211 | $discounts = array(); |
| 212 | 212 | |
| 213 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
| 214 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
| 213 | + foreach ($submission->get_discounts() as $name => $data) { |
|
| 214 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $this->response = array_merge( |
| 218 | 218 | $this->response, |
| 219 | - array( 'discounts' => $discounts ) |
|
| 219 | + array('discounts' => $discounts) |
|
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | } |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param GetPaid_Payment_Form_Submission $submission |
| 228 | 228 | */ |
| 229 | - public function add_taxes( $submission ) { |
|
| 229 | + public function add_taxes($submission) { |
|
| 230 | 230 | |
| 231 | 231 | $taxes = array(); |
| 232 | 232 | $markup = ''; |
| 233 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
| 234 | - $name = sanitize_text_field( $name ); |
|
| 235 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
| 233 | + foreach ($submission->get_taxes() as $name => $data) { |
|
| 234 | + $name = sanitize_text_field($name); |
|
| 235 | + $amount = $submission->format_amount($data['initial_tax']); |
|
| 236 | 236 | $taxes[$name] = $amount; |
| 237 | 237 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
| 240 | + if (wpinv_display_individual_tax_rates() && !empty($taxes)) { |
|
| 241 | 241 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $this->response = array_merge( |
| 245 | 245 | $this->response, |
| 246 | - array( 'taxes' => $taxes ) |
|
| 246 | + array('taxes' => $taxes) |
|
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | 249 | } |
@@ -253,29 +253,29 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param GetPaid_Payment_Form_Submission $submission |
| 255 | 255 | */ |
| 256 | - public function add_gateways( $submission ) { |
|
| 256 | + public function add_gateways($submission) { |
|
| 257 | 257 | |
| 258 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 258 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 259 | 259 | |
| 260 | - if ( $this->response['has_recurring'] ) { |
|
| 260 | + if ($this->response['has_recurring']) { |
|
| 261 | 261 | |
| 262 | - foreach ( $gateways as $i => $gateway ) { |
|
| 262 | + foreach ($gateways as $i => $gateway) { |
|
| 263 | 263 | |
| 264 | 264 | if ( |
| 265 | - ! getpaid_payment_gateway_supports( $gateway, 'subscription' ) |
|
| 266 | - || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) ) |
|
| 267 | - || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) { |
|
| 268 | - unset( $gateways[ $i ] ); |
|
| 265 | + !getpaid_payment_gateway_supports($gateway, 'subscription') |
|
| 266 | + || ($this->response['has_subscription_group'] && !getpaid_payment_gateway_supports($gateway, 'single_subscription_group')) |
|
| 267 | + || ($this->response['has_multiple_subscription_groups'] && !getpaid_payment_gateway_supports($gateway, 'multiple_subscription_groups')) ) { |
|
| 268 | + unset($gateways[$i]); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
| 275 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
| 276 | 276 | $this->response = array_merge( |
| 277 | 277 | $this->response, |
| 278 | - array( 'gateways' => $gateways ) |
|
| 278 | + array('gateways' => $gateways) |
|
| 279 | 279 | ); |
| 280 | 280 | |
| 281 | 281 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @param GetPaid_Payment_Form_Submission $submission |
| 287 | 287 | */ |
| 288 | - public function add_data( $submission ) { |
|
| 288 | + public function add_data($submission) { |
|
| 289 | 289 | |
| 290 | 290 | $this->response = array_merge( |
| 291 | 291 | $this->response, |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' ); |
|
| 27 | + protected $supports = array('subscription', 'sandbox', 'single_subscription_group'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @var array |
| 61 | 61 | */ |
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * URL to view a transaction. |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct() { |
| 82 | 82 | |
| 83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
| 84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
| 85 | - $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
| 86 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
| 83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
| 84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
| 85 | + $this->checkout_button_text = __('Proceed to PayPal', 'invoicing'); |
|
| 86 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | - add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
| 90 | - add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 ); |
|
| 91 | - add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) ); |
|
| 88 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
| 89 | + add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice')); |
|
| 90 | + add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2); |
|
| 91 | + add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal')); |
|
| 92 | 92 | |
| 93 | 93 | parent::__construct(); |
| 94 | 94 | } |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 105 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 106 | 106 | |
| 107 | 107 | // Get redirect url. |
| 108 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
| 108 | + $paypal_redirect = $this->get_request_url($invoice); |
|
| 109 | 109 | |
| 110 | 110 | // Add a note about the request url. |
| 111 | 111 | $invoice->add_note( |
| 112 | 112 | sprintf( |
| 113 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
| 114 | - esc_url( $paypal_redirect ) |
|
| 113 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
| 114 | + esc_url($paypal_redirect) |
|
| 115 | 115 | ), |
| 116 | 116 | false, |
| 117 | 117 | false, |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | // Redirect to PayPal |
| 122 | - wp_redirect( $paypal_redirect ); |
|
| 122 | + wp_redirect($paypal_redirect); |
|
| 123 | 123 | exit; |
| 124 | 124 | |
| 125 | 125 | } |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | * @param WPInv_Invoice $invoice Invoice object. |
| 131 | 131 | * @return string |
| 132 | 132 | */ |
| 133 | - public function get_request_url( $invoice ) { |
|
| 133 | + public function get_request_url($invoice) { |
|
| 134 | 134 | |
| 135 | 135 | // Endpoint for this request |
| 136 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 136 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 137 | 137 | |
| 138 | 138 | // Retrieve paypal args. |
| 139 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
| 139 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
| 140 | 140 | |
| 141 | - if ( $invoice->is_recurring() ) { |
|
| 141 | + if ($invoice->is_recurring()) { |
|
| 142 | 142 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
| 143 | 143 | } else { |
| 144 | 144 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
| 147 | + return add_query_arg($paypal_args, $this->endpoint); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | * @param WPInv_Invoice $invoice Invoice object. |
| 155 | 155 | * @return array |
| 156 | 156 | */ |
| 157 | - protected function get_paypal_args( $invoice ) { |
|
| 157 | + protected function get_paypal_args($invoice) { |
|
| 158 | 158 | |
| 159 | 159 | // Whether or not to send the line items as one item. |
| 160 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
| 160 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice); |
|
| 161 | 161 | |
| 162 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 162 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
| 163 | 163 | $force_one_line_item = true; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $paypal_args = apply_filters( |
| 167 | 167 | 'getpaid_paypal_args', |
| 168 | 168 | array_merge( |
| 169 | - $this->get_transaction_args( $invoice ), |
|
| 170 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | + $this->get_transaction_args($invoice), |
|
| 170 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
| 171 | 171 | ), |
| 172 | 172 | $invoice |
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 175 | + return $this->fix_request_length($invoice, $paypal_args); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | * @param WPInv_Invoice $invoice Invoice object. |
| 182 | 182 | * @return array |
| 183 | 183 | */ |
| 184 | - protected function get_transaction_args( $invoice ) { |
|
| 184 | + protected function get_transaction_args($invoice) { |
|
| 185 | 185 | |
| 186 | - $email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' ); |
|
| 186 | + $email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', ''); |
|
| 187 | 187 | return array( |
| 188 | 188 | 'cmd' => '_cart', |
| 189 | 189 | 'business' => $email, |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | 'rm' => is_ssl() ? 2 : 1, |
| 195 | 195 | 'upload' => 1, |
| 196 | 196 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
| 197 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
| 198 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
| 199 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
| 200 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
| 197 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
| 198 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
| 199 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
| 200 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
| 201 | 201 | 'custom' => $invoice->get_id(), |
| 202 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
| 203 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
| 204 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
| 205 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
| 206 | - 'cbt' => get_bloginfo( 'name' ) |
|
| 202 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
| 203 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
| 204 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
| 205 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
| 206 | + 'cbt' => get_bloginfo('name') |
|
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | 209 | } |
@@ -215,30 +215,30 @@ discard block |
||
| 215 | 215 | * @param bool $force_one_line_item Create only one item for this invoice. |
| 216 | 216 | * @return array |
| 217 | 217 | */ |
| 218 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 218 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
| 219 | 219 | |
| 220 | 220 | // Maybe send invoice as a single item. |
| 221 | - if ( $force_one_line_item ) { |
|
| 222 | - return $this->get_line_item_args_single_item( $invoice ); |
|
| 221 | + if ($force_one_line_item) { |
|
| 222 | + return $this->get_line_item_args_single_item($invoice); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Send each line item individually. |
| 226 | 226 | $line_item_args = array(); |
| 227 | 227 | |
| 228 | 228 | // Prepare line items. |
| 229 | - $this->prepare_line_items( $invoice ); |
|
| 229 | + $this->prepare_line_items($invoice); |
|
| 230 | 230 | |
| 231 | 231 | // Add taxes to the cart |
| 232 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 233 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
| 232 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 233 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Add discount. |
| 237 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 238 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
| 237 | + if ($invoice->get_total_discount() > 0) { |
|
| 238 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 241 | + return array_merge($line_item_args, $this->get_line_items()); |
|
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | * @param WPInv_Invoice $invoice Invoice object. |
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 251 | + protected function get_line_item_args_single_item($invoice) { |
|
| 252 | 252 | $this->delete_line_items(); |
| 253 | 253 | |
| 254 | - $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 255 | - $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
| 254 | + $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 255 | + $this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id()); |
|
| 256 | 256 | |
| 257 | 257 | return $this->get_line_items(); |
| 258 | 258 | } |
@@ -276,19 +276,19 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @param WPInv_Invoice $invoice Invoice object. |
| 278 | 278 | */ |
| 279 | - protected function prepare_line_items( $invoice ) { |
|
| 279 | + protected function prepare_line_items($invoice) { |
|
| 280 | 280 | $this->delete_line_items(); |
| 281 | 281 | |
| 282 | 282 | // Items. |
| 283 | - foreach ( $invoice->get_items() as $item ) { |
|
| 283 | + foreach ($invoice->get_items() as $item) { |
|
| 284 | 284 | $amount = $item->get_price(); |
| 285 | 285 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
| 286 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 286 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // Fees. |
| 290 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 291 | - $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
|
| 290 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
| 291 | + $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee'])); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | } |
@@ -301,15 +301,15 @@ discard block |
||
| 301 | 301 | * @param float $amount Amount. |
| 302 | 302 | * @param string $item_number Item number. |
| 303 | 303 | */ |
| 304 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 305 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 304 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
| 305 | + $index = (count($this->line_items) / 4) + 1; |
|
| 306 | 306 | |
| 307 | 307 | $item = apply_filters( |
| 308 | 308 | 'getpaid_paypal_line_item', |
| 309 | 309 | array( |
| 310 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 310 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
| 311 | 311 | 'quantity' => (float) $quantity, |
| 312 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 312 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
| 313 | 313 | 'item_number' => $item_number, |
| 314 | 314 | ), |
| 315 | 315 | $item_name, |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | $item_number |
| 319 | 319 | ); |
| 320 | 320 | |
| 321 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 322 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
| 321 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
| 322 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
| 323 | 323 | |
| 324 | 324 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 325 | - $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
| 326 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 325 | + $this->line_items['amount_' . $index] = $item['amount'] * $item['quantity']; |
|
| 326 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -335,19 +335,19 @@ discard block |
||
| 335 | 335 | * @param array $paypal_args Arguments sent to Paypal in the request. |
| 336 | 336 | * @return array |
| 337 | 337 | */ |
| 338 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 338 | + protected function fix_request_length($invoice, $paypal_args) { |
|
| 339 | 339 | $max_paypal_length = 2083; |
| 340 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 340 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
| 341 | 341 | |
| 342 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 342 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
| 343 | 343 | return $paypal_args; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | return apply_filters( |
| 347 | 347 | 'getpaid_paypal_args', |
| 348 | 348 | array_merge( |
| 349 | - $this->get_transaction_args( $invoice ), |
|
| 350 | - $this->get_line_item_args( $invoice, true ) |
|
| 349 | + $this->get_transaction_args($invoice), |
|
| 350 | + $this->get_line_item_args($invoice, true) |
|
| 351 | 351 | ), |
| 352 | 352 | $invoice |
| 353 | 353 | ); |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | * @param array $paypal_args PayPal args. |
| 361 | 361 | * @param WPInv_Invoice $invoice Invoice object. |
| 362 | 362 | */ |
| 363 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 363 | + public function process_subscription($paypal_args, $invoice) { |
|
| 364 | 364 | |
| 365 | 365 | // Make sure this is a subscription. |
| 366 | - if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) { |
|
| 366 | + if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) { |
|
| 367 | 367 | return $paypal_args; |
| 368 | 368 | } |
| 369 | 369 | |
@@ -371,23 +371,23 @@ discard block |
||
| 371 | 371 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
| 372 | 372 | |
| 373 | 373 | // Subscription name. |
| 374 | - $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 374 | + $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 375 | 375 | |
| 376 | 376 | // Get subscription args. |
| 377 | - $period = strtoupper( substr( $subscription->get_period(), 0, 1) ); |
|
| 377 | + $period = strtoupper(substr($subscription->get_period(), 0, 1)); |
|
| 378 | 378 | $interval = (int) $subscription->get_frequency(); |
| 379 | 379 | $bill_times = (int) $subscription->get_bill_times(); |
| 380 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
| 381 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
| 382 | - $subscription_item = $invoice->get_recurring( true ); |
|
| 380 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
| 381 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
| 382 | + $subscription_item = $invoice->get_recurring(true); |
|
| 383 | 383 | |
| 384 | 384 | // Convert 365 days to 1 year. |
| 385 | - if ( 'D' == $period && 365 == $interval ) { |
|
| 385 | + if ('D' == $period && 365 == $interval) { |
|
| 386 | 386 | $period = 'Y'; |
| 387 | 387 | $interval = 1; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if ( $subscription_item->has_free_trial() ) { |
|
| 390 | + if ($subscription_item->has_free_trial()) { |
|
| 391 | 391 | |
| 392 | 392 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 393 | 393 | |
@@ -397,28 +397,28 @@ discard block |
||
| 397 | 397 | // Trial period. |
| 398 | 398 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
| 399 | 399 | |
| 400 | - } else if ( $initial_amount != $recurring_amount ) { |
|
| 400 | + } else if ($initial_amount != $recurring_amount) { |
|
| 401 | 401 | |
| 402 | 402 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
| 403 | 403 | |
| 404 | - if ( 1 == $bill_times ) { |
|
| 404 | + if (1 == $bill_times) { |
|
| 405 | 405 | $param_number = 3; |
| 406 | 406 | } else { |
| 407 | 407 | $param_number = 1; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0; |
|
| 410 | + $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0; |
|
| 411 | 411 | |
| 412 | 412 | // Sign Up interval |
| 413 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
| 413 | + $paypal_args['p' . $param_number] = $interval; |
|
| 414 | 414 | |
| 415 | 415 | // Sign Up unit of duration |
| 416 | - $paypal_args[ 't' . $param_number ] = $period; |
|
| 416 | + $paypal_args['t' . $param_number] = $period; |
|
| 417 | 417 | |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | // We have a recurring payment |
| 421 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 421 | + if (!isset($param_number) || 1 == $param_number) { |
|
| 422 | 422 | |
| 423 | 423 | // Subscription price |
| 424 | 424 | $paypal_args['a3'] = $recurring_amount; |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // Recurring payments |
| 435 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 435 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
| 436 | 436 | |
| 437 | 437 | // Non-recurring payments |
| 438 | 438 | $paypal_args['src'] = 0; |
@@ -441,15 +441,15 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | $paypal_args['src'] = 1; |
| 443 | 443 | |
| 444 | - if ( $bill_times > 0 ) { |
|
| 444 | + if ($bill_times > 0) { |
|
| 445 | 445 | |
| 446 | 446 | // An initial period is being used to charge a sign-up fee |
| 447 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 447 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
| 448 | 448 | $bill_times--; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | // Make sure it's not over the max of 52 |
| 452 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
| 452 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
| 453 | 453 | |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | $paypal_args['rm'] = 2; |
| 459 | 459 | |
| 460 | 460 | // Get rid of redudant items. |
| 461 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
| 461 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
| 462 | 462 | |
| 463 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
| 464 | - unset( $paypal_args[ $arg ] ); |
|
| 463 | + if (isset($paypal_args[$arg])) { |
|
| 464 | + unset($paypal_args[$arg]); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * @return void |
| 481 | 481 | */ |
| 482 | 482 | public function verify_ipn() { |
| 483 | - new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
|
| 483 | + new GetPaid_Paypal_Gateway_IPN_Handler($this); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | public function sandbox_notice() { |
| 490 | 490 | |
| 491 | 491 | return sprintf( |
| 492 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 492 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 493 | 493 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
| 494 | 494 | '</a>' |
| 495 | 495 | ); |
@@ -501,30 +501,30 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @param array $admin_settings |
| 503 | 503 | */ |
| 504 | - public function admin_settings( $admin_settings ) { |
|
| 504 | + public function admin_settings($admin_settings) { |
|
| 505 | 505 | |
| 506 | 506 | $currencies = sprintf( |
| 507 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
| 508 | - implode( ', ', $this->currencies ) |
|
| 507 | + __('Supported Currencies: %s', 'invoicing'), |
|
| 508 | + implode(', ', $this->currencies) |
|
| 509 | 509 | ); |
| 510 | 510 | |
| 511 | 511 | $admin_settings['paypal_active']['desc'] .= " ($currencies)"; |
| 512 | - $admin_settings['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
| 512 | + $admin_settings['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
| 513 | 513 | |
| 514 | 514 | // Access tokens. |
| 515 | - $live_email = wpinv_get_option( 'paypal_email' ); |
|
| 516 | - $sandbox_email = wpinv_get_option( 'paypal_sandbox_email' ); |
|
| 515 | + $live_email = wpinv_get_option('paypal_email'); |
|
| 516 | + $sandbox_email = wpinv_get_option('paypal_sandbox_email'); |
|
| 517 | 517 | |
| 518 | 518 | $admin_settings['paypal_connect'] = array( |
| 519 | 519 | 'type' => 'raw_html', |
| 520 | 520 | 'id' => 'paypal_connect', |
| 521 | - 'name' => __( 'Connect to PayPal', 'invoicing' ), |
|
| 521 | + 'name' => __('Connect to PayPal', 'invoicing'), |
|
| 522 | 522 | 'desc' => sprintf( |
| 523 | 523 | '<div class="wpinv-paypal-connect-live"><a class="button button-primary" href="%s">%s</a></div><div class="wpinv-paypal-connect-sandbox"><a class="button button-primary" href="%s">%s</a></div>%s', |
| 524 | - esc_url( self::get_connect_url( false ) ), |
|
| 525 | - __( 'Connect to PayPal', 'invoicing' ), |
|
| 526 | - esc_url( self::get_connect_url( true ) ), |
|
| 527 | - __( 'Connect to PayPal Sandox', 'invoicing' ), |
|
| 524 | + esc_url(self::get_connect_url(false)), |
|
| 525 | + __('Connect to PayPal', 'invoicing'), |
|
| 526 | + esc_url(self::get_connect_url(true)), |
|
| 527 | + __('Connect to PayPal Sandox', 'invoicing'), |
|
| 528 | 528 | $this->get_js() |
| 529 | 529 | ), |
| 530 | 530 | ); |
@@ -533,25 +533,25 @@ discard block |
||
| 533 | 533 | 'type' => 'text', |
| 534 | 534 | 'class' => 'live-auth-data', |
| 535 | 535 | 'id' => 'paypal_email', |
| 536 | - 'name' => __( 'Live Email Address', 'invoicing' ), |
|
| 537 | - 'desc' => __( 'The email address of your PayPal account.', 'invoicing' ), |
|
| 536 | + 'name' => __('Live Email Address', 'invoicing'), |
|
| 537 | + 'desc' => __('The email address of your PayPal account.', 'invoicing'), |
|
| 538 | 538 | ); |
| 539 | 539 | |
| 540 | 540 | $admin_settings['paypal_sandbox_email'] = array( |
| 541 | 541 | 'type' => 'text', |
| 542 | 542 | 'class' => 'sandbox-auth-data', |
| 543 | 543 | 'id' => 'paypal_sandbox_email', |
| 544 | - 'name' => __( 'Sandbox Email Address', 'invoicing' ), |
|
| 545 | - 'desc' => __( 'The email address of your sandbox PayPal account.', 'invoicing' ), |
|
| 546 | - 'std' => wpinv_get_option( 'paypal_email', '' ), |
|
| 544 | + 'name' => __('Sandbox Email Address', 'invoicing'), |
|
| 545 | + 'desc' => __('The email address of your sandbox PayPal account.', 'invoicing'), |
|
| 546 | + 'std' => wpinv_get_option('paypal_email', ''), |
|
| 547 | 547 | ); |
| 548 | 548 | |
| 549 | 549 | $admin_settings['paypal_ipn_url'] = array( |
| 550 | 550 | 'type' => 'ipn_url', |
| 551 | 551 | 'id' => 'paypal_ipn_url', |
| 552 | - 'name' => __( 'IPN Url', 'invoicing' ), |
|
| 552 | + 'name' => __('IPN Url', 'invoicing'), |
|
| 553 | 553 | 'std' => $this->notify_url, |
| 554 | - 'desc' => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
| 554 | + 'desc' => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
| 555 | 555 | 'readonly' => true, |
| 556 | 556 | ); |
| 557 | 557 | |
@@ -565,8 +565,8 @@ discard block |
||
| 565 | 565 | * @param array $data |
| 566 | 566 | * @return string |
| 567 | 567 | */ |
| 568 | - public static function maybe_get_connect_url( $url = '', $data = array() ) { |
|
| 569 | - return self::get_connect_url( false, urldecode( $data['redirect'] ) ); |
|
| 568 | + public static function maybe_get_connect_url($url = '', $data = array()) { |
|
| 569 | + return self::get_connect_url(false, urldecode($data['redirect'])); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |
@@ -577,25 +577,25 @@ discard block |
||
| 577 | 577 | * @param string $redirect |
| 578 | 578 | * @return string |
| 579 | 579 | */ |
| 580 | - public static function get_connect_url( $is_sandbox, $redirect = '' ) { |
|
| 580 | + public static function get_connect_url($is_sandbox, $redirect = '') { |
|
| 581 | 581 | |
| 582 | 582 | $redirect_url = add_query_arg( |
| 583 | 583 | array( |
| 584 | 584 | 'getpaid-admin-action' => 'connect_paypal', |
| 585 | 585 | 'page' => 'wpinv-settings', |
| 586 | - 'live_mode' => (int) empty( $is_sandbox ), |
|
| 586 | + 'live_mode' => (int) empty($is_sandbox), |
|
| 587 | 587 | 'tab' => 'gateways', |
| 588 | 588 | 'section' => 'paypal', |
| 589 | - 'getpaid-nonce' => wp_create_nonce( 'getpaid-nonce' ), |
|
| 590 | - 'redirect' => urlencode( $redirect ), |
|
| 589 | + 'getpaid-nonce' => wp_create_nonce('getpaid-nonce'), |
|
| 590 | + 'redirect' => urlencode($redirect), |
|
| 591 | 591 | ), |
| 592 | - admin_url( 'admin.php' ) |
|
| 592 | + admin_url('admin.php') |
|
| 593 | 593 | ); |
| 594 | 594 | |
| 595 | 595 | return add_query_arg( |
| 596 | 596 | array( |
| 597 | - 'live_mode' => (int) empty( $is_sandbox ), |
|
| 598 | - 'redirect_url' => urlencode( str_replace( '&', '&', $redirect_url ) ) |
|
| 597 | + 'live_mode' => (int) empty($is_sandbox), |
|
| 598 | + 'redirect_url' => urlencode(str_replace('&', '&', $redirect_url)) |
|
| 599 | 599 | ), |
| 600 | 600 | 'https://ayecode.io/oauth/paypal' |
| 601 | 601 | ); |
@@ -649,26 +649,26 @@ discard block |
||
| 649 | 649 | * @param array $data Connection data. |
| 650 | 650 | * @return void |
| 651 | 651 | */ |
| 652 | - public function connect_paypal( $data ) { |
|
| 652 | + public function connect_paypal($data) { |
|
| 653 | 653 | |
| 654 | 654 | $sandbox = $this->is_sandbox(); |
| 655 | - $data = wp_unslash( $data ); |
|
| 656 | - $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] ); |
|
| 655 | + $data = wp_unslash($data); |
|
| 656 | + $access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']); |
|
| 657 | 657 | |
| 658 | - if ( isset( $data['live_mode'] ) ) { |
|
| 659 | - $sandbox = empty( $data['live_mode'] ); |
|
| 658 | + if (isset($data['live_mode'])) { |
|
| 659 | + $sandbox = empty($data['live_mode']); |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - wpinv_update_option( 'paypal_sandbox', (int) $sandbox ); |
|
| 663 | - wpinv_update_option( 'paypal_active', 1 ); |
|
| 662 | + wpinv_update_option('paypal_sandbox', (int) $sandbox); |
|
| 663 | + wpinv_update_option('paypal_active', 1); |
|
| 664 | 664 | |
| 665 | - if ( ! empty( $data['error_description'] ) ) { |
|
| 666 | - getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) ); |
|
| 665 | + if (!empty($data['error_description'])) { |
|
| 666 | + getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description']))); |
|
| 667 | 667 | } else { |
| 668 | 668 | |
| 669 | 669 | // Retrieve the user info. |
| 670 | 670 | $user_info = wp_remote_get( |
| 671 | - ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1', |
|
| 671 | + !$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1', |
|
| 672 | 672 | array( |
| 673 | 673 | |
| 674 | 674 | 'headers' => array( |
@@ -679,35 +679,35 @@ discard block |
||
| 679 | 679 | ) |
| 680 | 680 | ); |
| 681 | 681 | |
| 682 | - if ( is_wp_error( $user_info ) ) { |
|
| 683 | - getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) ); |
|
| 682 | + if (is_wp_error($user_info)) { |
|
| 683 | + getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message())); |
|
| 684 | 684 | } else { |
| 685 | 685 | |
| 686 | 686 | // Create application. |
| 687 | - $user_info = json_decode( wp_remote_retrieve_body( $user_info ) ); |
|
| 687 | + $user_info = json_decode(wp_remote_retrieve_body($user_info)); |
|
| 688 | 688 | |
| 689 | - if ( $sandbox ) { |
|
| 690 | - wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) ); |
|
| 691 | - wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) ); |
|
| 692 | - set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] ); |
|
| 693 | - getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) ); |
|
| 689 | + if ($sandbox) { |
|
| 690 | + wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value)); |
|
| 691 | + wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token']))); |
|
| 692 | + set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']); |
|
| 693 | + getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing')); |
|
| 694 | 694 | } else { |
| 695 | - wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) ); |
|
| 696 | - wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) ); |
|
| 697 | - set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] ); |
|
| 698 | - getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) ); |
|
| 695 | + wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value)); |
|
| 696 | + wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token']))); |
|
| 697 | + set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']); |
|
| 698 | + getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing')); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways§ion=paypal' ) : urldecode( $data['redirect'] ); |
|
| 705 | + $redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways§ion=paypal') : urldecode($data['redirect']); |
|
| 706 | 706 | |
| 707 | - if ( isset( $data['step'] ) ) { |
|
| 708 | - $redirect = add_query_arg( 'step', $data['step'], $redirect ); |
|
| 707 | + if (isset($data['step'])) { |
|
| 708 | + $redirect = add_query_arg('step', $data['step'], $redirect); |
|
| 709 | 709 | } |
| 710 | - wp_redirect( $redirect ); |
|
| 710 | + wp_redirect($redirect); |
|
| 711 | 711 | exit; |
| 712 | 712 | } |
| 713 | 713 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Authorize.net Legacy Payment Gateway class. |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @param WPInv_Invoice $invoice Invoice. |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - public function get_api_url( $invoice ) { |
|
| 32 | - return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api'; |
|
| 31 | + public function get_api_url($invoice) { |
|
| 32 | + return $this->is_sandbox($invoice) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -40,48 +40,48 @@ discard block |
||
| 40 | 40 | * @param WPInv_Invoice $invoice Invoice. |
| 41 | 41 | * @return stdClass|WP_Error |
| 42 | 42 | */ |
| 43 | - public function post( $post, $invoice ){ |
|
| 43 | + public function post($post, $invoice) { |
|
| 44 | 44 | |
| 45 | - $url = $this->get_api_url( $invoice ); |
|
| 45 | + $url = $this->get_api_url($invoice); |
|
| 46 | 46 | $response = wp_remote_post( |
| 47 | 47 | $url, |
| 48 | 48 | array( |
| 49 | 49 | 'headers' => array( |
| 50 | 50 | 'Content-Type' => 'application/json; charset=utf-8' |
| 51 | 51 | ), |
| 52 | - 'body' => json_encode( $post ), |
|
| 52 | + 'body' => json_encode($post), |
|
| 53 | 53 | 'method' => 'POST' |
| 54 | 54 | ) |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - if ( is_wp_error( $response ) ) { |
|
| 57 | + if (is_wp_error($response)) { |
|
| 58 | 58 | return $response; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $response = wp_unslash( wp_remote_retrieve_body( $response ) ); |
|
| 61 | + $response = wp_unslash(wp_remote_retrieve_body($response)); |
|
| 62 | 62 | $response = preg_replace('/\xEF\xBB\xBF/', '', $response); // https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851 |
| 63 | - $response = json_decode( $response ); |
|
| 63 | + $response = json_decode($response); |
|
| 64 | 64 | |
| 65 | - if ( empty( $response ) ) { |
|
| 66 | - return new WP_Error( 'invalid_reponse', __( 'Invalid gateway response', 'invoicing' ) ); |
|
| 65 | + if (empty($response)) { |
|
| 66 | + return new WP_Error('invalid_reponse', __('Invalid gateway response', 'invoicing')); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( $response->messages->resultCode == 'Error' ) { |
|
| 69 | + if ($response->messages->resultCode == 'Error') { |
|
| 70 | 70 | |
| 71 | - if ( $this->is_sandbox( $invoice ) ) { |
|
| 72 | - wpinv_error_log( $response ); |
|
| 71 | + if ($this->is_sandbox($invoice)) { |
|
| 72 | + wpinv_error_log($response); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( $response->messages->message[0]->code == 'E00039' && ! empty( $response->customerProfileId ) && ! empty( $response->customerPaymentProfileId ) ) { |
|
| 76 | - return new WP_Error( 'dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId ); |
|
| 75 | + if ($response->messages->message[0]->code == 'E00039' && !empty($response->customerProfileId) && !empty($response->customerPaymentProfileId)) { |
|
| 76 | + return new WP_Error('dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( ! empty( $response->transactionResponse ) && ! empty( $response->transactionResponse->errors ) ) { |
|
| 79 | + if (!empty($response->transactionResponse) && !empty($response->transactionResponse->errors)) { |
|
| 80 | 80 | $error = $response->transactionResponse->errors[0]; |
| 81 | - return new WP_Error( $error->errorCode, $error->errorText ); |
|
| 81 | + return new WP_Error($error->errorCode, $error->errorText); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return new WP_Error( $response->messages->message[0]->code, $response->messages->message[0]->text ); |
|
| 84 | + return new WP_Error($response->messages->message[0]->code, $response->messages->message[0]->text); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $response; |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | public function get_auth_params() { |
| 98 | 98 | |
| 99 | 99 | return array( |
| 100 | - 'name' => $this->get_option( 'login_id' ), |
|
| 101 | - 'transactionKey' => $this->get_option( 'transaction_key' ), |
|
| 100 | + 'name' => $this->get_option('login_id'), |
|
| 101 | + 'transactionKey' => $this->get_option('transaction_key'), |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param WPInv_Subscription $subscription Subscription. |
| 111 | 111 | * @param WPInv_Invoice $invoice Invoice. |
| 112 | 112 | */ |
| 113 | - public function cancel_subscription( $subscription, $invoice ) { |
|
| 113 | + public function cancel_subscription($subscription, $invoice) { |
|
| 114 | 114 | |
| 115 | 115 | // Backwards compatibility. New version do not use authorize.net subscriptions. |
| 116 | 116 | $this->post( |
@@ -135,38 +135,38 @@ discard block |
||
| 135 | 135 | $this->maybe_process_old_ipn(); |
| 136 | 136 | |
| 137 | 137 | // Validate the IPN. |
| 138 | - if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
| 139 | - wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 200 ) ); |
|
| 138 | + if (empty($_POST) || !$this->validate_ipn()) { |
|
| 139 | + wp_die('Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array('response' => 200)); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Event type. |
| 143 | - $posted = json_decode( file_get_contents( 'php://input' ) ); |
|
| 144 | - if ( empty( $posted ) ) { |
|
| 145 | - wp_die( 'Invalid JSON', 'Authorize.NET IPN', array( 'response' => 200 ) ); |
|
| 143 | + $posted = json_decode(file_get_contents('php://input')); |
|
| 144 | + if (empty($posted)) { |
|
| 145 | + wp_die('Invalid JSON', 'Authorize.NET IPN', array('response' => 200)); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Process the IPN. |
| 149 | - $posted = (object) wp_unslash( $posted ); |
|
| 149 | + $posted = (object) wp_unslash($posted); |
|
| 150 | 150 | |
| 151 | 151 | // Process refunds. |
| 152 | - if ( 'net.authorize.payment.refund.created' == $posted->eventType ) { |
|
| 153 | - $invoice = new WPInv_Invoice( $posted->payload->merchantReferenceId ); |
|
| 154 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
| 152 | + if ('net.authorize.payment.refund.created' == $posted->eventType) { |
|
| 153 | + $invoice = new WPInv_Invoice($posted->payload->merchantReferenceId); |
|
| 154 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
| 155 | 155 | $invoice->refund(); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Held funds approved. |
| 159 | - if ( 'net.authorize.payment.fraud.approved' == $posted->eventType ) { |
|
| 160 | - $invoice = new WPInv_Invoice( $posted->payload->id ); |
|
| 161 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
| 162 | - $invoice->mark_paid( false, __( 'Payment released', 'invoicing' ) ); |
|
| 159 | + if ('net.authorize.payment.fraud.approved' == $posted->eventType) { |
|
| 160 | + $invoice = new WPInv_Invoice($posted->payload->id); |
|
| 161 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
| 162 | + $invoice->mark_paid(false, __('Payment released', 'invoicing')); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Held funds declined. |
| 166 | - if ( 'net.authorize.payment.fraud.declined' == $posted->eventType ) { |
|
| 167 | - $invoice = new WPInv_Invoice( $posted->payload->id ); |
|
| 168 | - $this->validate_ipn_invoice( $invoice, $posted->payload ); |
|
| 169 | - $invoice->set_status( 'wpi-failed', __( 'Payment declined', 'invoicing' ) ); |
|
| 166 | + if ('net.authorize.payment.fraud.declined' == $posted->eventType) { |
|
| 167 | + $invoice = new WPInv_Invoice($posted->payload->id); |
|
| 168 | + $this->validate_ipn_invoice($invoice, $posted->payload); |
|
| 169 | + $invoice->set_status('wpi-failed', __('Payment declined', 'invoicing')); |
|
| 170 | 170 | $invoice->save(); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | * @param object $payload |
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | - public function validate_ipn_invoice( $invoice, $payload ) { |
|
| 185 | - if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) { |
|
| 184 | + public function validate_ipn_invoice($invoice, $payload) { |
|
| 185 | + if (!$invoice->exists() || $payload->id != $invoice->get_transaction_id()) { |
|
| 186 | 186 | exit; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -194,32 +194,32 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function maybe_process_old_ipn() { |
| 196 | 196 | |
| 197 | - $data = wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
| 197 | + $data = wp_kses_post_deep(wp_unslash($_POST)); |
|
| 198 | 198 | |
| 199 | 199 | // Only process subscriptions subscriptions. |
| 200 | - if ( empty( $data['x_subscription_id'] ) ) { |
|
| 200 | + if (empty($data['x_subscription_id'])) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Check validity. |
| 205 | - $this->validate_old_ipn_signature( $data ); |
|
| 205 | + $this->validate_old_ipn_signature($data); |
|
| 206 | 206 | |
| 207 | 207 | // Fetch the associated subscription. |
| 208 | - $subscription_id = WPInv_Subscription::get_subscription_id_by_field( $data['x_subscription_id'] ); |
|
| 209 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
| 208 | + $subscription_id = WPInv_Subscription::get_subscription_id_by_field($data['x_subscription_id']); |
|
| 209 | + $subscription = new WPInv_Subscription($subscription_id); |
|
| 210 | 210 | |
| 211 | 211 | // Abort if it is missing or completed. |
| 212 | - if ( ! $subscription->get_id() || $subscription->has_status( 'completed' ) ) { |
|
| 212 | + if (!$subscription->get_id() || $subscription->has_status('completed')) { |
|
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Payment status. |
| 217 | - if ( 1 == $data['x_response_code'] ) { |
|
| 217 | + if (1 == $data['x_response_code']) { |
|
| 218 | 218 | |
| 219 | 219 | // Renew the subscription. |
| 220 | 220 | $subscription->add_payment( |
| 221 | 221 | array( |
| 222 | - 'transaction_id' => sanitize_text_field( $data['x_trans_id'] ), |
|
| 222 | + 'transaction_id' => sanitize_text_field($data['x_trans_id']), |
|
| 223 | 223 | 'gateway' => $this->id |
| 224 | 224 | ) |
| 225 | 225 | ); |
@@ -238,17 +238,17 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param array $posted |
| 240 | 240 | */ |
| 241 | - public function validate_old_ipn_signature( $posted ) { |
|
| 241 | + public function validate_old_ipn_signature($posted) { |
|
| 242 | 242 | |
| 243 | - $signature = $this->get_option( 'signature_key' ); |
|
| 244 | - if ( ! empty( $signature ) ) { |
|
| 245 | - $login_id = $this->get_option( 'login_id' ); |
|
| 246 | - $trans_id = wpinv_clean( $_POST['x_trans_id'] ); |
|
| 247 | - $amount = wpinv_clean( $_POST['x_amount'] ); |
|
| 248 | - $hash = hash_hmac ( 'sha512', "^$login_id^$trans_id^$amount^", hex2bin( $signature ) ); |
|
| 243 | + $signature = $this->get_option('signature_key'); |
|
| 244 | + if (!empty($signature)) { |
|
| 245 | + $login_id = $this->get_option('login_id'); |
|
| 246 | + $trans_id = wpinv_clean($_POST['x_trans_id']); |
|
| 247 | + $amount = wpinv_clean($_POST['x_amount']); |
|
| 248 | + $hash = hash_hmac('sha512', "^$login_id^$trans_id^$amount^", hex2bin($signature)); |
|
| 249 | 249 | |
| 250 | - if ( ! hash_equals( $hash, $posted['x_SHA2_Hash'] ) ) { |
|
| 251 | - wpinv_error_log( $posted['x_SHA2_Hash'], "Invalid signature. Expected $hash" ); |
|
| 250 | + if (!hash_equals($hash, $posted['x_SHA2_Hash'])) { |
|
| 251 | + wpinv_error_log($posted['x_SHA2_Hash'], "Invalid signature. Expected $hash"); |
|
| 252 | 252 | exit; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -261,28 +261,28 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function validate_ipn() { |
| 263 | 263 | |
| 264 | - wpinv_error_log( 'Validating Authorize.NET IPN response' ); |
|
| 264 | + wpinv_error_log('Validating Authorize.NET IPN response'); |
|
| 265 | 265 | |
| 266 | - if ( empty( $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) { |
|
| 266 | + if (empty($_SERVER['HTTP_X_ANET_SIGNATURE'])) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $signature = $this->get_option( 'signature_key' ); |
|
| 270 | + $signature = $this->get_option('signature_key'); |
|
| 271 | 271 | |
| 272 | - if ( empty( $signature ) ) { |
|
| 273 | - wpinv_error_log( 'Error: You have not set a signature key' ); |
|
| 272 | + if (empty($signature)) { |
|
| 273 | + wpinv_error_log('Error: You have not set a signature key'); |
|
| 274 | 274 | return false; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $hash = hash_hmac ( 'sha512', file_get_contents( 'php://input' ), hex2bin( $signature ) ); |
|
| 277 | + $hash = hash_hmac('sha512', file_get_contents('php://input'), hex2bin($signature)); |
|
| 278 | 278 | |
| 279 | - if ( hash_equals( $hash, $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) { |
|
| 280 | - wpinv_error_log( 'Successfully validated the IPN' ); |
|
| 279 | + if (hash_equals($hash, $_SERVER['HTTP_X_ANET_SIGNATURE'])) { |
|
| 280 | + wpinv_error_log('Successfully validated the IPN'); |
|
| 281 | 281 | return true; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - wpinv_error_log( 'IPN hash is not valid' ); |
|
| 285 | - wpinv_error_log( $_SERVER['HTTP_X_ANET_SIGNATURE'] ); |
|
| 284 | + wpinv_error_log('IPN hash is not valid'); |
|
| 285 | + wpinv_error_log($_SERVER['HTTP_X_ANET_SIGNATURE']); |
|
| 286 | 286 | return false; |
| 287 | 287 | |
| 288 | 288 | } |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Prepare the selectable items. |
| 13 | 13 | $selectable = array(); |
| 14 | -foreach ( $form->get_items() as $item ) { |
|
| 15 | - if ( ! $item->is_required ) { |
|
| 16 | - $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
| 14 | +foreach ($form->get_items() as $item) { |
|
| 15 | + if (!$item->is_required) { |
|
| 16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if ( empty( $selectable ) ) { |
|
| 20 | +if (empty($selectable)) { |
|
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | echo '<div class="getpaid-payment-form-items-checkbox form-group">'; |
| 25 | 25 | |
| 26 | -foreach ( $selectable as $item_id => $item_name ) { |
|
| 26 | +foreach ($selectable as $item_id => $item_name) { |
|
| 27 | 27 | |
| 28 | - $is_checked = get_post_meta( $item_id, 'selected_by_default', true ); |
|
| 28 | + $is_checked = get_post_meta($item_id, 'selected_by_default', true); |
|
| 29 | 29 | |
| 30 | 30 | echo aui()->input( |
| 31 | 31 | array( |
| 32 | 32 | 'type' => 'checkbox', |
| 33 | 33 | 'name' => 'getpaid-payment-form-selected-item', |
| 34 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ) . $item_id, |
|
| 34 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_') . $item_id, |
|
| 35 | 35 | 'label' => $item_name, |
| 36 | 36 | 'value' => $item_id, |
| 37 | 37 | 'no_wrap' => true, |
@@ -9,41 +9,41 @@ discard block |
||
| 9 | 9 | * @version 1.0.19 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | return array( |
| 15 | 15 | |
| 16 | 16 | array( |
| 17 | 17 | 'type' => 'heading', |
| 18 | - 'name' => __( 'Heading', 'invoicing' ), |
|
| 18 | + 'name' => __('Heading', 'invoicing'), |
|
| 19 | 19 | 'defaults' => array( |
| 20 | 20 | 'level' => 'h2', |
| 21 | - 'text' => __( 'Heading', 'invoicing' ), |
|
| 21 | + 'text' => __('Heading', 'invoicing'), |
|
| 22 | 22 | ) |
| 23 | 23 | ), |
| 24 | 24 | |
| 25 | 25 | array( |
| 26 | 26 | 'type' => 'paragraph', |
| 27 | - 'name' => __( 'Paragraph', 'invoicing' ), |
|
| 27 | + 'name' => __('Paragraph', 'invoicing'), |
|
| 28 | 28 | 'defaults' => array( |
| 29 | - 'text' => __( 'Paragraph text', 'invoicing' ), |
|
| 29 | + 'text' => __('Paragraph text', 'invoicing'), |
|
| 30 | 30 | ) |
| 31 | 31 | ), |
| 32 | 32 | |
| 33 | 33 | array( |
| 34 | 34 | 'type' => 'alert', |
| 35 | - 'name' => __( 'Alert', 'invoicing' ), |
|
| 35 | + 'name' => __('Alert', 'invoicing'), |
|
| 36 | 36 | 'defaults' => array( |
| 37 | 37 | 'value' => '', |
| 38 | 38 | 'class' => 'alert-warning', |
| 39 | - 'text' => __( 'Alert', 'invoicing' ), |
|
| 39 | + 'text' => __('Alert', 'invoicing'), |
|
| 40 | 40 | 'dismissible' => false, |
| 41 | 41 | ) |
| 42 | 42 | ), |
| 43 | 43 | |
| 44 | 44 | array( |
| 45 | 45 | 'type' => 'separator', |
| 46 | - 'name' => __( 'Separator', 'invoicing' ), |
|
| 46 | + 'name' => __('Separator', 'invoicing'), |
|
| 47 | 47 | 'defaults' => array( |
| 48 | 48 | 'value' => '', |
| 49 | 49 | ), |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | array( |
| 53 | 53 | 'type' => 'text', |
| 54 | - 'name' => __( 'Text Input', 'invoicing' ), |
|
| 54 | + 'name' => __('Text Input', 'invoicing'), |
|
| 55 | 55 | 'defaults' => array( |
| 56 | - 'placeholder' => __( 'Enter some text', 'invoicing' ), |
|
| 56 | + 'placeholder' => __('Enter some text', 'invoicing'), |
|
| 57 | 57 | 'value' => '', |
| 58 | - 'label' => __( 'Field Label', 'invoicing' ), |
|
| 58 | + 'label' => __('Field Label', 'invoicing'), |
|
| 59 | 59 | 'description' => '', |
| 60 | 60 | 'required' => false, |
| 61 | 61 | ) |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | array( |
| 65 | 65 | 'type' => 'textarea', |
| 66 | - 'name' => __( 'Textarea', 'invoicing' ), |
|
| 66 | + 'name' => __('Textarea', 'invoicing'), |
|
| 67 | 67 | 'defaults' => array( |
| 68 | - 'placeholder' => __( 'Enter your text here', 'invoicing' ), |
|
| 68 | + 'placeholder' => __('Enter your text here', 'invoicing'), |
|
| 69 | 69 | 'value' => '', |
| 70 | - 'label' => __( 'Textarea Label', 'invoicing' ), |
|
| 70 | + 'label' => __('Textarea Label', 'invoicing'), |
|
| 71 | 71 | 'description' => '', |
| 72 | 72 | 'required' => false, |
| 73 | 73 | ) |
@@ -75,27 +75,27 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | array( |
| 77 | 77 | 'type' => 'select', |
| 78 | - 'name' => __( 'Dropdown', 'invoicing' ), |
|
| 78 | + 'name' => __('Dropdown', 'invoicing'), |
|
| 79 | 79 | 'defaults' => array( |
| 80 | - 'placeholder' => __( 'Select a value', 'invoicing' ), |
|
| 80 | + 'placeholder' => __('Select a value', 'invoicing'), |
|
| 81 | 81 | 'value' => '', |
| 82 | - 'label' => __( 'Dropdown Label', 'invoicing' ), |
|
| 82 | + 'label' => __('Dropdown Label', 'invoicing'), |
|
| 83 | 83 | 'description' => '', |
| 84 | 84 | 'required' => false, |
| 85 | 85 | 'options' => array( |
| 86 | - esc_attr__( 'Option One', 'invoicing' ), |
|
| 87 | - esc_attr__( 'Option Two', 'invoicing' ), |
|
| 88 | - esc_attr__( 'Option Three', 'invoicing' ) |
|
| 86 | + esc_attr__('Option One', 'invoicing'), |
|
| 87 | + esc_attr__('Option Two', 'invoicing'), |
|
| 88 | + esc_attr__('Option Three', 'invoicing') |
|
| 89 | 89 | ), |
| 90 | 90 | ) |
| 91 | 91 | ), |
| 92 | 92 | |
| 93 | 93 | array( |
| 94 | 94 | 'type' => 'checkbox', |
| 95 | - 'name' => __( 'Checkbox', 'invoicing' ), |
|
| 95 | + 'name' => __('Checkbox', 'invoicing'), |
|
| 96 | 96 | 'defaults' => array( |
| 97 | 97 | 'value' => '', |
| 98 | - 'label' => __( 'Checkbox Label', 'invoicing' ), |
|
| 98 | + 'label' => __('Checkbox Label', 'invoicing'), |
|
| 99 | 99 | 'description' => '', |
| 100 | 100 | 'required' => false, |
| 101 | 101 | ) |
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | array( |
| 105 | 105 | 'type' => 'radio', |
| 106 | - 'name' => __( 'Radio', 'invoicing' ), |
|
| 106 | + 'name' => __('Radio', 'invoicing'), |
|
| 107 | 107 | 'defaults' => array( |
| 108 | - 'label' => __( 'Select one choice', 'invoicing' ), |
|
| 108 | + 'label' => __('Select one choice', 'invoicing'), |
|
| 109 | 109 | 'options' => array( |
| 110 | - esc_attr__( 'Choice One', 'invoicing' ), |
|
| 111 | - esc_attr__( 'Choice Two', 'invoicing' ), |
|
| 112 | - esc_attr__( 'Choice Three', 'invoicing' ) |
|
| 110 | + esc_attr__('Choice One', 'invoicing'), |
|
| 111 | + esc_attr__('Choice Two', 'invoicing'), |
|
| 112 | + esc_attr__('Choice Three', 'invoicing') |
|
| 113 | 113 | ), |
| 114 | 114 | ) |
| 115 | 115 | ), |
| 116 | 116 | |
| 117 | 117 | array( |
| 118 | 118 | 'type' => 'date', |
| 119 | - 'name' => __( 'Date', 'invoicing' ), |
|
| 119 | + 'name' => __('Date', 'invoicing'), |
|
| 120 | 120 | 'defaults' => array( |
| 121 | 121 | 'value' => '', |
| 122 | - 'label' => __( 'Date', 'invoicing' ), |
|
| 122 | + 'label' => __('Date', 'invoicing'), |
|
| 123 | 123 | 'description' => '', |
| 124 | 124 | 'single' => 'single', |
| 125 | 125 | 'required' => false, |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | array( |
| 130 | 130 | 'type' => 'time', |
| 131 | - 'name' => __( 'Time', 'invoicing' ), |
|
| 131 | + 'name' => __('Time', 'invoicing'), |
|
| 132 | 132 | 'defaults' => array( |
| 133 | 133 | 'value' => '', |
| 134 | - 'label' => __( 'Time', 'invoicing' ), |
|
| 134 | + 'label' => __('Time', 'invoicing'), |
|
| 135 | 135 | 'description' => '', |
| 136 | 136 | 'required' => false, |
| 137 | 137 | ) |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | array( |
| 141 | 141 | 'type' => 'number', |
| 142 | - 'name' => __( 'Number', 'invoicing' ), |
|
| 142 | + 'name' => __('Number', 'invoicing'), |
|
| 143 | 143 | 'defaults' => array( |
| 144 | 144 | 'placeholder' => '', |
| 145 | 145 | 'value' => '', |
| 146 | - 'label' => __( 'Number', 'invoicing' ), |
|
| 146 | + 'label' => __('Number', 'invoicing'), |
|
| 147 | 147 | 'description' => '', |
| 148 | 148 | 'required' => false, |
| 149 | 149 | ) |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | array( |
| 153 | 153 | 'type' => 'website', |
| 154 | - 'name' => __( 'Website', 'invoicing' ), |
|
| 154 | + 'name' => __('Website', 'invoicing'), |
|
| 155 | 155 | 'defaults' => array( |
| 156 | 156 | 'placeholder' => 'http://example.com', |
| 157 | 157 | 'value' => '', |
| 158 | - 'label' => __( 'Website', 'invoicing' ), |
|
| 158 | + 'label' => __('Website', 'invoicing'), |
|
| 159 | 159 | 'description' => '', |
| 160 | 160 | 'required' => false, |
| 161 | 161 | ) |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | array( |
| 165 | 165 | 'type' => 'email', |
| 166 | - 'name' => __( 'Email', 'invoicing' ), |
|
| 166 | + 'name' => __('Email', 'invoicing'), |
|
| 167 | 167 | 'defaults' => array( |
| 168 | 168 | 'placeholder' => '[email protected]', |
| 169 | 169 | 'value' => '', |
| 170 | - 'label' => __( 'Email Address', 'invoicing' ), |
|
| 170 | + 'label' => __('Email Address', 'invoicing'), |
|
| 171 | 171 | 'description' => '', |
| 172 | 172 | 'required' => false, |
| 173 | 173 | ) |
@@ -175,31 +175,31 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | array( |
| 177 | 177 | 'type' => 'file_upload', |
| 178 | - 'name' => __( 'File Upload', 'invoicing' ), |
|
| 178 | + 'name' => __('File Upload', 'invoicing'), |
|
| 179 | 179 | 'defaults' => array( |
| 180 | 180 | 'value' => '', |
| 181 | - 'label' => __( 'Upload File', 'invoicing' ), |
|
| 181 | + 'label' => __('Upload File', 'invoicing'), |
|
| 182 | 182 | 'description' => '', |
| 183 | 183 | 'required' => false, |
| 184 | 184 | 'max_file_num' => 1, |
| 185 | - 'file_types' => array( 'jpg|jpeg|jpe', 'gif', 'png' ), |
|
| 185 | + 'file_types' => array('jpg|jpeg|jpe', 'gif', 'png'), |
|
| 186 | 186 | ) |
| 187 | 187 | ), |
| 188 | 188 | |
| 189 | 189 | array( |
| 190 | 190 | 'type' => 'address', |
| 191 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 191 | + 'name' => __('Address', 'invoicing'), |
|
| 192 | 192 | 'defaults' => array( |
| 193 | 193 | |
| 194 | 194 | 'address_type' => 'billing', |
| 195 | - 'billing_address_title' => __( 'Billing Address', 'invoicing' ), |
|
| 196 | - 'shipping_address_title' => __( 'Shipping Address', 'invoicing' ), |
|
| 197 | - 'shipping_address_toggle' => __( 'Same billing & shipping address.', 'invoicing' ), |
|
| 195 | + 'billing_address_title' => __('Billing Address', 'invoicing'), |
|
| 196 | + 'shipping_address_title' => __('Shipping Address', 'invoicing'), |
|
| 197 | + 'shipping_address_toggle' => __('Same billing & shipping address.', 'invoicing'), |
|
| 198 | 198 | 'fields' => array( |
| 199 | 199 | array( |
| 200 | 200 | 'placeholder' => 'Jon', |
| 201 | 201 | 'value' => '', |
| 202 | - 'label' => __( 'First Name', 'invoicing' ), |
|
| 202 | + 'label' => __('First Name', 'invoicing'), |
|
| 203 | 203 | 'description' => '', |
| 204 | 204 | 'required' => false, |
| 205 | 205 | 'visible' => true, |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | array( |
| 211 | 211 | 'placeholder' => 'Snow', |
| 212 | 212 | 'value' => '', |
| 213 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
| 213 | + 'label' => __('Last Name', 'invoicing'), |
|
| 214 | 214 | 'description' => '', |
| 215 | 215 | 'required' => false, |
| 216 | 216 | 'visible' => true, |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | array( |
| 222 | 222 | 'placeholder' => '', |
| 223 | 223 | 'value' => '', |
| 224 | - 'label' => __( 'Address', 'invoicing' ), |
|
| 224 | + 'label' => __('Address', 'invoicing'), |
|
| 225 | 225 | 'description' => '', |
| 226 | 226 | 'required' => false, |
| 227 | 227 | 'visible' => true, |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | array( |
| 233 | 233 | 'placeholder' => '', |
| 234 | 234 | 'value' => '', |
| 235 | - 'label' => __( 'City', 'invoicing' ), |
|
| 235 | + 'label' => __('City', 'invoicing'), |
|
| 236 | 236 | 'description' => '', |
| 237 | 237 | 'required' => false, |
| 238 | 238 | 'visible' => true, |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | ), |
| 242 | 242 | |
| 243 | 243 | array( |
| 244 | - 'placeholder' => __( 'Select your country' ), |
|
| 244 | + 'placeholder' => __('Select your country'), |
|
| 245 | 245 | 'value' => '', |
| 246 | - 'label' => __( 'Country', 'invoicing' ), |
|
| 246 | + 'label' => __('Country', 'invoicing'), |
|
| 247 | 247 | 'description' => '', |
| 248 | 248 | 'required' => false, |
| 249 | 249 | 'visible' => true, |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | ), |
| 253 | 253 | |
| 254 | 254 | array( |
| 255 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 255 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 256 | 256 | 'value' => '', |
| 257 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
| 257 | + 'label' => __('State / Province', 'invoicing'), |
|
| 258 | 258 | 'description' => '', |
| 259 | 259 | 'required' => false, |
| 260 | 260 | 'visible' => true, |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | array( |
| 266 | 266 | 'placeholder' => '', |
| 267 | 267 | 'value' => '', |
| 268 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 268 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
| 269 | 269 | 'description' => '', |
| 270 | 270 | 'required' => false, |
| 271 | 271 | 'visible' => true, |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | array( |
| 277 | 277 | 'placeholder' => '', |
| 278 | 278 | 'value' => '', |
| 279 | - 'label' => __( 'Phone', 'invoicing' ), |
|
| 279 | + 'label' => __('Phone', 'invoicing'), |
|
| 280 | 280 | 'description' => '', |
| 281 | 281 | 'required' => false, |
| 282 | 282 | 'visible' => true, |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | array( |
| 288 | 288 | 'placeholder' => '', |
| 289 | 289 | 'value' => '', |
| 290 | - 'label' => __( 'Company', 'invoicing' ), |
|
| 290 | + 'label' => __('Company', 'invoicing'), |
|
| 291 | 291 | 'description' => '', |
| 292 | 292 | 'required' => false, |
| 293 | 293 | 'visible' => false, |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | array( |
| 299 | 299 | 'placeholder' => '', |
| 300 | 300 | 'value' => '', |
| 301 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
| 301 | + 'label' => __('Company ID', 'invoicing'), |
|
| 302 | 302 | 'description' => '', |
| 303 | 303 | 'required' => false, |
| 304 | 304 | 'visible' => false, |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | array( |
| 310 | 310 | 'placeholder' => '', |
| 311 | 311 | 'value' => '', |
| 312 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
| 312 | + 'label' => __('VAT Number', 'invoicing'), |
|
| 313 | 313 | 'description' => '', |
| 314 | 314 | 'required' => false, |
| 315 | 315 | 'visible' => false, |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | array( |
| 324 | 324 | 'type' => 'billing_email', |
| 325 | - 'name' => __( 'Billing Email', 'invoicing' ), |
|
| 325 | + 'name' => __('Billing Email', 'invoicing'), |
|
| 326 | 326 | 'defaults' => array( |
| 327 | 327 | 'placeholder' => '[email protected]', |
| 328 | 328 | 'value' => '', |
| 329 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
| 329 | + 'label' => __('Billing Email', 'invoicing'), |
|
| 330 | 330 | 'description' => '', |
| 331 | 331 | 'premade' => true, |
| 332 | 332 | ) |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | array( |
| 336 | 336 | 'type' => 'discount', |
| 337 | - 'name' => __( 'Discount Input', 'invoicing' ), |
|
| 337 | + 'name' => __('Discount Input', 'invoicing'), |
|
| 338 | 338 | 'defaults' => array( |
| 339 | 339 | 'value' => '', |
| 340 | - 'input_label' => __( 'Coupon Code', 'invoicing' ), |
|
| 341 | - 'button_label' => __( 'Apply Coupon', 'invoicing' ), |
|
| 342 | - 'description' => __( 'Have a discount code? Enter it above.', 'invoicing' ), |
|
| 340 | + 'input_label' => __('Coupon Code', 'invoicing'), |
|
| 341 | + 'button_label' => __('Apply Coupon', 'invoicing'), |
|
| 342 | + 'description' => __('Have a discount code? Enter it above.', 'invoicing'), |
|
| 343 | 343 | ) |
| 344 | 344 | ), |
| 345 | 345 | |
| 346 | 346 | array( |
| 347 | 347 | 'type' => 'items', |
| 348 | - 'name' => __( 'Items', 'invoicing' ), |
|
| 348 | + 'name' => __('Items', 'invoicing'), |
|
| 349 | 349 | 'defaults' => array( |
| 350 | 350 | 'value' => '', |
| 351 | 351 | 'items_type' => 'total', |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | array( |
| 359 | 359 | 'type' => 'price_input', |
| 360 | - 'name' => __( 'Price Input', 'invoicing' ), |
|
| 360 | + 'name' => __('Price Input', 'invoicing'), |
|
| 361 | 361 | 'defaults' => array( |
| 362 | 362 | 'placeholder' => wpinv_format_amount(0), |
| 363 | 363 | 'value' => wpinv_format_amount(0), |
| 364 | 364 | 'minimum' => wpinv_format_amount(0), |
| 365 | - 'label' => __( 'Enter Amount', 'invoicing' ), |
|
| 365 | + 'label' => __('Enter Amount', 'invoicing'), |
|
| 366 | 366 | 'description' => '', |
| 367 | 367 | ) |
| 368 | 368 | ), |
| 369 | 369 | |
| 370 | 370 | array( |
| 371 | 371 | 'type' => 'price_select', |
| 372 | - 'name' => __( 'Price Select', 'invoicing' ), |
|
| 372 | + 'name' => __('Price Select', 'invoicing'), |
|
| 373 | 373 | 'defaults' => array( |
| 374 | 374 | 'description' => '', |
| 375 | - 'label' => __( 'Select Amount', 'invoicing' ), |
|
| 375 | + 'label' => __('Select Amount', 'invoicing'), |
|
| 376 | 376 | 'options' => 'Option 1|10, Option 2|20', |
| 377 | 377 | 'placeholder' => '', |
| 378 | 378 | 'select_type' => 'select', |
@@ -381,39 +381,39 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | array( |
| 383 | 383 | 'type' => 'pay_button', |
| 384 | - 'name' => __( 'Payment Button', 'invoicing' ), |
|
| 384 | + 'name' => __('Payment Button', 'invoicing'), |
|
| 385 | 385 | 'defaults' => array( |
| 386 | 386 | 'value' => '', |
| 387 | 387 | 'class' => 'btn-primary', |
| 388 | - 'label' => __( 'Pay %price% »', 'invoicing' ), |
|
| 389 | - 'free' => __( 'Continue »', 'invoicing' ), |
|
| 390 | - 'description' => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
| 388 | + 'label' => __('Pay %price% »', 'invoicing'), |
|
| 389 | + 'free' => __('Continue »', 'invoicing'), |
|
| 390 | + 'description' => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
| 391 | 391 | 'premade' => true, |
| 392 | 392 | ) |
| 393 | 393 | ), |
| 394 | 394 | |
| 395 | 395 | array( |
| 396 | 396 | 'type' => 'gateway_select', |
| 397 | - 'name' => __( 'Gateway Select', 'invoicing' ), |
|
| 397 | + 'name' => __('Gateway Select', 'invoicing'), |
|
| 398 | 398 | 'defaults' => array( |
| 399 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
| 399 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
| 400 | 400 | 'premade' => true, |
| 401 | 401 | ) |
| 402 | 402 | ), |
| 403 | 403 | |
| 404 | 404 | array( |
| 405 | 405 | 'type' => 'total_payable', |
| 406 | - 'name' => __( 'Total Payable', 'invoicing' ), |
|
| 406 | + 'name' => __('Total Payable', 'invoicing'), |
|
| 407 | 407 | 'defaults' => array( |
| 408 | - 'text' => __( 'Total to pay:', 'invoicing' ), |
|
| 408 | + 'text' => __('Total to pay:', 'invoicing'), |
|
| 409 | 409 | ) |
| 410 | 410 | ), |
| 411 | 411 | |
| 412 | 412 | array( |
| 413 | 413 | 'type' => 'ip_address', |
| 414 | - 'name' => __( 'IP Address', 'invoicing' ), |
|
| 414 | + 'name' => __('IP Address', 'invoicing'), |
|
| 415 | 415 | 'defaults' => array( |
| 416 | - 'text' => __( 'Your IP address is:', 'invoicing' ), |
|
| 416 | + 'text' => __('Your IP address is:', 'invoicing'), |
|
| 417 | 417 | ) |
| 418 | 418 | ) |
| 419 | 419 | ); |
@@ -7,34 +7,34 @@ 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 ) ) { |
|
| 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 | 15 | $label .= "<span class='text-danger'> *</span>"; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 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, '|' ) ) { |
|
| 29 | + if (false === strpos($disabled_date, '|')) { |
|
| 30 | 30 | $disable_dates[] = $disabled_date; |
| 31 | 31 | continue; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $disabled_date = explode( '|', $disabled_date ); |
|
| 34 | + $disabled_date = explode('|', $disabled_date); |
|
| 35 | 35 | $disable_dates[] = array( |
| 36 | - 'from' => trim( $disabled_date[0] ), |
|
| 37 | - 'to' => trim( $disabled_date[1] ), |
|
| 36 | + 'from' => trim($disabled_date[0]), |
|
| 37 | + 'to' => trim($disabled_date[1]), |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | } |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $options = array( |
| 45 | - 'data-default-date' => empty( 'default_date' ) ? false : $default_date, |
|
| 46 | - 'data-min-date' => empty( 'min_date' ) ? false : $min_date, |
|
| 47 | - 'data-max-date' => empty( 'max_date' ) ? false : $max_date, |
|
| 48 | - 'data-mode' => empty( 'mode' ) ? 'single' : $mode, |
|
| 49 | - 'data-alt-format' => get_option( 'date_format', 'F j, Y' ), |
|
| 45 | + 'data-default-date' => empty('default_date') ? false : $default_date, |
|
| 46 | + 'data-min-date' => empty('min_date') ? false : $min_date, |
|
| 47 | + 'data-max-date' => empty('max_date') ? false : $max_date, |
|
| 48 | + 'data-mode' => empty('mode') ? 'single' : $mode, |
|
| 49 | + 'data-alt-format' => get_option('date_format', 'F j, Y'), |
|
| 50 | 50 | 'data-date-format' => 'Y-m-d', |
| 51 | 51 | 'data-alt-input' => 'true', |
| 52 | - 'data-disable_alt' => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ), |
|
| 53 | - 'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ), |
|
| 52 | + 'data-disable_alt' => empty($disabled_dates) ? false : wp_json_encode($disable_dates), |
|
| 53 | + 'data-disable_days_alt' => empty($disable_days) ? false : wp_json_encode(wp_parse_id_list($disable_days)), |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | echo aui()->input( |
| 57 | 57 | array( |
| 58 | - 'name' => esc_attr( $id ), |
|
| 59 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 60 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
| 61 | - 'required' => ! empty( $required ), |
|
| 58 | + 'name' => esc_attr($id), |
|
| 59 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 60 | + 'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder), |
|
| 61 | + 'required' => !empty($required), |
|
| 62 | 62 | 'label' => $label, |
| 63 | 63 | 'label_type' => 'vertical', |
| 64 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 64 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 65 | 65 | 'type' => 'datepicker', |
| 66 | 66 | 'class' => $label_class . ' getpaid-init-flatpickr flatpickr-input', |
| 67 | - 'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ), |
|
| 67 | + 'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)), |
|
| 68 | 68 | ) |
| 69 | 69 | ); |
@@ -7,104 +7,104 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class='form-group'> |
| 15 | 15 | <label class="d-block"> |
| 16 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
| 16 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
| 17 | 17 | <input v-model='active_form_element.label' class='form-control' type="text"/> |
| 18 | 18 | </label> |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class='form-group'> |
| 22 | 22 | <label class="d-block"> |
| 23 | - <span><?php esc_html_e( 'Default Date', 'invoicing' ); ?></span> |
|
| 24 | - <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?> |
|
| 25 | - <input v-model='active_form_element.default_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/> |
|
| 23 | + <span><?php esc_html_e('Default Date', 'invoicing'); ?></span> |
|
| 24 | + <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?> |
|
| 25 | + <input v-model='active_form_element.default_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/> |
|
| 26 | 26 | </label> |
| 27 | 27 | </div> |
| 28 | 28 | |
| 29 | 29 | <div class='form-group'> |
| 30 | 30 | <label class="d-block"> |
| 31 | - <span><?php esc_html_e( 'Minimum Date', 'invoicing' ); ?></span> |
|
| 32 | - <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?> |
|
| 33 | - <input v-model='active_form_element.min_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/> |
|
| 34 | - <small class="form-text text-muted"><?php _e( 'Specify the minimum/earliest date (inclusively) allowed for selection.', 'invoicing' ); ?></small> |
|
| 31 | + <span><?php esc_html_e('Minimum Date', 'invoicing'); ?></span> |
|
| 32 | + <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?> |
|
| 33 | + <input v-model='active_form_element.min_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/> |
|
| 34 | + <small class="form-text text-muted"><?php _e('Specify the minimum/earliest date (inclusively) allowed for selection.', 'invoicing'); ?></small> |
|
| 35 | 35 | </label> |
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | 38 | <div class='form-group'> |
| 39 | 39 | <label class="d-block"> |
| 40 | - <span><?php esc_html_e( 'Maximum Date', 'invoicing' ); ?></span> |
|
| 41 | - <?php echo wpi_help_tip( sprintf( __( 'You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?> |
|
| 42 | - <input v-model='active_form_element.max_date' placeholder="<?php esc_attr_e( 'None', 'invoicing' ); ?>" class='form-control' type="text"/> |
|
| 43 | - <small class="form-text text-muted"><?php _e( 'Specify the maximum/latest date (inclusively) allowed for selection.', 'invoicing' ); ?></small> |
|
| 40 | + <span><?php esc_html_e('Maximum Date', 'invoicing'); ?></span> |
|
| 41 | + <?php echo wpi_help_tip(sprintf(__('You can enter the shortcut "today" or enter a date matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?> |
|
| 42 | + <input v-model='active_form_element.max_date' placeholder="<?php esc_attr_e('None', 'invoicing'); ?>" class='form-control' type="text"/> |
|
| 43 | + <small class="form-text text-muted"><?php _e('Specify the maximum/latest date (inclusively) allowed for selection.', 'invoicing'); ?></small> |
|
| 44 | 44 | </label> |
| 45 | 45 | </div> |
| 46 | 46 | |
| 47 | 47 | <div class='form-group'> |
| 48 | 48 | <label class="d-block"> |
| 49 | - <span><?php esc_html_e( 'Disabled Dates', 'invoicing' ); ?></span> |
|
| 50 | - <?php echo wpi_help_tip( sprintf( __( 'You can use the shortcut "today" or enter dates matching the format Y-m-d, e.g %s', 'invoicing' ), current_time( 'Y-m-d' ) ), false, true ); ?> |
|
| 51 | - <input v-model='active_form_element.disabled_dates' placeholder="<?php echo esc_attr( sprintf( __( 'For example, %s', 'invoicing' ), 'today,2025-04-01|2025-05-01,2025-09-01|2025-12-01' ) ); ?>" class='form-control' type="text"/> |
|
| 52 | - <small class="form-text text-muted"><?php _e( 'Specify the dates to ignore. Use commas to separate dates and "|" to separate date ranges.', 'invoicing' ); ?></small> |
|
| 49 | + <span><?php esc_html_e('Disabled Dates', 'invoicing'); ?></span> |
|
| 50 | + <?php echo wpi_help_tip(sprintf(__('You can use the shortcut "today" or enter dates matching the format Y-m-d, e.g %s', 'invoicing'), current_time('Y-m-d')), false, true); ?> |
|
| 51 | + <input v-model='active_form_element.disabled_dates' placeholder="<?php echo esc_attr(sprintf(__('For example, %s', 'invoicing'), 'today,2025-04-01|2025-05-01,2025-09-01|2025-12-01')); ?>" class='form-control' type="text"/> |
|
| 52 | + <small class="form-text text-muted"><?php _e('Specify the dates to ignore. Use commas to separate dates and "|" to separate date ranges.', 'invoicing'); ?></small> |
|
| 53 | 53 | </label> |
| 54 | 54 | </div> |
| 55 | 55 | |
| 56 | 56 | <div class='form-group'> |
| 57 | 57 | <label class="d-block"> |
| 58 | - <span><?php esc_html_e( 'Disable Days', 'invoicing' ) ?></span> |
|
| 58 | + <span><?php esc_html_e('Disable Days', 'invoicing') ?></span> |
|
| 59 | 59 | <gpselect2 class='form-control custom-select' v-model='active_form_element.disable_days' multiple> |
| 60 | - <option value='0'><?php esc_html_e( 'Sundays', 'invoicing' ); ?></option> |
|
| 61 | - <option value='1'><?php esc_html_e( 'Mondays', 'invoicing' ); ?></option> |
|
| 62 | - <option value='2'><?php esc_html_e( 'Tuesdays', 'invoicing' ); ?></option> |
|
| 63 | - <option value='3'><?php esc_html_e( 'Wednesdays', 'invoicing' ); ?></option> |
|
| 64 | - <option value='4'><?php esc_html_e( 'Thursdays', 'invoicing' ); ?></option> |
|
| 65 | - <option value='5'><?php esc_html_e( 'Fridays', 'invoicing' ); ?></option> |
|
| 66 | - <option value='6'><?php esc_html_e( 'Saturdays', 'invoicing' ); ?></option> |
|
| 60 | + <option value='0'><?php esc_html_e('Sundays', 'invoicing'); ?></option> |
|
| 61 | + <option value='1'><?php esc_html_e('Mondays', 'invoicing'); ?></option> |
|
| 62 | + <option value='2'><?php esc_html_e('Tuesdays', 'invoicing'); ?></option> |
|
| 63 | + <option value='3'><?php esc_html_e('Wednesdays', 'invoicing'); ?></option> |
|
| 64 | + <option value='4'><?php esc_html_e('Thursdays', 'invoicing'); ?></option> |
|
| 65 | + <option value='5'><?php esc_html_e('Fridays', 'invoicing'); ?></option> |
|
| 66 | + <option value='6'><?php esc_html_e('Saturdays', 'invoicing'); ?></option> |
|
| 67 | 67 | </gpselect2> |
| 68 | - <small class="form-text text-muted"><?php _e( 'Optionally specify the days of the week to disable.', 'invoicing' ); ?></small> |
|
| 68 | + <small class="form-text text-muted"><?php _e('Optionally specify the days of the week to disable.', 'invoicing'); ?></small> |
|
| 69 | 69 | </label> |
| 70 | 70 | </div> |
| 71 | 71 | |
| 72 | 72 | <div class='form-group'> |
| 73 | 73 | <label class="d-block"> |
| 74 | - <span><?php esc_html_e( 'Mode', 'invoicing' ) ?></span> |
|
| 74 | + <span><?php esc_html_e('Mode', 'invoicing') ?></span> |
|
| 75 | 75 | <select class='form-control custom-select' v-model='active_form_element.mode'> |
| 76 | - <option value='single'><?php esc_html_e( 'Users can only select a single date', 'invoicing' ); ?></option> |
|
| 77 | - <option value='range'><?php esc_html_e( 'Users can select a date range', 'invoicing' ); ?></option> |
|
| 78 | - <option value='multiple'><?php esc_html_e( 'Users can select multiple dates', 'invoicing' ); ?></option> |
|
| 76 | + <option value='single'><?php esc_html_e('Users can only select a single date', 'invoicing'); ?></option> |
|
| 77 | + <option value='range'><?php esc_html_e('Users can select a date range', 'invoicing'); ?></option> |
|
| 78 | + <option value='multiple'><?php esc_html_e('Users can select multiple dates', 'invoicing'); ?></option> |
|
| 79 | 79 | </select> |
| 80 | 80 | </label> |
| 81 | 81 | </div> |
| 82 | 82 | |
| 83 | 83 | <div class='form-group'> |
| 84 | 84 | <label class="d-block"> |
| 85 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
| 86 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
| 87 | - <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small> |
|
| 85 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
| 86 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
| 87 | + <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small> |
|
| 88 | 88 | </label> |
| 89 | 89 | </div> |
| 90 | 90 | |
| 91 | 91 | <div class='form-group form-check'> |
| 92 | 92 | <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' /> |
| 93 | - <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label> |
|
| 93 | + <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label> |
|
| 94 | 94 | </div> |
| 95 | 95 | |
| 96 | 96 | <div class='form-group form-check'> |
| 97 | 97 | <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' /> |
| 98 | - <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label> |
|
| 98 | + <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label> |
|
| 99 | 99 | </div> |
| 100 | 100 | |
| 101 | 101 | <hr class='featurette-divider mt-4'> |
| 102 | 102 | |
| 103 | 103 | <div class='form-group'> |
| 104 | 104 | <label class="d-block"> |
| 105 | - <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span> |
|
| 105 | + <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span> |
|
| 106 | 106 | <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" /> |
| 107 | - <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span> |
|
| 107 | + <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span> |
|
| 108 | 108 | </label> |
| 109 | 109 | </div> |
| 110 | 110 | |
@@ -9,26 +9,26 @@ discard block |
||
| 9 | 9 | * @var WPInv_Invoice $invoice |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | 14 | // Totals rows. |
| 15 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
| 15 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
| 16 | 16 | |
| 17 | -do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals ); |
|
| 17 | +do_action('getpaid_before_invoice_line_totals', $invoice, $totals); |
|
| 18 | 18 | |
| 19 | 19 | ?> |
| 20 | 20 | <div class='getpaid-invoice-line-totals'> |
| 21 | 21 | <div class="row"> |
| 22 | 22 | <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0"> |
| 23 | 23 | |
| 24 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
| 24 | + <?php foreach ($totals as $key => $label) : ?> |
|
| 25 | 25 | |
| 26 | - <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>"> |
|
| 26 | + <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>"> |
|
| 27 | 27 | |
| 28 | 28 | <div class="form-row"> |
| 29 | 29 | |
| 30 | 30 | <div class="col-8 getpaid-invoice-line-totals-label"> |
| 31 | - <?php echo esc_html( $label ); ?> |
|
| 31 | + <?php echo esc_html($label); ?> |
|
| 32 | 32 | </div> |
| 33 | 33 | |
| 34 | 34 | <div class="col-4 getpaid-invoice-line-totals-value pl-0"> |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | <?php |
| 37 | 37 | |
| 38 | 38 | // Total tax. |
| 39 | - if ( 'tax' == $key ) { |
|
| 40 | - echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
| 39 | + if ('tax' == $key) { |
|
| 40 | + echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
| 41 | 41 | |
| 42 | - if ( wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
| 42 | + if (wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
| 43 | 43 | |
| 44 | 44 | $taxes = $invoice->get_total_tax(); |
| 45 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
| 45 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
| 46 | 46 | echo ' <em class="text-muted small">'; |
| 47 | - _x( '(Reverse charged)','This is a legal term for reverse charging tax in the EU', 'invoicing' ); |
|
| 47 | + _x('(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing'); |
|
| 48 | 48 | echo '</em>'; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -53,32 +53,32 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Total Fee. |
| 56 | - if ( 'fee' == $key ) { |
|
| 57 | - echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
| 56 | + if ('fee' == $key) { |
|
| 57 | + echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Total discount. |
| 61 | - if ( 'discount' == $key ) { |
|
| 62 | - echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
| 61 | + if ('discount' == $key) { |
|
| 62 | + echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Shipping. |
| 66 | - if ( 'shipping' == $key ) { |
|
| 67 | - echo wpinv_price( $invoice->get_shipping(), $invoice->get_currency() ); |
|
| 66 | + if ('shipping' == $key) { |
|
| 67 | + echo wpinv_price($invoice->get_shipping(), $invoice->get_currency()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Sub total. |
| 71 | - if ( 'subtotal' == $key ) { |
|
| 72 | - echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
| 71 | + if ('subtotal' == $key) { |
|
| 72 | + echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Total. |
| 76 | - if ( 'total' == $key ) { |
|
| 77 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 76 | + if ('total' == $key) { |
|
| 77 | + echo wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Fires when printing a cart total. |
| 81 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
| 81 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | |
@@ -92,4 +92,4 @@ discard block |
||
| 92 | 92 | </div> |
| 93 | 93 | </div> <!-- end .getpaid-invoice-line-totals --> |
| 94 | 94 | |
| 95 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
| 95 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
|