@@ -194,6 +194,9 @@ |
||
| 194 | 194 | return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | +/** |
|
| 198 | + * @return integer |
|
| 199 | + */ |
|
| 197 | 200 | function wpinv_currency_decimal_filter( $decimals = 2 ) { |
| 198 | 201 | $currency = wpinv_get_currency(); |
| 199 | 202 | |
@@ -1,121 +1,121 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function wpinv_use_taxes() { |
| 8 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
| 8 | + $ret = wpinv_get_option('enable_taxes', false); |
|
| 9 | 9 | |
| 10 | - return (bool) apply_filters( 'wpinv_use_taxes', $ret ); |
|
| 10 | + return (bool)apply_filters('wpinv_use_taxes', $ret); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | function wpinv_get_tax_rates() { |
| 14 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 14 | + $rates = get_option('wpinv_tax_rates', array()); |
|
| 15 | 15 | |
| 16 | - return apply_filters( 'wpinv_get_tax_rates', $rates ); |
|
| 16 | + return apply_filters('wpinv_get_tax_rates', $rates); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) { |
|
| 19 | +function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) { |
|
| 20 | 20 | global $wpinv_euvat, $wpi_tax_rates, $wpi_userID; |
| 21 | - $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array(); |
|
| 21 | + $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array(); |
|
| 22 | 22 | |
| 23 | - if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) { |
|
| 23 | + if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) { |
|
| 24 | 24 | return $wpi_tax_rates[$item_id]; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) { |
|
| 27 | + if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) { |
|
| 28 | 28 | $wpi_tax_rates[$item_id] = 0; |
| 29 | 29 | return 0; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $is_global = false; |
| 33 | - if ( $item_id == 'global' ) { |
|
| 33 | + if ($item_id == 'global') { |
|
| 34 | 34 | $is_global = true; |
| 35 | 35 | $item_id = 0; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $rate = (float)wpinv_get_option( 'tax_rate', 0 ); |
|
| 39 | - $user_address = wpinv_get_user_address( $wpi_userID ); |
|
| 38 | + $rate = (float)wpinv_get_option('tax_rate', 0); |
|
| 39 | + $user_address = wpinv_get_user_address($wpi_userID); |
|
| 40 | 40 | |
| 41 | - if( empty( $country ) ) { |
|
| 42 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
| 41 | + if (empty($country)) { |
|
| 42 | + if (!empty($_POST['wpinv_country'])) { |
|
| 43 | 43 | $country = $_POST['wpinv_country']; |
| 44 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
| 44 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
| 45 | 45 | $country = $_POST['wpinv_country']; |
| 46 | - } elseif( !empty( $_POST['country'] ) ) { |
|
| 46 | + } elseif (!empty($_POST['country'])) { |
|
| 47 | 47 | $country = $_POST['country']; |
| 48 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
| 48 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
| 49 | 49 | $country = $user_address['country']; |
| 50 | 50 | } |
| 51 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 51 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if( empty( $state ) ) { |
|
| 55 | - if( !empty( $_POST['wpinv_state'] ) ) { |
|
| 54 | + if (empty($state)) { |
|
| 55 | + if (!empty($_POST['wpinv_state'])) { |
|
| 56 | 56 | $state = $_POST['wpinv_state']; |
| 57 | - } elseif( !empty( $_POST['wpinv_state'] ) ) { |
|
| 57 | + } elseif (!empty($_POST['wpinv_state'])) { |
|
| 58 | 58 | $state = $_POST['wpinv_state']; |
| 59 | - } elseif( !empty( $_POST['state'] ) ) { |
|
| 59 | + } elseif (!empty($_POST['state'])) { |
|
| 60 | 60 | $state = $_POST['state']; |
| 61 | - } elseif( is_user_logged_in() && !empty( $user_address ) ) { |
|
| 61 | + } elseif (is_user_logged_in() && !empty($user_address)) { |
|
| 62 | 62 | $state = $user_address['state']; |
| 63 | 63 | } |
| 64 | - $state = !empty( $state ) ? $state : wpinv_get_default_state(); |
|
| 64 | + $state = !empty($state) ? $state : wpinv_get_default_state(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if( !empty( $country ) ) { |
|
| 68 | - $tax_rates = wpinv_get_tax_rates(); |
|
| 67 | + if (!empty($country)) { |
|
| 68 | + $tax_rates = wpinv_get_tax_rates(); |
|
| 69 | 69 | |
| 70 | - if( !empty( $tax_rates ) ) { |
|
| 70 | + if (!empty($tax_rates)) { |
|
| 71 | 71 | // Locate the tax rate for this country / state, if it exists |
| 72 | - foreach( $tax_rates as $key => $tax_rate ) { |
|
| 73 | - if( $country != $tax_rate['country'] ) |
|
| 72 | + foreach ($tax_rates as $key => $tax_rate) { |
|
| 73 | + if ($country != $tax_rate['country']) |
|
| 74 | 74 | continue; |
| 75 | 75 | |
| 76 | - if( !empty( $tax_rate['global'] ) ) { |
|
| 77 | - if( !empty( $tax_rate['rate'] ) ) { |
|
| 78 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 76 | + if (!empty($tax_rate['global'])) { |
|
| 77 | + if (!empty($tax_rate['rate'])) { |
|
| 78 | + $rate = number_format($tax_rate['rate'], 4); |
|
| 79 | 79 | } |
| 80 | 80 | } else { |
| 81 | 81 | |
| 82 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 82 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
| 83 | 83 | continue; |
| 84 | 84 | |
| 85 | 85 | $state_rate = $tax_rate['rate']; |
| 86 | - if( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 87 | - $rate = number_format( $state_rate, 4 ); |
|
| 86 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
| 87 | + $rate = number_format($state_rate, 4); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id ); |
|
| 94 | + $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id); |
|
| 95 | 95 | |
| 96 | - if ( !empty( $item_id ) ) { |
|
| 96 | + if (!empty($item_id)) { |
|
| 97 | 97 | $wpi_tax_rates[$item_id] = $rate; |
| 98 | - } else if ( $is_global ) { |
|
| 98 | + } else if ($is_global) { |
|
| 99 | 99 | $wpi_tax_rates['global'] = $rate; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return $rate; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) { |
|
| 106 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
| 107 | - $rate = round( $rate, 4 ); |
|
| 105 | +function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) { |
|
| 106 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
| 107 | + $rate = round($rate, 4); |
|
| 108 | 108 | $formatted = $rate .= '%'; |
| 109 | - return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id ); |
|
| 109 | + return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | -function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) { |
|
| 113 | - $rate = wpinv_get_tax_rate( $country, $state, $item_id ); |
|
| 112 | +function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) { |
|
| 113 | + $rate = wpinv_get_tax_rate($country, $state, $item_id); |
|
| 114 | 114 | $tax = 0.00; |
| 115 | 115 | |
| 116 | - if ( wpinv_use_taxes() ) { |
|
| 117 | - if ( wpinv_prices_include_tax() ) { |
|
| 118 | - $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) ); |
|
| 116 | + if (wpinv_use_taxes()) { |
|
| 117 | + if (wpinv_prices_include_tax()) { |
|
| 118 | + $pre_tax = ($amount / ((1 + $rate) * 0.01)); |
|
| 119 | 119 | $tax = $amount - $pre_tax; |
| 120 | 120 | } else { |
| 121 | 121 | $tax = $amount * $rate * 0.01; |
@@ -123,46 +123,46 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id ); |
|
| 126 | + return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | function wpinv_prices_include_tax() { |
| 130 | 130 | return false; // TODO |
| 131 | - $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
| 131 | + $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
| 132 | 132 | |
| 133 | - return apply_filters( 'wpinv_prices_include_tax', $ret ); |
|
| 133 | + return apply_filters('wpinv_prices_include_tax', $ret); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
| 137 | - return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) ); |
|
| 136 | +function wpinv_sales_tax_for_year($year = null) { |
|
| 137 | + return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year))); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
| 140 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
| 141 | 141 | global $wpdb; |
| 142 | 142 | |
| 143 | 143 | // Start at zero |
| 144 | 144 | $tax = 0; |
| 145 | 145 | |
| 146 | - if ( ! empty( $year ) ) { |
|
| 146 | + if (!empty($year)) { |
|
| 147 | 147 | $args = array( |
| 148 | 148 | 'post_type' => 'wpi_invoice', |
| 149 | - 'post_status' => array( 'publish', 'revoked' ), |
|
| 149 | + 'post_status' => array('publish', 'revoked'), |
|
| 150 | 150 | 'posts_per_page' => -1, |
| 151 | 151 | 'year' => $year, |
| 152 | 152 | 'fields' => 'ids' |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - $payments = get_posts( $args ); |
|
| 156 | - $payment_ids = implode( ',', $payments ); |
|
| 155 | + $payments = get_posts($args); |
|
| 156 | + $payment_ids = implode(',', $payments); |
|
| 157 | 157 | |
| 158 | - if ( count( $payments ) > 0 ) { |
|
| 158 | + if (count($payments) > 0) { |
|
| 159 | 159 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
| 160 | - $tax = $wpdb->get_var( $sql ); |
|
| 160 | + $tax = $wpdb->get_var($sql); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
| 165 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | function wpinv_is_cart_taxed() { |
@@ -171,33 +171,33 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | function wpinv_prices_show_tax_on_checkout() { |
| 173 | 173 | return false; // TODO |
| 174 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
| 174 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
| 175 | 175 | |
| 176 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
| 176 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | function wpinv_display_tax_rate() { |
| 180 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
| 180 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
| 181 | 181 | |
| 182 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
| 182 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | function wpinv_cart_needs_tax_address_fields() { |
| 186 | - if( !wpinv_is_cart_taxed() ) |
|
| 186 | + if (!wpinv_is_cart_taxed()) |
|
| 187 | 187 | return false; |
| 188 | 188 | |
| 189 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
| 189 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
| 193 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
| 194 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
| 192 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
| 193 | + $ret = (bool)get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
| 194 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
| 197 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
| 198 | 198 | $currency = wpinv_get_currency(); |
| 199 | 199 | |
| 200 | - switch ( $currency ) { |
|
| 200 | + switch ($currency) { |
|
| 201 | 201 | case 'RIAL' : |
| 202 | 202 | case 'JPY' : |
| 203 | 203 | case 'TWD' : |
@@ -206,48 +206,48 @@ discard block |
||
| 206 | 206 | break; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
| 209 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | function wpinv_tax_amount() { |
| 213 | 213 | $output = 0.00; |
| 214 | 214 | |
| 215 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
| 215 | + return apply_filters('wpinv_tax_amount', $output); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | function wpinv_recalculated_tax() { |
| 219 | - define( 'WPINV_RECALCTAX', true ); |
|
| 219 | + define('WPINV_RECALCTAX', true); |
|
| 220 | 220 | } |
| 221 | -add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1 ); |
|
| 221 | +add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculated_tax', 1); |
|
| 222 | 222 | |
| 223 | -function wpinv_recalculate_tax( $return = false ) { |
|
| 223 | +function wpinv_recalculate_tax($return = false) { |
|
| 224 | 224 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 225 | - if ( empty( $invoice_id ) ) { |
|
| 225 | + if (empty($invoice_id)) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 229 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 230 | 230 | |
| 231 | - if ( empty( $invoice ) ) { |
|
| 231 | + if (empty($invoice)) { |
|
| 232 | 232 | return false; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( empty( $_POST['country'] ) ) { |
|
| 235 | + if (empty($_POST['country'])) { |
|
| 236 | 236 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | $invoice->country = sanitize_text_field($_POST['country']); |
| 240 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
| 240 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
| 241 | 241 | if (isset($_POST['state'])) { |
| 242 | 242 | $invoice->state = sanitize_text_field($_POST['state']); |
| 243 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
| 243 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $invoice->cart_details = wpinv_get_cart_content_details(); |
| 247 | 247 | |
| 248 | - $subtotal = wpinv_get_cart_subtotal( $invoice->cart_details ); |
|
| 249 | - $tax = wpinv_get_cart_tax( $invoice->cart_details ); |
|
| 250 | - $total = wpinv_get_cart_total( $invoice->cart_details ); |
|
| 248 | + $subtotal = wpinv_get_cart_subtotal($invoice->cart_details); |
|
| 249 | + $tax = wpinv_get_cart_tax($invoice->cart_details); |
|
| 250 | + $total = wpinv_get_cart_total($invoice->cart_details); |
|
| 251 | 251 | |
| 252 | 252 | $invoice->tax = $tax; |
| 253 | 253 | $invoice->subtotal = $subtotal; |
@@ -255,60 +255,60 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $invoice->save(); |
| 257 | 257 | |
| 258 | - if ( $invoice->is_free_trial() ) { |
|
| 258 | + if ($invoice->is_free_trial()) { |
|
| 259 | 259 | $total = 0; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $response = array( |
| 263 | - 'total' => html_entity_decode( wpinv_price( wpinv_format_amount( $total ) ), ENT_COMPAT, 'UTF-8' ), |
|
| 263 | + 'total' => html_entity_decode(wpinv_price(wpinv_format_amount($total)), ENT_COMPAT, 'UTF-8'), |
|
| 264 | 264 | 'total_raw' => $total, |
| 265 | - 'html' => wpinv_checkout_cart( $invoice->cart_details, false ), |
|
| 265 | + 'html' => wpinv_checkout_cart($invoice->cart_details, false), |
|
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | - if ( $return ) { |
|
| 268 | + if ($return) { |
|
| 269 | 269 | return $response; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - wp_send_json( $response ); |
|
| 272 | + wp_send_json($response); |
|
| 273 | 273 | } |
| 274 | -add_action( 'wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax' ); |
|
| 275 | -add_action( 'wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax' ); |
|
| 274 | +add_action('wp_ajax_wpinv_recalculate_tax', 'wpinv_recalculate_tax'); |
|
| 275 | +add_action('wp_ajax_nopriv_wpinv_recalculate_tax', 'wpinv_recalculate_tax'); |
|
| 276 | 276 | |
| 277 | 277 | // VAT Settings |
| 278 | -function wpinv_vat_rate_add_callback( $args ) { |
|
| 278 | +function wpinv_vat_rate_add_callback($args) { |
|
| 279 | 279 | ?> |
| 280 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 280 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 281 | 281 | <?php |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | -function wpinv_vat_rate_delete_callback( $args ) { |
|
| 284 | +function wpinv_vat_rate_delete_callback($args) { |
|
| 285 | 285 | global $wpinv_euvat; |
| 286 | 286 | |
| 287 | 287 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
| 288 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : ''; |
|
| 289 | - if ( isset( $vat_classes[$vat_class] ) ) { |
|
| 288 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : ''; |
|
| 289 | + if (isset($vat_classes[$vat_class])) { |
|
| 290 | 290 | ?> |
| 291 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 291 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
| 292 | 292 | <?php |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -function wpinv_vat_rates_callback( $args ) { |
|
| 296 | +function wpinv_vat_rates_callback($args) { |
|
| 297 | 297 | global $wpinv_euvat; |
| 298 | 298 | |
| 299 | 299 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
| 300 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard'; |
|
| 300 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard'; |
|
| 301 | 301 | |
| 302 | 302 | $eu_states = $wpinv_euvat->get_eu_states(); |
| 303 | 303 | $countries = wpinv_get_country_list(); |
| 304 | 304 | $vat_groups = $wpinv_euvat->get_vat_groups(); |
| 305 | - $rates = $wpinv_euvat->get_vat_rates( $vat_class ); |
|
| 305 | + $rates = $wpinv_euvat->get_vat_rates($vat_class); |
|
| 306 | 306 | ob_start(); |
| 307 | 307 | ?> |
| 308 | 308 | </td><tr> |
| 309 | 309 | <td colspan="2" class="wpinv_vat_tdbox"> |
| 310 | - <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" /> |
|
| 311 | - <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p> |
|
| 310 | + <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" /> |
|
| 311 | + <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p> |
|
| 312 | 312 | <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts"> |
| 313 | 313 | <colgroup> |
| 314 | 314 | <col width="50px" /> |
@@ -320,43 +320,43 @@ discard block |
||
| 320 | 320 | </colgroup> |
| 321 | 321 | <thead> |
| 322 | 322 | <tr> |
| 323 | - <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 324 | - <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 325 | - <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 326 | - <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th> |
|
| 327 | - <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th> |
|
| 323 | + <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th> |
|
| 324 | + <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 325 | + <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 326 | + <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th> |
|
| 327 | + <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th> |
|
| 328 | 328 | </tr> |
| 329 | 329 | </thead> |
| 330 | 330 | <tbody> |
| 331 | - <?php if( !empty( $eu_states ) ) { ?> |
|
| 331 | + <?php if (!empty($eu_states)) { ?> |
|
| 332 | 332 | <?php |
| 333 | - foreach ( $eu_states as $state ) { |
|
| 334 | - $country_name = isset( $countries[$state] ) ? $countries[$state] : ''; |
|
| 333 | + foreach ($eu_states as $state) { |
|
| 334 | + $country_name = isset($countries[$state]) ? $countries[$state] : ''; |
|
| 335 | 335 | |
| 336 | 336 | // Filter the rate for each country |
| 337 | - $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } ); |
|
| 337 | + $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } ); |
|
| 338 | 338 | |
| 339 | 339 | // If one does not exist create a default |
| 340 | - $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array(); |
|
| 340 | + $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array(); |
|
| 341 | 341 | |
| 342 | - $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true; |
|
| 343 | - $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : ''; |
|
| 344 | - $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : ''; |
|
| 345 | - $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' ); |
|
| 342 | + $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true; |
|
| 343 | + $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : ''; |
|
| 344 | + $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : ''; |
|
| 345 | + $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced'); |
|
| 346 | 346 | ?> |
| 347 | 347 | <tr> |
| 348 | 348 | <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td> |
| 349 | 349 | <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td> |
| 350 | 350 | <td class="wpinv_vat_global"> |
| 351 | - <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" /> |
|
| 352 | - <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 353 | - <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" /> |
|
| 351 | + <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" /> |
|
| 352 | + <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 353 | + <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" /> |
|
| 354 | 354 | </td> |
| 355 | - <td class="wpinv_vat_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
| 356 | - <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
| 355 | + <td class="wpinv_vat_rate"><input type="number" class="small-text" step="0.10" min="0.00" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
| 356 | + <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
| 357 | 357 | <td class="wpinv_vat_group"> |
| 358 | 358 | <?php |
| 359 | - echo wpinv_html_select( array( |
|
| 359 | + echo wpinv_html_select(array( |
|
| 360 | 360 | 'name' => 'vat_rates[' . $state . '][group]', |
| 361 | 361 | 'selected' => $vat_group, |
| 362 | 362 | 'id' => 'vat_rates[' . $state . '][group]', |
@@ -366,14 +366,14 @@ discard block |
||
| 366 | 366 | 'chosen' => false, |
| 367 | 367 | 'show_option_all' => false, |
| 368 | 368 | 'show_option_none' => false |
| 369 | - ) ); |
|
| 369 | + )); |
|
| 370 | 370 | ?> |
| 371 | 371 | </td> |
| 372 | 372 | </tr> |
| 373 | 373 | <?php } ?> |
| 374 | 374 | <tr> |
| 375 | 375 | <td colspan="6" style="background-color:#fafafa;"> |
| 376 | - <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
| 376 | + <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
| 377 | 377 | </td> |
| 378 | 378 | </tr> |
| 379 | 379 | <?php } ?> |
@@ -385,35 +385,35 @@ discard block |
||
| 385 | 385 | echo $content; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -function wpinv_vat_number_callback( $args ) { |
|
| 388 | +function wpinv_vat_number_callback($args) { |
|
| 389 | 389 | global $wpinv_euvat; |
| 390 | 390 | |
| 391 | 391 | $vat_number = $wpinv_euvat->get_vat_number(); |
| 392 | 392 | $vat_valid = $wpinv_euvat->is_vat_validated(); |
| 393 | 393 | |
| 394 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 395 | - $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' ); |
|
| 394 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 395 | + $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing'); |
|
| 396 | 396 | $disabled = $vat_valid ? 'disabled="disabled"' : " "; |
| 397 | 397 | |
| 398 | - $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>'; |
|
| 399 | - $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>'; |
|
| 398 | + $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>'; |
|
| 399 | + $html .= '<span> <input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>'; |
|
| 400 | 400 | $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>'; |
| 401 | - $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>'; |
|
| 402 | - $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">'; |
|
| 401 | + $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>'; |
|
| 402 | + $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">'; |
|
| 403 | 403 | |
| 404 | 404 | echo $html; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | -function wpinv_eu_fallback_rate_callback( $args ) { |
|
| 407 | +function wpinv_eu_fallback_rate_callback($args) { |
|
| 408 | 408 | global $wpinv_options; |
| 409 | 409 | |
| 410 | - $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' ); |
|
| 411 | - $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small'; |
|
| 410 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : ''); |
|
| 411 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small'; |
|
| 412 | 412 | |
| 413 | - $html = '<input type="number" min="0", max="99.99" step="0.10" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 414 | - $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>'; |
|
| 415 | - $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>'; |
|
| 416 | - $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
| 413 | + $html = '<input type="number" min="0", max="99.99" step="0.10" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 414 | + $html .= '<span> <input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>'; |
|
| 415 | + $html .= '<span> <input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>'; |
|
| 416 | + $html .= '<span> <input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span>'; |
|
| 417 | 417 | $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>'; |
| 418 | 418 | echo $html; |
| 419 | 419 | ?> |
@@ -421,36 +421,36 @@ discard block |
||
| 421 | 421 | <?php |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | -function wpinv_vat_ip_lookup_callback( $args ) { |
|
| 424 | +function wpinv_vat_ip_lookup_callback($args) { |
|
| 425 | 425 | global $wpinv_options, $wpinv_euvat; |
| 426 | 426 | |
| 427 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : 'default' ); |
|
| 427 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default'); |
|
| 428 | 428 | |
| 429 | 429 | $options = array(); |
| 430 | - if ( function_exists( 'geoip_country_code_by_name' ) ) { |
|
| 431 | - $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' ); |
|
| 430 | + if (function_exists('geoip_country_code_by_name')) { |
|
| 431 | + $options['geoip'] = __('PHP GeoIP extension', 'invoicing'); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | $geoip2_database = $wpinv_euvat->geoip2_country_dbfile(); |
| 435 | 435 | |
| 436 | - if ( !function_exists( 'bcadd' ) ) { |
|
| 437 | - $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' ); |
|
| 436 | + if (!function_exists('bcadd')) { |
|
| 437 | + $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing'); |
|
| 438 | 438 | } else { |
| 439 | - $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : ''; |
|
| 439 | + $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : ''; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if ( $geoip2_database !== false && empty( $geoip2_message ) ) { |
|
| 443 | - $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' ); |
|
| 442 | + if ($geoip2_database !== false && empty($geoip2_message)) { |
|
| 443 | + $options['geoip2'] = __('GeoIP2 Database', 'invoicing'); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - if ( function_exists( 'simplexml_load_file' ) ) { |
|
| 447 | - $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' ); |
|
| 446 | + if (function_exists('simplexml_load_file')) { |
|
| 447 | + $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing'); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - $options['site'] = __( 'Use default country', 'invoicing' ); |
|
| 451 | - $options['default'] = __( 'Auto', 'invoicing' ); |
|
| 450 | + $options['site'] = __('Use default country', 'invoicing'); |
|
| 451 | + $options['default'] = __('Auto', 'invoicing'); |
|
| 452 | 452 | |
| 453 | - $html = wpinv_html_select( array( |
|
| 453 | + $html = wpinv_html_select(array( |
|
| 454 | 454 | 'name' => "wpinv_settings[{$args['id']}]", |
| 455 | 455 | 'selected' => $value, |
| 456 | 456 | 'id' => "wpinv_settings[{$args['id']}]", |
@@ -463,23 +463,23 @@ discard block |
||
| 463 | 463 | )); |
| 464 | 464 | |
| 465 | 465 | $desc = '<label for="wpinv_settings[' . $args['id'] . ']">'; |
| 466 | - $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' ); |
|
| 466 | + $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing'); |
|
| 467 | 467 | $desc .= '<p>'; |
| 468 | - if ( empty( $geoip2_message ) ) { |
|
| 469 | - if ( $geoip2_database ) { |
|
| 468 | + if (empty($geoip2_message)) { |
|
| 469 | + if ($geoip2_database) { |
|
| 470 | 470 | $last_updated = ''; |
| 471 | - if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) { |
|
| 472 | - $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated ); |
|
| 473 | - $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated ); |
|
| 471 | + if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) { |
|
| 472 | + $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated); |
|
| 473 | + $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated); |
|
| 474 | 474 | } |
| 475 | - $desc .= __( 'GeoIP2 database exists:', 'invoicing' ) . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~55MB)', 'invoicing' ) . '"></input>'; |
|
| 475 | + $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . ' <input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~55MB)', 'invoicing') . '"></input>'; |
|
| 476 | 476 | } else { |
| 477 | - $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~53MB)"></input><br>' . __( 'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' ); |
|
| 477 | + $desc .= __('GeoIP2 database does not exist:', 'invoicing') . ' <input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~53MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing'); |
|
| 478 | 478 | } |
| 479 | 479 | } else { |
| 480 | 480 | $desc .= $geoip2_message; |
| 481 | 481 | } |
| 482 | - $desc .= '</p><p>'. __( 'GeoPlugin is a great free service please consider supporting them: ', 'invoicing' ) . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
| 482 | + $desc .= '</p><p>' . __('GeoPlugin is a great free service please consider supporting them: ', 'invoicing') . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>'; |
|
| 483 | 483 | $desc .= '</label>'; |
| 484 | 484 | |
| 485 | 485 | $html .= $desc; |
@@ -70,8 +70,9 @@ discard block |
||
| 70 | 70 | if( !empty( $tax_rates ) ) { |
| 71 | 71 | // Locate the tax rate for this country / state, if it exists |
| 72 | 72 | foreach( $tax_rates as $key => $tax_rate ) { |
| 73 | - if( $country != $tax_rate['country'] ) |
|
| 74 | - continue; |
|
| 73 | + if( $country != $tax_rate['country'] ) { |
|
| 74 | + continue; |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | if( !empty( $tax_rate['global'] ) ) { |
| 77 | 78 | if( !empty( $tax_rate['rate'] ) ) { |
@@ -79,8 +80,9 @@ discard block |
||
| 79 | 80 | } |
| 80 | 81 | } else { |
| 81 | 82 | |
| 82 | - if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 83 | - continue; |
|
| 83 | + if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | $state_rate = $tax_rate['rate']; |
| 86 | 88 | if( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -183,8 +185,9 @@ discard block |
||
| 183 | 185 | } |
| 184 | 186 | |
| 185 | 187 | function wpinv_cart_needs_tax_address_fields() { |
| 186 | - if( !wpinv_is_cart_taxed() ) |
|
| 187 | - return false; |
|
| 188 | + if( !wpinv_is_cart_taxed() ) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 188 | 191 | |
| 189 | 192 | return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
| 190 | 193 | } |
@@ -136,6 +136,9 @@ discard block |
||
| 136 | 136 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | +/** |
|
| 140 | + * @param string $template_name |
|
| 141 | + */ |
|
| 139 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 140 | 143 | ob_start(); |
| 141 | 144 | wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
@@ -168,6 +171,10 @@ discard block |
||
| 168 | 171 | return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
| 169 | 172 | } |
| 170 | 173 | |
| 174 | +/** |
|
| 175 | + * @param string $slug |
|
| 176 | + * @param boolean $name |
|
| 177 | + */ |
|
| 171 | 178 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 172 | 179 | do_action( 'get_template_part_' . $slug, $slug, $name ); |
| 173 | 180 | |
@@ -867,6 +874,9 @@ discard block |
||
| 867 | 874 | return apply_filters( 'wpinv_get_watermark', $output, $id ); |
| 868 | 875 | } |
| 869 | 876 | |
| 877 | +/** |
|
| 878 | + * @param integer $id |
|
| 879 | + */ |
|
| 870 | 880 | function wpinv_get_watermark( $id ) { |
| 871 | 881 | if ( !$id > 0 ) { |
| 872 | 882 | return NULL; |
@@ -117,29 +117,29 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 119 | 119 | if ( ! empty( $args ) && is_array( $args ) ) { |
| 120 | - extract( $args ); |
|
| 121 | - } |
|
| 120 | + extract( $args ); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 124 | - if ( ! file_exists( $located ) ) { |
|
| 123 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 124 | + if ( ! file_exists( $located ) ) { |
|
| 125 | 125 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
| 126 | - return; |
|
| 127 | - } |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - // Allow 3rd party plugin filter template file from their plugin. |
|
| 130 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 129 | + // Allow 3rd party plugin filter template file from their plugin. |
|
| 130 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 131 | 131 | |
| 132 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 132 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 133 | 133 | |
| 134 | - include( $located ); |
|
| 134 | + include( $located ); |
|
| 135 | 135 | |
| 136 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 136 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 140 | - ob_start(); |
|
| 141 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | - return ob_get_clean(); |
|
| 140 | + ob_start(); |
|
| 141 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | + return ob_get_clean(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -169,120 +169,120 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 172 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 172 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 173 | 173 | |
| 174 | - // Setup possible parts |
|
| 175 | - $templates = array(); |
|
| 176 | - if ( isset( $name ) ) |
|
| 177 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 178 | - $templates[] = $slug . '.php'; |
|
| 174 | + // Setup possible parts |
|
| 175 | + $templates = array(); |
|
| 176 | + if ( isset( $name ) ) |
|
| 177 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 178 | + $templates[] = $slug . '.php'; |
|
| 179 | 179 | |
| 180 | - // Allow template parts to be filtered |
|
| 181 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 180 | + // Allow template parts to be filtered |
|
| 181 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 182 | 182 | |
| 183 | - // Return the part that is found |
|
| 184 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 183 | + // Return the part that is found |
|
| 184 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 188 | - // No file found yet |
|
| 189 | - $located = false; |
|
| 188 | + // No file found yet |
|
| 189 | + $located = false; |
|
| 190 | 190 | |
| 191 | - // Try to find a template file |
|
| 192 | - foreach ( (array)$template_names as $template_name ) { |
|
| 191 | + // Try to find a template file |
|
| 192 | + foreach ( (array)$template_names as $template_name ) { |
|
| 193 | 193 | |
| 194 | - // Continue if template is empty |
|
| 195 | - if ( empty( $template_name ) ) |
|
| 196 | - continue; |
|
| 194 | + // Continue if template is empty |
|
| 195 | + if ( empty( $template_name ) ) |
|
| 196 | + continue; |
|
| 197 | 197 | |
| 198 | - // Trim off any slashes from the template name |
|
| 199 | - $template_name = ltrim( $template_name, '/' ); |
|
| 198 | + // Trim off any slashes from the template name |
|
| 199 | + $template_name = ltrim( $template_name, '/' ); |
|
| 200 | 200 | |
| 201 | - // try locating this template file by looping through the template paths |
|
| 202 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 201 | + // try locating this template file by looping through the template paths |
|
| 202 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 203 | 203 | |
| 204 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 205 | - $located = $template_path . $template_name; |
|
| 206 | - break; |
|
| 207 | - } |
|
| 208 | - } |
|
| 204 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 205 | + $located = $template_path . $template_name; |
|
| 206 | + break; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - if( !empty( $located ) ) { |
|
| 211 | - break; |
|
| 212 | - } |
|
| 213 | - } |
|
| 210 | + if( !empty( $located ) ) { |
|
| 211 | + break; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 216 | - load_template( $located, $require_once ); |
|
| 215 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 216 | + load_template( $located, $require_once ); |
|
| 217 | 217 | |
| 218 | - return $located; |
|
| 218 | + return $located; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | function wpinv_get_theme_template_paths() { |
| 222 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 222 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 223 | 223 | |
| 224 | - $file_paths = array( |
|
| 225 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 226 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 227 | - 100 => wpinv_get_templates_dir() |
|
| 228 | - ); |
|
| 224 | + $file_paths = array( |
|
| 225 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 226 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 227 | + 100 => wpinv_get_templates_dir() |
|
| 228 | + ); |
|
| 229 | 229 | |
| 230 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 230 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 231 | 231 | |
| 232 | - // sort the file paths based on priority |
|
| 233 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 232 | + // sort the file paths based on priority |
|
| 233 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 234 | 234 | |
| 235 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 235 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | function wpinv_get_theme_template_dir_name() { |
| 239 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 239 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function wpinv_checkout_meta_tags() { |
| 243 | 243 | |
| 244 | - $pages = array(); |
|
| 245 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 246 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 247 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 244 | + $pages = array(); |
|
| 245 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 246 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 247 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 248 | 248 | |
| 249 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 250 | - return; |
|
| 251 | - } |
|
| 249 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 250 | + return; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 253 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 254 | 254 | } |
| 255 | 255 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 256 | 256 | |
| 257 | 257 | function wpinv_add_body_classes( $class ) { |
| 258 | - $classes = (array)$class; |
|
| 258 | + $classes = (array)$class; |
|
| 259 | 259 | |
| 260 | - if( wpinv_is_checkout() ) { |
|
| 261 | - $classes[] = 'wpinv-checkout'; |
|
| 262 | - $classes[] = 'wpinv-page'; |
|
| 263 | - } |
|
| 260 | + if( wpinv_is_checkout() ) { |
|
| 261 | + $classes[] = 'wpinv-checkout'; |
|
| 262 | + $classes[] = 'wpinv-page'; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - if( wpinv_is_success_page() ) { |
|
| 266 | - $classes[] = 'wpinv-success'; |
|
| 267 | - $classes[] = 'wpinv-page'; |
|
| 268 | - } |
|
| 265 | + if( wpinv_is_success_page() ) { |
|
| 266 | + $classes[] = 'wpinv-success'; |
|
| 267 | + $classes[] = 'wpinv-page'; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 271 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 272 | - $classes[] = 'wpinv-page'; |
|
| 273 | - } |
|
| 270 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 271 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 272 | + $classes[] = 'wpinv-page'; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - if( wpinv_is_invoice_history_page() ) { |
|
| 276 | - $classes[] = 'wpinv-history'; |
|
| 277 | - $classes[] = 'wpinv-page'; |
|
| 278 | - } |
|
| 275 | + if( wpinv_is_invoice_history_page() ) { |
|
| 276 | + $classes[] = 'wpinv-history'; |
|
| 277 | + $classes[] = 'wpinv-page'; |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - if( wpinv_is_test_mode() ) { |
|
| 281 | - $classes[] = 'wpinv-test-mode'; |
|
| 282 | - $classes[] = 'wpinv-page'; |
|
| 283 | - } |
|
| 280 | + if( wpinv_is_test_mode() ) { |
|
| 281 | + $classes[] = 'wpinv-test-mode'; |
|
| 282 | + $classes[] = 'wpinv-page'; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - return array_unique( $classes ); |
|
| 285 | + return array_unique( $classes ); |
|
| 286 | 286 | } |
| 287 | 287 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 288 | 288 | |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
| 1444 | 1444 | |
| 1445 | 1445 | function wpinv_empty_cart_message() { |
| 1446 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1446 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | * @return void |
| 1454 | 1454 | */ |
| 1455 | 1455 | function wpinv_empty_checkout_cart() { |
| 1456 | - echo wpinv_empty_cart_message(); |
|
| 1456 | + echo wpinv_empty_cart_message(); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1459 | 1459 | |
@@ -1589,11 +1589,11 @@ discard block |
||
| 1589 | 1589 | $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
| 1590 | 1590 | |
| 1591 | 1591 | if(!empty($gateways)){ |
| 1592 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1593 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1594 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1595 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1596 | - ?> |
|
| 1592 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1593 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1594 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1595 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1596 | + ?> |
|
| 1597 | 1597 | <div class="list-group-item"> |
| 1598 | 1598 | <div class="radio"> |
| 1599 | 1599 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1606,9 +1606,9 @@ discard block |
||
| 1606 | 1606 | </div> |
| 1607 | 1607 | </div> |
| 1608 | 1608 | <?php |
| 1609 | - } |
|
| 1609 | + } |
|
| 1610 | 1610 | }else{ |
| 1611 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1611 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -7,109 +7,109 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( !is_admin() ) { |
|
| 15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
| 17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
| 18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
| 14 | +if (!is_admin()) { |
|
| 15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
| 17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
| 18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_template_path() { |
| 22 | - return apply_filters( 'wpinv_template_path', 'invoicing/' ); |
|
| 22 | + return apply_filters('wpinv_template_path', 'invoicing/'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function wpinv_post_class( $classes, $class, $post_id ) { |
|
| 25 | +function wpinv_post_class($classes, $class, $post_id) { |
|
| 26 | 26 | global $pagenow, $typenow; |
| 27 | 27 | |
| 28 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' ) { |
|
| 28 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && get_post_meta($post_id, '_wpinv_type', true) == 'package') { |
|
| 29 | 29 | $classes[] = 'wpi-gd-package'; |
| 30 | 30 | } |
| 31 | 31 | return $classes; |
| 32 | 32 | } |
| 33 | -add_filter( 'post_class', 'wpinv_post_class', 10, 3 ); |
|
| 33 | +add_filter('post_class', 'wpinv_post_class', 10, 3); |
|
| 34 | 34 | |
| 35 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
| 36 | - if ( empty( $invoice ) ) { |
|
| 35 | +function wpinv_display_invoice_top_bar($invoice) { |
|
| 36 | + if (empty($invoice)) { |
|
| 37 | 37 | return; |
| 38 | 38 | } |
| 39 | 39 | ?> |
| 40 | 40 | <div class="row wpinv-top-bar no-print"> |
| 41 | 41 | <div class="container"> |
| 42 | 42 | <div class="col-xs-6"> |
| 43 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
| 43 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
| 44 | 44 | </div> |
| 45 | 45 | <div class="col-xs-6 text-right"> |
| 46 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
| 46 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
| 47 | 47 | </div> |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
| 50 | 50 | <?php |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
| 54 | - if ( empty( $invoice ) ) { |
|
| 53 | +function wpinv_invoice_display_left_actions($invoice) { |
|
| 54 | + if (empty($invoice)) { |
|
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if($invoice->post_type == 'wpi_invoice'){ |
|
| 58 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 59 | 59 | |
| 60 | 60 | $user_id = (int)$invoice->get_user_id(); |
| 61 | 61 | $current_user_id = (int)get_current_user_id(); |
| 62 | 62 | |
| 63 | - if ( $user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment() ) { |
|
| 63 | + if ($user_id > 0 && $user_id == $current_user_id && $invoice->needs_payment()) { |
|
| 64 | 64 | ?> |
| 65 | - <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a> |
|
| 65 | + <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a> |
|
| 66 | 66 | <?php |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | do_action('wpinv_invoice_display_left_actions', $invoice); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
| 73 | - if ( empty( $invoice ) ) return; //Exit if invoice is not set. |
|
| 72 | +function wpinv_invoice_display_right_actions($invoice) { |
|
| 73 | + if (empty($invoice)) return; //Exit if invoice is not set. |
|
| 74 | 74 | |
| 75 | - if($invoice->post_type == 'wpi_invoice'){ |
|
| 75 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 76 | 76 | $user_id = (int)$invoice->get_user_id(); |
| 77 | 77 | $current_user_id = (int)get_current_user_id(); |
| 78 | 78 | |
| 79 | - if ( $user_id > 0 && $user_id == $current_user_id ) { |
|
| 79 | + if ($user_id > 0 && $user_id == $current_user_id) { |
|
| 80 | 80 | ?> |
| 81 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
| 82 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
| 81 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
| 82 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
| 83 | 83 | <?php } |
| 84 | 84 | } |
| 85 | 85 | do_action('wpinv_invoice_display_right_actions', $invoice); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -function wpinv_before_invoice_content( $content ) { |
|
| 88 | +function wpinv_before_invoice_content($content) { |
|
| 89 | 89 | global $post; |
| 90 | 90 | |
| 91 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 91 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 92 | 92 | ob_start(); |
| 93 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 93 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 94 | 94 | $content = ob_get_clean() . $content; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $content; |
| 98 | 98 | } |
| 99 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 99 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 100 | 100 | |
| 101 | -function wpinv_after_invoice_content( $content ) { |
|
| 101 | +function wpinv_after_invoice_content($content) { |
|
| 102 | 102 | global $post; |
| 103 | 103 | |
| 104 | - if ( $post && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 104 | + if ($post && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 105 | 105 | ob_start(); |
| 106 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 106 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 107 | 107 | $content .= ob_get_clean(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return $content; |
| 111 | 111 | } |
| 112 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 112 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 113 | 113 | |
| 114 | 114 | function wpinv_get_templates_dir() { |
| 115 | 115 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -119,105 +119,105 @@ discard block |
||
| 119 | 119 | return WPINV_PLUGIN_URL . 'templates'; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 123 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 124 | - extract( $args ); |
|
| 122 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 123 | + if (!empty($args) && is_array($args)) { |
|
| 124 | + extract($args); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 128 | - if ( ! file_exists( $located ) ) { |
|
| 129 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 127 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 128 | + if (!file_exists($located)) { |
|
| 129 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // Allow 3rd party plugin filter template file from their plugin. |
| 134 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 134 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 135 | 135 | |
| 136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 136 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 137 | 137 | |
| 138 | - include( $located ); |
|
| 138 | + include($located); |
|
| 139 | 139 | |
| 140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 140 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 144 | 144 | ob_start(); |
| 145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 145 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 146 | 146 | return ob_get_clean(); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 150 | - if ( ! $template_path ) { |
|
| 149 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 150 | + if (!$template_path) { |
|
| 151 | 151 | $template_path = wpinv_template_path(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ( ! $default_path ) { |
|
| 154 | + if (!$default_path) { |
|
| 155 | 155 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Look within passed path within the theme - this is priority. |
| 159 | 159 | $template = locate_template( |
| 160 | 160 | array( |
| 161 | - trailingslashit( $template_path ) . $template_name, |
|
| 161 | + trailingslashit($template_path) . $template_name, |
|
| 162 | 162 | $template_name |
| 163 | 163 | ) |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | // Get default templates/ |
| 167 | - if ( !$template && $default_path ) { |
|
| 168 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 167 | + if (!$template && $default_path) { |
|
| 168 | + $template = trailingslashit($default_path) . $template_name; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Return what we found. |
| 172 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 172 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 175 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 176 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 177 | 177 | |
| 178 | 178 | // Setup possible parts |
| 179 | 179 | $templates = array(); |
| 180 | - if ( isset( $name ) ) |
|
| 180 | + if (isset($name)) |
|
| 181 | 181 | $templates[] = $slug . '-' . $name . '.php'; |
| 182 | 182 | $templates[] = $slug . '.php'; |
| 183 | 183 | |
| 184 | 184 | // Allow template parts to be filtered |
| 185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 185 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 186 | 186 | |
| 187 | 187 | // Return the part that is found |
| 188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 188 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 191 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 192 | 192 | // No file found yet |
| 193 | 193 | $located = false; |
| 194 | 194 | |
| 195 | 195 | // Try to find a template file |
| 196 | - foreach ( (array)$template_names as $template_name ) { |
|
| 196 | + foreach ((array)$template_names as $template_name) { |
|
| 197 | 197 | |
| 198 | 198 | // Continue if template is empty |
| 199 | - if ( empty( $template_name ) ) |
|
| 199 | + if (empty($template_name)) |
|
| 200 | 200 | continue; |
| 201 | 201 | |
| 202 | 202 | // Trim off any slashes from the template name |
| 203 | - $template_name = ltrim( $template_name, '/' ); |
|
| 203 | + $template_name = ltrim($template_name, '/'); |
|
| 204 | 204 | |
| 205 | 205 | // try locating this template file by looping through the template paths |
| 206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 206 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 207 | 207 | |
| 208 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 208 | + if (file_exists($template_path . $template_name)) { |
|
| 209 | 209 | $located = $template_path . $template_name; |
| 210 | 210 | break; |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if( !empty( $located ) ) { |
|
| 214 | + if (!empty($located)) { |
|
| 215 | 215 | break; |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | - load_template( $located, $require_once ); |
|
| 219 | + if ((true == $load) && !empty($located)) |
|
| 220 | + load_template($located, $require_once); |
|
| 221 | 221 | |
| 222 | 222 | return $located; |
| 223 | 223 | } |
@@ -226,143 +226,143 @@ discard block |
||
| 226 | 226 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 227 | 227 | |
| 228 | 228 | $file_paths = array( |
| 229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 229 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 230 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 231 | 231 | 100 => wpinv_get_templates_dir() |
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 234 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 235 | 235 | |
| 236 | 236 | // sort the file paths based on priority |
| 237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 237 | + ksort($file_paths, SORT_NUMERIC); |
|
| 238 | 238 | |
| 239 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 239 | + return array_map('trailingslashit', $file_paths); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function wpinv_get_theme_template_dir_name() { |
| 243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 243 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates')); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | function wpinv_checkout_meta_tags() { |
| 247 | 247 | |
| 248 | 248 | $pages = array(); |
| 249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 249 | + $pages[] = wpinv_get_option('success_page'); |
|
| 250 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 251 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 252 | 252 | |
| 253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 253 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 254 | 254 | return; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 258 | 258 | } |
| 259 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 259 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 260 | 260 | |
| 261 | -function wpinv_add_body_classes( $class ) { |
|
| 261 | +function wpinv_add_body_classes($class) { |
|
| 262 | 262 | $classes = (array)$class; |
| 263 | 263 | |
| 264 | - if( wpinv_is_checkout() ) { |
|
| 264 | + if (wpinv_is_checkout()) { |
|
| 265 | 265 | $classes[] = 'wpinv-checkout'; |
| 266 | 266 | $classes[] = 'wpinv-page'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if( wpinv_is_success_page() ) { |
|
| 269 | + if (wpinv_is_success_page()) { |
|
| 270 | 270 | $classes[] = 'wpinv-success'; |
| 271 | 271 | $classes[] = 'wpinv-page'; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 274 | + if (wpinv_is_failed_transaction_page()) { |
|
| 275 | 275 | $classes[] = 'wpinv-failed-transaction'; |
| 276 | 276 | $classes[] = 'wpinv-page'; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if( wpinv_is_invoice_history_page() ) { |
|
| 279 | + if (wpinv_is_invoice_history_page()) { |
|
| 280 | 280 | $classes[] = 'wpinv-history'; |
| 281 | 281 | $classes[] = 'wpinv-page'; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if( wpinv_is_test_mode() ) { |
|
| 284 | + if (wpinv_is_test_mode()) { |
|
| 285 | 285 | $classes[] = 'wpinv-test-mode'; |
| 286 | 286 | $classes[] = 'wpinv-page'; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - return array_unique( $classes ); |
|
| 289 | + return array_unique($classes); |
|
| 290 | 290 | } |
| 291 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 291 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 292 | 292 | |
| 293 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 294 | - $args = array( 'nopaging' => true ); |
|
| 293 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 294 | + $args = array('nopaging' => true); |
|
| 295 | 295 | |
| 296 | - if ( ! empty( $status ) ) |
|
| 296 | + if (!empty($status)) |
|
| 297 | 297 | $args['post_status'] = $status; |
| 298 | 298 | |
| 299 | - $discounts = wpinv_get_discounts( $args ); |
|
| 299 | + $discounts = wpinv_get_discounts($args); |
|
| 300 | 300 | $options = array(); |
| 301 | 301 | |
| 302 | - if ( $discounts ) { |
|
| 303 | - foreach ( $discounts as $discount ) { |
|
| 304 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 302 | + if ($discounts) { |
|
| 303 | + foreach ($discounts as $discount) { |
|
| 304 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 305 | 305 | } |
| 306 | 306 | } else { |
| 307 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 307 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $output = wpinv_html_select( array( |
|
| 310 | + $output = wpinv_html_select(array( |
|
| 311 | 311 | 'name' => $name, |
| 312 | 312 | 'selected' => $selected, |
| 313 | 313 | 'options' => $options, |
| 314 | 314 | 'show_option_all' => false, |
| 315 | 315 | 'show_option_none' => false, |
| 316 | - ) ); |
|
| 316 | + )); |
|
| 317 | 317 | |
| 318 | 318 | return $output; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 322 | - $current = date( 'Y' ); |
|
| 323 | - $start_year = $current - absint( $years_before ); |
|
| 324 | - $end_year = $current + absint( $years_after ); |
|
| 325 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 321 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 322 | + $current = date('Y'); |
|
| 323 | + $start_year = $current - absint($years_before); |
|
| 324 | + $end_year = $current + absint($years_after); |
|
| 325 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 326 | 326 | $options = array(); |
| 327 | 327 | |
| 328 | - while ( $start_year <= $end_year ) { |
|
| 329 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 328 | + while ($start_year <= $end_year) { |
|
| 329 | + $options[absint($start_year)] = $start_year; |
|
| 330 | 330 | $start_year++; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $output = wpinv_html_select( array( |
|
| 333 | + $output = wpinv_html_select(array( |
|
| 334 | 334 | 'name' => $name, |
| 335 | 335 | 'selected' => $selected, |
| 336 | 336 | 'options' => $options, |
| 337 | 337 | 'show_option_all' => false, |
| 338 | 338 | 'show_option_none' => false |
| 339 | - ) ); |
|
| 339 | + )); |
|
| 340 | 340 | |
| 341 | 341 | return $output; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 344 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 345 | 345 | $month = 1; |
| 346 | 346 | $options = array(); |
| 347 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 347 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 348 | 348 | |
| 349 | - while ( $month <= 12 ) { |
|
| 350 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
| 349 | + while ($month <= 12) { |
|
| 350 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
| 351 | 351 | $month++; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $output = wpinv_html_select( array( |
|
| 354 | + $output = wpinv_html_select(array( |
|
| 355 | 355 | 'name' => $name, |
| 356 | 356 | 'selected' => $selected, |
| 357 | 357 | 'options' => $options, |
| 358 | 358 | 'show_option_all' => false, |
| 359 | 359 | 'show_option_none' => false |
| 360 | - ) ); |
|
| 360 | + )); |
|
| 361 | 361 | |
| 362 | 362 | return $output; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | -function wpinv_html_select( $args = array() ) { |
|
| 365 | +function wpinv_html_select($args = array()) { |
|
| 366 | 366 | $defaults = array( |
| 367 | 367 | 'options' => array(), |
| 368 | 368 | 'name' => null, |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | 'chosen' => false, |
| 373 | 373 | 'placeholder' => null, |
| 374 | 374 | 'multiple' => false, |
| 375 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 376 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 375 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 376 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 377 | 377 | 'data' => array(), |
| 378 | 378 | 'onchange' => null, |
| 379 | 379 | 'required' => false, |
@@ -381,78 +381,78 @@ discard block |
||
| 381 | 381 | 'readonly' => false, |
| 382 | 382 | ); |
| 383 | 383 | |
| 384 | - $args = wp_parse_args( $args, $defaults ); |
|
| 384 | + $args = wp_parse_args($args, $defaults); |
|
| 385 | 385 | |
| 386 | 386 | $data_elements = ''; |
| 387 | - foreach ( $args['data'] as $key => $value ) { |
|
| 388 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 387 | + foreach ($args['data'] as $key => $value) { |
|
| 388 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - if( $args['multiple'] ) { |
|
| 391 | + if ($args['multiple']) { |
|
| 392 | 392 | $multiple = ' MULTIPLE'; |
| 393 | 393 | } else { |
| 394 | 394 | $multiple = ''; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if( $args['chosen'] ) { |
|
| 397 | + if ($args['chosen']) { |
|
| 398 | 398 | $args['class'] .= ' wpinv-select-chosen'; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if( $args['placeholder'] ) { |
|
| 401 | + if ($args['placeholder']) { |
|
| 402 | 402 | $placeholder = $args['placeholder']; |
| 403 | 403 | } else { |
| 404 | 404 | $placeholder = ''; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $options = ''; |
| 408 | - if( !empty( $args['onchange'] ) ) { |
|
| 409 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 408 | + if (!empty($args['onchange'])) { |
|
| 409 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if( !empty( $args['required'] ) ) { |
|
| 412 | + if (!empty($args['required'])) { |
|
| 413 | 413 | $options .= ' required="required"'; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if( !empty( $args['disabled'] ) ) { |
|
| 416 | + if (!empty($args['disabled'])) { |
|
| 417 | 417 | $options .= ' disabled'; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if( !empty( $args['readonly'] ) ) { |
|
| 420 | + if (!empty($args['readonly'])) { |
|
| 421 | 421 | $options .= ' readonly'; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 425 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 424 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 425 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 426 | 426 | |
| 427 | - if ( $args['show_option_all'] ) { |
|
| 428 | - if( $args['multiple'] ) { |
|
| 429 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 427 | + if ($args['show_option_all']) { |
|
| 428 | + if ($args['multiple']) { |
|
| 429 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 430 | 430 | } else { |
| 431 | - $selected = selected( $args['selected'], 0, false ); |
|
| 431 | + $selected = selected($args['selected'], 0, false); |
|
| 432 | 432 | } |
| 433 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 433 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if ( !empty( $args['options'] ) ) { |
|
| 436 | + if (!empty($args['options'])) { |
|
| 437 | 437 | |
| 438 | - if ( $args['show_option_none'] ) { |
|
| 439 | - if( $args['multiple'] ) { |
|
| 440 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 438 | + if ($args['show_option_none']) { |
|
| 439 | + if ($args['multiple']) { |
|
| 440 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 441 | 441 | } else { |
| 442 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 442 | + $selected = selected($args['selected'] === "", true, false); |
|
| 443 | 443 | } |
| 444 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 444 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - foreach( $args['options'] as $key => $option ) { |
|
| 447 | + foreach ($args['options'] as $key => $option) { |
|
| 448 | 448 | |
| 449 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 450 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 449 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 450 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
| 451 | 451 | } else { |
| 452 | - $selected = selected( $args['selected'], $key, false ); |
|
| 452 | + $selected = selected($args['selected'], $key, false); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 455 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | return $output; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 464 | +function wpinv_item_dropdown($args = array()) { |
|
| 465 | 465 | $defaults = array( |
| 466 | 466 | 'name' => 'wpi_item', |
| 467 | 467 | 'id' => 'wpi_item', |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | 'selected' => 0, |
| 471 | 471 | 'chosen' => false, |
| 472 | 472 | 'number' => 100, |
| 473 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 474 | - 'data' => array( 'search-type' => 'item' ), |
|
| 473 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 474 | + 'data' => array('search-type' => 'item'), |
|
| 475 | 475 | 'show_option_all' => false, |
| 476 | 476 | 'show_option_none' => false, |
| 477 | 477 | 'with_packages' => true, |
| 478 | 478 | 'show_recurring' => false, |
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | - $args = wp_parse_args( $args, $defaults ); |
|
| 481 | + $args = wp_parse_args($args, $defaults); |
|
| 482 | 482 | |
| 483 | 483 | $item_args = array( |
| 484 | 484 | 'post_type' => 'wpi_item', |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | 'posts_per_page' => $args['number'] |
| 488 | 488 | ); |
| 489 | 489 | |
| 490 | - if ( !$args['with_packages'] ) { |
|
| 490 | + if (!$args['with_packages']) { |
|
| 491 | 491 | $item_args['meta_query'] = array( |
| 492 | 492 | array( |
| 493 | 493 | 'key' => '_wpinv_type', |
@@ -497,42 +497,42 @@ discard block |
||
| 497 | 497 | ); |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - $items = get_posts( $item_args ); |
|
| 500 | + $items = get_posts($item_args); |
|
| 501 | 501 | $options = array(); |
| 502 | - if ( $items ) { |
|
| 503 | - foreach ( $items as $item ) { |
|
| 504 | - $title = esc_html( $item->post_title ); |
|
| 502 | + if ($items) { |
|
| 503 | + foreach ($items as $item) { |
|
| 504 | + $title = esc_html($item->post_title); |
|
| 505 | 505 | |
| 506 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 507 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 506 | + if (!empty($args['show_recurring'])) { |
|
| 507 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $options[ absint( $item->ID ) ] = $title; |
|
| 510 | + $options[absint($item->ID)] = $title; |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // This ensures that any selected items are included in the drop down |
| 515 | - if( is_array( $args['selected'] ) ) { |
|
| 516 | - foreach( $args['selected'] as $item ) { |
|
| 517 | - if( ! in_array( $item, $options ) ) { |
|
| 518 | - $title = get_the_title( $item ); |
|
| 519 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 520 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 515 | + if (is_array($args['selected'])) { |
|
| 516 | + foreach ($args['selected'] as $item) { |
|
| 517 | + if (!in_array($item, $options)) { |
|
| 518 | + $title = get_the_title($item); |
|
| 519 | + if (!empty($args['show_recurring'])) { |
|
| 520 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 521 | 521 | } |
| 522 | 522 | $options[$item] = $title; |
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 526 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 527 | - $title = get_the_title( $args['selected'] ); |
|
| 528 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 529 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 525 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 526 | + if (!in_array($args['selected'], $options)) { |
|
| 527 | + $title = get_the_title($args['selected']); |
|
| 528 | + if (!empty($args['show_recurring'])) { |
|
| 529 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 530 | 530 | } |
| 531 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 531 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $output = wpinv_html_select( array( |
|
| 535 | + $output = wpinv_html_select(array( |
|
| 536 | 536 | 'name' => $args['name'], |
| 537 | 537 | 'selected' => $args['selected'], |
| 538 | 538 | 'id' => $args['id'], |
@@ -544,12 +544,12 @@ discard block |
||
| 544 | 544 | 'show_option_all' => $args['show_option_all'], |
| 545 | 545 | 'show_option_none' => $args['show_option_none'], |
| 546 | 546 | 'data' => $args['data'], |
| 547 | - ) ); |
|
| 547 | + )); |
|
| 548 | 548 | |
| 549 | 549 | return $output; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 552 | +function wpinv_html_checkbox($args = array()) { |
|
| 553 | 553 | $defaults = array( |
| 554 | 554 | 'name' => null, |
| 555 | 555 | 'current' => null, |
@@ -560,38 +560,38 @@ discard block |
||
| 560 | 560 | ) |
| 561 | 561 | ); |
| 562 | 562 | |
| 563 | - $args = wp_parse_args( $args, $defaults ); |
|
| 563 | + $args = wp_parse_args($args, $defaults); |
|
| 564 | 564 | |
| 565 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 565 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 566 | 566 | $options = ''; |
| 567 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 567 | + if (!empty($args['options']['disabled'])) { |
|
| 568 | 568 | $options .= ' disabled="disabled"'; |
| 569 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 569 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 570 | 570 | $options .= ' readonly'; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 573 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 574 | 574 | |
| 575 | 575 | return $output; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | -function wpinv_html_text( $args = array() ) { |
|
| 578 | +function wpinv_html_text($args = array()) { |
|
| 579 | 579 | // Backwards compatibility |
| 580 | - if ( func_num_args() > 1 ) { |
|
| 580 | + if (func_num_args() > 1) { |
|
| 581 | 581 | $args = func_get_args(); |
| 582 | 582 | |
| 583 | 583 | $name = $args[0]; |
| 584 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 585 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 586 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 584 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 585 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 586 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | $defaults = array( |
| 590 | 590 | 'id' => '', |
| 591 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 592 | - 'value' => isset( $value ) ? $value : null, |
|
| 593 | - 'label' => isset( $label ) ? $label : null, |
|
| 594 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 591 | + 'name' => isset($name) ? $name : 'text', |
|
| 592 | + 'value' => isset($value) ? $value : null, |
|
| 593 | + 'label' => isset($label) ? $label : null, |
|
| 594 | + 'desc' => isset($desc) ? $desc : null, |
|
| 595 | 595 | 'placeholder' => '', |
| 596 | 596 | 'class' => 'regular-text', |
| 597 | 597 | 'disabled' => false, |
@@ -601,51 +601,51 @@ discard block |
||
| 601 | 601 | 'data' => false |
| 602 | 602 | ); |
| 603 | 603 | |
| 604 | - $args = wp_parse_args( $args, $defaults ); |
|
| 604 | + $args = wp_parse_args($args, $defaults); |
|
| 605 | 605 | |
| 606 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 606 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 607 | 607 | $options = ''; |
| 608 | - if( $args['required'] ) { |
|
| 608 | + if ($args['required']) { |
|
| 609 | 609 | $options .= ' required="required"'; |
| 610 | 610 | } |
| 611 | - if( $args['readonly'] ) { |
|
| 611 | + if ($args['readonly']) { |
|
| 612 | 612 | $options .= ' readonly'; |
| 613 | 613 | } |
| 614 | - if( $args['readonly'] ) { |
|
| 614 | + if ($args['readonly']) { |
|
| 615 | 615 | $options .= ' readonly'; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | $data = ''; |
| 619 | - if ( !empty( $args['data'] ) ) { |
|
| 620 | - foreach ( $args['data'] as $key => $value ) { |
|
| 621 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 619 | + if (!empty($args['data'])) { |
|
| 620 | + foreach ($args['data'] as $key => $value) { |
|
| 621 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 626 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 627 | - if ( ! empty( $args['desc'] ) ) { |
|
| 628 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 625 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 626 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 627 | + if (!empty($args['desc'])) { |
|
| 628 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 631 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 632 | 632 | |
| 633 | 633 | $output .= '</span>'; |
| 634 | 634 | |
| 635 | 635 | return $output; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | -function wpinv_html_date_field( $args = array() ) { |
|
| 639 | - if( empty( $args['class'] ) ) { |
|
| 638 | +function wpinv_html_date_field($args = array()) { |
|
| 639 | + if (empty($args['class'])) { |
|
| 640 | 640 | $args['class'] = 'wpiDatepicker'; |
| 641 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 641 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 642 | 642 | $args['class'] .= ' wpiDatepicker'; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - return wpinv_html_text( $args ); |
|
| 645 | + return wpinv_html_text($args); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | -function wpinv_html_textarea( $args = array() ) { |
|
| 648 | +function wpinv_html_textarea($args = array()) { |
|
| 649 | 649 | $defaults = array( |
| 650 | 650 | 'name' => 'textarea', |
| 651 | 651 | 'value' => null, |
@@ -655,31 +655,31 @@ discard block |
||
| 655 | 655 | 'disabled' => false |
| 656 | 656 | ); |
| 657 | 657 | |
| 658 | - $args = wp_parse_args( $args, $defaults ); |
|
| 658 | + $args = wp_parse_args($args, $defaults); |
|
| 659 | 659 | |
| 660 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 660 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 661 | 661 | $disabled = ''; |
| 662 | - if( $args['disabled'] ) { |
|
| 662 | + if ($args['disabled']) { |
|
| 663 | 663 | $disabled = ' disabled="disabled"'; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 667 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 668 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 666 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 667 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 668 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 669 | 669 | |
| 670 | - if ( ! empty( $args['desc'] ) ) { |
|
| 671 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 670 | + if (!empty($args['desc'])) { |
|
| 671 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 672 | 672 | } |
| 673 | 673 | $output .= '</span>'; |
| 674 | 674 | |
| 675 | 675 | return $output; |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 678 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 679 | 679 | $defaults = array( |
| 680 | 680 | 'name' => 'user_id', |
| 681 | 681 | 'value' => null, |
| 682 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 682 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 683 | 683 | 'label' => null, |
| 684 | 684 | 'desc' => null, |
| 685 | 685 | 'class' => '', |
@@ -688,13 +688,13 @@ discard block |
||
| 688 | 688 | 'data' => false |
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | - $args = wp_parse_args( $args, $defaults ); |
|
| 691 | + $args = wp_parse_args($args, $defaults); |
|
| 692 | 692 | |
| 693 | 693 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 694 | 694 | |
| 695 | 695 | $output = '<span class="wpinv_user_search_wrap">'; |
| 696 | - $output .= wpinv_html_text( $args ); |
|
| 697 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 696 | + $output .= wpinv_html_text($args); |
|
| 697 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 698 | 698 | $output .= '</span>'; |
| 699 | 699 | |
| 700 | 700 | return $output; |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | function wpinv_ip_geolocation() { |
| 704 | 704 | global $wpinv_euvat; |
| 705 | 705 | |
| 706 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 706 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 707 | 707 | $content = ''; |
| 708 | 708 | $iso = ''; |
| 709 | 709 | $country = ''; |
@@ -714,69 +714,69 @@ discard block |
||
| 714 | 714 | $credit = ''; |
| 715 | 715 | $address = ''; |
| 716 | 716 | |
| 717 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 717 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 718 | 718 | try { |
| 719 | 719 | $iso = $geoip2_city->country->isoCode; |
| 720 | 720 | $country = $geoip2_city->country->name; |
| 721 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 721 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 722 | 722 | $city = $geoip2_city->city->name; |
| 723 | 723 | $longitude = $geoip2_city->location->longitude; |
| 724 | 724 | $latitude = $geoip2_city->location->latitude; |
| 725 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 726 | - } catch( Exception $e ) { } |
|
| 725 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 726 | + } catch (Exception $e) { } |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 729 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 730 | 730 | try { |
| 731 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 731 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 732 | 732 | |
| 733 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 733 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 734 | 734 | $iso = $load_xml->geoplugin_countryCode; |
| 735 | 735 | $country = $load_xml->geoplugin_countryName; |
| 736 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 737 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 736 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 737 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 738 | 738 | $longitude = $load_xml->geoplugin_longitude; |
| 739 | 739 | $latitude = $load_xml->geoplugin_latitude; |
| 740 | 740 | $credit = $load_xml->geoplugin_credit; |
| 741 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
| 741 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
| 742 | 742 | } |
| 743 | - } catch( Exception $e ) { } |
|
| 743 | + } catch (Exception $e) { } |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if ( $iso && $longitude && $latitude ) { |
|
| 747 | - if ( $city ) { |
|
| 746 | + if ($iso && $longitude && $latitude) { |
|
| 747 | + if ($city) { |
|
| 748 | 748 | $address .= $city . ', '; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - if ( $region ) { |
|
| 751 | + if ($region) { |
|
| 752 | 752 | $address .= $region . ', '; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | $address .= $country . ' (' . $iso . ')'; |
| 756 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 757 | - $content .= '<p>'. $credit . '</p>'; |
|
| 756 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 757 | + $content .= '<p>' . $credit . '</p>'; |
|
| 758 | 758 | } else { |
| 759 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 759 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 760 | 760 | } |
| 761 | 761 | ?> |
| 762 | 762 | <!DOCTYPE html> |
| 763 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 763 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
| 764 | 764 | <body> |
| 765 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 765 | + <?php if ($latitude && $latitude) { ?> |
|
| 766 | 766 | <div id="map"></div> |
| 767 | 767 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 768 | 768 | <script type="text/javascript"> |
| 769 | 769 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 770 | 770 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 771 | 771 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 772 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 772 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 773 | 773 | |
| 774 | 774 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 775 | 775 | |
| 776 | 776 | var marker = new L.Marker(latlng); |
| 777 | 777 | map.addLayer(marker); |
| 778 | 778 | |
| 779 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 779 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 780 | 780 | </script> |
| 781 | 781 | <?php } ?> |
| 782 | 782 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -784,31 +784,31 @@ discard block |
||
| 784 | 784 | <?php |
| 785 | 785 | exit; |
| 786 | 786 | } |
| 787 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 788 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 787 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 788 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 789 | 789 | |
| 790 | 790 | // Set up the template for the invoice. |
| 791 | -function wpinv_template( $template ) { |
|
| 791 | +function wpinv_template($template) { |
|
| 792 | 792 | global $post, $wp_query; |
| 793 | 793 | |
| 794 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
| 795 | - if ( wpinv_user_can_print_invoice( $post->ID ) ) { |
|
| 796 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 794 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
| 795 | + if (wpinv_user_can_print_invoice($post->ID)) { |
|
| 796 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 797 | 797 | } else { |
| 798 | - if ( !is_user_logged_in() && !empty( $_REQUEST['_wpipay'] ) && $invoice = wpinv_get_invoice( $post->ID ) ) { |
|
| 798 | + if (!is_user_logged_in() && !empty($_REQUEST['_wpipay']) && $invoice = wpinv_get_invoice($post->ID)) { |
|
| 799 | 799 | $user_id = $invoice->get_user_id(); |
| 800 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
| 800 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
| 801 | 801 | |
| 802 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key() ) ) { // valid invoice link |
|
| 803 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
| 802 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice->get_key())) { // valid invoice link |
|
| 803 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
| 804 | 804 | |
| 805 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
| 805 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
| 806 | 806 | wpinv_die(); |
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | - $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
| 809 | + $redirect_to = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
| 810 | 810 | |
| 811 | - wp_redirect( $redirect_to ); |
|
| 811 | + wp_redirect($redirect_to); |
|
| 812 | 812 | wpinv_die(); |
| 813 | 813 | } |
| 814 | 814 | } |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | function wpinv_get_business_address() { |
| 820 | 820 | $business_address = wpinv_store_address(); |
| 821 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 821 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 822 | 822 | |
| 823 | 823 | /* |
| 824 | 824 | $default_country = wpinv_get_default_country(); |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | |
| 843 | 843 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 844 | 844 | |
| 845 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 845 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | function wpinv_display_from_address() { |
@@ -852,185 +852,185 @@ discard block |
||
| 852 | 852 | if (empty($from_name)) { |
| 853 | 853 | $from_name = wpinv_get_business_name(); |
| 854 | 854 | } |
| 855 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
| 855 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
| 856 | 856 | <div class="wrapper col-xs-10"> |
| 857 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
| 858 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 859 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
| 857 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
| 858 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 859 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
| 860 | 860 | <?php } ?> |
| 861 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 862 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s' ), $email_from );?></div> |
|
| 861 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 862 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s'), $email_from); ?></div> |
|
| 863 | 863 | <?php } ?> |
| 864 | 864 | </div> |
| 865 | 865 | <?php |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | -function wpinv_watermark( $id = 0 ) { |
|
| 869 | - $output = wpinv_get_watermark( $id ); |
|
| 868 | +function wpinv_watermark($id = 0) { |
|
| 869 | + $output = wpinv_get_watermark($id); |
|
| 870 | 870 | |
| 871 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 871 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | -function wpinv_get_watermark( $id ) { |
|
| 875 | - if ( !$id > 0 ) { |
|
| 874 | +function wpinv_get_watermark($id) { |
|
| 875 | + if (!$id > 0) { |
|
| 876 | 876 | return NULL; |
| 877 | 877 | } |
| 878 | - $invoice = wpinv_get_invoice( $id ); |
|
| 878 | + $invoice = wpinv_get_invoice($id); |
|
| 879 | 879 | |
| 880 | - if ( !empty( $invoice ) ) { |
|
| 881 | - if ( $invoice->is_paid() ) { |
|
| 882 | - return __( 'Paid', 'invoicing' ); |
|
| 880 | + if (!empty($invoice)) { |
|
| 881 | + if ($invoice->is_paid()) { |
|
| 882 | + return __('Paid', 'invoicing'); |
|
| 883 | 883 | } |
| 884 | - if ( $invoice->has_status( array( 'cancelled' ) ) ) { |
|
| 885 | - return __( 'Cancelled', 'invoicing' ); |
|
| 884 | + if ($invoice->has_status(array('cancelled'))) { |
|
| 885 | + return __('Cancelled', 'invoicing'); |
|
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | return NULL; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 892 | +function wpinv_display_invoice_details($invoice) { |
|
| 893 | 893 | global $wpinv_euvat; |
| 894 | 894 | |
| 895 | 895 | $invoice_id = $invoice->ID; |
| 896 | 896 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 897 | 897 | $use_taxes = wpinv_use_taxes(); |
| 898 | 898 | |
| 899 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
| 899 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
| 900 | 900 | |
| 901 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
| 902 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
| 901 | + if ($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
| 902 | + elseif ($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
| 903 | 903 | ?> |
| 904 | 904 | <table class="table table-bordered table-sm"> |
| 905 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
| 905 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
| 906 | 906 | <tr class="wpi-row-number"> |
| 907 | - <th><?php echo sprintf(__( '%s Number', 'invoicing' ), $type); ?></th> |
|
| 908 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
| 907 | + <th><?php echo sprintf(__('%s Number', 'invoicing'), $type); ?></th> |
|
| 908 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
| 909 | 909 | </tr> |
| 910 | 910 | <?php } ?> |
| 911 | 911 | <tr class="wpi-row-status"> |
| 912 | - <th><?php echo wp_sprintf(__( '%s Status', 'invoicing' ), $type); ?></th> |
|
| 913 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
| 912 | + <th><?php echo wp_sprintf(__('%s Status', 'invoicing'), $type); ?></th> |
|
| 913 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
| 914 | 914 | </tr> |
| 915 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 915 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 916 | 916 | <tr class="wpi-row-parent"> |
| 917 | - <th><?php echo wp_sprintf(__( 'Parent %s', 'invoicing' ), $type); ?></th> |
|
| 918 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 917 | + <th><?php echo wp_sprintf(__('Parent %s', 'invoicing'), $type); ?></th> |
|
| 918 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 919 | 919 | </tr> |
| 920 | 920 | <?php } ?> |
| 921 | 921 | <tr class="wpi-row-gateway"> |
| 922 | - <th><?php _e( 'Payment Method', 'invoicing' ); ?></th> |
|
| 923 | - <td><?php echo wpinv_get_payment_gateway_name( $invoice_id ); ?></td> |
|
| 922 | + <th><?php _e('Payment Method', 'invoicing'); ?></th> |
|
| 923 | + <td><?php echo wpinv_get_payment_gateway_name($invoice_id); ?></td> |
|
| 924 | 924 | </tr> |
| 925 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
| 925 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
| 926 | 926 | <tr class="wpi-row-date"> |
| 927 | - <th><?php echo wp_sprintf(__( '%s Date', 'invoicing' ), $type); ?></th> |
|
| 927 | + <th><?php echo wp_sprintf(__('%s Date', 'invoicing'), $type); ?></th> |
|
| 928 | 928 | <td><?php echo $invoice_date; ?></td> |
| 929 | 929 | </tr> |
| 930 | 930 | <?php } ?> |
| 931 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
| 931 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
| 932 | 932 | <tr class="wpi-row-date"> |
| 933 | - <th><?php _e( 'Due Date', 'invoicing' ); ?></th> |
|
| 933 | + <th><?php _e('Due Date', 'invoicing'); ?></th> |
|
| 934 | 934 | <td><?php echo $due_date; ?></td> |
| 935 | 935 | </tr> |
| 936 | 936 | <?php } ?> |
| 937 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
| 937 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
| 938 | 938 | <tr class="wpi-row-ovatno"> |
| 939 | - <th><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
| 939 | + <th><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></th> |
|
| 940 | 940 | <td><?php echo $owner_vat_number; ?></td> |
| 941 | 941 | </tr> |
| 942 | 942 | <?php } ?> |
| 943 | - <?php if ( $use_taxes && $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?> |
|
| 943 | + <?php if ($use_taxes && $user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?> |
|
| 944 | 944 | <tr class="wpi-row-uvatno"> |
| 945 | - <th><?php echo wp_sprintf( __( 'Your %s Number', 'invoicing' ), $vat_name ); ?></th> |
|
| 945 | + <th><?php echo wp_sprintf(__('Your %s Number', 'invoicing'), $vat_name); ?></th> |
|
| 946 | 946 | <td><?php echo $user_vat_number; ?></td> |
| 947 | 947 | </tr> |
| 948 | 948 | <?php } ?> |
| 949 | 949 | <tr class="table-active tr-total wpi-row-total"> |
| 950 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
| 951 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
| 950 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
| 951 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
| 952 | 952 | </tr> |
| 953 | 953 | </table> |
| 954 | 954 | <?php |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
| 958 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 957 | +function wpinv_display_to_address($invoice_id = 0) { |
|
| 958 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 959 | 959 | |
| 960 | - if ( empty( $invoice ) ) { |
|
| 960 | + if (empty($invoice)) { |
|
| 961 | 961 | return NULL; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | $billing_details = $invoice->get_user_info(); |
| 965 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
| 965 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
| 966 | 966 | $output .= '<div class="wrapper col-xs-10">'; |
| 967 | 967 | |
| 968 | 968 | ob_start(); |
| 969 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
| 969 | + do_action('wpinv_display_to_address_top', $invoice); |
|
| 970 | 970 | $output .= ob_get_clean(); |
| 971 | 971 | |
| 972 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
| 973 | - if ( $company = $billing_details['company'] ) { |
|
| 974 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
| 972 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
| 973 | + if ($company = $billing_details['company']) { |
|
| 974 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
| 975 | 975 | } |
| 976 | 976 | $address_row = ''; |
| 977 | - if ( $address = $billing_details['address'] ) { |
|
| 978 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 977 | + if ($address = $billing_details['address']) { |
|
| 978 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | $address_fields = array(); |
| 982 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 982 | + if (!empty($billing_details['city'])) { |
|
| 983 | 983 | $address_fields[] = $billing_details['city']; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 987 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 988 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 986 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 987 | + if (!empty($billing_details['state'])) { |
|
| 988 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - if ( !empty( $billing_country ) ) { |
|
| 992 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 991 | + if (!empty($billing_country)) { |
|
| 992 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | - if ( !empty( $address_fields ) ) { |
|
| 996 | - $address_fields = implode( ", ", $address_fields ); |
|
| 995 | + if (!empty($address_fields)) { |
|
| 996 | + $address_fields = implode(", ", $address_fields); |
|
| 997 | 997 | |
| 998 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 998 | + if (!empty($billing_details['zip'])) { |
|
| 999 | 999 | $address_fields .= ' ' . $billing_details['zip']; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 1002 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | - if ( $address_row ) { |
|
| 1005 | + if ($address_row) { |
|
| 1006 | 1006 | $output .= '<div class="address">' . $address_row . '</div>'; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( $phone = $invoice->get_phone() ) { |
|
| 1010 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s' ), esc_html( $phone ) ) . '</div>'; |
|
| 1009 | + if ($phone = $invoice->get_phone()) { |
|
| 1010 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s'), esc_html($phone)) . '</div>'; |
|
| 1011 | 1011 | } |
| 1012 | - if ( $email = $invoice->get_email() ) { |
|
| 1013 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' ), esc_html( $email ) ) . '</div>'; |
|
| 1012 | + if ($email = $invoice->get_email()) { |
|
| 1013 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s'), esc_html($email)) . '</div>'; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | ob_start(); |
| 1017 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
| 1017 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
| 1018 | 1018 | $output .= ob_get_clean(); |
| 1019 | 1019 | |
| 1020 | 1020 | $output .= '</div>'; |
| 1021 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
| 1021 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
| 1022 | 1022 | |
| 1023 | 1023 | echo $output; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 1026 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 1027 | 1027 | global $wpinv_euvat, $ajax_cart_details; |
| 1028 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1028 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1029 | 1029 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 1030 | 1030 | $use_taxes = wpinv_use_taxes(); |
| 1031 | 1031 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
| 1032 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 1033 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 1032 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 1033 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 1034 | 1034 | |
| 1035 | 1035 | $cart_details = $invoice->get_cart_details(); |
| 1036 | 1036 | $ajax_cart_details = $cart_details; |
@@ -1039,68 +1039,68 @@ discard block |
||
| 1039 | 1039 | <table class="table table-sm table-bordered table-responsive"> |
| 1040 | 1040 | <thead> |
| 1041 | 1041 | <tr> |
| 1042 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
| 1043 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
| 1042 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
| 1043 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
| 1044 | 1044 | <?php if ($quantities_enabled) { ?> |
| 1045 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
| 1045 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
| 1046 | 1046 | <?php } ?> |
| 1047 | 1047 | <?php if ($use_taxes && !$zero_tax) { ?> |
| 1048 | 1048 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
| 1049 | 1049 | <?php } ?> |
| 1050 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
| 1050 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
| 1051 | 1051 | </tr> |
| 1052 | 1052 | </thead> |
| 1053 | 1053 | <tbody> |
| 1054 | 1054 | <?php |
| 1055 | - if ( !empty( $cart_details ) ) { |
|
| 1056 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
| 1055 | + if (!empty($cart_details)) { |
|
| 1056 | + do_action('wpinv_display_line_items_start', $invoice); |
|
| 1057 | 1057 | |
| 1058 | 1058 | $count = 0; |
| 1059 | 1059 | $cols = 3; |
| 1060 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1061 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
| 1062 | - $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount( $cart_item["item_price"] ) : 0; |
|
| 1063 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount( $cart_item["subtotal"] ) : 0; |
|
| 1064 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
| 1060 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1061 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
| 1062 | + $item_price = isset($cart_item["item_price"]) ? wpinv_format_amount($cart_item["item_price"]) : 0; |
|
| 1063 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_format_amount($cart_item["subtotal"]) : 0; |
|
| 1064 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
| 1065 | 1065 | |
| 1066 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
| 1066 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
| 1067 | 1067 | $summary = ''; |
| 1068 | 1068 | $cols = 3; |
| 1069 | - if ( !empty($item) ) { |
|
| 1069 | + if (!empty($item)) { |
|
| 1070 | 1070 | $item_name = $item->get_name(); |
| 1071 | 1071 | $summary = $item->get_summary(); |
| 1072 | 1072 | } |
| 1073 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1073 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1074 | 1074 | |
| 1075 | 1075 | if (!empty($item) && $item->is_package() && !empty($cart_item['meta']['post_id'])) { |
| 1076 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
| 1077 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $item->get_cpt_singular_name(), $post_link ); |
|
| 1076 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
| 1077 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $item->get_cpt_singular_name(), $post_link); |
|
| 1078 | 1078 | } |
| 1079 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
| 1079 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
| 1080 | 1080 | |
| 1081 | 1081 | $item_tax = ''; |
| 1082 | 1082 | $tax_rate = ''; |
| 1083 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1084 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
| 1085 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1086 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
| 1083 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1084 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
| 1085 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1086 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
| 1087 | 1087 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | $line_item_tax = $item_tax . $tax_rate; |
| 1091 | 1091 | |
| 1092 | - if ( $line_item_tax === '' ) { |
|
| 1092 | + if ($line_item_tax === '') { |
|
| 1093 | 1093 | $line_item_tax = 0; // Zero tax |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
| 1097 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
| 1098 | - if ( $summary !== '' ) { |
|
| 1099 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 1096 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
| 1097 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
| 1098 | + if ($summary !== '') { |
|
| 1099 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 1100 | 1100 | } |
| 1101 | 1101 | $line_item .= '</td>'; |
| 1102 | 1102 | |
| 1103 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( $item_price, $invoice->get_currency() ) ) . '</td>'; |
|
| 1103 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price($item_price, $invoice->get_currency())) . '</td>'; |
|
| 1104 | 1104 | if ($quantities_enabled) { |
| 1105 | 1105 | $cols++; |
| 1106 | 1106 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1109,55 +1109,55 @@ discard block |
||
| 1109 | 1109 | $cols++; |
| 1110 | 1110 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1111 | 1111 | } |
| 1112 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( $line_total, $invoice->get_currency() ) ) . '</td>'; |
|
| 1112 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price($line_total, $invoice->get_currency())) . '</td>'; |
|
| 1113 | 1113 | $line_item .= '</tr>'; |
| 1114 | 1114 | |
| 1115 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
| 1115 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
| 1116 | 1116 | |
| 1117 | 1117 | $count++; |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
| 1120 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
| 1121 | 1121 | ?> |
| 1122 | 1122 | <tr class="row-sub-total row_odd"> |
| 1123 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1124 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1123 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1124 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1125 | 1125 | </tr> |
| 1126 | 1126 | <?php |
| 1127 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
| 1127 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
| 1128 | 1128 | |
| 1129 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
| 1130 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
| 1129 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
| 1130 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
| 1131 | 1131 | ?> |
| 1132 | 1132 | <tr class="row-discount"> |
| 1133 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
| 1134 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1133 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
| 1134 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1135 | 1135 | </tr> |
| 1136 | 1136 | <?php |
| 1137 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
| 1137 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - if ( $use_taxes ) { |
|
| 1141 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
| 1140 | + if ($use_taxes) { |
|
| 1141 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
| 1142 | 1142 | ?> |
| 1143 | 1143 | <tr class="row-tax"> |
| 1144 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
| 1145 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1144 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
| 1145 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1146 | 1146 | </tr> |
| 1147 | 1147 | <?php |
| 1148 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
| 1148 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
| 1151 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
| 1152 | 1152 | ?> |
| 1153 | 1153 | <tr class="table-active row-total"> |
| 1154 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1155 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1154 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1155 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1156 | 1156 | </tr> |
| 1157 | 1157 | <?php |
| 1158 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
| 1158 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
| 1159 | 1159 | |
| 1160 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
| 1160 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | ?> |
| 1163 | 1163 | </tbody> |
@@ -1166,35 +1166,35 @@ discard block |
||
| 1166 | 1166 | echo ob_get_clean(); |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1169 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1170 | 1170 | $use_taxes = wpinv_use_taxes(); |
| 1171 | 1171 | |
| 1172 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1172 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1173 | 1173 | ?> |
| 1174 | 1174 | <table class="table table-sm table-bordered table-responsive"> |
| 1175 | 1175 | <tbody> |
| 1176 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1176 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1177 | 1177 | <tr class="row-sub-total"> |
| 1178 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1179 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1178 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1179 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1180 | 1180 | </tr> |
| 1181 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1182 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1181 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1182 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1183 | 1183 | <tr class="row-discount"> |
| 1184 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1185 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1184 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1185 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1186 | 1186 | </tr> |
| 1187 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1187 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1188 | 1188 | <?php } ?> |
| 1189 | - <?php if ( $use_taxes ) { ?> |
|
| 1189 | + <?php if ($use_taxes) { ?> |
|
| 1190 | 1190 | <tr class="row-tax"> |
| 1191 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1192 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1191 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1192 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1193 | 1193 | </tr> |
| 1194 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1194 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1195 | 1195 | <?php } ?> |
| 1196 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1197 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1196 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1197 | + <?php foreach ($fees as $fee) { ?> |
|
| 1198 | 1198 | <tr class="row-fee"> |
| 1199 | 1199 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1200 | 1200 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1202,72 +1202,72 @@ discard block |
||
| 1202 | 1202 | <?php } ?> |
| 1203 | 1203 | <?php } ?> |
| 1204 | 1204 | <tr class="table-active row-total"> |
| 1205 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1206 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1205 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1206 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1207 | 1207 | </tr> |
| 1208 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1208 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1209 | 1209 | </tbody> |
| 1210 | 1210 | |
| 1211 | 1211 | </table> |
| 1212 | 1212 | |
| 1213 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1213 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1217 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1216 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1217 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1218 | 1218 | |
| 1219 | 1219 | ob_start(); |
| 1220 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1221 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() ) { |
|
| 1220 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1221 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid()) { |
|
| 1222 | 1222 | ?> |
| 1223 | 1223 | <div class="wpi-payment-info"> |
| 1224 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1225 | - <?php if ( $gateway_title ) { ?> |
|
| 1226 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1224 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1225 | + <?php if ($gateway_title) { ?> |
|
| 1226 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1227 | 1227 | <?php } ?> |
| 1228 | 1228 | </div> |
| 1229 | 1229 | <?php |
| 1230 | 1230 | } |
| 1231 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1231 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1232 | 1232 | $outout = ob_get_clean(); |
| 1233 | 1233 | |
| 1234 | - if ( $echo ) { |
|
| 1234 | + if ($echo) { |
|
| 1235 | 1235 | echo $outout; |
| 1236 | 1236 | } else { |
| 1237 | 1237 | return $outout; |
| 1238 | 1238 | } |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | -function wpinv_display_style( $invoice ) { |
|
| 1242 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
| 1241 | +function wpinv_display_style($invoice) { |
|
| 1242 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
| 1243 | 1243 | |
| 1244 | - wp_print_styles( 'open-sans' ); |
|
| 1245 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1244 | + wp_print_styles('open-sans'); |
|
| 1245 | + wp_print_styles('wpinv-single-style'); |
|
| 1246 | 1246 | } |
| 1247 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1247 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1248 | 1248 | |
| 1249 | 1249 | function wpinv_checkout_billing_details() { |
| 1250 | 1250 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 1251 | 1251 | if (empty($invoice_id)) { |
| 1252 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1252 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1253 | 1253 | return null; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1256 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1257 | 1257 | if (empty($invoice)) { |
| 1258 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1258 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1259 | 1259 | return null; |
| 1260 | 1260 | } |
| 1261 | 1261 | $user_id = $invoice->get_user_id(); |
| 1262 | 1262 | $user_info = $invoice->get_user_info(); |
| 1263 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1263 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1264 | 1264 | |
| 1265 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1265 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1266 | 1266 | $user_info['first_name'] = $user_info['first_name']; |
| 1267 | 1267 | $user_info['last_name'] = $user_info['last_name']; |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1270 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1271 | 1271 | $user_info['country'] = $address_info['country']; |
| 1272 | 1272 | $user_info['state'] = $address_info['state']; |
| 1273 | 1273 | $user_info['city'] = $address_info['city']; |
@@ -1283,103 +1283,103 @@ discard block |
||
| 1283 | 1283 | 'address' |
| 1284 | 1284 | ); |
| 1285 | 1285 | |
| 1286 | - foreach ( $address_fields as $field ) { |
|
| 1287 | - if ( empty( $user_info[$field] ) ) { |
|
| 1286 | + foreach ($address_fields as $field) { |
|
| 1287 | + if (empty($user_info[$field])) { |
|
| 1288 | 1288 | $user_info[$field] = $address_info[$field]; |
| 1289 | 1289 | } |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1292 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1296 | 1296 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1297 | 1297 | $use_taxes = wpinv_use_taxes(); |
| 1298 | 1298 | |
| 1299 | - if ( empty( $invoice ) ) { |
|
| 1299 | + if (empty($invoice)) { |
|
| 1300 | 1300 | return NULL; |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | $cart_items = $invoice->get_cart_details(); |
| 1304 | - if ( empty( $cart_items ) ) { |
|
| 1304 | + if (empty($cart_items)) { |
|
| 1305 | 1305 | return NULL; |
| 1306 | 1306 | } |
| 1307 | 1307 | ob_start(); |
| 1308 | 1308 | |
| 1309 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1309 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1310 | 1310 | |
| 1311 | 1311 | $count = 0; |
| 1312 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1312 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1313 | 1313 | $item_id = $cart_item['id']; |
| 1314 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1314 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1315 | 1315 | |
| 1316 | 1316 | if (empty($wpi_item)) { |
| 1317 | 1317 | continue; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ) ); |
|
| 1321 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1322 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ) ); |
|
| 1320 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price'])); |
|
| 1321 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1322 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal'])); |
|
| 1323 | 1323 | $can_remove = true; |
| 1324 | 1324 | |
| 1325 | 1325 | $summary = ''; |
| 1326 | 1326 | if ($wpi_item->is_package() && !empty($cart_item['meta']['post_id'])) { |
| 1327 | - $post_link = '<a href="' . get_edit_post_link( $cart_item['meta']['post_id'] ) .'" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title( $cart_item['meta']['post_id']) ) . '</a>'; |
|
| 1328 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_cpt_singular_name(), $post_link ); |
|
| 1327 | + $post_link = '<a href="' . get_edit_post_link($cart_item['meta']['post_id']) . '" target="_blank">' . (!empty($cart_item['meta']['invoice_title']) ? $cart_item['meta']['invoice_title'] : get_the_title($cart_item['meta']['post_id'])) . '</a>'; |
|
| 1328 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_cpt_singular_name(), $post_link); |
|
| 1329 | 1329 | } |
| 1330 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice ); |
|
| 1330 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', $summary, $cart_item, $wpi_item, $invoice); |
|
| 1331 | 1331 | |
| 1332 | 1332 | $item_tax = ''; |
| 1333 | 1333 | $tax_rate = ''; |
| 1334 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1335 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ) ); |
|
| 1336 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1337 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount( $tax_rate, 2 ) : ''; |
|
| 1334 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1335 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax'])); |
|
| 1336 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1337 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_format_amount($tax_rate, 2) : ''; |
|
| 1338 | 1338 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1339 | 1339 | } |
| 1340 | 1340 | $line_item_tax = $item_tax . $tax_rate; |
| 1341 | 1341 | |
| 1342 | - if ( $line_item_tax === '' ) { |
|
| 1342 | + if ($line_item_tax === '') { |
|
| 1343 | 1343 | $line_item_tax = 0; // Zero tax |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1346 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1347 | 1347 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1348 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
| 1349 | - if ( $summary !== '' ) { |
|
| 1350 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1348 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
| 1349 | + if ($summary !== '') { |
|
| 1350 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1351 | 1351 | } |
| 1352 | 1352 | $line_item .= '</td>'; |
| 1353 | 1353 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1354 | 1354 | |
| 1355 | - if ( $item_quantities ) { |
|
| 1356 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1355 | + if ($item_quantities) { |
|
| 1356 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1357 | 1357 | $can_remove = false; |
| 1358 | 1358 | } |
| 1359 | 1359 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1360 | 1360 | } else { |
| 1361 | - if ( count( $cart_items ) == 1 ) { |
|
| 1361 | + if (count($cart_items) == 1) { |
|
| 1362 | 1362 | $can_remove = false; |
| 1363 | 1363 | } |
| 1364 | 1364 | } |
| 1365 | 1365 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1366 | 1366 | |
| 1367 | - if ( $use_taxes ) { |
|
| 1367 | + if ($use_taxes) { |
|
| 1368 | 1368 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1369 | 1369 | } |
| 1370 | 1370 | $line_item .= '<td class="action">'; |
| 1371 | - if ( !$invoice->is_paid() && $can_remove ) { |
|
| 1371 | + if (!$invoice->is_paid() && $can_remove) { |
|
| 1372 | 1372 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1373 | 1373 | } |
| 1374 | 1374 | $line_item .= '</td>'; |
| 1375 | 1375 | $line_item .= '</tr>'; |
| 1376 | 1376 | |
| 1377 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1377 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1378 | 1378 | |
| 1379 | 1379 | $count++; |
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1382 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1383 | 1383 | |
| 1384 | 1384 | return ob_get_clean(); |
| 1385 | 1385 | } |
@@ -1390,35 +1390,35 @@ discard block |
||
| 1390 | 1390 | // Set current invoice id. |
| 1391 | 1391 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1392 | 1392 | |
| 1393 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1393 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1394 | 1394 | |
| 1395 | 1395 | ob_start(); |
| 1396 | 1396 | echo '<div id="wpinv_checkout_wrap">'; |
| 1397 | 1397 | |
| 1398 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
| 1398 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
| 1399 | 1399 | ?> |
| 1400 | 1400 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
| 1401 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
| 1401 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
| 1402 | 1402 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
| 1403 | 1403 | <?php |
| 1404 | - do_action( 'wpinv_checkout_form_top' ); |
|
| 1405 | - do_action( 'wpinv_checkout_billing_info' ); |
|
| 1406 | - do_action( 'wpinv_checkout_cart' ); |
|
| 1407 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 1408 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
| 1404 | + do_action('wpinv_checkout_form_top'); |
|
| 1405 | + do_action('wpinv_checkout_billing_info'); |
|
| 1406 | + do_action('wpinv_checkout_cart'); |
|
| 1407 | + do_action('wpinv_payment_mode_select'); |
|
| 1408 | + do_action('wpinv_checkout_form_bottom') |
|
| 1409 | 1409 | ?> |
| 1410 | 1410 | </form> |
| 1411 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
| 1411 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
| 1412 | 1412 | </div><!--end #wpinv_checkout_form_wrap--> |
| 1413 | 1413 | <?php |
| 1414 | 1414 | } else { |
| 1415 | - do_action( 'wpinv_cart_empty' ); |
|
| 1415 | + do_action('wpinv_cart_empty'); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1418 | 1418 | return ob_get_clean(); |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1421 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1422 | 1422 | global $ajax_cart_details; |
| 1423 | 1423 | $ajax_cart_details = $cart_details; |
| 1424 | 1424 | /* |
@@ -1433,25 +1433,25 @@ discard block |
||
| 1433 | 1433 | } |
| 1434 | 1434 | */ |
| 1435 | 1435 | ob_start(); |
| 1436 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1436 | + do_action('wpinv_before_checkout_cart'); |
|
| 1437 | 1437 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1438 | 1438 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1439 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1439 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1440 | 1440 | echo '</div>'; |
| 1441 | 1441 | echo '</div>'; |
| 1442 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1442 | + do_action('wpinv_after_checkout_cart'); |
|
| 1443 | 1443 | $content = ob_get_clean(); |
| 1444 | 1444 | |
| 1445 | - if ( $echo ) { |
|
| 1445 | + if ($echo) { |
|
| 1446 | 1446 | echo $content; |
| 1447 | 1447 | } else { |
| 1448 | 1448 | return $content; |
| 1449 | 1449 | } |
| 1450 | 1450 | } |
| 1451 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1451 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1452 | 1452 | |
| 1453 | 1453 | function wpinv_empty_cart_message() { |
| 1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1454 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | /** |
@@ -1463,91 +1463,91 @@ discard block |
||
| 1463 | 1463 | function wpinv_empty_checkout_cart() { |
| 1464 | 1464 | echo wpinv_empty_cart_message(); |
| 1465 | 1465 | } |
| 1466 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1466 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1467 | 1467 | |
| 1468 | 1468 | function wpinv_save_cart_button() { |
| 1469 | - if ( wpinv_is_cart_saving_disabled() ) |
|
| 1469 | + if (wpinv_is_cart_saving_disabled()) |
|
| 1470 | 1470 | return; |
| 1471 | 1471 | ?> |
| 1472 | - <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
|
| 1472 | + <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a> |
|
| 1473 | 1473 | <?php |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | function wpinv_update_cart_button() { |
| 1477 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1477 | + if (!wpinv_item_quantities_enabled()) |
|
| 1478 | 1478 | return; |
| 1479 | 1479 | ?> |
| 1480 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1480 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1481 | 1481 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1482 | 1482 | <?php |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | function wpinv_checkout_cart_columns() { |
| 1486 | 1486 | $default = 3; |
| 1487 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1487 | + if (wpinv_item_quantities_enabled()) { |
|
| 1488 | 1488 | $default++; |
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | - if ( wpinv_use_taxes() ) { |
|
| 1491 | + if (wpinv_use_taxes()) { |
|
| 1492 | 1492 | $default++; |
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1495 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | function wpinv_display_cart_messages() { |
| 1499 | 1499 | global $wpi_session; |
| 1500 | 1500 | |
| 1501 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1501 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1502 | 1502 | |
| 1503 | - if ( $messages ) { |
|
| 1504 | - foreach ( $messages as $message_id => $message ) { |
|
| 1503 | + if ($messages) { |
|
| 1504 | + foreach ($messages as $message_id => $message) { |
|
| 1505 | 1505 | // Try and detect what type of message this is |
| 1506 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1506 | + if (strpos(strtolower($message), 'error')) { |
|
| 1507 | 1507 | $type = 'error'; |
| 1508 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1508 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1509 | 1509 | $type = 'success'; |
| 1510 | 1510 | } else { |
| 1511 | 1511 | $type = 'info'; |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1514 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1515 | 1515 | |
| 1516 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1516 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1517 | 1517 | // Loop message codes and display messages |
| 1518 | 1518 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1519 | 1519 | echo '</div>'; |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // Remove all of the cart saving messages |
| 1523 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1523 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1524 | 1524 | } |
| 1525 | 1525 | } |
| 1526 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1526 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1527 | 1527 | |
| 1528 | 1528 | function wpinv_discount_field() { |
| 1529 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1529 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1530 | 1530 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - if ( !wpinv_is_checkout() ) { |
|
| 1533 | + if (!wpinv_is_checkout()) { |
|
| 1534 | 1534 | return; |
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1537 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1538 | 1538 | ?> |
| 1539 | 1539 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1540 | 1540 | <div class="panel-body"> |
| 1541 | 1541 | <p> |
| 1542 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1543 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1542 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1543 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1544 | 1544 | </p> |
| 1545 | 1545 | <div class="form-group row"> |
| 1546 | 1546 | <div class="col-sm-4"> |
| 1547 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1547 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1548 | 1548 | </div> |
| 1549 | 1549 | <div class="col-sm-3"> |
| 1550 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1550 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1551 | 1551 | </div> |
| 1552 | 1552 | <div class="col-sm-12 wpinv-discount-msg"> |
| 1553 | 1553 | <div class="alert alert-success"><i class="fa fa-check-circle"></i><span class="wpi-msg"></span></div> |
@@ -1559,10 +1559,10 @@ discard block |
||
| 1559 | 1559 | <?php |
| 1560 | 1560 | } |
| 1561 | 1561 | } |
| 1562 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1562 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1563 | 1563 | |
| 1564 | 1564 | function wpinv_agree_to_terms_js() { |
| 1565 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1565 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1566 | 1566 | ?> |
| 1567 | 1567 | <script type="text/javascript"> |
| 1568 | 1568 | jQuery(document).ready(function($){ |
@@ -1577,124 +1577,124 @@ discard block |
||
| 1577 | 1577 | <?php |
| 1578 | 1578 | } |
| 1579 | 1579 | } |
| 1580 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1580 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1581 | 1581 | |
| 1582 | 1582 | function wpinv_payment_mode_select() { |
| 1583 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1584 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1583 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1584 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1585 | 1585 | $page_URL = wpinv_get_current_page_url(); |
| 1586 | 1586 | |
| 1587 | 1587 | do_action('wpinv_payment_mode_top'); |
| 1588 | 1588 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 1589 | 1589 | ?> |
| 1590 | 1590 | <div id="wpinv_payment_mode_select"> |
| 1591 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1591 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1592 | 1592 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1593 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
| 1593 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
| 1594 | 1594 | <div class="panel-body list-group wpi-payment_methods"> |
| 1595 | 1595 | <?php |
| 1596 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1597 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1596 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1597 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1598 | 1598 | |
| 1599 | - if(!empty($gateways)){ |
|
| 1600 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1601 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1602 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1603 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1599 | + if (!empty($gateways)) { |
|
| 1600 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1601 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1602 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1603 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1604 | 1604 | ?> |
| 1605 | 1605 | <div class="list-group-item"> |
| 1606 | 1606 | <div class="radio"> |
| 1607 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1607 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1608 | 1608 | </div> |
| 1609 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1610 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1611 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
| 1609 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1610 | + <?php if (!empty($description)) { ?> |
|
| 1611 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
| 1612 | 1612 | <?php } ?> |
| 1613 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1613 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1614 | 1614 | </div> |
| 1615 | 1615 | </div> |
| 1616 | 1616 | <?php |
| 1617 | 1617 | } |
| 1618 | - }else{ |
|
| 1619 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1618 | + } else { |
|
| 1619 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1622 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1623 | 1623 | ?> |
| 1624 | 1624 | </div> |
| 1625 | 1625 | </div> |
| 1626 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1626 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1627 | 1627 | </div> |
| 1628 | 1628 | <?php |
| 1629 | 1629 | do_action('wpinv_payment_mode_bottom'); |
| 1630 | 1630 | } |
| 1631 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1631 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1632 | 1632 | |
| 1633 | 1633 | function wpinv_checkout_billing_info() { |
| 1634 | - if ( wpinv_is_checkout() ) { |
|
| 1634 | + if (wpinv_is_checkout()) { |
|
| 1635 | 1635 | $logged_in = is_user_logged_in(); |
| 1636 | 1636 | $billing_details = wpinv_checkout_billing_details(); |
| 1637 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1637 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1638 | 1638 | ?> |
| 1639 | 1639 | <div id="wpinv-fields" class="clearfix"> |
| 1640 | 1640 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1641 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1641 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1642 | 1642 | <div id="wpinv-fields-box" class="panel-body"> |
| 1643 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1643 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1644 | 1644 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1645 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
| 1645 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
| 1646 | 1646 | <?php |
| 1647 | - echo wpinv_html_text( array( |
|
| 1647 | + echo wpinv_html_text(array( |
|
| 1648 | 1648 | 'id' => 'wpinv_first_name', |
| 1649 | 1649 | 'name' => 'wpinv_first_name', |
| 1650 | 1650 | 'value' => $billing_details['first_name'], |
| 1651 | 1651 | 'class' => 'wpi-input form-control required', |
| 1652 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1652 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1653 | 1653 | 'required' => true, |
| 1654 | - ) ); |
|
| 1654 | + )); |
|
| 1655 | 1655 | ?> |
| 1656 | 1656 | </p> |
| 1657 | 1657 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1658 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?></label> |
|
| 1658 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?></label> |
|
| 1659 | 1659 | <?php |
| 1660 | - echo wpinv_html_text( array( |
|
| 1660 | + echo wpinv_html_text(array( |
|
| 1661 | 1661 | 'id' => 'wpinv_last_name', |
| 1662 | 1662 | 'name' => 'wpinv_last_name', |
| 1663 | 1663 | 'value' => $billing_details['last_name'], |
| 1664 | 1664 | 'class' => 'wpi-input form-control', |
| 1665 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1666 | - ) ); |
|
| 1665 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1666 | + )); |
|
| 1667 | 1667 | ?> |
| 1668 | 1668 | </p> |
| 1669 | 1669 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1670 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
| 1670 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
| 1671 | 1671 | <?php |
| 1672 | - echo wpinv_html_text( array( |
|
| 1672 | + echo wpinv_html_text(array( |
|
| 1673 | 1673 | 'id' => 'wpinv_address', |
| 1674 | 1674 | 'name' => 'wpinv_address', |
| 1675 | 1675 | 'value' => $billing_details['address'], |
| 1676 | 1676 | 'class' => 'wpi-input form-control required', |
| 1677 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1677 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1678 | 1678 | 'required' => true, |
| 1679 | - ) ); |
|
| 1679 | + )); |
|
| 1680 | 1680 | ?> |
| 1681 | 1681 | </p> |
| 1682 | 1682 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1683 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
| 1683 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
| 1684 | 1684 | <?php |
| 1685 | - echo wpinv_html_text( array( |
|
| 1685 | + echo wpinv_html_text(array( |
|
| 1686 | 1686 | 'id' => 'wpinv_city', |
| 1687 | 1687 | 'name' => 'wpinv_city', |
| 1688 | 1688 | 'value' => $billing_details['city'], |
| 1689 | 1689 | 'class' => 'wpi-input form-control required', |
| 1690 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1690 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1691 | 1691 | 'required' => true, |
| 1692 | - ) ); |
|
| 1692 | + )); |
|
| 1693 | 1693 | ?> |
| 1694 | 1694 | </p> |
| 1695 | 1695 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1696 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
| 1697 | - <?php echo wpinv_html_select( array( |
|
| 1696 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
| 1697 | + <?php echo wpinv_html_select(array( |
|
| 1698 | 1698 | 'options' => wpinv_get_country_list(), |
| 1699 | 1699 | 'name' => 'wpinv_country', |
| 1700 | 1700 | 'id' => 'wpinv_country', |
@@ -1702,16 +1702,16 @@ discard block |
||
| 1702 | 1702 | 'show_option_all' => false, |
| 1703 | 1703 | 'show_option_none' => false, |
| 1704 | 1704 | 'class' => 'wpi-input form-control required', |
| 1705 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1705 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1706 | 1706 | 'required' => true, |
| 1707 | - ) ); ?> |
|
| 1707 | + )); ?> |
|
| 1708 | 1708 | </p> |
| 1709 | 1709 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1710 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><span class="wpi-required">*</span></label> |
|
| 1710 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><span class="wpi-required">*</span></label> |
|
| 1711 | 1711 | <?php |
| 1712 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1713 | - if( !empty( $states ) ) { |
|
| 1714 | - echo wpinv_html_select( array( |
|
| 1712 | + $states = wpinv_get_country_states($selected_country); |
|
| 1713 | + if (!empty($states)) { |
|
| 1714 | + echo wpinv_html_select(array( |
|
| 1715 | 1715 | 'options' => $states, |
| 1716 | 1716 | 'name' => 'wpinv_state', |
| 1717 | 1717 | 'id' => 'wpinv_state', |
@@ -1719,60 +1719,60 @@ discard block |
||
| 1719 | 1719 | 'show_option_all' => false, |
| 1720 | 1720 | 'show_option_none' => false, |
| 1721 | 1721 | 'class' => 'wpi-input form-control required', |
| 1722 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1722 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1723 | 1723 | 'required' => true, |
| 1724 | - ) ); |
|
| 1724 | + )); |
|
| 1725 | 1725 | } else { |
| 1726 | - echo wpinv_html_text( array( |
|
| 1726 | + echo wpinv_html_text(array( |
|
| 1727 | 1727 | 'name' => 'wpinv_state', |
| 1728 | 1728 | 'value' => $billing_details['state'], |
| 1729 | 1729 | 'id' => 'wpinv_state', |
| 1730 | 1730 | 'class' => 'wpi-input form-control required', |
| 1731 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1731 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1732 | 1732 | 'required' => true, |
| 1733 | - ) ); |
|
| 1733 | + )); |
|
| 1734 | 1734 | } |
| 1735 | 1735 | ?> |
| 1736 | 1736 | </p> |
| 1737 | 1737 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1738 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?></label> |
|
| 1738 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?></label> |
|
| 1739 | 1739 | <?php |
| 1740 | - echo wpinv_html_text( array( |
|
| 1740 | + echo wpinv_html_text(array( |
|
| 1741 | 1741 | 'name' => 'wpinv_zip', |
| 1742 | 1742 | 'value' => $billing_details['zip'], |
| 1743 | 1743 | 'id' => 'wpinv_zip', |
| 1744 | 1744 | 'class' => 'wpi-input form-control', |
| 1745 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1746 | - ) ); |
|
| 1745 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1746 | + )); |
|
| 1747 | 1747 | ?> |
| 1748 | 1748 | </p> |
| 1749 | 1749 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1750 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1750 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1751 | 1751 | <?php |
| 1752 | - echo wpinv_html_text( array( |
|
| 1752 | + echo wpinv_html_text(array( |
|
| 1753 | 1753 | 'id' => 'wpinv_phone', |
| 1754 | 1754 | 'name' => 'wpinv_phone', |
| 1755 | 1755 | 'value' => $billing_details['phone'], |
| 1756 | 1756 | 'class' => 'wpi-input form-control', |
| 1757 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1758 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1759 | - ) ); |
|
| 1757 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1758 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
| 1759 | + )); |
|
| 1760 | 1760 | ?> |
| 1761 | 1761 | </p> |
| 1762 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1762 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1763 | 1763 | <div class="clearfix"></div> |
| 1764 | 1764 | </div> |
| 1765 | 1765 | </div> |
| 1766 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1766 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1767 | 1767 | </div> |
| 1768 | 1768 | <?php |
| 1769 | 1769 | } |
| 1770 | 1770 | } |
| 1771 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1771 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1772 | 1772 | |
| 1773 | 1773 | function wpinv_checkout_hidden_fields() { |
| 1774 | 1774 | ?> |
| 1775 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1775 | + <?php if (is_user_logged_in()) { ?> |
|
| 1776 | 1776 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1777 | 1777 | <?php } ?> |
| 1778 | 1778 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1782,9 +1782,9 @@ discard block |
||
| 1782 | 1782 | function wpinv_checkout_button_purchase() { |
| 1783 | 1783 | ob_start(); |
| 1784 | 1784 | ?> |
| 1785 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
| 1785 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
| 1786 | 1786 | <?php |
| 1787 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1787 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | function wpinv_checkout_total() { |
@@ -1793,96 +1793,96 @@ discard block |
||
| 1793 | 1793 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1794 | 1794 | <div class="panel-body"> |
| 1795 | 1795 | <?php |
| 1796 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1796 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1797 | 1797 | ?> |
| 1798 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1798 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1799 | 1799 | <?php |
| 1800 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1800 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1801 | 1801 | ?> |
| 1802 | 1802 | </div> |
| 1803 | 1803 | </div> |
| 1804 | 1804 | <?php |
| 1805 | 1805 | } |
| 1806 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1806 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1807 | 1807 | |
| 1808 | 1808 | function wpinv_checkout_submit() { |
| 1809 | 1809 | ?> |
| 1810 | 1810 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1811 | 1811 | <div class="panel-body text-center"> |
| 1812 | 1812 | <?php |
| 1813 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1813 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1814 | 1814 | wpinv_checkout_hidden_fields(); |
| 1815 | 1815 | echo wpinv_checkout_button_purchase(); |
| 1816 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1816 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1817 | 1817 | ?> |
| 1818 | 1818 | </div> |
| 1819 | 1819 | </div> |
| 1820 | 1820 | <?php |
| 1821 | 1821 | } |
| 1822 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1822 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1823 | 1823 | |
| 1824 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1825 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1824 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1825 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1826 | 1826 | |
| 1827 | - if ( empty( $invoice ) ) { |
|
| 1827 | + if (empty($invoice)) { |
|
| 1828 | 1828 | return NULL; |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | 1831 | $billing_details = $invoice->get_user_info(); |
| 1832 | 1832 | $address_row = ''; |
| 1833 | - if ( $address = $billing_details['address'] ) { |
|
| 1834 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 1833 | + if ($address = $billing_details['address']) { |
|
| 1834 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | $address_fields = array(); |
| 1838 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 1838 | + if (!empty($billing_details['city'])) { |
|
| 1839 | 1839 | $address_fields[] = $billing_details['city']; |
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 1843 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 1844 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 1842 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 1843 | + if (!empty($billing_details['state'])) { |
|
| 1844 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | - if ( !empty( $billing_country ) ) { |
|
| 1848 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 1847 | + if (!empty($billing_country)) { |
|
| 1848 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | - if ( !empty( $address_fields ) ) { |
|
| 1852 | - $address_fields = implode( ", ", $address_fields ); |
|
| 1851 | + if (!empty($address_fields)) { |
|
| 1852 | + $address_fields = implode(", ", $address_fields); |
|
| 1853 | 1853 | |
| 1854 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 1854 | + if (!empty($billing_details['zip'])) { |
|
| 1855 | 1855 | $address_fields .= ' ' . $billing_details['zip']; |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 1858 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 1859 | 1859 | } |
| 1860 | 1860 | ob_start(); |
| 1861 | 1861 | ?> |
| 1862 | 1862 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1863 | 1863 | <tbody> |
| 1864 | 1864 | <tr class="wpi-receipt-name"> |
| 1865 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1866 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1865 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1866 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1867 | 1867 | </tr> |
| 1868 | 1868 | <tr class="wpi-receipt-email"> |
| 1869 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1870 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1869 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1870 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1871 | 1871 | </tr> |
| 1872 | - <?php if ( $billing_details['company'] ) { ?> |
|
| 1872 | + <?php if ($billing_details['company']) { ?> |
|
| 1873 | 1873 | <tr class="wpi-receipt-company"> |
| 1874 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
| 1875 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
| 1874 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
| 1875 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
| 1876 | 1876 | </tr> |
| 1877 | 1877 | <?php } ?> |
| 1878 | 1878 | <tr class="wpi-receipt-address"> |
| 1879 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1880 | - <td><?php echo $address_row ;?></td> |
|
| 1879 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1880 | + <td><?php echo $address_row; ?></td> |
|
| 1881 | 1881 | </tr> |
| 1882 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1882 | + <?php if ($billing_details['phone']) { ?> |
|
| 1883 | 1883 | <tr class="wpi-receipt-phone"> |
| 1884 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1885 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1884 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1885 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1886 | 1886 | </tr> |
| 1887 | 1887 | <?php } ?> |
| 1888 | 1888 | </tbody> |
@@ -1890,98 +1890,98 @@ discard block |
||
| 1890 | 1890 | <?php |
| 1891 | 1891 | $output = ob_get_clean(); |
| 1892 | 1892 | |
| 1893 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1893 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1894 | 1894 | |
| 1895 | 1895 | echo $output; |
| 1896 | 1896 | } |
| 1897 | 1897 | |
| 1898 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1899 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1900 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1901 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1898 | +function wpinv_filter_success_page_content($content) { |
|
| 1899 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1900 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1901 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1902 | 1902 | } |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | return $content; |
| 1906 | 1906 | } |
| 1907 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1907 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1908 | 1908 | |
| 1909 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1910 | - if ( !empty( $invoice ) ) { |
|
| 1909 | +function wpinv_receipt_actions($invoice) { |
|
| 1910 | + if (!empty($invoice)) { |
|
| 1911 | 1911 | $actions = array( |
| 1912 | 1912 | 'print' => array( |
| 1913 | 1913 | 'url' => $invoice->get_view_url(), |
| 1914 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1914 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1915 | 1915 | 'class' => 'btn-primary', |
| 1916 | 1916 | ), |
| 1917 | 1917 | 'history' => array( |
| 1918 | 1918 | 'url' => wpinv_get_history_page_uri(), |
| 1919 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1919 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1920 | 1920 | 'class' => 'btn-warning', |
| 1921 | 1921 | ) |
| 1922 | 1922 | ); |
| 1923 | 1923 | |
| 1924 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1924 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1925 | 1925 | |
| 1926 | - if ( !empty( $actions ) ) { |
|
| 1926 | + if (!empty($actions)) { |
|
| 1927 | 1927 | ?> |
| 1928 | 1928 | <div class="wpinv-receipt-actions text-right"> |
| 1929 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1930 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
| 1929 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1930 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
| 1931 | 1931 | <?php } ?> |
| 1932 | 1932 | </div> |
| 1933 | 1933 | <?php |
| 1934 | 1934 | } |
| 1935 | 1935 | } |
| 1936 | 1936 | } |
| 1937 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1937 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1938 | 1938 | |
| 1939 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1940 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1939 | +function wpinv_invoice_link($invoice_id) { |
|
| 1940 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1941 | 1941 | |
| 1942 | - if ( empty( $invoice ) ) { |
|
| 1942 | + if (empty($invoice)) { |
|
| 1943 | 1943 | return NULL; |
| 1944 | 1944 | } |
| 1945 | 1945 | |
| 1946 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1946 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1947 | 1947 | |
| 1948 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1948 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1952 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1951 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1952 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1953 | 1953 | $total_payments = (int)$invoice->get_total_payments(); |
| 1954 | 1954 | $payments = $invoice->get_child_payments(); |
| 1955 | 1955 | |
| 1956 | 1956 | $subscription = $invoice->get_subscription_data(); |
| 1957 | 1957 | |
| 1958 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
| 1958 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
| 1959 | 1959 | return; |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
| 1963 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
| 1962 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
| 1963 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
| 1964 | 1964 | |
| 1965 | 1965 | $subscription_status = $invoice->get_subscription_status(); |
| 1966 | 1966 | |
| 1967 | 1967 | $status_desc = ''; |
| 1968 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
| 1969 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
| 1970 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
| 1971 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
| 1968 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
| 1969 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
| 1970 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
| 1971 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
| 1972 | 1972 | } |
| 1973 | 1973 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
| 1974 | 1974 | ?> |
| 1975 | 1975 | <div class="wpinv-subscriptions-details"> |
| 1976 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 1976 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 1977 | 1977 | <table class="table"> |
| 1978 | 1978 | <thead> |
| 1979 | 1979 | <tr> |
| 1980 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 1981 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 1982 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 1983 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 1984 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 1980 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 1981 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 1982 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 1983 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 1984 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 1985 | 1985 | </tr> |
| 1986 | 1986 | </thead> |
| 1987 | 1987 | <tbody> |
@@ -1990,32 +1990,32 @@ discard block |
||
| 1990 | 1990 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
| 1991 | 1991 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
| 1992 | 1992 | <td class="text-center"><?php echo $times_billed; ?></td> |
| 1993 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
| 1993 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
| 1994 | 1994 | <?php echo $status_desc; ?> |
| 1995 | 1995 | </td> |
| 1996 | 1996 | </tr> |
| 1997 | 1997 | </tbody> |
| 1998 | 1998 | </table> |
| 1999 | 1999 | </div> |
| 2000 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 2000 | + <?php if (!empty($payments)) { ?> |
|
| 2001 | 2001 | <div class="wpinv-renewal-payments"> |
| 2002 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 2002 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 2003 | 2003 | <table class="table"> |
| 2004 | 2004 | <thead> |
| 2005 | 2005 | <tr> |
| 2006 | 2006 | <th>#</th> |
| 2007 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 2008 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 2009 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 2007 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 2008 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 2009 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 2010 | 2010 | </tr> |
| 2011 | 2011 | </thead> |
| 2012 | 2012 | <tbody> |
| 2013 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
| 2013 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
| 2014 | 2014 | <tr> |
| 2015 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
| 2016 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 2017 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 2018 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 2015 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
| 2016 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 2017 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 2018 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 2019 | 2019 | </tr> |
| 2020 | 2020 | <?php } ?> |
| 2021 | 2021 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -2027,52 +2027,52 @@ discard block |
||
| 2027 | 2027 | } |
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 2031 | - if ( empty( $invoice ) ) { |
|
| 2030 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 2031 | + if (empty($invoice)) { |
|
| 2032 | 2032 | return $label; |
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | $prefix_label = ''; |
| 2036 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2037 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2038 | - } else if ( $invoice->is_renewal() ) { |
|
| 2039 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 2036 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2037 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2038 | + } else if ($invoice->is_renewal()) { |
|
| 2039 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | - if ( $prefix_label != '' ) { |
|
| 2043 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2042 | + if ($prefix_label != '') { |
|
| 2043 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2044 | 2044 | } |
| 2045 | 2045 | |
| 2046 | 2046 | return $label; |
| 2047 | 2047 | } |
| 2048 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2049 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2050 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2048 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2049 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2050 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2051 | 2051 | |
| 2052 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2052 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2053 | 2053 | |
| 2054 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2055 | - if ( empty( $invoice ) ) { |
|
| 2054 | +function wpinv_invoice_print_description($invoice) { |
|
| 2055 | + if (empty($invoice)) { |
|
| 2056 | 2056 | return NULL; |
| 2057 | 2057 | } |
| 2058 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2058 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2059 | 2059 | ?> |
| 2060 | 2060 | <div class="row wpinv-lower"> |
| 2061 | 2061 | <div class="col-sm-12 wpinv-description"> |
| 2062 | - <?php echo wpautop( $description ); ?> |
|
| 2062 | + <?php echo wpautop($description); ?> |
|
| 2063 | 2063 | </div> |
| 2064 | 2064 | </div> |
| 2065 | 2065 | <?php |
| 2066 | 2066 | } |
| 2067 | 2067 | } |
| 2068 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2068 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2069 | 2069 | |
| 2070 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2071 | - if ( empty( $invoice ) ) { |
|
| 2070 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2071 | + if (empty($invoice)) { |
|
| 2072 | 2072 | return NULL; |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2075 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2076 | 2076 | ?> |
| 2077 | 2077 | <div class="row wpinv-payments"> |
| 2078 | 2078 | <div class="col-sm-12"> |
@@ -2084,40 +2084,40 @@ discard block |
||
| 2084 | 2084 | } |
| 2085 | 2085 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2086 | 2086 | |
| 2087 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2088 | - if ( empty( $note ) ) { |
|
| 2087 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2088 | + if (empty($note)) { |
|
| 2089 | 2089 | return NULL; |
| 2090 | 2090 | } |
| 2091 | 2091 | |
| 2092 | - if ( is_int( $note ) ) { |
|
| 2093 | - $note = get_comment( $note ); |
|
| 2092 | + if (is_int($note)) { |
|
| 2093 | + $note = get_comment($note); |
|
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2096 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2097 | 2097 | return NULL; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - $note_classes = array( 'note' ); |
|
| 2101 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2102 | - $note_classes[] = $note->comment_author === __( 'GeoDirectory', 'invoicing' ) ? 'system-note' : ''; |
|
| 2103 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2104 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2100 | + $note_classes = array('note'); |
|
| 2101 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2102 | + $note_classes[] = $note->comment_author === __('GeoDirectory', 'invoicing') ? 'system-note' : ''; |
|
| 2103 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2104 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2105 | 2105 | |
| 2106 | 2106 | ob_start(); |
| 2107 | 2107 | ?> |
| 2108 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2108 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2109 | 2109 | <div class="note_content"> |
| 2110 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2110 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2111 | 2111 | </div> |
| 2112 | 2112 | <p class="meta"> |
| 2113 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2113 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2114 | 2114 | </p> |
| 2115 | 2115 | </li> |
| 2116 | 2116 | <?php |
| 2117 | 2117 | $note_content = ob_get_clean(); |
| 2118 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2118 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2119 | 2119 | |
| 2120 | - if ( $echo ) { |
|
| 2120 | + if ($echo) { |
|
| 2121 | 2121 | echo $note_content; |
| 2122 | 2122 | } else { |
| 2123 | 2123 | return $note_content; |
@@ -70,7 +70,10 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function wpinv_invoice_display_right_actions( $invoice ) { |
| 73 | - if ( empty( $invoice ) ) return; //Exit if invoice is not set. |
|
| 73 | + if ( empty( $invoice ) ) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 76 | + //Exit if invoice is not set. |
|
| 74 | 77 | |
| 75 | 78 | if($invoice->post_type == 'wpi_invoice'){ |
| 76 | 79 | $user_id = (int)$invoice->get_user_id(); |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | |
| 178 | 181 | // Setup possible parts |
| 179 | 182 | $templates = array(); |
| 180 | - if ( isset( $name ) ) |
|
| 181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 183 | + if ( isset( $name ) ) { |
|
| 184 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 185 | + } |
|
| 182 | 186 | $templates[] = $slug . '.php'; |
| 183 | 187 | |
| 184 | 188 | // Allow template parts to be filtered |
@@ -196,8 +200,9 @@ discard block |
||
| 196 | 200 | foreach ( (array)$template_names as $template_name ) { |
| 197 | 201 | |
| 198 | 202 | // Continue if template is empty |
| 199 | - if ( empty( $template_name ) ) |
|
| 200 | - continue; |
|
| 203 | + if ( empty( $template_name ) ) { |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 201 | 206 | |
| 202 | 207 | // Trim off any slashes from the template name |
| 203 | 208 | $template_name = ltrim( $template_name, '/' ); |
@@ -216,8 +221,9 @@ discard block |
||
| 216 | 221 | } |
| 217 | 222 | } |
| 218 | 223 | |
| 219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | - load_template( $located, $require_once ); |
|
| 224 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 225 | + load_template( $located, $require_once ); |
|
| 226 | + } |
|
| 221 | 227 | |
| 222 | 228 | return $located; |
| 223 | 229 | } |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
| 294 | 300 | $args = array( 'nopaging' => true ); |
| 295 | 301 | |
| 296 | - if ( ! empty( $status ) ) |
|
| 297 | - $args['post_status'] = $status; |
|
| 302 | + if ( ! empty( $status ) ) { |
|
| 303 | + $args['post_status'] = $status; |
|
| 304 | + } |
|
| 298 | 305 | |
| 299 | 306 | $discounts = wpinv_get_discounts( $args ); |
| 300 | 307 | $options = array(); |
@@ -898,8 +905,11 @@ discard block |
||
| 898 | 905 | |
| 899 | 906 | $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
| 900 | 907 | |
| 901 | - if($invoice->post_type == 'wpi_invoice') $type = 'Invoice'; |
|
| 902 | - elseif($invoice->post_type == 'wpi_quote') $type = 'Quote'; |
|
| 908 | + if($invoice->post_type == 'wpi_invoice') { |
|
| 909 | + $type = 'Invoice'; |
|
| 910 | + } elseif($invoice->post_type == 'wpi_quote') { |
|
| 911 | + $type = 'Quote'; |
|
| 912 | + } |
|
| 903 | 913 | ?> |
| 904 | 914 | <table class="table table-bordered table-sm"> |
| 905 | 915 | <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
@@ -1466,17 +1476,19 @@ discard block |
||
| 1466 | 1476 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1467 | 1477 | |
| 1468 | 1478 | function wpinv_save_cart_button() { |
| 1469 | - if ( wpinv_is_cart_saving_disabled() ) |
|
| 1470 | - return; |
|
| 1471 | -?> |
|
| 1479 | + if ( wpinv_is_cart_saving_disabled() ) { |
|
| 1480 | + return; |
|
| 1481 | + } |
|
| 1482 | + ?> |
|
| 1472 | 1483 | <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a> |
| 1473 | 1484 | <?php |
| 1474 | 1485 | } |
| 1475 | 1486 | |
| 1476 | 1487 | function wpinv_update_cart_button() { |
| 1477 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1478 | - return; |
|
| 1479 | -?> |
|
| 1488 | + if ( !wpinv_item_quantities_enabled() ) { |
|
| 1489 | + return; |
|
| 1490 | + } |
|
| 1491 | + ?> |
|
| 1480 | 1492 | <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
| 1481 | 1493 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1482 | 1494 | <?php |
@@ -1615,7 +1627,7 @@ discard block |
||
| 1615 | 1627 | </div> |
| 1616 | 1628 | <?php |
| 1617 | 1629 | } |
| 1618 | - }else{ |
|
| 1630 | + } else{ |
|
| 1619 | 1631 | echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
| 1620 | 1632 | } |
| 1621 | 1633 | |
@@ -161,6 +161,9 @@ |
||
| 161 | 161 | wp_redirect( $redirect_to ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | +/** |
|
| 165 | + * @param integer $user_id |
|
| 166 | + */ |
|
| 164 | 167 | function wpinv_login_user( $user_id ) { |
| 165 | 168 | if ( is_user_logged_in() ) { |
| 166 | 169 | return true; |
@@ -1,28 +1,28 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -function wpinv_user_invoices( $current_page = 1 ) { |
|
| 5 | +function wpinv_user_invoices($current_page = 1) { |
|
| 6 | 6 | global $current_page; |
| 7 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
| 7 | + wpinv_get_template_part('wpinv-invoice-history'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 11 | - if ( empty( $user ) ) { |
|
| 10 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 11 | + if (empty($user)) { |
|
| 12 | 12 | $user = get_current_user_id(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( 0 === $user ) { |
|
| 15 | + if (0 === $user) { |
|
| 16 | 16 | return false; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $status = $status === 'complete' ? 'publish' : $status; |
| 20 | 20 | |
| 21 | - if ( $pagination ) { |
|
| 22 | - if ( get_query_var( 'paged' ) ) |
|
| 21 | + if ($pagination) { |
|
| 22 | + if (get_query_var('paged')) |
|
| 23 | 23 | $paged = get_query_var('paged'); |
| 24 | - else if ( get_query_var( 'page' ) ) |
|
| 25 | - $paged = get_query_var( 'page' ); |
|
| 24 | + else if (get_query_var('page')) |
|
| 25 | + $paged = get_query_var('page'); |
|
| 26 | 26 | else |
| 27 | 27 | $paged = 1; |
| 28 | 28 | } |
@@ -31,21 +31,21 @@ discard block |
||
| 31 | 31 | 'post_type' => 'wpi_invoice', |
| 32 | 32 | 'posts_per_page' => 20, |
| 33 | 33 | 'paged' => null, |
| 34 | - 'post_status' => array( 'complete', 'publish', 'pending' ), |
|
| 34 | + 'post_status' => array('complete', 'publish', 'pending'), |
|
| 35 | 35 | 'user' => $user, |
| 36 | 36 | 'order' => 'date', |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - $invoices = get_posts( $args ); |
|
| 39 | + $invoices = get_posts($args); |
|
| 40 | 40 | |
| 41 | 41 | // No invoices |
| 42 | - if ( ! $invoices ) |
|
| 42 | + if (!$invoices) |
|
| 43 | 43 | return false; |
| 44 | 44 | |
| 45 | 45 | return $invoices; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 48 | +function wpinv_dropdown_users($args = '') { |
|
| 49 | 49 | $defaults = array( |
| 50 | 50 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
| 51 | 51 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | 'option_none_value' => -1 |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
| 59 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
| 60 | 60 | |
| 61 | - $r = wp_parse_args( $args, $defaults ); |
|
| 61 | + $r = wp_parse_args($args, $defaults); |
|
| 62 | 62 | |
| 63 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
| 63 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
| 64 | 64 | |
| 65 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
| 65 | + $fields = array('ID', 'user_login', 'user_email'); |
|
| 66 | 66 | |
| 67 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
| 68 | - if ( 'display_name_with_login' === $show ) { |
|
| 67 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
| 68 | + if ('display_name_with_login' === $show) { |
|
| 69 | 69 | $fields[] = 'display_name'; |
| 70 | - } else if ( 'display_name_with_email' === $show ) { |
|
| 70 | + } else if ('display_name_with_email' === $show) { |
|
| 71 | 71 | $fields[] = 'display_name'; |
| 72 | 72 | } else { |
| 73 | 73 | $fields[] = $show; |
@@ -79,99 +79,99 @@ discard block |
||
| 79 | 79 | $show_option_none = $r['show_option_none']; |
| 80 | 80 | $option_none_value = $r['option_none_value']; |
| 81 | 81 | |
| 82 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
| 82 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
| 83 | 83 | |
| 84 | - $users = get_users( $query_args ); |
|
| 84 | + $users = get_users($query_args); |
|
| 85 | 85 | |
| 86 | 86 | $output = ''; |
| 87 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
| 88 | - $name = esc_attr( $r['name'] ); |
|
| 89 | - if ( $r['multi'] && ! $r['id'] ) { |
|
| 87 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
| 88 | + $name = esc_attr($r['name']); |
|
| 89 | + if ($r['multi'] && !$r['id']) { |
|
| 90 | 90 | $id = ''; |
| 91 | 91 | } else { |
| 92 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
| 92 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
| 93 | 93 | } |
| 94 | 94 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
| 95 | 95 | |
| 96 | - if ( $show_option_all ) { |
|
| 96 | + if ($show_option_all) { |
|
| 97 | 97 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( $show_option_none ) { |
|
| 101 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
| 102 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
| 100 | + if ($show_option_none) { |
|
| 101 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
| 102 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
| 105 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
| 106 | 106 | $found_selected = false; |
| 107 | - $r['selected'] = (int) $r['selected']; |
|
| 108 | - foreach ( (array) $users as $user ) { |
|
| 109 | - $user->ID = (int) $user->ID; |
|
| 110 | - if ( $user->ID === $r['selected'] ) { |
|
| 107 | + $r['selected'] = (int)$r['selected']; |
|
| 108 | + foreach ((array)$users as $user) { |
|
| 109 | + $user->ID = (int)$user->ID; |
|
| 110 | + if ($user->ID === $r['selected']) { |
|
| 111 | 111 | $found_selected = true; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( ! $found_selected ) { |
|
| 116 | - $users[] = get_userdata( $r['selected'] ); |
|
| 115 | + if (!$found_selected) { |
|
| 116 | + $users[] = get_userdata($r['selected']); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach ( (array) $users as $user ) { |
|
| 121 | - if ( 'display_name_with_login' === $show ) { |
|
| 120 | + foreach ((array)$users as $user) { |
|
| 121 | + if ('display_name_with_login' === $show) { |
|
| 122 | 122 | /* translators: 1: display name, 2: user_login */ |
| 123 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
| 124 | - } elseif ( 'display_name_with_email' === $show ) { |
|
| 123 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
| 124 | + } elseif ('display_name_with_email' === $show) { |
|
| 125 | 125 | /* translators: 1: display name, 2: user_email */ |
| 126 | - if ( $user->display_name == $user->user_email ) { |
|
| 126 | + if ($user->display_name == $user->user_email) { |
|
| 127 | 127 | $display = $user->display_name; |
| 128 | 128 | } else { |
| 129 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
| 129 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
| 130 | 130 | } |
| 131 | - } elseif ( ! empty( $user->$show ) ) { |
|
| 131 | + } elseif (!empty($user->$show)) { |
|
| 132 | 132 | $display = $user->$show; |
| 133 | 133 | } else { |
| 134 | 134 | $display = '(' . $user->user_login . ')'; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
| 138 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
| 137 | + $_selected = selected($user->ID, $r['selected'], false); |
|
| 138 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $output .= "</select>"; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
| 144 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
| 145 | 145 | |
| 146 | - if ( $r['echo'] ) { |
|
| 146 | + if ($r['echo']) { |
|
| 147 | 147 | echo $html; |
| 148 | 148 | } |
| 149 | 149 | return $html; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
| 153 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
| 154 | - wpinv_login_user( $user_id ); |
|
| 152 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
| 153 | + if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
| 154 | + wpinv_login_user($user_id); |
|
| 155 | 155 | } else { |
| 156 | - $redirect_to = wp_login_url( $redirect_to ); |
|
| 156 | + $redirect_to = wp_login_url($redirect_to); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
| 159 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
| 160 | 160 | |
| 161 | - wp_redirect( $redirect_to ); |
|
| 161 | + wp_redirect($redirect_to); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function wpinv_login_user( $user_id ) { |
|
| 165 | - if ( is_user_logged_in() ) { |
|
| 164 | +function wpinv_login_user($user_id) { |
|
| 165 | + if (is_user_logged_in()) { |
|
| 166 | 166 | return true; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $user = get_user_by( 'id', $user_id ); |
|
| 169 | + $user = get_user_by('id', $user_id); |
|
| 170 | 170 | |
| 171 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
| 172 | - wp_set_current_user( $user_id, $user->user_login ); |
|
| 173 | - wp_set_auth_cookie( $user_id ); |
|
| 174 | - do_action( 'wp_login', $user->user_login ); |
|
| 171 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
| 172 | + wp_set_current_user($user_id, $user->user_login); |
|
| 173 | + wp_set_auth_cookie($user_id); |
|
| 174 | + do_action('wp_login', $user->user_login); |
|
| 175 | 175 | |
| 176 | 176 | return true; |
| 177 | 177 | } |
@@ -1,6 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | function wpinv_user_invoices( $current_page = 1 ) { |
| 6 | 8 | global $current_page; |
@@ -19,12 +21,13 @@ discard block |
||
| 19 | 21 | $status = $status === 'complete' ? 'publish' : $status; |
| 20 | 22 | |
| 21 | 23 | if ( $pagination ) { |
| 22 | - if ( get_query_var( 'paged' ) ) |
|
| 23 | - $paged = get_query_var('paged'); |
|
| 24 | - else if ( get_query_var( 'page' ) ) |
|
| 25 | - $paged = get_query_var( 'page' ); |
|
| 26 | - else |
|
| 27 | - $paged = 1; |
|
| 24 | + if ( get_query_var( 'paged' ) ) { |
|
| 25 | + $paged = get_query_var('paged'); |
|
| 26 | + } else if ( get_query_var( 'page' ) ) { |
|
| 27 | + $paged = get_query_var( 'page' ); |
|
| 28 | + } else { |
|
| 29 | + $paged = 1; |
|
| 30 | + } |
|
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | $args = array( |
@@ -39,8 +42,9 @@ discard block |
||
| 39 | 42 | $invoices = get_posts( $args ); |
| 40 | 43 | |
| 41 | 44 | // No invoices |
| 42 | - if ( ! $invoices ) |
|
| 43 | - return false; |
|
| 45 | + if ( ! $invoices ) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 44 | 48 | |
| 45 | 49 | return $invoices; |
| 46 | 50 | } |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // If uninstall not called from WordPress, then exit. |
| 12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
@@ -5,140 +5,140 @@ |
||
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns, $wpi_session; |
| 7 | 7 | $invoice = wpinv_get_invoice_cart(); |
| 8 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 8 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 9 | 9 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $tax_label = $wpinv_euvat->tax_label(); |
| 12 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 12 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 13 | 13 | ?> |
| 14 | 14 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
| 15 | 15 | <thead> |
| 16 | 16 | <tr class="wpinv_cart_header_row"> |
| 17 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
| 18 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
| 19 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
| 20 | - <?php if ( $quantities_enabled ) { ?> |
|
| 21 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
| 17 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
| 18 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
| 19 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
| 20 | + <?php if ($quantities_enabled) { ?> |
|
| 21 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 22 | 22 | <?php } ?> |
| 23 | - <?php if ( $use_taxes ) { ?> |
|
| 23 | + <?php if ($use_taxes) { ?> |
|
| 24 | 24 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
| 25 | 25 | <?php } ?> |
| 26 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
| 26 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
| 28 | 28 | </tr> |
| 29 | 29 | </thead> |
| 30 | 30 | <tbody> |
| 31 | 31 | <?php |
| 32 | - do_action( 'wpinv_cart_items_before' ); |
|
| 32 | + do_action('wpinv_cart_items_before'); |
|
| 33 | 33 | |
| 34 | - if ( $cart_items ) { |
|
| 35 | - foreach ( $cart_items as $key => $item ) { |
|
| 36 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
| 34 | + if ($cart_items) { |
|
| 35 | + foreach ($cart_items as $key => $item) { |
|
| 36 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
| 37 | 37 | ?> |
| 38 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
| 39 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
| 38 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
| 39 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
| 40 | 40 | <td class="wpinv_cart_item_name text-left"> |
| 41 | 41 | <?php |
| 42 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
| 42 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
| 43 | 43 | echo '<div class="wpinv_cart_item_image">'; |
| 44 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
| 44 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
| 45 | 45 | echo '</div>'; |
| 46 | 46 | } |
| 47 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
| 47 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
| 48 | 48 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
| 49 | - if ( !empty( $wpi_item ) && $wpi_item->is_package() && !empty( $item['meta']['post_id'] ) ) { |
|
| 50 | - $post_link = !empty( $item['meta']['invoice_title'] ) ? $item['meta']['invoice_title'] : get_the_title( $item['meta']['post_id'] ); |
|
| 51 | - $summary = wp_sprintf( __( '%s: %s', 'invoicing' ), $wpi_item->get_cpt_singular_name(), $post_link ); |
|
| 52 | - echo '<small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 49 | + if (!empty($wpi_item) && $wpi_item->is_package() && !empty($item['meta']['post_id'])) { |
|
| 50 | + $post_link = !empty($item['meta']['invoice_title']) ? $item['meta']['invoice_title'] : get_the_title($item['meta']['post_id']); |
|
| 51 | + $summary = wp_sprintf(__('%s: %s', 'invoicing'), $wpi_item->get_cpt_singular_name(), $post_link); |
|
| 52 | + echo '<small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 53 | 53 | } |
| 54 | - do_action( 'wpinv_checkout_cart_item_title_after', $item, $key ); |
|
| 54 | + do_action('wpinv_checkout_cart_item_title_after', $item, $key); |
|
| 55 | 55 | ?> |
| 56 | 56 | </td> |
| 57 | 57 | <td class="wpinv_cart_item_price text-right"> |
| 58 | 58 | <?php |
| 59 | - echo wpinv_cart_item_price( $item ); |
|
| 60 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
| 59 | + echo wpinv_cart_item_price($item); |
|
| 60 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
| 61 | 61 | ?> |
| 62 | 62 | </td> |
| 63 | - <?php if ( $quantities_enabled ) { ?> |
|
| 63 | + <?php if ($quantities_enabled) { ?> |
|
| 64 | 64 | <td class="wpinv_cart_item_qty text-right"> |
| 65 | 65 | <?php |
| 66 | - echo wpinv_get_cart_item_quantity( $item ); |
|
| 67 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
| 66 | + echo wpinv_get_cart_item_quantity($item); |
|
| 67 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
| 68 | 68 | ?> |
| 69 | 69 | </td> |
| 70 | 70 | <?php } ?> |
| 71 | - <?php if ( $use_taxes ) { ?> |
|
| 71 | + <?php if ($use_taxes) { ?> |
|
| 72 | 72 | <td class="wpinv_cart_item_tax text-right"> |
| 73 | 73 | <?php |
| 74 | - echo wpinv_cart_item_tax( $item ); |
|
| 74 | + echo wpinv_cart_item_tax($item); |
|
| 75 | 75 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
| 76 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
| 76 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
| 77 | 77 | ?> |
| 78 | 78 | </td> |
| 79 | 79 | <?php } ?> |
| 80 | 80 | <td class="wpinv_cart_item_subtotal text-right"> |
| 81 | 81 | <?php |
| 82 | - echo wpinv_cart_item_subtotal( $item ); |
|
| 83 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
| 82 | + echo wpinv_cart_item_subtotal($item); |
|
| 83 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
| 84 | 84 | ?> |
| 85 | 85 | </td> |
| 86 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
| 86 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
| 87 | 87 | </tr> |
| 88 | 88 | <?php } ?> |
| 89 | 89 | <?php } ?> |
| 90 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
| 91 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
| 90 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
| 91 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
| 92 | 92 | </tbody> |
| 93 | 93 | <tfoot> |
| 94 | 94 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
| 95 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
| 95 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
| 96 | 96 | <tr class="wpinv_cart_footer_row"> |
| 97 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 98 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
| 99 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
| 97 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 98 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
| 99 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
| 100 | 100 | </td> |
| 101 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 101 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 102 | 102 | </tr> |
| 103 | 103 | <?php } ?> |
| 104 | 104 | |
| 105 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
| 106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 107 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
| 108 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 109 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
| 105 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
| 106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 107 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
| 108 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 109 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
| 110 | 110 | </td> |
| 111 | 111 | <td class="wpinv_cart_subtotal text-right"> |
| 112 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span> |
|
| 112 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span> |
|
| 113 | 113 | </td> |
| 114 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
| 114 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
| 115 | 115 | </tr> |
| 116 | 116 | <?php } ?> |
| 117 | 117 | |
| 118 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
| 118 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
| 119 | 119 | |
| 120 | - <?php if ( $use_taxes ) { ?> |
|
| 121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 122 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
| 123 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 120 | + <?php if ($use_taxes) { ?> |
|
| 121 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 122 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
| 123 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 124 | 124 | <strong><?php echo $tax_label; ?>:</strong> |
| 125 | 125 | </td> |
| 126 | 126 | <td class="wpinv_cart_tax text-right"> |
| 127 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span> |
|
| 127 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span> |
|
| 128 | 128 | </td> |
| 129 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
| 129 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
| 130 | 130 | </tr> |
| 131 | 131 | <?php } ?> |
| 132 | 132 | |
| 133 | 133 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
| 134 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
| 135 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
| 136 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
| 134 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
| 135 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
| 136 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
| 137 | 137 | </td> |
| 138 | 138 | <td class="wpinv_cart_total text-right"> |
| 139 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
| 139 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
| 140 | 140 | </td> |
| 141 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
| 141 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
| 142 | 142 | </tr> |
| 143 | 143 | </tfoot> |
| 144 | 144 | </table> |
@@ -103,7 +103,10 @@ discard block |
||
| 103 | 103 | <?php } ?> |
| 104 | 104 | |
| 105 | 105 | <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
| 106 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 106 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) { |
|
| 107 | + echo ' style="display:none;"'; |
|
| 108 | +} |
|
| 109 | +?>> |
|
| 107 | 110 | <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
| 108 | 111 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
| 109 | 112 | <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
@@ -118,7 +121,10 @@ discard block |
||
| 118 | 121 | <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
| 119 | 122 | |
| 120 | 123 | <?php if ( $use_taxes ) { ?> |
| 121 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 124 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) { |
|
| 125 | + echo ' style="display:none;"'; |
|
| 126 | +} |
|
| 127 | +?>> |
|
| 122 | 128 | <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
| 123 | 129 | <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
| 124 | 130 | <strong><?php echo $tax_label; ?>:</strong> |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
|
| 7 | -$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
|
| 6 | +$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text')); |
|
| 7 | +$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : ''; |
|
| 8 | 8 | ?> |
| 9 | 9 | </div> |
| 10 | 10 | </td> |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) ); |
| 7 | 8 | $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : ''; |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -if ( !isset( $email_heading ) ) { |
|
| 6 | +if (!isset($email_heading)) { |
|
| 7 | 7 | global $email_heading; |
| 8 | 8 | } |
| 9 | 9 | ?> |
| 10 | 10 | <!DOCTYPE html> |
| 11 | 11 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>"> |
| 12 | 12 | <head> |
| 13 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
| 13 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
| 14 | 14 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 15 | 15 | <meta name="robots" content="noindex,nofollow"> |
| 16 | 16 | <title><?php echo wpinv_get_blogname(); ?></title> |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | <td align="center" valign="top"> |
| 23 | 23 | <div id="template_header_image"> |
| 24 | 24 | <?php |
| 25 | - if ( $img = wpinv_get_option( 'email_header_image' ) ) { |
|
| 26 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
| 25 | + if ($img = wpinv_get_option('email_header_image')) { |
|
| 26 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
| 27 | 27 | } |
| 28 | 28 | ?> |
| 29 | 29 | </div> |
| 30 | 30 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
| 31 | - <?php if ( !empty( $email_heading ) ) { ?> |
|
| 31 | + <?php if (!empty($email_heading)) { ?> |
|
| 32 | 32 | <tr> |
| 33 | 33 | <td align="center" valign="top"> |
| 34 | 34 | <!-- Header --> |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | if ( !isset( $email_heading ) ) { |
| 7 | 8 | global $email_heading; |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( $invoice->needs_payment() ) { |
|
| 8 | +if ($invoice->needs_payment()) { |
|
| 9 | 9 | ?> |
| 10 | - <p><?php printf( __( 'An invoice has been created for you on %s. To pay for this invoice please use the following link: %s', 'invoicing' ), wpinv_get_business_name(), '<a href="' . esc_url( $invoice->get_checkout_payment_url( false, true ) ) . '">' . __( 'Pay Now', 'invoicing' ) . '</a>' ); ?></p> |
|
| 10 | + <p><?php printf(__('An invoice has been created for you on %s. To pay for this invoice please use the following link: %s', 'invoicing'), wpinv_get_business_name(), '<a href="' . esc_url($invoice->get_checkout_payment_url(false, true)) . '">' . __('Pay Now', 'invoicing') . '</a>'); ?></p> |
|
| 11 | 11 | <?php |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 18 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 19 | 19 | |
| 20 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 21 | 20 | \ No newline at end of file |
| 21 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 22 | 22 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | 8 | ?> |
| 9 | -<p><?php _e( 'Hello, a note has just been added to your invoice:', 'invoicing' ); ?></p> |
|
| 10 | -<blockquote class="wpinv-note"><?php echo wpautop( wptexturize( $customer_note ) ) ?></blockquote> |
|
| 11 | -<p><?php _e( 'For your reference, your invoice details are shown below.', 'invoicing' ); ?></p> |
|
| 9 | +<p><?php _e('Hello, a note has just been added to your invoice:', 'invoicing'); ?></p> |
|
| 10 | +<blockquote class="wpinv-note"><?php echo wpautop(wptexturize($customer_note)) ?></blockquote> |
|
| 11 | +<p><?php _e('For your reference, your invoice details are shown below.', 'invoicing'); ?></p> |
|
| 12 | 12 | <?php |
| 13 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 13 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 14 | 14 | |
| 15 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 15 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 16 | 16 | |
| 17 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 17 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 18 | 18 | |
| 19 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 20 | 19 | \ No newline at end of file |
| 20 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 21 | 21 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |