@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,43 +21,43 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | global $wpinv_euvat, $ajax_cart_details; |
| 26 | 26 | |
| 27 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 28 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 27 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 28 | + $invoice = new WPInv_Invoice($post_id); |
|
| 29 | 29 | $ajax_cart_details = $invoice->get_cart_details(); |
| 30 | - $subtotal = $invoice->get_subtotal( true ); |
|
| 30 | + $subtotal = $invoice->get_subtotal(true); |
|
| 31 | 31 | $discount_raw = $invoice->get_discount(); |
| 32 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
| 32 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
| 33 | 33 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
| 34 | - $tax = $invoice->get_tax( true ); |
|
| 35 | - $total = $invoice->get_total( true ); |
|
| 34 | + $tax = $invoice->get_tax(true); |
|
| 35 | + $total = $invoice->get_total(true); |
|
| 36 | 36 | $item_quantities = wpinv_item_quantities_enabled(); |
| 37 | 37 | $use_taxes = wpinv_use_taxes(); |
| 38 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
| 38 | + if (!$use_taxes && (float) $invoice->get_tax() > 0) { |
|
| 39 | 39 | $use_taxes = true; |
| 40 | 40 | } |
| 41 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
| 41 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
| 42 | 42 | $is_recurring = $invoice->is_recurring(); |
| 43 | 43 | $post_type_object = get_post_type_object($invoice->post_type); |
| 44 | 44 | $type_title = $post_type_object->labels->singular_name; |
| 45 | 45 | |
| 46 | 46 | $cols = 5; |
| 47 | - if ( $item_quantities ) { |
|
| 47 | + if ($item_quantities) { |
|
| 48 | 48 | $cols++; |
| 49 | 49 | } |
| 50 | - if ( $use_taxes ) { |
|
| 50 | + if ($use_taxes) { |
|
| 51 | 51 | $cols++; |
| 52 | 52 | } |
| 53 | 53 | $class = ''; |
| 54 | - if ( $invoice->is_paid() ) { |
|
| 54 | + if ($invoice->is_paid()) { |
|
| 55 | 55 | $class .= ' wpinv-paid'; |
| 56 | 56 | } |
| 57 | - if ( $invoice->is_refunded() ) { |
|
| 57 | + if ($invoice->is_refunded()) { |
|
| 58 | 58 | $class .= ' wpinv-refunded'; |
| 59 | 59 | } |
| 60 | - if ( $is_recurring ) { |
|
| 60 | + if ($is_recurring) { |
|
| 61 | 61 | $class .= ' wpi-recurring'; |
| 62 | 62 | } |
| 63 | 63 | ?> |
@@ -65,21 +65,21 @@ discard block |
||
| 65 | 65 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
| 66 | 66 | <thead> |
| 67 | 67 | <tr> |
| 68 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
| 69 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
| 70 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
| 71 | - <?php if ( $item_quantities ) { ?> |
|
| 72 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
| 68 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
| 69 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
| 70 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
| 71 | + <?php if ($item_quantities) { ?> |
|
| 72 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 73 | 73 | <?php } ?> |
| 74 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
| 75 | - <?php if ( $use_taxes ) { ?> |
|
| 76 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
| 74 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
| 75 | + <?php if ($use_taxes) { ?> |
|
| 76 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
| 77 | 77 | <?php } ?> |
| 78 | 78 | <th class="action"></th> |
| 79 | 79 | </tr> |
| 80 | 80 | </thead> |
| 81 | 81 | <tbody class="wpinv-line-items"> |
| 82 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
| 82 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
| 83 | 83 | </tbody> |
| 84 | 84 | <tfoot class="wpinv-totals"> |
| 85 | 85 | <tr> |
@@ -90,45 +90,45 @@ discard block |
||
| 90 | 90 | <td class="id"> |
| 91 | 91 | </td> |
| 92 | 92 | <td class="title"> |
| 93 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
| 94 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
| 93 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
| 94 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
| 95 | 95 | <div class="wp-clearfix"> |
| 96 | 96 | <label class="wpi-vat-rule"> |
| 97 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
| 97 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
| 98 | 98 | <span class="input-text-wrap"> |
| 99 | - <?php echo wpinv_html_select( array( |
|
| 99 | + <?php echo wpinv_html_select(array( |
|
| 100 | 100 | 'options' => $wpinv_euvat->get_rules(), |
| 101 | 101 | 'name' => '_wpinv_quick[vat_rule]', |
| 102 | 102 | 'id' => '_wpinv_quick_vat_rule', |
| 103 | 103 | 'show_option_all' => false, |
| 104 | 104 | 'show_option_none' => false, |
| 105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
| 106 | - ) ); ?> |
|
| 106 | + )); ?> |
|
| 107 | 107 | </span> |
| 108 | 108 | </label> |
| 109 | 109 | </div> |
| 110 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
| 110 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
| 111 | 111 | <div class="wp-clearfix"> |
| 112 | 112 | <label class="wpi-vat-class"> |
| 113 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
| 113 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
| 114 | 114 | <span class="input-text-wrap"> |
| 115 | - <?php echo wpinv_html_select( array( |
|
| 115 | + <?php echo wpinv_html_select(array( |
|
| 116 | 116 | 'options' => $wpinv_euvat->get_all_classes(), |
| 117 | 117 | 'name' => '_wpinv_quick[vat_class]', |
| 118 | 118 | 'id' => '_wpinv_quick_vat_class', |
| 119 | 119 | 'show_option_all' => false, |
| 120 | 120 | 'show_option_none' => false, |
| 121 | 121 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
| 122 | - ) ); ?> |
|
| 122 | + )); ?> |
|
| 123 | 123 | </span> |
| 124 | 124 | </label> |
| 125 | 125 | </div> |
| 126 | 126 | <?php } ?> |
| 127 | 127 | <div class="wp-clearfix"> |
| 128 | 128 | <label class="wpi-item-type"> |
| 129 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
| 129 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
| 130 | 130 | <span class="input-text-wrap"> |
| 131 | - <?php echo wpinv_html_select( array( |
|
| 131 | + <?php echo wpinv_html_select(array( |
|
| 132 | 132 | 'options' => $item_types, |
| 133 | 133 | 'name' => '_wpinv_quick[type]', |
| 134 | 134 | 'id' => '_wpinv_quick_type', |
@@ -136,37 +136,37 @@ discard block |
||
| 136 | 136 | 'show_option_all' => false, |
| 137 | 137 | 'show_option_none' => false, |
| 138 | 138 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
| 139 | - ) ); ?> |
|
| 139 | + )); ?> |
|
| 140 | 140 | </span> |
| 141 | 141 | </label> |
| 142 | 142 | </div> |
| 143 | 143 | |
| 144 | 144 | <div class="wp-clearfix"> |
| 145 | 145 | <?php |
| 146 | - echo wpinv_html_textarea( array( |
|
| 146 | + echo wpinv_html_textarea(array( |
|
| 147 | 147 | 'name' => '_wpinv_quick[excerpt]', |
| 148 | 148 | 'id' => '_wpinv_quick_excerpt', |
| 149 | 149 | 'value' => '', |
| 150 | 150 | 'class' => 'large-text', |
| 151 | - 'label' => __( 'Item description', 'invoicing' ), |
|
| 152 | - ) ); |
|
| 151 | + 'label' => __('Item description', 'invoicing'), |
|
| 152 | + )); |
|
| 153 | 153 | ?> |
| 154 | 154 | </div> |
| 155 | 155 | |
| 156 | 156 | <div class="wp-clearfix"> |
| 157 | 157 | <label class="wpi-item-actions"> |
| 158 | 158 | <span class="input-text-wrap"> |
| 159 | - <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
| 159 | + <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
| 160 | 160 | </span> |
| 161 | 161 | </label> |
| 162 | 162 | </div> |
| 163 | 163 | </td> |
| 164 | 164 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
| 165 | - <?php if ( $item_quantities ) { ?> |
|
| 165 | + <?php if ($item_quantities) { ?> |
|
| 166 | 166 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
| 167 | 167 | <?php } ?> |
| 168 | 168 | <td class="total"></td> |
| 169 | - <?php if ( $use_taxes ) { ?> |
|
| 169 | + <?php if ($use_taxes) { ?> |
|
| 170 | 170 | <td class="tax"></td> |
| 171 | 171 | <?php } ?> |
| 172 | 172 | <td class="action"></td> |
@@ -179,29 +179,29 @@ discard block |
||
| 179 | 179 | <td colspan="<?php echo $cols; ?>"></td> |
| 180 | 180 | </tr> |
| 181 | 181 | <tr class="totals"> |
| 182 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
| 182 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
| 183 | 183 | <td colspan="4"> |
| 184 | 184 | <table cellspacing="0" cellpadding="0"> |
| 185 | 185 | <tr class="subtotal"> |
| 186 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
| 187 | - <td class="total"><?php echo $subtotal;?></td> |
|
| 186 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
| 187 | + <td class="total"><?php echo $subtotal; ?></td> |
|
| 188 | 188 | <td class="action"></td> |
| 189 | 189 | </tr> |
| 190 | 190 | <tr class="discount"> |
| 191 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
| 192 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
| 191 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
| 192 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
| 193 | 193 | <td class="action"></td> |
| 194 | 194 | </tr> |
| 195 | - <?php if ( $use_taxes ) { ?> |
|
| 195 | + <?php if ($use_taxes) { ?> |
|
| 196 | 196 | <tr class="tax"> |
| 197 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
| 198 | - <td class="total"><?php echo $tax;?></td> |
|
| 197 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
| 198 | + <td class="total"><?php echo $tax; ?></td> |
|
| 199 | 199 | <td class="action"></td> |
| 200 | 200 | </tr> |
| 201 | 201 | <?php } ?> |
| 202 | 202 | <tr class="total"> |
| 203 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
| 204 | - <td class="total"><?php echo $total;?></td> |
|
| 203 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
| 204 | + <td class="total"><?php echo $total; ?></td> |
|
| 205 | 205 | <td class="action"></td> |
| 206 | 206 | </tr> |
| 207 | 207 | </table> |
@@ -212,31 +212,31 @@ discard block |
||
| 212 | 212 | <div class="wpinv-actions"> |
| 213 | 213 | <?php ob_start(); ?> |
| 214 | 214 | <?php |
| 215 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
| 216 | - if ( !$invoice->is_recurring() ) { |
|
| 217 | - echo wpinv_item_dropdown( array( |
|
| 215 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 216 | + if (!$invoice->is_recurring()) { |
|
| 217 | + echo wpinv_item_dropdown(array( |
|
| 218 | 218 | 'name' => 'wpinv_invoice_item', |
| 219 | 219 | 'id' => 'wpinv_invoice_item', |
| 220 | 220 | 'show_recurring' => true, |
| 221 | 221 | 'class' => 'wpi_select2', |
| 222 | - ) ); |
|
| 222 | + )); |
|
| 223 | 223 | ?> |
| 224 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
| 224 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
| 225 | 225 | <?php } ?> |
| 226 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
| 227 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
| 226 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
| 227 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
| 228 | 228 | </div> |
| 229 | 229 | </div> |
| 230 | 230 | <?php |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - public static function vat_rules( $post ) { |
|
| 233 | + public static function vat_rules($post) { |
|
| 234 | 234 | global $wpinv_euvat; |
| 235 | 235 | |
| 236 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
| 236 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
| 237 | 237 | ?> |
| 238 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
| 239 | - <?php echo wpinv_html_select( array( |
|
| 238 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
| 239 | + <?php echo wpinv_html_select(array( |
|
| 240 | 240 | 'options' => $wpinv_euvat->get_rules(), |
| 241 | 241 | 'name' => 'wpinv_vat_rules', |
| 242 | 242 | 'id' => 'wpinv_vat_rules', |
@@ -244,20 +244,20 @@ discard block |
||
| 244 | 244 | 'show_option_all' => false, |
| 245 | 245 | 'show_option_none' => false, |
| 246 | 246 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2', |
| 247 | - ) ); ?> |
|
| 247 | + )); ?> |
|
| 248 | 248 | </p> |
| 249 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
| 250 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
| 251 | - <p class="wpi-m0"><?php _e( 'Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing' ); ?></p> |
|
| 249 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
| 250 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
| 251 | + <p class="wpi-m0"><?php _e('Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing'); ?></p> |
|
| 252 | 252 | <?php |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - public static function vat_classes( $post ) { |
|
| 255 | + public static function vat_classes($post) { |
|
| 256 | 256 | global $wpinv_euvat; |
| 257 | 257 | |
| 258 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
| 258 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
| 259 | 259 | ?> |
| 260 | - <p><?php echo wpinv_html_select( array( |
|
| 260 | + <p><?php echo wpinv_html_select(array( |
|
| 261 | 261 | 'options' => $wpinv_euvat->get_all_classes(), |
| 262 | 262 | 'name' => 'wpinv_vat_class', |
| 263 | 263 | 'id' => 'wpinv_vat_class', |
@@ -265,18 +265,18 @@ discard block |
||
| 265 | 265 | 'show_option_all' => false, |
| 266 | 266 | 'show_option_none' => false, |
| 267 | 267 | 'class' => 'gdmbx2-text-medium wpinv-vat-class wpi_select2', |
| 268 | - ) ); ?> |
|
| 268 | + )); ?> |
|
| 269 | 269 | </p> |
| 270 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
| 270 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
| 271 | 271 | <?php |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - public static function item_info( $post ) { |
|
| 275 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
| 276 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
| 274 | + public static function item_info($post) { |
|
| 275 | + $item_type = wpinv_get_item_type($post->ID); |
|
| 276 | + do_action('wpinv_item_info_metabox_before', $post); |
|
| 277 | 277 | ?> |
| 278 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
| 279 | - <?php echo wpinv_html_select( array( |
|
| 278 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
| 279 | + <?php echo wpinv_html_select(array( |
|
| 280 | 280 | 'options' => wpinv_get_item_types(), |
| 281 | 281 | 'name' => 'wpinv_item_type', |
| 282 | 282 | 'id' => 'wpinv_item_type', |
@@ -284,127 +284,127 @@ discard block |
||
| 284 | 284 | 'show_option_all' => false, |
| 285 | 285 | 'show_option_none' => false, |
| 286 | 286 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
| 287 | - ) ); ?> |
|
| 287 | + )); ?> |
|
| 288 | 288 | </p> |
| 289 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
| 289 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
| 290 | 290 | <?php |
| 291 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
| 291 | + do_action('wpinv_item_info_metabox_after', $post); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - public static function meta_values( $post ) { |
|
| 295 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
| 294 | + public static function meta_values($post) { |
|
| 295 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
| 296 | 296 | 'type', |
| 297 | 297 | 'custom_id' |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | - if ( empty( $meta_keys ) ) { |
|
| 300 | + if (empty($meta_keys)) { |
|
| 301 | 301 | return; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
| 304 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
| 305 | 305 | |
| 306 | - foreach ( $meta_keys as $meta_key ) { |
|
| 306 | + foreach ($meta_keys as $meta_key) { |
|
| 307 | 307 | ?> |
| 308 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
| 308 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
| 309 | 309 | <?php |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
| 312 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | 316 | * Display the items buy now shortcode. |
| 317 | 317 | */ |
| 318 | - public static function shortcode( $post ) { |
|
| 318 | + public static function shortcode($post) { |
|
| 319 | 319 | |
| 320 | - if ( ! is_numeric( $post ) ) { |
|
| 320 | + if (!is_numeric($post)) { |
|
| 321 | 321 | $post = $post->ID; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | echo "<input type='text' style='min-width: 100%; font-size: small;' value='[getpaid item=$post]' disabled>"; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - public static function save( $post_id, $data, $post ) { |
|
| 328 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 327 | + public static function save($post_id, $data, $post) { |
|
| 328 | + $invoice = new WPInv_Invoice($post_id); |
|
| 329 | 329 | |
| 330 | 330 | // Billing |
| 331 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
| 332 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
| 333 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
| 334 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
| 335 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
| 336 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
| 337 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
| 338 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
| 339 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
| 340 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
| 331 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
| 332 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
| 333 | + $company = sanitize_text_field($data['wpinv_company']); |
|
| 334 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
| 335 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
| 336 | + $address = sanitize_text_field($data['wpinv_address']); |
|
| 337 | + $city = sanitize_text_field($data['wpinv_city']); |
|
| 338 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
| 339 | + $country = sanitize_text_field($data['wpinv_country']); |
|
| 340 | + $state = sanitize_text_field($data['wpinv_state']); |
|
| 341 | 341 | |
| 342 | 342 | // Details |
| 343 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
| 344 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
| 345 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
| 346 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
| 347 | - $date_created = isset( $data['date_created'] ) ? sanitize_text_field( $data['date_created'] ) : ''; |
|
| 343 | + $status = sanitize_text_field($data['wpinv_status']); |
|
| 344 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
| 345 | + $number = sanitize_text_field($data['wpinv_number']); |
|
| 346 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
| 347 | + $date_created = isset($data['date_created']) ? sanitize_text_field($data['date_created']) : ''; |
|
| 348 | 348 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
| 349 | 349 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
| 350 | 350 | |
| 351 | 351 | $disable_taxes = 0; |
| 352 | 352 | |
| 353 | - if ( ! empty( $data['disable_taxes'] ) ) { |
|
| 353 | + if (!empty($data['disable_taxes'])) { |
|
| 354 | 354 | $disable_taxes = 1; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
| 358 | - |
|
| 359 | - $invoice->set( 'due_date', $due_date ); |
|
| 360 | - $invoice->set( 'first_name', $first_name ); |
|
| 361 | - $invoice->set( 'last_name', $last_name ); |
|
| 362 | - $invoice->set( 'company', $company ); |
|
| 363 | - $invoice->set( 'vat_number', $vat_number ); |
|
| 364 | - $invoice->set( 'phone', $phone ); |
|
| 365 | - $invoice->set( 'address', $address ); |
|
| 366 | - $invoice->set( 'city', $city ); |
|
| 367 | - $invoice->set( 'zip', $zip ); |
|
| 368 | - $invoice->set( 'country', $country ); |
|
| 369 | - $invoice->set( 'state', $state ); |
|
| 370 | - $invoice->set( 'status', $status ); |
|
| 371 | - $invoice->set( 'set', $status ); |
|
| 357 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
| 358 | + |
|
| 359 | + $invoice->set('due_date', $due_date); |
|
| 360 | + $invoice->set('first_name', $first_name); |
|
| 361 | + $invoice->set('last_name', $last_name); |
|
| 362 | + $invoice->set('company', $company); |
|
| 363 | + $invoice->set('vat_number', $vat_number); |
|
| 364 | + $invoice->set('phone', $phone); |
|
| 365 | + $invoice->set('address', $address); |
|
| 366 | + $invoice->set('city', $city); |
|
| 367 | + $invoice->set('zip', $zip); |
|
| 368 | + $invoice->set('country', $country); |
|
| 369 | + $invoice->set('state', $state); |
|
| 370 | + $invoice->set('status', $status); |
|
| 371 | + $invoice->set('set', $status); |
|
| 372 | 372 | //$invoice->set( 'number', $number ); |
| 373 | 373 | //$invoice->set( 'discounts', $discounts ); |
| 374 | 374 | //$invoice->set( 'discount', $discount ); |
| 375 | - $invoice->set( 'disable_taxes', $disable_taxes ); |
|
| 376 | - $invoice->set( 'ip', $ip ); |
|
| 375 | + $invoice->set('disable_taxes', $disable_taxes); |
|
| 376 | + $invoice->set('ip', $ip); |
|
| 377 | 377 | $invoice->old_status = $_POST['original_post_status']; |
| 378 | 378 | |
| 379 | 379 | $currency = $invoice->get_currency(); |
| 380 | - if ( ! empty( $data['wpinv_currency'] ) ) { |
|
| 381 | - $currency = sanitize_text_field( $data['wpinv_currency'] ); |
|
| 380 | + if (!empty($data['wpinv_currency'])) { |
|
| 381 | + $currency = sanitize_text_field($data['wpinv_currency']); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if ( empty( $currency ) ) { |
|
| 384 | + if (empty($currency)) { |
|
| 385 | 385 | $currency = wpinv_get_currency(); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if ( ! $invoice->is_paid() ) { |
|
| 388 | + if (!$invoice->is_paid()) { |
|
| 389 | 389 | $invoice->currency = $currency; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
| 393 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
| 392 | + if (!empty($data['wpinv_gateway'])) { |
|
| 393 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
| 394 | 394 | } |
| 395 | 395 | $saved = $invoice->save(); |
| 396 | 396 | |
| 397 | 397 | $emails = ''; |
| 398 | - if ( ! empty( $data['wpinv_cc'] ) ) { |
|
| 399 | - $emails = wpinv_clean( $data['wpinv_cc'] ); |
|
| 398 | + if (!empty($data['wpinv_cc'])) { |
|
| 399 | + $emails = wpinv_clean($data['wpinv_cc']); |
|
| 400 | 400 | } |
| 401 | - update_post_meta( $invoice->ID, 'wpinv_email_cc', $emails ); |
|
| 401 | + update_post_meta($invoice->ID, 'wpinv_email_cc', $emails); |
|
| 402 | 402 | |
| 403 | - if ( ! empty( $date_created ) && strtotime( $date_created, current_time( 'timestamp' ) ) ) { |
|
| 403 | + if (!empty($date_created) && strtotime($date_created, current_time('timestamp'))) { |
|
| 404 | 404 | |
| 405 | - $time = strtotime( $date_created, current_time( 'timestamp' ) ); |
|
| 406 | - $date = date( 'Y-m-d H:i:s', $time ); |
|
| 407 | - $date_gmt = get_gmt_from_date( $date ); |
|
| 405 | + $time = strtotime($date_created, current_time('timestamp')); |
|
| 406 | + $date = date('Y-m-d H:i:s', $time); |
|
| 407 | + $date_gmt = get_gmt_from_date($date); |
|
| 408 | 408 | |
| 409 | 409 | wp_update_post( |
| 410 | 410 | array( |
@@ -419,37 +419,37 @@ discard block |
||
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // Check for payment notes |
| 422 | - if ( !empty( $data['invoice_note'] ) ) { |
|
| 423 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
| 424 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
| 422 | + if (!empty($data['invoice_note'])) { |
|
| 423 | + $note = wp_kses($data['invoice_note'], array()); |
|
| 424 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
| 425 | 425 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
| 426 | 426 | |
| 427 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
| 427 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Update user address if empty. |
| 431 | - if ( $saved && !empty( $invoice ) ) { |
|
| 432 | - if ( $user_id = $invoice->get_user_id() ) { |
|
| 433 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
| 431 | + if ($saved && !empty($invoice)) { |
|
| 432 | + if ($user_id = $invoice->get_user_id()) { |
|
| 433 | + $user_address = wpinv_get_user_address($user_id, false); |
|
| 434 | 434 | |
| 435 | 435 | if (empty($user_address['first_name'])) { |
| 436 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
| 437 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
| 436 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
| 437 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
| 438 | 438 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
| 439 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
| 439 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
| 443 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
| 444 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
| 445 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
| 446 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
| 447 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
| 448 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
| 443 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
| 444 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
| 445 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
| 446 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
| 447 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
| 448 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
| 452 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | return $saved; |