@@ -1,68 +1,68 @@ |
||
| 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 | global $wpinv_euvat; |
| 7 | 7 | |
| 8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
| 9 | -$invoice_url = $invoice->get_view_url( true ); |
|
| 8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
| 9 | +$invoice_url = $invoice->get_view_url(true); |
|
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 12 | 12 | |
| 13 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 13 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 14 | 14 | <div id="wpinv-email-details"> |
| 15 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3> |
|
| 15 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3> |
|
| 16 | 16 | <table class="table table-bordered table-sm"> |
| 17 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
| 17 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
| 18 | 18 | <tr> |
| 19 | - <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td> |
|
| 20 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
| 19 | + <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td> |
|
| 20 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
| 21 | 21 | </tr> |
| 22 | 22 | <?php } ?> |
| 23 | 23 | <tr> |
| 24 | - <td><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td> |
|
| 25 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
| 24 | + <td><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></td> |
|
| 25 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
| 26 | 26 | </tr> |
| 27 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 27 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 28 | 28 | <tr> |
| 29 | - <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td> |
|
| 30 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 29 | + <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td> |
|
| 30 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 31 | 31 | </tr> |
| 32 | 32 | <?php } ?> |
| 33 | - <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 34 | - <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td> |
|
| 33 | + <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 34 | + <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td> |
|
| 35 | 35 | <td><?php echo $gateway_title; ?></td> |
| 36 | 36 | <?php } ?> |
| 37 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
| 37 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
| 38 | 38 | <tr> |
| 39 | - <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td> |
|
| 40 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
| 39 | + <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td> |
|
| 40 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
| 41 | 41 | </tr> |
| 42 | 42 | <?php } ?> |
| 43 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
| 43 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
| 44 | 44 | <tr> |
| 45 | - <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td> |
|
| 46 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
| 45 | + <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td> |
|
| 46 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
| 47 | 47 | </tr> |
| 48 | 48 | <?php } ?> |
| 49 | - <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?> |
|
| 50 | - <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?> |
|
| 49 | + <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?> |
|
| 50 | + <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?> |
|
| 51 | 51 | <tr> |
| 52 | - <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 52 | + <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 53 | 53 | <td><?php echo $owner_vat_number; ?></td> |
| 54 | 54 | </tr> |
| 55 | 55 | <?php } ?> |
| 56 | - <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?> |
|
| 56 | + <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?> |
|
| 57 | 57 | <tr> |
| 58 | - <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 58 | + <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 59 | 59 | <td><?php echo $user_vat_number; ?></td> |
| 60 | 60 | </tr> |
| 61 | 61 | <?php } ?> |
| 62 | 62 | <tr class="table-active"> |
| 63 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
| 64 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
| 63 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
| 64 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
| 65 | 65 | </tr> |
| 66 | 66 | </table> |
| 67 | 67 | </div> |
| 68 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 69 | 68 | \ No newline at end of file |
| 69 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 70 | 70 | \ No newline at end of file |
@@ -1,30 +1,30 @@ 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 | class WPInv_Meta_Box_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
| 10 | 10 | $statuses = wpinv_get_invoice_statuses(); |
| 11 | 11 | |
| 12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 13 | + $invoice = new WPInv_Invoice($post_id); |
|
| 14 | 14 | |
| 15 | - $status = $invoice->get_status( false ); // Current status |
|
| 15 | + $status = $invoice->get_status(false); // Current status |
|
| 16 | 16 | $discount = $invoice->get_discount(); |
| 17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
| 18 | 18 | $invoice_number = $invoice->get_number(); |
| 19 | 19 | |
| 20 | 20 | $date_created = $invoice->get_created_date(); |
| 21 | - $datetime_created = strtotime( $date_created ); |
|
| 22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
| 21 | + $datetime_created = strtotime($date_created); |
|
| 22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
| 23 | 23 | $date_completed = $invoice->get_completed_date(); |
| 24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
| 25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
| 26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
| 27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
| 24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
| 25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
| 26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
| 27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
| 28 | 28 | |
| 29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
| 30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,30 +34,30 @@ discard block |
||
| 34 | 34 | <div class="gdmbx2-wrap form-table"> |
| 35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
| 36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
| 37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
| 38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
| 37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
| 38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
| 39 | 39 | </div> |
| 40 | - <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
| 40 | + <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?> |
|
| 41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
| 42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
| 42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
| 43 | 43 | <div class="gdmbx-td"> |
| 44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
| 44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
| 45 | 45 | </div> |
| 46 | 46 | </div> |
| 47 | 47 | <?php } ?> |
| 48 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
| 48 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
| 49 | 49 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
| 50 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
| 51 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
| 50 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
| 51 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
| 52 | 52 | </div> |
| 53 | 53 | <?php } ?> |
| 54 | - <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
| 54 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
| 55 | 55 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
| 56 | 56 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
| 57 | 57 | <div class="gdmbx-td"> |
| 58 | 58 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
| 59 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
| 60 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
| 59 | + <?php foreach ($statuses as $value => $label) { ?> |
|
| 60 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
| 61 | 61 | <?php } ?> |
| 62 | 62 | </select> |
| 63 | 63 | </div> |
@@ -65,107 +65,107 @@ discard block |
||
| 65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
| 66 | 66 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
| 67 | 67 | <div class="gdmbx-td"> |
| 68 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
| 68 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?> |
|
| 72 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) || $discount_code ) { ?> |
|
| 71 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); ?> |
|
| 72 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) || $discount_code) { ?> |
|
| 73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
| 74 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
| 74 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
| 75 | 75 | <div class="gdmbx-td"> |
| 76 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
| 76 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
| 77 | 77 | </div> |
| 78 | 78 | </div> |
| 79 | 79 | <?php } ?> |
| 80 | 80 | </div> |
| 81 | 81 | </div> |
| 82 | 82 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
| 83 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
| 83 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
| 84 | 84 | <select id="wpi_save_send" name="wpi_save_send"> |
| 85 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
| 86 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
| 85 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
| 86 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
| 87 | 87 | </select> |
| 88 | 88 | </p> |
| 89 | 89 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
| 90 | 90 | </div> |
| 91 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
| 91 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
| 92 | 92 | <?php |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public static function resend_invoice( $post ) { |
|
| 95 | + public static function resend_invoice($post) { |
|
| 96 | 96 | global $wpi_mb_invoice; |
| 97 | 97 | |
| 98 | - if ( empty( $wpi_mb_invoice ) ) { |
|
| 98 | + if (empty($wpi_mb_invoice)) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $text = array( |
| 103 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
| 104 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
| 103 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
| 104 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
| 108 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
| 108 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
| 109 | 109 | |
| 110 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
| 110 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
| 111 | 111 | $email_actions = array(); |
| 112 | - $email_actions['email_url'] = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ); |
|
| 113 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
| 112 | + $email_actions['email_url'] = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)); |
|
| 113 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
| 114 | 114 | |
| 115 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
| 115 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
| 116 | 116 | ?> |
| 117 | 117 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
| 118 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
| 119 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
| 120 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
| 118 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
| 119 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
| 120 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
| 121 | 121 | <?php } ?> |
| 122 | 122 | <?php |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
| 125 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public static function subscriptions( $post ) { |
|
| 128 | + public static function subscriptions($post) { |
|
| 129 | 129 | global $wpi_mb_invoice; |
| 130 | 130 | |
| 131 | 131 | $invoice = $wpi_mb_invoice; |
| 132 | 132 | |
| 133 | - if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
| 133 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
| 134 | 134 | $payments = $invoice->get_child_payments(); |
| 135 | 135 | |
| 136 | 136 | $total_payments = (int)$invoice->get_total_payments(); |
| 137 | 137 | $subscription = $invoice->get_subscription_data(); |
| 138 | 138 | |
| 139 | - $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() ); |
|
| 140 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
| 139 | + $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()); |
|
| 140 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
| 141 | 141 | $subscription_status = $invoice->get_subscription_status(); |
| 142 | 142 | ?> |
| 143 | - <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p> |
|
| 144 | - <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?> |
|
| 145 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p> |
|
| 143 | + <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
|
| 144 | + <?php if ($subscription_id = $invoice->get_subscription_id()) { ?> |
|
| 145 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p> |
|
| 146 | 146 | <?php } ?> |
| 147 | - <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p> |
|
| 148 | - <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p> |
|
| 149 | - <?php if ( !empty( $payments ) || ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 150 | - <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
| 151 | - <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
| 152 | - <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?> |
|
| 153 | - <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p> |
|
| 147 | + <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p> |
|
| 148 | + <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p> |
|
| 149 | + <?php if (!empty($payments) || ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 150 | + <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
| 151 | + <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
| 152 | + <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?> |
|
| 153 | + <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p> |
|
| 154 | 154 | <?php } ?> |
| 155 | - <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?> |
|
| 156 | - <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p> |
|
| 155 | + <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?> |
|
| 156 | + <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p> |
|
| 157 | 157 | <?php } ?> |
| 158 | - <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?> |
|
| 159 | - <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p> |
|
| 158 | + <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?> |
|
| 159 | + <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p> |
|
| 160 | 160 | <?php } ?> |
| 161 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 162 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
| 161 | + <?php if (!empty($payments)) { ?> |
|
| 162 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
| 163 | 163 | <ul id="wpi-sub-payments"> |
| 164 | - <?php foreach ( $payments as $invoice_id ) { ?> |
|
| 164 | + <?php foreach ($payments as $invoice_id) { ?> |
|
| 165 | 165 | <li> |
| 166 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
| 167 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
| 168 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
| 166 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
| 167 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
| 168 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
| 169 | 169 | </li> |
| 170 | 170 | <?php } ?> |
| 171 | 171 | </ul> |
@@ -173,49 +173,49 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public static function renewals( $post ) { |
|
| 176 | + public static function renewals($post) { |
|
| 177 | 177 | global $wpi_mb_invoice; |
| 178 | 178 | |
| 179 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
| 180 | - $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice ); |
|
| 181 | - $parent_id = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice ); |
|
| 179 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
| 180 | + $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice); |
|
| 181 | + $parent_id = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice); |
|
| 182 | 182 | ?> |
| 183 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
| 184 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
| 183 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
| 184 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
| 185 | 185 | <?php |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public static function payment_meta( $post ) { |
|
| 189 | + public static function payment_meta($post) { |
|
| 190 | 190 | global $wpi_mb_invoice; |
| 191 | 191 | |
| 192 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
| 193 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
| 192 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
| 193 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
| 194 | 194 | $set_dateway = true; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | ?> |
| 198 | 198 | <p class="wpi-meta-row"> |
| 199 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
| 200 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
| 199 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
| 200 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
| 201 | 201 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
| 202 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
| 203 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
| 202 | + <?php foreach ($gateways as $name => $gateway) { |
|
| 203 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
| 204 | 204 | continue; |
| 205 | 205 | } |
| 206 | 206 | ?> |
| 207 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
| 207 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
| 208 | 208 | <?php } ?> |
| 209 | 209 | </select> |
| 210 | 210 | <?php } else { |
| 211 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) ); |
|
| 211 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway)); |
|
| 212 | 212 | } ?> |
| 213 | 213 | </p> |
| 214 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
| 215 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
| 214 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
| 215 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
| 216 | 216 | <?php } ?> |
| 217 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
| 218 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
| 217 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
| 218 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
| 219 | 219 | <?php } ?> |
| 220 | 220 | <?php |
| 221 | 221 | } |
@@ -7,91 +7,91 @@ 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', wpinv_get_theme_template_dir_name() ); |
|
| 22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
| 26 | - if ( empty( $invoice ) ) { |
|
| 25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
| 26 | + if (empty($invoice)) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | ?> |
| 30 | 30 | <div class="row wpinv-top-bar no-print"> |
| 31 | 31 | <div class="container"> |
| 32 | 32 | <div class="col-xs-6"> |
| 33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
| 33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | <div class="col-xs-6 text-right"> |
| 36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
| 36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
| 44 | - if ( empty( $invoice ) ) { |
|
| 43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
| 44 | + if (empty($invoice)) { |
|
| 45 | 45 | return; // Exit if invoice is not set. |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
| 49 | - if ( $invoice->needs_payment() ) { |
|
| 50 | - ?> <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><?php |
|
| 48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
| 49 | + if ($invoice->needs_payment()) { |
|
| 50 | + ?> <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><?php |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
| 57 | - if ( empty( $invoice ) ) { |
|
| 56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
| 57 | + if (empty($invoice)) { |
|
| 58 | 58 | return; // Exit if invoice is not set. |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
| 62 | - <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
| 63 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 64 | - <a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
| 61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
| 62 | + <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
| 63 | + <?php if (is_user_logged_in()) { ?> |
|
| 64 | + <a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
| 65 | 65 | <?php } |
| 66 | 66 | } |
| 67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function wpinv_before_invoice_content( $content ) { |
|
| 70 | +function wpinv_before_invoice_content($content) { |
|
| 71 | 71 | global $post; |
| 72 | 72 | |
| 73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 74 | 74 | ob_start(); |
| 75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
| 75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
| 76 | 76 | $content = ob_get_clean() . $content; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $content; |
| 80 | 80 | } |
| 81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
| 81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
| 82 | 82 | |
| 83 | -function wpinv_after_invoice_content( $content ) { |
|
| 83 | +function wpinv_after_invoice_content($content) { |
|
| 84 | 84 | global $post; |
| 85 | 85 | |
| 86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
| 86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
| 87 | 87 | ob_start(); |
| 88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
| 88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
| 89 | 89 | $content .= ob_get_clean(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $content; |
| 93 | 93 | } |
| 94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
| 94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
| 95 | 95 | |
| 96 | 96 | function wpinv_get_templates_dir() { |
| 97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
| 101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 106 | - extract( $args ); |
|
| 104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 105 | + if (!empty($args) && is_array($args)) { |
|
| 106 | + extract($args); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
| 110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
| 111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 112 | 112 | |
| 113 | - if ( ! file_exists( $located ) ) { |
|
| 114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
| 113 | + if (!file_exists($located)) { |
|
| 114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
| 119 | 119 | |
| 120 | - include( $located ); |
|
| 120 | + include($located); |
|
| 121 | 121 | |
| 122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 126 | 126 | ob_start(); |
| 127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
| 128 | 128 | return ob_get_clean(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 132 | - if ( ! $template_path ) { |
|
| 131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 132 | + if (!$template_path) { |
|
| 133 | 133 | $template_path = wpinv_template_path(); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( ! $default_path ) { |
|
| 136 | + if (!$default_path) { |
|
| 137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Look within passed path within the theme - this is priority. |
| 141 | 141 | $template = locate_template( |
| 142 | 142 | array( |
| 143 | - trailingslashit( $template_path ) . $template_name, |
|
| 143 | + trailingslashit($template_path) . $template_name, |
|
| 144 | 144 | $template_name |
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | // Get default templates/ |
| 149 | - if ( !$template && $default_path ) { |
|
| 150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
| 149 | + if (!$template && $default_path) { |
|
| 150 | + $template = trailingslashit($default_path) . $template_name; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Return what we found. |
| 154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
| 154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 159 | 159 | |
| 160 | 160 | // Setup possible parts |
| 161 | 161 | $templates = array(); |
| 162 | - if ( isset( $name ) ) |
|
| 162 | + if (isset($name)) |
|
| 163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
| 164 | 164 | $templates[] = $slug . '.php'; |
| 165 | 165 | |
| 166 | 166 | // Allow template parts to be filtered |
| 167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 168 | 168 | |
| 169 | 169 | // Return the part that is found |
| 170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 174 | 174 | // No file found yet |
| 175 | 175 | $located = false; |
| 176 | 176 | |
| 177 | 177 | // Try to find a template file |
| 178 | - foreach ( (array)$template_names as $template_name ) { |
|
| 178 | + foreach ((array)$template_names as $template_name) { |
|
| 179 | 179 | |
| 180 | 180 | // Continue if template is empty |
| 181 | - if ( empty( $template_name ) ) |
|
| 181 | + if (empty($template_name)) |
|
| 182 | 182 | continue; |
| 183 | 183 | |
| 184 | 184 | // Trim off any slashes from the template name |
| 185 | - $template_name = ltrim( $template_name, '/' ); |
|
| 185 | + $template_name = ltrim($template_name, '/'); |
|
| 186 | 186 | |
| 187 | 187 | // try locating this template file by looping through the template paths |
| 188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 189 | 189 | |
| 190 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 190 | + if (file_exists($template_path . $template_name)) { |
|
| 191 | 191 | $located = $template_path . $template_name; |
| 192 | 192 | break; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if( !empty( $located ) ) { |
|
| 196 | + if (!empty($located)) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 202 | - load_template( $located, $require_once ); |
|
| 201 | + if ((true == $load) && !empty($located)) |
|
| 202 | + load_template($located, $require_once); |
|
| 203 | 203 | |
| 204 | 204 | return $located; |
| 205 | 205 | } |
@@ -208,143 +208,143 @@ discard block |
||
| 208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 209 | 209 | |
| 210 | 210 | $file_paths = array( |
| 211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 213 | 213 | 100 => wpinv_get_templates_dir() |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 217 | 217 | |
| 218 | 218 | // sort the file paths based on priority |
| 219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 219 | + ksort($file_paths, SORT_NUMERIC); |
|
| 220 | 220 | |
| 221 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 221 | + return array_map('trailingslashit', $file_paths); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | function wpinv_get_theme_template_dir_name() { |
| 225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function wpinv_checkout_meta_tags() { |
| 229 | 229 | |
| 230 | 230 | $pages = array(); |
| 231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 231 | + $pages[] = wpinv_get_option('success_page'); |
|
| 232 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 234 | 234 | |
| 235 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 235 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 240 | 240 | } |
| 241 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 241 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 242 | 242 | |
| 243 | -function wpinv_add_body_classes( $class ) { |
|
| 243 | +function wpinv_add_body_classes($class) { |
|
| 244 | 244 | $classes = (array)$class; |
| 245 | 245 | |
| 246 | - if( wpinv_is_checkout() ) { |
|
| 246 | + if (wpinv_is_checkout()) { |
|
| 247 | 247 | $classes[] = 'wpinv-checkout'; |
| 248 | 248 | $classes[] = 'wpinv-page'; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if( wpinv_is_success_page() ) { |
|
| 251 | + if (wpinv_is_success_page()) { |
|
| 252 | 252 | $classes[] = 'wpinv-success'; |
| 253 | 253 | $classes[] = 'wpinv-page'; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 256 | + if (wpinv_is_failed_transaction_page()) { |
|
| 257 | 257 | $classes[] = 'wpinv-failed-transaction'; |
| 258 | 258 | $classes[] = 'wpinv-page'; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if( wpinv_is_invoice_history_page() ) { |
|
| 261 | + if (wpinv_is_invoice_history_page()) { |
|
| 262 | 262 | $classes[] = 'wpinv-history'; |
| 263 | 263 | $classes[] = 'wpinv-page'; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if( wpinv_is_test_mode() ) { |
|
| 266 | + if (wpinv_is_test_mode()) { |
|
| 267 | 267 | $classes[] = 'wpinv-test-mode'; |
| 268 | 268 | $classes[] = 'wpinv-page'; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - return array_unique( $classes ); |
|
| 271 | + return array_unique($classes); |
|
| 272 | 272 | } |
| 273 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 273 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 274 | 274 | |
| 275 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 276 | - $args = array( 'nopaging' => true ); |
|
| 275 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 276 | + $args = array('nopaging' => true); |
|
| 277 | 277 | |
| 278 | - if ( ! empty( $status ) ) |
|
| 278 | + if (!empty($status)) |
|
| 279 | 279 | $args['post_status'] = $status; |
| 280 | 280 | |
| 281 | - $discounts = wpinv_get_discounts( $args ); |
|
| 281 | + $discounts = wpinv_get_discounts($args); |
|
| 282 | 282 | $options = array(); |
| 283 | 283 | |
| 284 | - if ( $discounts ) { |
|
| 285 | - foreach ( $discounts as $discount ) { |
|
| 286 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 284 | + if ($discounts) { |
|
| 285 | + foreach ($discounts as $discount) { |
|
| 286 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 287 | 287 | } |
| 288 | 288 | } else { |
| 289 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 289 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $output = wpinv_html_select( array( |
|
| 292 | + $output = wpinv_html_select(array( |
|
| 293 | 293 | 'name' => $name, |
| 294 | 294 | 'selected' => $selected, |
| 295 | 295 | 'options' => $options, |
| 296 | 296 | 'show_option_all' => false, |
| 297 | 297 | 'show_option_none' => false, |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | 300 | return $output; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 304 | - $current = date( 'Y' ); |
|
| 305 | - $start_year = $current - absint( $years_before ); |
|
| 306 | - $end_year = $current + absint( $years_after ); |
|
| 307 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 303 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 304 | + $current = date('Y'); |
|
| 305 | + $start_year = $current - absint($years_before); |
|
| 306 | + $end_year = $current + absint($years_after); |
|
| 307 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 308 | 308 | $options = array(); |
| 309 | 309 | |
| 310 | - while ( $start_year <= $end_year ) { |
|
| 311 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 310 | + while ($start_year <= $end_year) { |
|
| 311 | + $options[absint($start_year)] = $start_year; |
|
| 312 | 312 | $start_year++; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $output = wpinv_html_select( array( |
|
| 315 | + $output = wpinv_html_select(array( |
|
| 316 | 316 | 'name' => $name, |
| 317 | 317 | 'selected' => $selected, |
| 318 | 318 | 'options' => $options, |
| 319 | 319 | 'show_option_all' => false, |
| 320 | 320 | 'show_option_none' => false |
| 321 | - ) ); |
|
| 321 | + )); |
|
| 322 | 322 | |
| 323 | 323 | return $output; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 326 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 327 | 327 | $month = 1; |
| 328 | 328 | $options = array(); |
| 329 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 329 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 330 | 330 | |
| 331 | - while ( $month <= 12 ) { |
|
| 332 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
| 331 | + while ($month <= 12) { |
|
| 332 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
| 333 | 333 | $month++; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - $output = wpinv_html_select( array( |
|
| 336 | + $output = wpinv_html_select(array( |
|
| 337 | 337 | 'name' => $name, |
| 338 | 338 | 'selected' => $selected, |
| 339 | 339 | 'options' => $options, |
| 340 | 340 | 'show_option_all' => false, |
| 341 | 341 | 'show_option_none' => false |
| 342 | - ) ); |
|
| 342 | + )); |
|
| 343 | 343 | |
| 344 | 344 | return $output; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | -function wpinv_html_select( $args = array() ) { |
|
| 347 | +function wpinv_html_select($args = array()) { |
|
| 348 | 348 | $defaults = array( |
| 349 | 349 | 'options' => array(), |
| 350 | 350 | 'name' => null, |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | 'chosen' => false, |
| 355 | 355 | 'placeholder' => null, |
| 356 | 356 | 'multiple' => false, |
| 357 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 358 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 357 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 358 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 359 | 359 | 'data' => array(), |
| 360 | 360 | 'onchange' => null, |
| 361 | 361 | 'required' => false, |
@@ -363,78 +363,78 @@ discard block |
||
| 363 | 363 | 'readonly' => false, |
| 364 | 364 | ); |
| 365 | 365 | |
| 366 | - $args = wp_parse_args( $args, $defaults ); |
|
| 366 | + $args = wp_parse_args($args, $defaults); |
|
| 367 | 367 | |
| 368 | 368 | $data_elements = ''; |
| 369 | - foreach ( $args['data'] as $key => $value ) { |
|
| 370 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 369 | + foreach ($args['data'] as $key => $value) { |
|
| 370 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if( $args['multiple'] ) { |
|
| 373 | + if ($args['multiple']) { |
|
| 374 | 374 | $multiple = ' MULTIPLE'; |
| 375 | 375 | } else { |
| 376 | 376 | $multiple = ''; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if( $args['chosen'] ) { |
|
| 379 | + if ($args['chosen']) { |
|
| 380 | 380 | $args['class'] .= ' wpinv-select-chosen'; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if( $args['placeholder'] ) { |
|
| 383 | + if ($args['placeholder']) { |
|
| 384 | 384 | $placeholder = $args['placeholder']; |
| 385 | 385 | } else { |
| 386 | 386 | $placeholder = ''; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $options = ''; |
| 390 | - if( !empty( $args['onchange'] ) ) { |
|
| 391 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 390 | + if (!empty($args['onchange'])) { |
|
| 391 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if( !empty( $args['required'] ) ) { |
|
| 394 | + if (!empty($args['required'])) { |
|
| 395 | 395 | $options .= ' required="required"'; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if( !empty( $args['disabled'] ) ) { |
|
| 398 | + if (!empty($args['disabled'])) { |
|
| 399 | 399 | $options .= ' disabled'; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if( !empty( $args['readonly'] ) ) { |
|
| 402 | + if (!empty($args['readonly'])) { |
|
| 403 | 403 | $options .= ' readonly'; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 407 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 406 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 407 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 408 | 408 | |
| 409 | - if ( $args['show_option_all'] ) { |
|
| 410 | - if( $args['multiple'] ) { |
|
| 411 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 409 | + if ($args['show_option_all']) { |
|
| 410 | + if ($args['multiple']) { |
|
| 411 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 412 | 412 | } else { |
| 413 | - $selected = selected( $args['selected'], 0, false ); |
|
| 413 | + $selected = selected($args['selected'], 0, false); |
|
| 414 | 414 | } |
| 415 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 415 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if ( !empty( $args['options'] ) ) { |
|
| 418 | + if (!empty($args['options'])) { |
|
| 419 | 419 | |
| 420 | - if ( $args['show_option_none'] ) { |
|
| 421 | - if( $args['multiple'] ) { |
|
| 422 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 420 | + if ($args['show_option_none']) { |
|
| 421 | + if ($args['multiple']) { |
|
| 422 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 423 | 423 | } else { |
| 424 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 424 | + $selected = selected($args['selected'] === "", true, false); |
|
| 425 | 425 | } |
| 426 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 426 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - foreach( $args['options'] as $key => $option ) { |
|
| 429 | + foreach ($args['options'] as $key => $option) { |
|
| 430 | 430 | |
| 431 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 432 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 431 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 432 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
| 433 | 433 | } else { |
| 434 | - $selected = selected( $args['selected'], $key, false ); |
|
| 434 | + $selected = selected($args['selected'], $key, false); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 437 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | return $output; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 446 | +function wpinv_item_dropdown($args = array()) { |
|
| 447 | 447 | $defaults = array( |
| 448 | 448 | 'name' => 'wpi_item', |
| 449 | 449 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
| 452 | 452 | 'selected' => 0, |
| 453 | 453 | 'chosen' => false, |
| 454 | 454 | 'number' => 100, |
| 455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 456 | - 'data' => array( 'search-type' => 'item' ), |
|
| 455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 456 | + 'data' => array('search-type' => 'item'), |
|
| 457 | 457 | 'show_option_all' => false, |
| 458 | 458 | 'show_option_none' => false, |
| 459 | 459 | 'show_recurring' => false, |
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | - $args = wp_parse_args( $args, $defaults ); |
|
| 462 | + $args = wp_parse_args($args, $defaults); |
|
| 463 | 463 | |
| 464 | 464 | $item_args = array( |
| 465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
| 468 | 468 | 'posts_per_page' => $args['number'] |
| 469 | 469 | ); |
| 470 | 470 | |
| 471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 472 | 472 | |
| 473 | - $items = get_posts( $item_args ); |
|
| 473 | + $items = get_posts($item_args); |
|
| 474 | 474 | $options = array(); |
| 475 | - if ( $items ) { |
|
| 476 | - foreach ( $items as $item ) { |
|
| 477 | - $title = esc_html( $item->post_title ); |
|
| 475 | + if ($items) { |
|
| 476 | + foreach ($items as $item) { |
|
| 477 | + $title = esc_html($item->post_title); |
|
| 478 | 478 | |
| 479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 479 | + if (!empty($args['show_recurring'])) { |
|
| 480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - $options[ absint( $item->ID ) ] = $title; |
|
| 483 | + $options[absint($item->ID)] = $title; |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | // This ensures that any selected items are included in the drop down |
| 488 | - if( is_array( $args['selected'] ) ) { |
|
| 489 | - foreach( $args['selected'] as $item ) { |
|
| 490 | - if( ! in_array( $item, $options ) ) { |
|
| 491 | - $title = get_the_title( $item ); |
|
| 492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 488 | + if (is_array($args['selected'])) { |
|
| 489 | + foreach ($args['selected'] as $item) { |
|
| 490 | + if (!in_array($item, $options)) { |
|
| 491 | + $title = get_the_title($item); |
|
| 492 | + if (!empty($args['show_recurring'])) { |
|
| 493 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 494 | 494 | } |
| 495 | 495 | $options[$item] = $title; |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 500 | - $title = get_the_title( $args['selected'] ); |
|
| 501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 499 | + if (!in_array($args['selected'], $options)) { |
|
| 500 | + $title = get_the_title($args['selected']); |
|
| 501 | + if (!empty($args['show_recurring'])) { |
|
| 502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 503 | 503 | } |
| 504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $output = wpinv_html_select( array( |
|
| 508 | + $output = wpinv_html_select(array( |
|
| 509 | 509 | 'name' => $args['name'], |
| 510 | 510 | 'selected' => $args['selected'], |
| 511 | 511 | 'id' => $args['id'], |
@@ -517,12 +517,12 @@ discard block |
||
| 517 | 517 | 'show_option_all' => $args['show_option_all'], |
| 518 | 518 | 'show_option_none' => $args['show_option_none'], |
| 519 | 519 | 'data' => $args['data'], |
| 520 | - ) ); |
|
| 520 | + )); |
|
| 521 | 521 | |
| 522 | 522 | return $output; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 525 | +function wpinv_html_checkbox($args = array()) { |
|
| 526 | 526 | $defaults = array( |
| 527 | 527 | 'name' => null, |
| 528 | 528 | 'current' => null, |
@@ -533,38 +533,38 @@ discard block |
||
| 533 | 533 | ) |
| 534 | 534 | ); |
| 535 | 535 | |
| 536 | - $args = wp_parse_args( $args, $defaults ); |
|
| 536 | + $args = wp_parse_args($args, $defaults); |
|
| 537 | 537 | |
| 538 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 538 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 539 | 539 | $options = ''; |
| 540 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 540 | + if (!empty($args['options']['disabled'])) { |
|
| 541 | 541 | $options .= ' disabled="disabled"'; |
| 542 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 542 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 543 | 543 | $options .= ' readonly'; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $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 ) . ' />'; |
|
| 546 | + $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) . ' />'; |
|
| 547 | 547 | |
| 548 | 548 | return $output; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | -function wpinv_html_text( $args = array() ) { |
|
| 551 | +function wpinv_html_text($args = array()) { |
|
| 552 | 552 | // Backwards compatibility |
| 553 | - if ( func_num_args() > 1 ) { |
|
| 553 | + if (func_num_args() > 1) { |
|
| 554 | 554 | $args = func_get_args(); |
| 555 | 555 | |
| 556 | 556 | $name = $args[0]; |
| 557 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 558 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 559 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 557 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 558 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 559 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $defaults = array( |
| 563 | 563 | 'id' => '', |
| 564 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 565 | - 'value' => isset( $value ) ? $value : null, |
|
| 566 | - 'label' => isset( $label ) ? $label : null, |
|
| 567 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 564 | + 'name' => isset($name) ? $name : 'text', |
|
| 565 | + 'value' => isset($value) ? $value : null, |
|
| 566 | + 'label' => isset($label) ? $label : null, |
|
| 567 | + 'desc' => isset($desc) ? $desc : null, |
|
| 568 | 568 | 'placeholder' => '', |
| 569 | 569 | 'class' => 'regular-text', |
| 570 | 570 | 'disabled' => false, |
@@ -574,51 +574,51 @@ discard block |
||
| 574 | 574 | 'data' => false |
| 575 | 575 | ); |
| 576 | 576 | |
| 577 | - $args = wp_parse_args( $args, $defaults ); |
|
| 577 | + $args = wp_parse_args($args, $defaults); |
|
| 578 | 578 | |
| 579 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 579 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 580 | 580 | $options = ''; |
| 581 | - if( $args['required'] ) { |
|
| 581 | + if ($args['required']) { |
|
| 582 | 582 | $options .= ' required="required"'; |
| 583 | 583 | } |
| 584 | - if( $args['readonly'] ) { |
|
| 584 | + if ($args['readonly']) { |
|
| 585 | 585 | $options .= ' readonly'; |
| 586 | 586 | } |
| 587 | - if( $args['readonly'] ) { |
|
| 587 | + if ($args['readonly']) { |
|
| 588 | 588 | $options .= ' readonly'; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | $data = ''; |
| 592 | - if ( !empty( $args['data'] ) ) { |
|
| 593 | - foreach ( $args['data'] as $key => $value ) { |
|
| 594 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 592 | + if (!empty($args['data'])) { |
|
| 593 | + foreach ($args['data'] as $key => $value) { |
|
| 594 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 599 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 600 | - if ( ! empty( $args['desc'] ) ) { |
|
| 601 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 598 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 599 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 600 | + if (!empty($args['desc'])) { |
|
| 601 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - $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 ) . '/>'; |
|
| 604 | + $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) . '/>'; |
|
| 605 | 605 | |
| 606 | 606 | $output .= '</span>'; |
| 607 | 607 | |
| 608 | 608 | return $output; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | -function wpinv_html_date_field( $args = array() ) { |
|
| 612 | - if( empty( $args['class'] ) ) { |
|
| 611 | +function wpinv_html_date_field($args = array()) { |
|
| 612 | + if (empty($args['class'])) { |
|
| 613 | 613 | $args['class'] = 'wpiDatepicker'; |
| 614 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 614 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 615 | 615 | $args['class'] .= ' wpiDatepicker'; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - return wpinv_html_text( $args ); |
|
| 618 | + return wpinv_html_text($args); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | -function wpinv_html_textarea( $args = array() ) { |
|
| 621 | +function wpinv_html_textarea($args = array()) { |
|
| 622 | 622 | $defaults = array( |
| 623 | 623 | 'name' => 'textarea', |
| 624 | 624 | 'value' => null, |
@@ -628,31 +628,31 @@ discard block |
||
| 628 | 628 | 'disabled' => false |
| 629 | 629 | ); |
| 630 | 630 | |
| 631 | - $args = wp_parse_args( $args, $defaults ); |
|
| 631 | + $args = wp_parse_args($args, $defaults); |
|
| 632 | 632 | |
| 633 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 633 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 634 | 634 | $disabled = ''; |
| 635 | - if( $args['disabled'] ) { |
|
| 635 | + if ($args['disabled']) { |
|
| 636 | 636 | $disabled = ' disabled="disabled"'; |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 640 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 641 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 639 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 640 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 641 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 642 | 642 | |
| 643 | - if ( ! empty( $args['desc'] ) ) { |
|
| 644 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 643 | + if (!empty($args['desc'])) { |
|
| 644 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 645 | 645 | } |
| 646 | 646 | $output .= '</span>'; |
| 647 | 647 | |
| 648 | 648 | return $output; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 651 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 652 | 652 | $defaults = array( |
| 653 | 653 | 'name' => 'user_id', |
| 654 | 654 | 'value' => null, |
| 655 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 655 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 656 | 656 | 'label' => null, |
| 657 | 657 | 'desc' => null, |
| 658 | 658 | 'class' => '', |
@@ -661,13 +661,13 @@ discard block |
||
| 661 | 661 | 'data' => false |
| 662 | 662 | ); |
| 663 | 663 | |
| 664 | - $args = wp_parse_args( $args, $defaults ); |
|
| 664 | + $args = wp_parse_args($args, $defaults); |
|
| 665 | 665 | |
| 666 | 666 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 667 | 667 | |
| 668 | 668 | $output = '<span class="wpinv_user_search_wrap">'; |
| 669 | - $output .= wpinv_html_text( $args ); |
|
| 670 | - $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>'; |
|
| 669 | + $output .= wpinv_html_text($args); |
|
| 670 | + $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>'; |
|
| 671 | 671 | $output .= '</span>'; |
| 672 | 672 | |
| 673 | 673 | return $output; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | function wpinv_ip_geolocation() { |
| 677 | 677 | global $wpinv_euvat; |
| 678 | 678 | |
| 679 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
| 679 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
| 680 | 680 | $content = ''; |
| 681 | 681 | $iso = ''; |
| 682 | 682 | $country = ''; |
@@ -687,69 +687,69 @@ discard block |
||
| 687 | 687 | $credit = ''; |
| 688 | 688 | $address = ''; |
| 689 | 689 | |
| 690 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
| 690 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
| 691 | 691 | try { |
| 692 | 692 | $iso = $geoip2_city->country->isoCode; |
| 693 | 693 | $country = $geoip2_city->country->name; |
| 694 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 694 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
| 695 | 695 | $city = $geoip2_city->city->name; |
| 696 | 696 | $longitude = $geoip2_city->location->longitude; |
| 697 | 697 | $latitude = $geoip2_city->location->latitude; |
| 698 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
| 699 | - } catch( Exception $e ) { } |
|
| 698 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
| 699 | + } catch (Exception $e) { } |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
| 702 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
| 703 | 703 | try { |
| 704 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 704 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 705 | 705 | |
| 706 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
| 706 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
| 707 | 707 | $iso = $load_xml->geoplugin_countryCode; |
| 708 | 708 | $country = $load_xml->geoplugin_countryName; |
| 709 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
| 710 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
| 709 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
| 710 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
| 711 | 711 | $longitude = $load_xml->geoplugin_longitude; |
| 712 | 712 | $latitude = $load_xml->geoplugin_latitude; |
| 713 | 713 | $credit = $load_xml->geoplugin_credit; |
| 714 | - $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; |
|
| 714 | + $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; |
|
| 715 | 715 | } |
| 716 | - } catch( Exception $e ) { } |
|
| 716 | + } catch (Exception $e) { } |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - if ( $iso && $longitude && $latitude ) { |
|
| 720 | - if ( $city ) { |
|
| 719 | + if ($iso && $longitude && $latitude) { |
|
| 720 | + if ($city) { |
|
| 721 | 721 | $address .= $city . ', '; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - if ( $region ) { |
|
| 724 | + if ($region) { |
|
| 725 | 725 | $address .= $region . ', '; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $address .= $country . ' (' . $iso . ')'; |
| 729 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
| 730 | - $content .= '<p>'. $credit . '</p>'; |
|
| 729 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
| 730 | + $content .= '<p>' . $credit . '</p>'; |
|
| 731 | 731 | } else { |
| 732 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
| 732 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
| 733 | 733 | } |
| 734 | 734 | ?> |
| 735 | 735 | <!DOCTYPE html> |
| 736 | -<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> |
|
| 736 | +<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> |
|
| 737 | 737 | <body> |
| 738 | - <?php if ( $latitude && $latitude ) { ?> |
|
| 738 | + <?php if ($latitude && $latitude) { ?> |
|
| 739 | 739 | <div id="map"></div> |
| 740 | 740 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
| 741 | 741 | <script type="text/javascript"> |
| 742 | 742 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 743 | 743 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 744 | 744 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
| 745 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
| 745 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
| 746 | 746 | |
| 747 | 747 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
| 748 | 748 | |
| 749 | 749 | var marker = new L.Marker(latlng); |
| 750 | 750 | map.addLayer(marker); |
| 751 | 751 | |
| 752 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
| 752 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
| 753 | 753 | </script> |
| 754 | 754 | <?php } ?> |
| 755 | 755 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -757,18 +757,18 @@ discard block |
||
| 757 | 757 | <?php |
| 758 | 758 | exit; |
| 759 | 759 | } |
| 760 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 761 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
| 760 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 761 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
| 762 | 762 | |
| 763 | 763 | // Set up the template for the invoice. |
| 764 | -function wpinv_template( $template ) { |
|
| 764 | +function wpinv_template($template) { |
|
| 765 | 765 | global $post, $wp_query; |
| 766 | 766 | |
| 767 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
| 768 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 769 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 767 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
| 768 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 769 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 770 | 770 | } else { |
| 771 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 771 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | function wpinv_get_business_address() { |
| 779 | 779 | $business_address = wpinv_store_address(); |
| 780 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 780 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 781 | 781 | |
| 782 | 782 | /* |
| 783 | 783 | $default_country = wpinv_get_default_country(); |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 803 | 803 | |
| 804 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 804 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | function wpinv_display_from_address() { |
@@ -811,188 +811,188 @@ discard block |
||
| 811 | 811 | if (empty($from_name)) { |
| 812 | 812 | $from_name = wpinv_get_business_name(); |
| 813 | 813 | } |
| 814 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
| 814 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
| 815 | 815 | <div class="wrapper col-xs-10"> |
| 816 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
| 817 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
| 818 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
| 816 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
| 817 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
| 818 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
| 819 | 819 | <?php } ?> |
| 820 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
| 821 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
| 820 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
| 821 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
| 822 | 822 | <?php } ?> |
| 823 | 823 | </div> |
| 824 | 824 | <?php |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | -function wpinv_watermark( $id = 0 ) { |
|
| 828 | - $output = wpinv_get_watermark( $id ); |
|
| 827 | +function wpinv_watermark($id = 0) { |
|
| 828 | + $output = wpinv_get_watermark($id); |
|
| 829 | 829 | |
| 830 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 830 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | -function wpinv_get_watermark( $id ) { |
|
| 834 | - if ( !$id > 0 ) { |
|
| 833 | +function wpinv_get_watermark($id) { |
|
| 834 | + if (!$id > 0) { |
|
| 835 | 835 | return NULL; |
| 836 | 836 | } |
| 837 | - $invoice = wpinv_get_invoice( $id ); |
|
| 837 | + $invoice = wpinv_get_invoice($id); |
|
| 838 | 838 | |
| 839 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 840 | - if ( $invoice->is_paid() ) { |
|
| 841 | - return __( 'Paid', 'invoicing' ); |
|
| 839 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 840 | + if ($invoice->is_paid()) { |
|
| 841 | + return __('Paid', 'invoicing'); |
|
| 842 | 842 | } |
| 843 | - if ( $invoice->is_refunded() ) { |
|
| 844 | - return __( 'Refunded', 'invoicing' ); |
|
| 843 | + if ($invoice->is_refunded()) { |
|
| 844 | + return __('Refunded', 'invoicing'); |
|
| 845 | 845 | } |
| 846 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 847 | - return __( 'Cancelled', 'invoicing' ); |
|
| 846 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 847 | + return __('Cancelled', 'invoicing'); |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | return NULL; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 854 | +function wpinv_display_invoice_details($invoice) { |
|
| 855 | 855 | global $wpinv_euvat; |
| 856 | 856 | |
| 857 | 857 | $invoice_id = $invoice->ID; |
| 858 | 858 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 859 | 859 | $use_taxes = wpinv_use_taxes(); |
| 860 | 860 | |
| 861 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
| 861 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
| 862 | 862 | ?> |
| 863 | 863 | <table class="table table-bordered table-sm"> |
| 864 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
| 864 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
| 865 | 865 | <tr class="wpi-row-number"> |
| 866 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
| 867 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
| 866 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
| 867 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
| 868 | 868 | </tr> |
| 869 | 869 | <?php } ?> |
| 870 | 870 | <tr class="wpi-row-status"> |
| 871 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
| 872 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
| 871 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
| 872 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
| 873 | 873 | </tr> |
| 874 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 874 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 875 | 875 | <tr class="wpi-row-parent"> |
| 876 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
| 877 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 876 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
| 877 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 878 | 878 | </tr> |
| 879 | 879 | <?php } ?> |
| 880 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 880 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 881 | 881 | <tr class="wpi-row-gateway"> |
| 882 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
| 882 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
| 883 | 883 | <td><?php echo $gateway_name; ?></td> |
| 884 | 884 | </tr> |
| 885 | 885 | <?php } ?> |
| 886 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
| 886 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
| 887 | 887 | <tr class="wpi-row-date"> |
| 888 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
| 888 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
| 889 | 889 | <td><?php echo $invoice_date; ?></td> |
| 890 | 890 | </tr> |
| 891 | 891 | <?php } ?> |
| 892 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
| 892 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
| 893 | 893 | <tr class="wpi-row-date"> |
| 894 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
| 894 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
| 895 | 895 | <td><?php echo $due_date; ?></td> |
| 896 | 896 | </tr> |
| 897 | 897 | <?php } ?> |
| 898 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
| 899 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
| 898 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
| 899 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
| 900 | 900 | <tr class="wpi-row-ovatno"> |
| 901 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 901 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 902 | 902 | <td><?php echo $owner_vat_number; ?></td> |
| 903 | 903 | </tr> |
| 904 | 904 | <?php } ?> |
| 905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
| 905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
| 906 | 906 | <tr class="wpi-row-uvatno"> |
| 907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
| 907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
| 908 | 908 | <td><?php echo $user_vat_number; ?></td> |
| 909 | 909 | </tr> |
| 910 | 910 | <?php } ?> |
| 911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
| 912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
| 913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
| 912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
| 913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
| 914 | 914 | </tr> |
| 915 | 915 | </table> |
| 916 | 916 | <?php |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
| 920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
| 920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 921 | 921 | |
| 922 | - if ( empty( $invoice ) ) { |
|
| 922 | + if (empty($invoice)) { |
|
| 923 | 923 | return NULL; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | $billing_details = $invoice->get_user_info(); |
| 927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
| 927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
| 928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
| 929 | 929 | |
| 930 | 930 | ob_start(); |
| 931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
| 931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
| 932 | 932 | $output .= ob_get_clean(); |
| 933 | 933 | |
| 934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
| 935 | - if ( $company = $billing_details['company'] ) { |
|
| 936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
| 934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
| 935 | + if ($company = $billing_details['company']) { |
|
| 936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
| 937 | 937 | } |
| 938 | 938 | $address_row = ''; |
| 939 | - if ( $address = $billing_details['address'] ) { |
|
| 940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 939 | + if ($address = $billing_details['address']) { |
|
| 940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $address_fields = array(); |
| 944 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 944 | + if (!empty($billing_details['city'])) { |
|
| 945 | 945 | $address_fields[] = $billing_details['city']; |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 949 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 949 | + if (!empty($billing_details['state'])) { |
|
| 950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if ( !empty( $billing_country ) ) { |
|
| 954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 953 | + if (!empty($billing_country)) { |
|
| 954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if ( !empty( $address_fields ) ) { |
|
| 958 | - $address_fields = implode( ", ", $address_fields ); |
|
| 957 | + if (!empty($address_fields)) { |
|
| 958 | + $address_fields = implode(", ", $address_fields); |
|
| 959 | 959 | |
| 960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 960 | + if (!empty($billing_details['zip'])) { |
|
| 961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if ( $address_row ) { |
|
| 967 | + if ($address_row) { |
|
| 968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( $phone = $invoice->get_phone() ) { |
|
| 972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
| 971 | + if ($phone = $invoice->get_phone()) { |
|
| 972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
| 973 | 973 | } |
| 974 | - if ( $email = $invoice->get_email() ) { |
|
| 975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
| 974 | + if ($email = $invoice->get_email()) { |
|
| 975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | ob_start(); |
| 979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
| 979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
| 980 | 980 | $output .= ob_get_clean(); |
| 981 | 981 | |
| 982 | 982 | $output .= '</div>'; |
| 983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
| 983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
| 984 | 984 | |
| 985 | 985 | echo $output; |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
| 990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 992 | 992 | $use_taxes = wpinv_use_taxes(); |
| 993 | 993 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
| 994 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 995 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 994 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 995 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 996 | 996 | |
| 997 | 997 | $cart_details = $invoice->get_cart_details(); |
| 998 | 998 | $ajax_cart_details = $cart_details; |
@@ -1001,64 +1001,64 @@ discard block |
||
| 1001 | 1001 | <table class="table table-sm table-bordered table-responsive"> |
| 1002 | 1002 | <thead> |
| 1003 | 1003 | <tr> |
| 1004 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
| 1005 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
| 1004 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
| 1005 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
| 1006 | 1006 | <?php if ($quantities_enabled) { ?> |
| 1007 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
| 1007 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
| 1008 | 1008 | <?php } ?> |
| 1009 | 1009 | <?php if ($use_taxes && !$zero_tax) { ?> |
| 1010 | 1010 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
| 1011 | 1011 | <?php } ?> |
| 1012 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
| 1012 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
| 1013 | 1013 | </tr> |
| 1014 | 1014 | </thead> |
| 1015 | 1015 | <tbody> |
| 1016 | 1016 | <?php |
| 1017 | - if ( !empty( $cart_details ) ) { |
|
| 1018 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
| 1017 | + if (!empty($cart_details)) { |
|
| 1018 | + do_action('wpinv_display_line_items_start', $invoice); |
|
| 1019 | 1019 | |
| 1020 | 1020 | $count = 0; |
| 1021 | 1021 | $cols = 3; |
| 1022 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 1023 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
| 1024 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
| 1025 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
| 1026 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
| 1022 | + foreach ($cart_details as $key => $cart_item) { |
|
| 1023 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
| 1024 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
| 1025 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
| 1026 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
| 1027 | 1027 | |
| 1028 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
| 1028 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
| 1029 | 1029 | $summary = ''; |
| 1030 | 1030 | $cols = 3; |
| 1031 | - if ( !empty($item) ) { |
|
| 1031 | + if (!empty($item)) { |
|
| 1032 | 1032 | $item_name = $item->get_name(); |
| 1033 | 1033 | $summary = $item->get_summary(); |
| 1034 | 1034 | } |
| 1035 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1035 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
| 1036 | 1036 | |
| 1037 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
| 1037 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
| 1038 | 1038 | |
| 1039 | 1039 | $item_tax = ''; |
| 1040 | 1040 | $tax_rate = ''; |
| 1041 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1042 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1043 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1044 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1041 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1042 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1043 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1044 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1045 | 1045 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | $line_item_tax = $item_tax . $tax_rate; |
| 1049 | 1049 | |
| 1050 | - if ( $line_item_tax === '' ) { |
|
| 1050 | + if ($line_item_tax === '') { |
|
| 1051 | 1051 | $line_item_tax = 0; // Zero tax |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
| 1055 | - $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
| 1056 | - if ( $summary !== '' ) { |
|
| 1057 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
| 1054 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
| 1055 | + $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
| 1056 | + if ($summary !== '') { |
|
| 1057 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | $line_item .= '</td>'; |
| 1060 | 1060 | |
| 1061 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1061 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
| 1062 | 1062 | if ($quantities_enabled) { |
| 1063 | 1063 | $cols++; |
| 1064 | 1064 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1067,55 +1067,55 @@ discard block |
||
| 1067 | 1067 | $cols++; |
| 1068 | 1068 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1069 | 1069 | } |
| 1070 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
| 1070 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
| 1071 | 1071 | $line_item .= '</tr>'; |
| 1072 | 1072 | |
| 1073 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
| 1073 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
| 1074 | 1074 | |
| 1075 | 1075 | $count++; |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
| 1078 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
| 1079 | 1079 | ?> |
| 1080 | 1080 | <tr class="row-sub-total row_odd"> |
| 1081 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1082 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1081 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1082 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1083 | 1083 | </tr> |
| 1084 | 1084 | <?php |
| 1085 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
| 1085 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
| 1086 | 1086 | |
| 1087 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
| 1088 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
| 1087 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
| 1088 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
| 1089 | 1089 | ?> |
| 1090 | 1090 | <tr class="row-discount"> |
| 1091 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
| 1092 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1091 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
| 1092 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1093 | 1093 | </tr> |
| 1094 | 1094 | <?php |
| 1095 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
| 1095 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | - if ( $use_taxes ) { |
|
| 1099 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
| 1098 | + if ($use_taxes) { |
|
| 1099 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
| 1100 | 1100 | ?> |
| 1101 | 1101 | <tr class="row-tax"> |
| 1102 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
| 1103 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1102 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
| 1103 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1104 | 1104 | </tr> |
| 1105 | 1105 | <?php |
| 1106 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
| 1106 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
| 1109 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
| 1110 | 1110 | ?> |
| 1111 | 1111 | <tr class="table-active row-total"> |
| 1112 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
| 1113 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1112 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
| 1113 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1114 | 1114 | </tr> |
| 1115 | 1115 | <?php |
| 1116 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
| 1116 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
| 1117 | 1117 | |
| 1118 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
| 1118 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
| 1119 | 1119 | } |
| 1120 | 1120 | ?> |
| 1121 | 1121 | </tbody> |
@@ -1124,35 +1124,35 @@ discard block |
||
| 1124 | 1124 | echo ob_get_clean(); |
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
| 1127 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
| 1128 | 1128 | $use_taxes = wpinv_use_taxes(); |
| 1129 | 1129 | |
| 1130 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
| 1130 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
| 1131 | 1131 | ?> |
| 1132 | 1132 | <table class="table table-sm table-bordered table-responsive"> |
| 1133 | 1133 | <tbody> |
| 1134 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
| 1134 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
| 1135 | 1135 | <tr class="row-sub-total"> |
| 1136 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
| 1137 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
| 1136 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
| 1137 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
| 1138 | 1138 | </tr> |
| 1139 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
| 1140 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 1139 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
| 1140 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 1141 | 1141 | <tr class="row-discount"> |
| 1142 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
| 1143 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
| 1142 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
| 1143 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
| 1144 | 1144 | </tr> |
| 1145 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
| 1145 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
| 1146 | 1146 | <?php } ?> |
| 1147 | - <?php if ( $use_taxes ) { ?> |
|
| 1147 | + <?php if ($use_taxes) { ?> |
|
| 1148 | 1148 | <tr class="row-tax"> |
| 1149 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
| 1150 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
| 1149 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
| 1150 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
| 1151 | 1151 | </tr> |
| 1152 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
| 1152 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
| 1153 | 1153 | <?php } ?> |
| 1154 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
| 1155 | - <?php foreach ( $fees as $fee ) { ?> |
|
| 1154 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
| 1155 | + <?php foreach ($fees as $fee) { ?> |
|
| 1156 | 1156 | <tr class="row-fee"> |
| 1157 | 1157 | <td class="rate"><?php echo $fee['label']; ?></td> |
| 1158 | 1158 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1160,73 +1160,73 @@ discard block |
||
| 1160 | 1160 | <?php } ?> |
| 1161 | 1161 | <?php } ?> |
| 1162 | 1162 | <tr class="table-active row-total"> |
| 1163 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
| 1164 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
| 1163 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
| 1164 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
| 1165 | 1165 | </tr> |
| 1166 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
| 1166 | + <?php do_action('wpinv_after_totals'); ?> |
|
| 1167 | 1167 | </tbody> |
| 1168 | 1168 | |
| 1169 | 1169 | </table> |
| 1170 | 1170 | |
| 1171 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
| 1171 | + <?php do_action('wpinv_after_totals_table'); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
| 1175 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1174 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
| 1175 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1176 | 1176 | |
| 1177 | 1177 | ob_start(); |
| 1178 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
| 1179 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 1178 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
| 1179 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
| 1180 | 1180 | ?> |
| 1181 | 1181 | <div class="wpi-payment-info"> |
| 1182 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
| 1183 | - <?php if ( $gateway_title ) { ?> |
|
| 1184 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
| 1182 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
| 1183 | + <?php if ($gateway_title) { ?> |
|
| 1184 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
| 1185 | 1185 | <?php } ?> |
| 1186 | 1186 | </div> |
| 1187 | 1187 | <?php |
| 1188 | 1188 | } |
| 1189 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
| 1189 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
| 1190 | 1190 | $outout = ob_get_clean(); |
| 1191 | 1191 | |
| 1192 | - if ( $echo ) { |
|
| 1192 | + if ($echo) { |
|
| 1193 | 1193 | echo $outout; |
| 1194 | 1194 | } else { |
| 1195 | 1195 | return $outout; |
| 1196 | 1196 | } |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | -function wpinv_display_style( $invoice ) { |
|
| 1200 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
| 1199 | +function wpinv_display_style($invoice) { |
|
| 1200 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
| 1201 | 1201 | |
| 1202 | - wp_print_styles( 'open-sans' ); |
|
| 1203 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 1202 | + wp_print_styles('open-sans'); |
|
| 1203 | + wp_print_styles('wpinv-single-style'); |
|
| 1204 | 1204 | } |
| 1205 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 1206 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 1205 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 1206 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1207 | 1207 | |
| 1208 | 1208 | function wpinv_checkout_billing_details() { |
| 1209 | 1209 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 1210 | 1210 | if (empty($invoice_id)) { |
| 1211 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1211 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
| 1212 | 1212 | return null; |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 1215 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 1216 | 1216 | if (empty($invoice)) { |
| 1217 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
| 1217 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
| 1218 | 1218 | return null; |
| 1219 | 1219 | } |
| 1220 | 1220 | $user_id = $invoice->get_user_id(); |
| 1221 | 1221 | $user_info = $invoice->get_user_info(); |
| 1222 | - $address_info = wpinv_get_user_address( $user_id ); |
|
| 1222 | + $address_info = wpinv_get_user_address($user_id); |
|
| 1223 | 1223 | |
| 1224 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
| 1224 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
| 1225 | 1225 | $user_info['first_name'] = $user_info['first_name']; |
| 1226 | 1226 | $user_info['last_name'] = $user_info['last_name']; |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
| 1229 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
| 1230 | 1230 | $user_info['country'] = $address_info['country']; |
| 1231 | 1231 | $user_info['state'] = $address_info['state']; |
| 1232 | 1232 | $user_info['city'] = $address_info['city']; |
@@ -1242,98 +1242,98 @@ discard block |
||
| 1242 | 1242 | 'address' |
| 1243 | 1243 | ); |
| 1244 | 1244 | |
| 1245 | - foreach ( $address_fields as $field ) { |
|
| 1246 | - if ( empty( $user_info[$field] ) ) { |
|
| 1245 | + foreach ($address_fields as $field) { |
|
| 1246 | + if (empty($user_info[$field])) { |
|
| 1247 | 1247 | $user_info[$field] = $address_info[$field]; |
| 1248 | 1248 | } |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
| 1251 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | function wpinv_admin_get_line_items($invoice = array()) { |
| 1255 | 1255 | $item_quantities = wpinv_item_quantities_enabled(); |
| 1256 | 1256 | $use_taxes = wpinv_use_taxes(); |
| 1257 | 1257 | |
| 1258 | - if ( empty( $invoice ) ) { |
|
| 1258 | + if (empty($invoice)) { |
|
| 1259 | 1259 | return NULL; |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | $cart_items = $invoice->get_cart_details(); |
| 1263 | - if ( empty( $cart_items ) ) { |
|
| 1263 | + if (empty($cart_items)) { |
|
| 1264 | 1264 | return NULL; |
| 1265 | 1265 | } |
| 1266 | 1266 | ob_start(); |
| 1267 | 1267 | |
| 1268 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
| 1268 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
| 1269 | 1269 | |
| 1270 | 1270 | $count = 0; |
| 1271 | - foreach ( $cart_items as $key => $cart_item ) { |
|
| 1271 | + foreach ($cart_items as $key => $cart_item) { |
|
| 1272 | 1272 | $item_id = $cart_item['id']; |
| 1273 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
| 1273 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
| 1274 | 1274 | |
| 1275 | 1275 | if (empty($wpi_item)) { |
| 1276 | 1276 | continue; |
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
| 1280 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1281 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
| 1279 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
| 1280 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
| 1281 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
| 1282 | 1282 | $can_remove = true; |
| 1283 | 1283 | |
| 1284 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
| 1284 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
| 1285 | 1285 | |
| 1286 | 1286 | $item_tax = ''; |
| 1287 | 1287 | $tax_rate = ''; |
| 1288 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
| 1289 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
| 1290 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
| 1291 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
| 1288 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
| 1289 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
| 1290 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
| 1291 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
| 1292 | 1292 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
| 1293 | 1293 | } |
| 1294 | 1294 | $line_item_tax = $item_tax . $tax_rate; |
| 1295 | 1295 | |
| 1296 | - if ( $line_item_tax === '' ) { |
|
| 1296 | + if ($line_item_tax === '') { |
|
| 1297 | 1297 | $line_item_tax = 0; // Zero tax |
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
| 1300 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
| 1301 | 1301 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
| 1302 | - $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 ); |
|
| 1303 | - if ( $summary !== '' ) { |
|
| 1304 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
| 1302 | + $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); |
|
| 1303 | + if ($summary !== '') { |
|
| 1304 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
| 1305 | 1305 | } |
| 1306 | 1306 | $line_item .= '</td>'; |
| 1307 | 1307 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
| 1308 | 1308 | |
| 1309 | - if ( $item_quantities ) { |
|
| 1310 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
| 1309 | + if ($item_quantities) { |
|
| 1310 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
| 1311 | 1311 | $can_remove = false; |
| 1312 | 1312 | } |
| 1313 | 1313 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
| 1314 | 1314 | } else { |
| 1315 | - if ( count( $cart_items ) == 1 ) { |
|
| 1315 | + if (count($cart_items) == 1) { |
|
| 1316 | 1316 | $can_remove = false; |
| 1317 | 1317 | } |
| 1318 | 1318 | } |
| 1319 | 1319 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
| 1320 | 1320 | |
| 1321 | - if ( $use_taxes ) { |
|
| 1321 | + if ($use_taxes) { |
|
| 1322 | 1322 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
| 1323 | 1323 | } |
| 1324 | 1324 | $line_item .= '<td class="action">'; |
| 1325 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
| 1325 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
| 1326 | 1326 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
| 1327 | 1327 | } |
| 1328 | 1328 | $line_item .= '</td>'; |
| 1329 | 1329 | $line_item .= '</tr>'; |
| 1330 | 1330 | |
| 1331 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
| 1331 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
| 1332 | 1332 | |
| 1333 | 1333 | $count++; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
| 1336 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
| 1337 | 1337 | |
| 1338 | 1338 | return ob_get_clean(); |
| 1339 | 1339 | } |
@@ -1344,35 +1344,35 @@ discard block |
||
| 1344 | 1344 | // Set current invoice id. |
| 1345 | 1345 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
| 1346 | 1346 | |
| 1347 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
| 1347 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
| 1348 | 1348 | |
| 1349 | 1349 | ob_start(); |
| 1350 | 1350 | echo '<div id="wpinv_checkout_wrap">'; |
| 1351 | 1351 | |
| 1352 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
| 1352 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
| 1353 | 1353 | ?> |
| 1354 | 1354 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
| 1355 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
| 1355 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
| 1356 | 1356 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
| 1357 | 1357 | <?php |
| 1358 | - do_action( 'wpinv_checkout_form_top' ); |
|
| 1359 | - do_action( 'wpinv_checkout_billing_info' ); |
|
| 1360 | - do_action( 'wpinv_checkout_cart' ); |
|
| 1361 | - do_action( 'wpinv_payment_mode_select' ); |
|
| 1362 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
| 1358 | + do_action('wpinv_checkout_form_top'); |
|
| 1359 | + do_action('wpinv_checkout_billing_info'); |
|
| 1360 | + do_action('wpinv_checkout_cart'); |
|
| 1361 | + do_action('wpinv_payment_mode_select'); |
|
| 1362 | + do_action('wpinv_checkout_form_bottom') |
|
| 1363 | 1363 | ?> |
| 1364 | 1364 | </form> |
| 1365 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
| 1365 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
| 1366 | 1366 | </div><!--end #wpinv_checkout_form_wrap--> |
| 1367 | 1367 | <?php |
| 1368 | 1368 | } else { |
| 1369 | - do_action( 'wpinv_cart_empty' ); |
|
| 1369 | + do_action('wpinv_cart_empty'); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
| 1372 | 1372 | return ob_get_clean(); |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
| 1375 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
| 1376 | 1376 | global $ajax_cart_details; |
| 1377 | 1377 | $ajax_cart_details = $cart_details; |
| 1378 | 1378 | /* |
@@ -1387,25 +1387,25 @@ discard block |
||
| 1387 | 1387 | } |
| 1388 | 1388 | */ |
| 1389 | 1389 | ob_start(); |
| 1390 | - do_action( 'wpinv_before_checkout_cart' ); |
|
| 1390 | + do_action('wpinv_before_checkout_cart'); |
|
| 1391 | 1391 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
| 1392 | 1392 | echo '<div id="wpinv_checkout_cart_wrap">'; |
| 1393 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
| 1393 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
| 1394 | 1394 | echo '</div>'; |
| 1395 | 1395 | echo '</div>'; |
| 1396 | - do_action( 'wpinv_after_checkout_cart' ); |
|
| 1396 | + do_action('wpinv_after_checkout_cart'); |
|
| 1397 | 1397 | $content = ob_get_clean(); |
| 1398 | 1398 | |
| 1399 | - if ( $echo ) { |
|
| 1399 | + if ($echo) { |
|
| 1400 | 1400 | echo $content; |
| 1401 | 1401 | } else { |
| 1402 | 1402 | return $content; |
| 1403 | 1403 | } |
| 1404 | 1404 | } |
| 1405 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
| 1405 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
| 1406 | 1406 | |
| 1407 | 1407 | function wpinv_empty_cart_message() { |
| 1408 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1408 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | 1411 | /** |
@@ -1417,91 +1417,91 @@ discard block |
||
| 1417 | 1417 | function wpinv_empty_checkout_cart() { |
| 1418 | 1418 | echo wpinv_empty_cart_message(); |
| 1419 | 1419 | } |
| 1420 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1420 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1421 | 1421 | |
| 1422 | 1422 | function wpinv_save_cart_button() { |
| 1423 | - if ( wpinv_is_cart_saving_disabled() ) |
|
| 1423 | + if (wpinv_is_cart_saving_disabled()) |
|
| 1424 | 1424 | return; |
| 1425 | 1425 | ?> |
| 1426 | - <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> |
|
| 1426 | + <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> |
|
| 1427 | 1427 | <?php |
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | function wpinv_update_cart_button() { |
| 1431 | - if ( !wpinv_item_quantities_enabled() ) |
|
| 1431 | + if (!wpinv_item_quantities_enabled()) |
|
| 1432 | 1432 | return; |
| 1433 | 1433 | ?> |
| 1434 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
| 1434 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
| 1435 | 1435 | <input type="hidden" name="wpi_action" value="update_cart"/> |
| 1436 | 1436 | <?php |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | function wpinv_checkout_cart_columns() { |
| 1440 | 1440 | $default = 3; |
| 1441 | - if ( wpinv_item_quantities_enabled() ) { |
|
| 1441 | + if (wpinv_item_quantities_enabled()) { |
|
| 1442 | 1442 | $default++; |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | - if ( wpinv_use_taxes() ) { |
|
| 1445 | + if (wpinv_use_taxes()) { |
|
| 1446 | 1446 | $default++; |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
| 1449 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | function wpinv_display_cart_messages() { |
| 1453 | 1453 | global $wpi_session; |
| 1454 | 1454 | |
| 1455 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
| 1455 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
| 1456 | 1456 | |
| 1457 | - if ( $messages ) { |
|
| 1458 | - foreach ( $messages as $message_id => $message ) { |
|
| 1457 | + if ($messages) { |
|
| 1458 | + foreach ($messages as $message_id => $message) { |
|
| 1459 | 1459 | // Try and detect what type of message this is |
| 1460 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
| 1460 | + if (strpos(strtolower($message), 'error')) { |
|
| 1461 | 1461 | $type = 'error'; |
| 1462 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
| 1462 | + } elseif (strpos(strtolower($message), 'success')) { |
|
| 1463 | 1463 | $type = 'success'; |
| 1464 | 1464 | } else { |
| 1465 | 1465 | $type = 'info'; |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
| 1468 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
| 1469 | 1469 | |
| 1470 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
| 1470 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
| 1471 | 1471 | // Loop message codes and display messages |
| 1472 | 1472 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
| 1473 | 1473 | echo '</div>'; |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // Remove all of the cart saving messages |
| 1477 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
| 1477 | + $wpi_session->set('wpinv_cart_messages', null); |
|
| 1478 | 1478 | } |
| 1479 | 1479 | } |
| 1480 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
| 1480 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
| 1481 | 1481 | |
| 1482 | 1482 | function wpinv_discount_field() { |
| 1483 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
| 1483 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
| 1484 | 1484 | return; // Only show before a payment method has been selected if ajax is disabled |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | - if ( !wpinv_is_checkout() ) { |
|
| 1487 | + if (!wpinv_is_checkout()) { |
|
| 1488 | 1488 | return; |
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
| 1491 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
| 1492 | 1492 | ?> |
| 1493 | 1493 | <div id="wpinv-discount-field" class="panel panel-default"> |
| 1494 | 1494 | <div class="panel-body"> |
| 1495 | 1495 | <p> |
| 1496 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
| 1497 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
| 1496 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
| 1497 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
| 1498 | 1498 | </p> |
| 1499 | 1499 | <div class="form-group row"> |
| 1500 | 1500 | <div class="col-sm-4"> |
| 1501 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
| 1501 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
| 1502 | 1502 | </div> |
| 1503 | 1503 | <div class="col-sm-3"> |
| 1504 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
| 1504 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
| 1505 | 1505 | </div> |
| 1506 | 1506 | <div style="clear:both"></div> |
| 1507 | 1507 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1514,10 +1514,10 @@ discard block |
||
| 1514 | 1514 | <?php |
| 1515 | 1515 | } |
| 1516 | 1516 | } |
| 1517 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
| 1517 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
| 1518 | 1518 | |
| 1519 | 1519 | function wpinv_agree_to_terms_js() { |
| 1520 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 1520 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 1521 | 1521 | ?> |
| 1522 | 1522 | <script type="text/javascript"> |
| 1523 | 1523 | jQuery(document).ready(function($){ |
@@ -1532,126 +1532,126 @@ discard block |
||
| 1532 | 1532 | <?php |
| 1533 | 1533 | } |
| 1534 | 1534 | } |
| 1535 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
| 1535 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
| 1536 | 1536 | |
| 1537 | 1537 | function wpinv_payment_mode_select() { |
| 1538 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 1539 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
| 1538 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 1539 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
| 1540 | 1540 | $page_URL = wpinv_get_current_page_url(); |
| 1541 | - $invoice = wpinv_get_invoice( 0, true ); |
|
| 1541 | + $invoice = wpinv_get_invoice(0, true); |
|
| 1542 | 1542 | |
| 1543 | 1543 | do_action('wpinv_payment_mode_top'); |
| 1544 | 1544 | $invoice_id = (int)$invoice->ID; |
| 1545 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
| 1545 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
| 1546 | 1546 | ?> |
| 1547 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
| 1548 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
| 1547 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
| 1548 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
| 1549 | 1549 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
| 1550 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
| 1550 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
| 1551 | 1551 | <div class="panel-body list-group wpi-payment_methods"> |
| 1552 | 1552 | <?php |
| 1553 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
| 1553 | + do_action('wpinv_payment_mode_before_gateways'); |
|
| 1554 | 1554 | |
| 1555 | - if(!empty($gateways)){ |
|
| 1556 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1557 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1558 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1559 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1555 | + if (!empty($gateways)) { |
|
| 1556 | + foreach ($gateways as $gateway_id => $gateway) { |
|
| 1557 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
| 1558 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
| 1559 | + $description = wpinv_get_gateway_description($gateway_id); |
|
| 1560 | 1560 | ?> |
| 1561 | 1561 | <div class="list-group-item"> |
| 1562 | 1562 | <div class="radio"> |
| 1563 | - <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> |
|
| 1563 | + <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> |
|
| 1564 | 1564 | </div> |
| 1565 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
| 1566 | - <?php if ( !empty( $description ) ) { ?> |
|
| 1567 | - <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div> |
|
| 1565 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
| 1566 | + <?php if (!empty($description)) { ?> |
|
| 1567 | + <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div> |
|
| 1568 | 1568 | <?php } ?> |
| 1569 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
| 1569 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
| 1570 | 1570 | </div> |
| 1571 | 1571 | </div> |
| 1572 | 1572 | <?php |
| 1573 | 1573 | } |
| 1574 | - }else{ |
|
| 1575 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1574 | + } else { |
|
| 1575 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
| 1578 | + do_action('wpinv_payment_mode_after_gateways'); |
|
| 1579 | 1579 | ?> |
| 1580 | 1580 | </div> |
| 1581 | 1581 | </div> |
| 1582 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
| 1582 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
| 1583 | 1583 | </div> |
| 1584 | 1584 | <?php |
| 1585 | 1585 | do_action('wpinv_payment_mode_bottom'); |
| 1586 | 1586 | } |
| 1587 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
| 1587 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
| 1588 | 1588 | |
| 1589 | 1589 | function wpinv_checkout_billing_info() { |
| 1590 | - if ( wpinv_is_checkout() ) { |
|
| 1590 | + if (wpinv_is_checkout()) { |
|
| 1591 | 1591 | $logged_in = is_user_logged_in(); |
| 1592 | 1592 | $billing_details = wpinv_checkout_billing_details(); |
| 1593 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1593 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
| 1594 | 1594 | ?> |
| 1595 | 1595 | <div id="wpinv-fields" class="clearfix"> |
| 1596 | 1596 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
| 1597 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
| 1597 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
| 1598 | 1598 | <div id="wpinv-fields-box" class="panel-body"> |
| 1599 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
| 1599 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
| 1600 | 1600 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1601 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1601 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1602 | 1602 | <?php |
| 1603 | - echo wpinv_html_text( array( |
|
| 1603 | + echo wpinv_html_text(array( |
|
| 1604 | 1604 | 'id' => 'wpinv_first_name', |
| 1605 | 1605 | 'name' => 'wpinv_first_name', |
| 1606 | 1606 | 'value' => $billing_details['first_name'], |
| 1607 | 1607 | 'class' => 'wpi-input form-control', |
| 1608 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
| 1609 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
| 1610 | - ) ); |
|
| 1608 | + 'placeholder' => __('First name', 'invoicing'), |
|
| 1609 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
| 1610 | + )); |
|
| 1611 | 1611 | ?> |
| 1612 | 1612 | </p> |
| 1613 | 1613 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1614 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1614 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1615 | 1615 | <?php |
| 1616 | - echo wpinv_html_text( array( |
|
| 1616 | + echo wpinv_html_text(array( |
|
| 1617 | 1617 | 'id' => 'wpinv_last_name', |
| 1618 | 1618 | 'name' => 'wpinv_last_name', |
| 1619 | 1619 | 'value' => $billing_details['last_name'], |
| 1620 | 1620 | 'class' => 'wpi-input form-control', |
| 1621 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
| 1622 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
| 1623 | - ) ); |
|
| 1621 | + 'placeholder' => __('Last name', 'invoicing'), |
|
| 1622 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
| 1623 | + )); |
|
| 1624 | 1624 | ?> |
| 1625 | 1625 | </p> |
| 1626 | 1626 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1627 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1627 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1628 | 1628 | <?php |
| 1629 | - echo wpinv_html_text( array( |
|
| 1629 | + echo wpinv_html_text(array( |
|
| 1630 | 1630 | 'id' => 'wpinv_address', |
| 1631 | 1631 | 'name' => 'wpinv_address', |
| 1632 | 1632 | 'value' => $billing_details['address'], |
| 1633 | 1633 | 'class' => 'wpi-input form-control', |
| 1634 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
| 1635 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
| 1636 | - ) ); |
|
| 1634 | + 'placeholder' => __('Address', 'invoicing'), |
|
| 1635 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
| 1636 | + )); |
|
| 1637 | 1637 | ?> |
| 1638 | 1638 | </p> |
| 1639 | 1639 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1640 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1640 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1641 | 1641 | <?php |
| 1642 | - echo wpinv_html_text( array( |
|
| 1642 | + echo wpinv_html_text(array( |
|
| 1643 | 1643 | 'id' => 'wpinv_city', |
| 1644 | 1644 | 'name' => 'wpinv_city', |
| 1645 | 1645 | 'value' => $billing_details['city'], |
| 1646 | 1646 | 'class' => 'wpi-input form-control', |
| 1647 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
| 1648 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
| 1649 | - ) ); |
|
| 1647 | + 'placeholder' => __('City', 'invoicing'), |
|
| 1648 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
| 1649 | + )); |
|
| 1650 | 1650 | ?> |
| 1651 | 1651 | </p> |
| 1652 | 1652 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1653 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1654 | - <?php echo wpinv_html_select( array( |
|
| 1653 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1654 | + <?php echo wpinv_html_select(array( |
|
| 1655 | 1655 | 'options' => wpinv_get_country_list(), |
| 1656 | 1656 | 'name' => 'wpinv_country', |
| 1657 | 1657 | 'id' => 'wpinv_country', |
@@ -1659,16 +1659,16 @@ discard block |
||
| 1659 | 1659 | 'show_option_all' => false, |
| 1660 | 1660 | 'show_option_none' => false, |
| 1661 | 1661 | 'class' => 'wpi-input form-control', |
| 1662 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 1663 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
| 1664 | - ) ); ?> |
|
| 1662 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 1663 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
| 1664 | + )); ?> |
|
| 1665 | 1665 | </p> |
| 1666 | 1666 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1667 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1667 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1668 | 1668 | <?php |
| 1669 | - $states = wpinv_get_country_states( $selected_country ); |
|
| 1670 | - if( !empty( $states ) ) { |
|
| 1671 | - echo wpinv_html_select( array( |
|
| 1669 | + $states = wpinv_get_country_states($selected_country); |
|
| 1670 | + if (!empty($states)) { |
|
| 1671 | + echo wpinv_html_select(array( |
|
| 1672 | 1672 | 'options' => $states, |
| 1673 | 1673 | 'name' => 'wpinv_state', |
| 1674 | 1674 | 'id' => 'wpinv_state', |
@@ -1676,61 +1676,61 @@ discard block |
||
| 1676 | 1676 | 'show_option_all' => false, |
| 1677 | 1677 | 'show_option_none' => false, |
| 1678 | 1678 | 'class' => 'wpi-input form-control', |
| 1679 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 1680 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1681 | - ) ); |
|
| 1679 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 1680 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
| 1681 | + )); |
|
| 1682 | 1682 | } else { |
| 1683 | - echo wpinv_html_text( array( |
|
| 1683 | + echo wpinv_html_text(array( |
|
| 1684 | 1684 | 'name' => 'wpinv_state', |
| 1685 | 1685 | 'value' => $billing_details['state'], |
| 1686 | 1686 | 'id' => 'wpinv_state', |
| 1687 | 1687 | 'class' => 'wpi-input form-control', |
| 1688 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
| 1689 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
| 1690 | - ) ); |
|
| 1688 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
| 1689 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
| 1690 | + )); |
|
| 1691 | 1691 | } |
| 1692 | 1692 | ?> |
| 1693 | 1693 | </p> |
| 1694 | 1694 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
| 1695 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1695 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
| 1696 | 1696 | <?php |
| 1697 | - echo wpinv_html_text( array( |
|
| 1697 | + echo wpinv_html_text(array( |
|
| 1698 | 1698 | 'name' => 'wpinv_zip', |
| 1699 | 1699 | 'value' => $billing_details['zip'], |
| 1700 | 1700 | 'id' => 'wpinv_zip', |
| 1701 | 1701 | 'class' => 'wpi-input form-control', |
| 1702 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 1703 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
| 1704 | - ) ); |
|
| 1702 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
| 1703 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
| 1704 | + )); |
|
| 1705 | 1705 | ?> |
| 1706 | 1706 | </p> |
| 1707 | 1707 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
| 1708 | - <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> |
|
| 1708 | + <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> |
|
| 1709 | 1709 | <?php |
| 1710 | - echo wpinv_html_text( array( |
|
| 1710 | + echo wpinv_html_text(array( |
|
| 1711 | 1711 | 'id' => 'wpinv_phone', |
| 1712 | 1712 | 'name' => 'wpinv_phone', |
| 1713 | 1713 | 'value' => $billing_details['phone'], |
| 1714 | 1714 | 'class' => 'wpi-input form-control', |
| 1715 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
| 1716 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
| 1717 | - ) ); |
|
| 1715 | + 'placeholder' => __('Phone', 'invoicing'), |
|
| 1716 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
| 1717 | + )); |
|
| 1718 | 1718 | ?> |
| 1719 | 1719 | </p> |
| 1720 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
| 1720 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
| 1721 | 1721 | <div class="clearfix"></div> |
| 1722 | 1722 | </div> |
| 1723 | 1723 | </div> |
| 1724 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
| 1724 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
| 1725 | 1725 | </div> |
| 1726 | 1726 | <?php |
| 1727 | 1727 | } |
| 1728 | 1728 | } |
| 1729 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
| 1729 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
| 1730 | 1730 | |
| 1731 | 1731 | function wpinv_checkout_hidden_fields() { |
| 1732 | 1732 | ?> |
| 1733 | - <?php if ( is_user_logged_in() ) { ?> |
|
| 1733 | + <?php if (is_user_logged_in()) { ?> |
|
| 1734 | 1734 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
| 1735 | 1735 | <?php } ?> |
| 1736 | 1736 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1740,9 +1740,9 @@ discard block |
||
| 1740 | 1740 | function wpinv_checkout_button_purchase() { |
| 1741 | 1741 | ob_start(); |
| 1742 | 1742 | ?> |
| 1743 | - <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' ) ?>"/> |
|
| 1743 | + <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') ?>"/> |
|
| 1744 | 1744 | <?php |
| 1745 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
| 1745 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | 1748 | function wpinv_checkout_total() { |
@@ -1751,96 +1751,96 @@ discard block |
||
| 1751 | 1751 | <div id="wpinv_checkout_total" class="panel panel-info"> |
| 1752 | 1752 | <div class="panel-body"> |
| 1753 | 1753 | <?php |
| 1754 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
| 1754 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
| 1755 | 1755 | ?> |
| 1756 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
| 1756 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
| 1757 | 1757 | <?php |
| 1758 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
| 1758 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
| 1759 | 1759 | ?> |
| 1760 | 1760 | </div> |
| 1761 | 1761 | </div> |
| 1762 | 1762 | <?php |
| 1763 | 1763 | } |
| 1764 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
| 1764 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
| 1765 | 1765 | |
| 1766 | 1766 | function wpinv_checkout_submit() { |
| 1767 | 1767 | ?> |
| 1768 | 1768 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
| 1769 | 1769 | <div class="panel-body text-center"> |
| 1770 | 1770 | <?php |
| 1771 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
| 1771 | + do_action('wpinv_purchase_form_before_submit'); |
|
| 1772 | 1772 | wpinv_checkout_hidden_fields(); |
| 1773 | 1773 | echo wpinv_checkout_button_purchase(); |
| 1774 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
| 1774 | + do_action('wpinv_purchase_form_after_submit'); |
|
| 1775 | 1775 | ?> |
| 1776 | 1776 | </div> |
| 1777 | 1777 | </div> |
| 1778 | 1778 | <?php |
| 1779 | 1779 | } |
| 1780 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
| 1780 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
| 1781 | 1781 | |
| 1782 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1783 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1782 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1783 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1784 | 1784 | |
| 1785 | - if ( empty( $invoice ) ) { |
|
| 1785 | + if (empty($invoice)) { |
|
| 1786 | 1786 | return NULL; |
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | $billing_details = $invoice->get_user_info(); |
| 1790 | 1790 | $address_row = ''; |
| 1791 | - if ( $address = $billing_details['address'] ) { |
|
| 1792 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
| 1791 | + if ($address = $billing_details['address']) { |
|
| 1792 | + $address_row .= wpautop(wp_kses_post($address)); |
|
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | $address_fields = array(); |
| 1796 | - if ( !empty( $billing_details['city'] ) ) { |
|
| 1796 | + if (!empty($billing_details['city'])) { |
|
| 1797 | 1797 | $address_fields[] = $billing_details['city']; |
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
| 1801 | - if ( !empty( $billing_details['state'] ) ) { |
|
| 1802 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
| 1800 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
| 1801 | + if (!empty($billing_details['state'])) { |
|
| 1802 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | - if ( !empty( $billing_country ) ) { |
|
| 1806 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
| 1805 | + if (!empty($billing_country)) { |
|
| 1806 | + $address_fields[] = wpinv_country_name($billing_country); |
|
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | - if ( !empty( $address_fields ) ) { |
|
| 1810 | - $address_fields = implode( ", ", $address_fields ); |
|
| 1809 | + if (!empty($address_fields)) { |
|
| 1810 | + $address_fields = implode(", ", $address_fields); |
|
| 1811 | 1811 | |
| 1812 | - if ( !empty( $billing_details['zip'] ) ) { |
|
| 1812 | + if (!empty($billing_details['zip'])) { |
|
| 1813 | 1813 | $address_fields .= ' ' . $billing_details['zip']; |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
| 1816 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
| 1817 | 1817 | } |
| 1818 | 1818 | ob_start(); |
| 1819 | 1819 | ?> |
| 1820 | 1820 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1821 | 1821 | <tbody> |
| 1822 | 1822 | <tr class="wpi-receipt-name"> |
| 1823 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1824 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1823 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1824 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1825 | 1825 | </tr> |
| 1826 | 1826 | <tr class="wpi-receipt-email"> |
| 1827 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1828 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1827 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1828 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1829 | 1829 | </tr> |
| 1830 | - <?php if ( $billing_details['company'] ) { ?> |
|
| 1830 | + <?php if ($billing_details['company']) { ?> |
|
| 1831 | 1831 | <tr class="wpi-receipt-company"> |
| 1832 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
| 1833 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
| 1832 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
| 1833 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
| 1834 | 1834 | </tr> |
| 1835 | 1835 | <?php } ?> |
| 1836 | 1836 | <tr class="wpi-receipt-address"> |
| 1837 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1838 | - <td><?php echo $address_row ;?></td> |
|
| 1837 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1838 | + <td><?php echo $address_row; ?></td> |
|
| 1839 | 1839 | </tr> |
| 1840 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1840 | + <?php if ($billing_details['phone']) { ?> |
|
| 1841 | 1841 | <tr class="wpi-receipt-phone"> |
| 1842 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1843 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1842 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1843 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1844 | 1844 | </tr> |
| 1845 | 1845 | <?php } ?> |
| 1846 | 1846 | </tbody> |
@@ -1848,103 +1848,103 @@ discard block |
||
| 1848 | 1848 | <?php |
| 1849 | 1849 | $output = ob_get_clean(); |
| 1850 | 1850 | |
| 1851 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1851 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1852 | 1852 | |
| 1853 | 1853 | echo $output; |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1857 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1858 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
| 1859 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
| 1856 | +function wpinv_filter_success_page_content($content) { |
|
| 1857 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1858 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
| 1859 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
| 1860 | 1860 | } |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | 1863 | return $content; |
| 1864 | 1864 | } |
| 1865 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1865 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1866 | 1866 | |
| 1867 | -function wpinv_receipt_actions( $invoice ) { |
|
| 1868 | - if ( !empty( $invoice ) ) { |
|
| 1867 | +function wpinv_receipt_actions($invoice) { |
|
| 1868 | + if (!empty($invoice)) { |
|
| 1869 | 1869 | $actions = array(); |
| 1870 | 1870 | |
| 1871 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
| 1872 | - $actions['print'] = array( |
|
| 1873 | - 'url' => $invoice->get_view_url( true ), |
|
| 1874 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
| 1871 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
| 1872 | + $actions['print'] = array( |
|
| 1873 | + 'url' => $invoice->get_view_url(true), |
|
| 1874 | + 'name' => __('Print Invoice', 'invoicing'), |
|
| 1875 | 1875 | 'class' => 'btn-primary', |
| 1876 | 1876 | ); |
| 1877 | 1877 | } |
| 1878 | 1878 | |
| 1879 | - if ( is_user_logged_in() ) { |
|
| 1879 | + if (is_user_logged_in()) { |
|
| 1880 | 1880 | $actions['history'] = array( |
| 1881 | 1881 | 'url' => wpinv_get_history_page_uri(), |
| 1882 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
| 1882 | + 'name' => __('Invoice History', 'invoicing'), |
|
| 1883 | 1883 | 'class' => 'btn-warning', |
| 1884 | 1884 | ); |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
| 1887 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
| 1888 | 1888 | |
| 1889 | - if ( !empty( $actions ) ) { |
|
| 1889 | + if (!empty($actions)) { |
|
| 1890 | 1890 | ?> |
| 1891 | 1891 | <div class="wpinv-receipt-actions text-right"> |
| 1892 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
| 1893 | - <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> |
|
| 1892 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
| 1893 | + <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> |
|
| 1894 | 1894 | <?php } ?> |
| 1895 | 1895 | </div> |
| 1896 | 1896 | <?php |
| 1897 | 1897 | } |
| 1898 | 1898 | } |
| 1899 | 1899 | } |
| 1900 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
| 1900 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
| 1901 | 1901 | |
| 1902 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1903 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1902 | +function wpinv_invoice_link($invoice_id) { |
|
| 1903 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1904 | 1904 | |
| 1905 | - if ( empty( $invoice ) ) { |
|
| 1905 | + if (empty($invoice)) { |
|
| 1906 | 1906 | return NULL; |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1909 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1910 | 1910 | |
| 1911 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1911 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
| 1915 | - if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) { |
|
| 1914 | +function wpinv_invoice_subscription_details($invoice) { |
|
| 1915 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
| 1916 | 1916 | $total_payments = (int)$invoice->get_total_payments(); |
| 1917 | 1917 | $payments = $invoice->get_child_payments(); |
| 1918 | 1918 | |
| 1919 | 1919 | $subscription = $invoice->get_subscription_data(); |
| 1920 | 1920 | |
| 1921 | - if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) { |
|
| 1921 | + if (!(!empty($subscription) && !empty($subscription['item_id']))) { |
|
| 1922 | 1922 | return; |
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | - $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() ); |
|
| 1926 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
| 1925 | + $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()); |
|
| 1926 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
| 1927 | 1927 | |
| 1928 | 1928 | $subscription_status = $invoice->get_subscription_status(); |
| 1929 | 1929 | |
| 1930 | 1930 | $status_desc = ''; |
| 1931 | - if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { |
|
| 1932 | - $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date ); |
|
| 1933 | - } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) { |
|
| 1934 | - $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date ); |
|
| 1931 | + if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { |
|
| 1932 | + $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date); |
|
| 1933 | + } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) { |
|
| 1934 | + $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date); |
|
| 1935 | 1935 | } |
| 1936 | 1936 | $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : ''; |
| 1937 | 1937 | ?> |
| 1938 | 1938 | <div class="wpinv-subscriptions-details"> |
| 1939 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
| 1939 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
| 1940 | 1940 | <table class="table"> |
| 1941 | 1941 | <thead> |
| 1942 | 1942 | <tr> |
| 1943 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
| 1944 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
| 1945 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
| 1946 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
| 1947 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
| 1943 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
| 1944 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
| 1945 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
| 1946 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
| 1947 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
| 1948 | 1948 | </tr> |
| 1949 | 1949 | </thead> |
| 1950 | 1950 | <tbody> |
@@ -1953,32 +1953,32 @@ discard block |
||
| 1953 | 1953 | <td><?php echo $invoice->get_subscription_start(); ?></td> |
| 1954 | 1954 | <td><?php echo $invoice->get_subscription_end(); ?></td> |
| 1955 | 1955 | <td class="text-center"><?php echo $times_billed; ?></td> |
| 1956 | - <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?> |
|
| 1956 | + <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?> |
|
| 1957 | 1957 | <?php echo $status_desc; ?> |
| 1958 | 1958 | </td> |
| 1959 | 1959 | </tr> |
| 1960 | 1960 | </tbody> |
| 1961 | 1961 | </table> |
| 1962 | 1962 | </div> |
| 1963 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 1963 | + <?php if (!empty($payments)) { ?> |
|
| 1964 | 1964 | <div class="wpinv-renewal-payments"> |
| 1965 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
| 1965 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
| 1966 | 1966 | <table class="table"> |
| 1967 | 1967 | <thead> |
| 1968 | 1968 | <tr> |
| 1969 | 1969 | <th>#</th> |
| 1970 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
| 1971 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
| 1972 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
| 1970 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 1971 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 1972 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
| 1973 | 1973 | </tr> |
| 1974 | 1974 | </thead> |
| 1975 | 1975 | <tbody> |
| 1976 | - <?php foreach ( $payments as $key => $invoice_id ) { ?> |
|
| 1976 | + <?php foreach ($payments as $key => $invoice_id) { ?> |
|
| 1977 | 1977 | <tr> |
| 1978 | - <th scope="row"><?php echo ( $key + 1 );?></th> |
|
| 1979 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
| 1980 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
| 1981 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
| 1978 | + <th scope="row"><?php echo ($key + 1); ?></th> |
|
| 1979 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
| 1980 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
| 1981 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
| 1982 | 1982 | </tr> |
| 1983 | 1983 | <?php } ?> |
| 1984 | 1984 | <tr><td colspan="4" style="padding:0"></td></tr> |
@@ -1990,52 +1990,52 @@ discard block |
||
| 1990 | 1990 | } |
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
| 1994 | - if ( empty( $invoice ) ) { |
|
| 1993 | +function wpinv_cart_total_label($label, $invoice) { |
|
| 1994 | + if (empty($invoice)) { |
|
| 1995 | 1995 | return $label; |
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | 1998 | $prefix_label = ''; |
| 1999 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
| 2000 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
| 2001 | - } else if ( $invoice->is_renewal() ) { |
|
| 2002 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
| 1999 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
| 2000 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
| 2001 | + } else if ($invoice->is_renewal()) { |
|
| 2002 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | - if ( $prefix_label != '' ) { |
|
| 2006 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2005 | + if ($prefix_label != '') { |
|
| 2006 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | 2009 | return $label; |
| 2010 | 2010 | } |
| 2011 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2012 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2013 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
| 2011 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2012 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2013 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
| 2014 | 2014 | |
| 2015 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
| 2015 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
| 2016 | 2016 | |
| 2017 | -function wpinv_invoice_print_description( $invoice ) { |
|
| 2018 | - if ( empty( $invoice ) ) { |
|
| 2017 | +function wpinv_invoice_print_description($invoice) { |
|
| 2018 | + if (empty($invoice)) { |
|
| 2019 | 2019 | return NULL; |
| 2020 | 2020 | } |
| 2021 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
| 2021 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
| 2022 | 2022 | ?> |
| 2023 | 2023 | <div class="row wpinv-lower"> |
| 2024 | 2024 | <div class="col-sm-12 wpinv-description"> |
| 2025 | - <?php echo wpautop( $description ); ?> |
|
| 2025 | + <?php echo wpautop($description); ?> |
|
| 2026 | 2026 | </div> |
| 2027 | 2027 | </div> |
| 2028 | 2028 | <?php |
| 2029 | 2029 | } |
| 2030 | 2030 | } |
| 2031 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
| 2031 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
| 2032 | 2032 | |
| 2033 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
| 2034 | - if ( empty( $invoice ) ) { |
|
| 2033 | +function wpinv_invoice_print_payment_info($invoice) { |
|
| 2034 | + if (empty($invoice)) { |
|
| 2035 | 2035 | return NULL; |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
| 2038 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
| 2039 | 2039 | ?> |
| 2040 | 2040 | <div class="row wpinv-payments"> |
| 2041 | 2041 | <div class="col-sm-12"> |
@@ -2047,43 +2047,43 @@ discard block |
||
| 2047 | 2047 | } |
| 2048 | 2048 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
| 2049 | 2049 | |
| 2050 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 2051 | - if ( empty( $note ) ) { |
|
| 2050 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 2051 | + if (empty($note)) { |
|
| 2052 | 2052 | return NULL; |
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | - if ( is_int( $note ) ) { |
|
| 2056 | - $note = get_comment( $note ); |
|
| 2055 | + if (is_int($note)) { |
|
| 2056 | + $note = get_comment($note); |
|
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 2059 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 2060 | 2060 | return NULL; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - $note_classes = array( 'note' ); |
|
| 2064 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 2065 | - $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : ''; |
|
| 2066 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 2067 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 2063 | + $note_classes = array('note'); |
|
| 2064 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 2065 | + $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : ''; |
|
| 2066 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 2067 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 2068 | 2068 | |
| 2069 | 2069 | ob_start(); |
| 2070 | 2070 | ?> |
| 2071 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
| 2071 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
| 2072 | 2072 | <div class="note_content"> |
| 2073 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 2073 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 2074 | 2074 | </div> |
| 2075 | 2075 | <p class="meta"> |
| 2076 | - <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> |
|
| 2077 | - <?php if($note->comment_author !== 'System') {?> |
|
| 2078 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 2076 | + <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> |
|
| 2077 | + <?php if ($note->comment_author !== 'System') {?> |
|
| 2078 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 2079 | 2079 | <?php } ?> |
| 2080 | 2080 | </p> |
| 2081 | 2081 | </li> |
| 2082 | 2082 | <?php |
| 2083 | 2083 | $note_content = ob_get_clean(); |
| 2084 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 2084 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 2085 | 2085 | |
| 2086 | - if ( $echo ) { |
|
| 2086 | + if ($echo) { |
|
| 2087 | 2087 | echo $note_content; |
| 2088 | 2088 | } else { |
| 2089 | 2089 | return $note_content; |
@@ -2093,33 +2093,33 @@ discard block |
||
| 2093 | 2093 | function wpinv_invalid_invoice_content() { |
| 2094 | 2094 | global $post; |
| 2095 | 2095 | |
| 2096 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 2096 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 2097 | 2097 | |
| 2098 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
| 2099 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 2100 | - if ( is_user_logged_in() ) { |
|
| 2101 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2102 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2103 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 2098 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
| 2099 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 2100 | + if (is_user_logged_in()) { |
|
| 2101 | + if (wpinv_require_login_to_checkout()) { |
|
| 2102 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2103 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 2104 | 2104 | } |
| 2105 | 2105 | } |
| 2106 | 2106 | } else { |
| 2107 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 2108 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2109 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 2107 | + if (wpinv_require_login_to_checkout()) { |
|
| 2108 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 2109 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 2110 | 2110 | } |
| 2111 | 2111 | } |
| 2112 | 2112 | } |
| 2113 | 2113 | } else { |
| 2114 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 2114 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | ?> |
| 2117 | 2117 | <div class="row wpinv-row-invalid"> |
| 2118 | 2118 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 2119 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 2119 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 2120 | 2120 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 2121 | 2121 | </div> |
| 2122 | 2122 | </div> |
| 2123 | 2123 | <?php |
| 2124 | 2124 | } |
| 2125 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 2126 | 2125 | \ No newline at end of file |
| 2126 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 2127 | 2127 | \ No newline at end of file |