@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | <tbody> |
| 32 | 32 | <?php foreach ( $user_invoices->invoices as $invoice ) { |
| 33 | - ?> |
|
| 33 | + ?> |
|
| 34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
| 35 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
| 36 | 36 | <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
| 55 | 55 | <?php |
| 56 | - $actions = array( |
|
| 57 | - 'pay' => array( |
|
| 58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 56 | + $actions = array( |
|
| 57 | + 'pay' => array( |
|
| 58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 60 | 60 | 'class' => 'btn-success' |
| 61 | - ), |
|
| 61 | + ), |
|
| 62 | 62 | 'print' => array( |
| 63 | - 'url' => $invoice->get_view_url(), |
|
| 64 | - 'name' => __( 'Print', 'invoicing' ), |
|
| 63 | + 'url' => $invoice->get_view_url(), |
|
| 64 | + 'name' => __( 'Print', 'invoicing' ), |
|
| 65 | 65 | 'class' => 'btn-primary', |
| 66 | 66 | 'attrs' => 'target="_blank"' |
| 67 | - ) |
|
| 68 | - ); |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | 69 | |
| 70 | - if ( ! $invoice->needs_payment() ) { |
|
| 71 | - unset( $actions['pay'] ); |
|
| 72 | - } |
|
| 70 | + if ( ! $invoice->needs_payment() ) { |
|
| 71 | + unset( $actions['pay'] ); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | - foreach ( $actions as $key => $action ) { |
|
| 76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | + foreach ( $actions as $key => $action ) { |
|
| 76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 77 | 77 | echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
| 78 | - } |
|
| 79 | - } |
|
| 80 | - ?> |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + ?> |
|
| 81 | 81 | <?php endif; ?> |
| 82 | 82 | </td> |
| 83 | 83 | <?php endforeach; ?> |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
| 92 | 92 | <div class="invoicing-Pagination"> |
| 93 | 93 | <?php |
| 94 | - $big = 999999; |
|
| 95 | - echo paginate_links( array( |
|
| 96 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 97 | - 'format' => '?paged=%#%', |
|
| 98 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 99 | - 'total' => $user_invoices->max_num_pages, |
|
| 94 | + $big = 999999; |
|
| 95 | + echo paginate_links( array( |
|
| 96 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 97 | + 'format' => '?paged=%#%', |
|
| 98 | + 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 99 | + 'total' => $user_invoices->max_num_pages, |
|
| 100 | 100 | 'add_args' => array( |
| 101 | 101 | 'wpinv-cpt' => 'wpi_invoice', |
| 102 | 102 | ) |
| 103 | - ) ); |
|
| 104 | - ?> |
|
| 103 | + ) ); |
|
| 104 | + ?> |
|
| 105 | 105 | </div> |
| 106 | 106 | <?php endif; ?> |
| 107 | 107 | |
@@ -1,80 +1,80 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -if ( !( $user_id = get_current_user_id() ) ) { |
|
| 6 | +if (!($user_id = get_current_user_id())) { |
|
| 7 | 7 | ?> |
| 8 | - <div class="wpinv-empty alert alert-error"><?php _e( 'You are not allowed to access this section', 'invoicing' ) ;?></div> |
|
| 8 | + <div class="wpinv-empty alert alert-error"><?php _e('You are not allowed to access this section', 'invoicing'); ?></div> |
|
| 9 | 9 | <?php |
| 10 | 10 | return; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | global $current_page; |
| 14 | -$current_page = empty( $current_page ) ? 1 : absint( $current_page ); |
|
| 15 | -$query = apply_filters( 'wpinv_user_invoices_query', array( 'user' => $user_id, 'page' => $current_page, 'paginate' => true ) ); |
|
| 16 | -$user_invoices = wpinv_get_invoices( $query ); |
|
| 14 | +$current_page = empty($current_page) ? 1 : absint($current_page); |
|
| 15 | +$query = apply_filters('wpinv_user_invoices_query', array('user' => $user_id, 'page' => $current_page, 'paginate' => true)); |
|
| 16 | +$user_invoices = wpinv_get_invoices($query); |
|
| 17 | 17 | $has_invoices = 0 < $user_invoices->total; |
| 18 | 18 | |
| 19 | -do_action( 'wpinv_before_user_invoices', $has_invoices ); ?> |
|
| 19 | +do_action('wpinv_before_user_invoices', $has_invoices); ?> |
|
| 20 | 20 | |
| 21 | -<?php if ( $has_invoices ) { ?> |
|
| 21 | +<?php if ($has_invoices) { ?> |
|
| 22 | 22 | <table class="table table-bordered table-hover wpi-user-invoices"> |
| 23 | 23 | <thead> |
| 24 | 24 | <tr> |
| 25 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
| 26 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
| 25 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
| 26 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
| 27 | 27 | <?php endforeach; ?> |
| 28 | 28 | </tr> |
| 29 | 29 | </thead> |
| 30 | 30 | |
| 31 | 31 | <tbody> |
| 32 | - <?php foreach ( $user_invoices->invoices as $invoice ) { |
|
| 32 | + <?php foreach ($user_invoices->invoices as $invoice) { |
|
| 33 | 33 | ?> |
| 34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
| 35 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
| 36 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
| 37 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
| 38 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
| 35 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
| 36 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
| 37 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
| 38 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
| 39 | 39 | |
| 40 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
| 41 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
| 42 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
| 40 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
| 41 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
| 42 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
| 43 | 43 | </a> |
| 44 | 44 | |
| 45 | - <?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
| 46 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
| 45 | + <?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
| 46 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
| 47 | 47 | |
| 48 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
| 49 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
| 48 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
| 49 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
| 50 | 50 | |
| 51 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
| 52 | - <?php echo $invoice->get_total( true ); ?> |
|
| 51 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
| 52 | + <?php echo $invoice->get_total(true); ?> |
|
| 53 | 53 | |
| 54 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
| 54 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
| 55 | 55 | <?php |
| 56 | 56 | $actions = array( |
| 57 | 57 | 'pay' => array( |
| 58 | 58 | 'url' => $invoice->get_checkout_payment_url(), |
| 59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 59 | + 'name' => __('Pay Now', 'invoicing'), |
|
| 60 | 60 | 'class' => 'btn-success' |
| 61 | 61 | ), |
| 62 | 62 | 'print' => array( |
| 63 | 63 | 'url' => $invoice->get_view_url(), |
| 64 | - 'name' => __( 'Print', 'invoicing' ), |
|
| 64 | + 'name' => __('Print', 'invoicing'), |
|
| 65 | 65 | 'class' => 'btn-primary', |
| 66 | 66 | 'attrs' => 'target="_blank"' |
| 67 | 67 | ) |
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - if ( ! $invoice->needs_payment() ) { |
|
| 71 | - unset( $actions['pay'] ); |
|
| 70 | + if (!$invoice->needs_payment()) { |
|
| 71 | + unset($actions['pay']); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | - foreach ( $actions as $key => $action ) { |
|
| 74 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
| 75 | + foreach ($actions as $key => $action) { |
|
| 76 | 76 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
| 77 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
| 77 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | ?> |
@@ -86,29 +86,29 @@ discard block |
||
| 86 | 86 | </tbody> |
| 87 | 87 | </table> |
| 88 | 88 | |
| 89 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
| 89 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
| 90 | 90 | |
| 91 | - <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
|
| 91 | + <?php if (1 < $user_invoices->max_num_pages) : ?> |
|
| 92 | 92 | <div class="invoicing-Pagination"> |
| 93 | 93 | <?php |
| 94 | 94 | $big = 999999; |
| 95 | - echo paginate_links( array( |
|
| 96 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 95 | + echo paginate_links(array( |
|
| 96 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 97 | 97 | 'format' => '?paged=%#%', |
| 98 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 98 | + 'current' => max(1, get_query_var('paged')), |
|
| 99 | 99 | 'total' => $user_invoices->max_num_pages, |
| 100 | 100 | 'add_args' => array( |
| 101 | 101 | 'wpinv-cpt' => 'wpi_invoice', |
| 102 | 102 | ) |
| 103 | - ) ); |
|
| 103 | + )); |
|
| 104 | 104 | ?> |
| 105 | 105 | </div> |
| 106 | 106 | <?php endif; ?> |
| 107 | 107 | |
| 108 | 108 | <?php } else { ?> |
| 109 | 109 | <div class="wpinv-empty alert-info"> |
| 110 | - <?php _e( 'No invoice has been made yet.', 'invoicing' ); ?> |
|
| 110 | + <?php _e('No invoice has been made yet.', 'invoicing'); ?> |
|
| 111 | 111 | </div> |
| 112 | 112 | <?php } ?> |
| 113 | 113 | |
| 114 | -<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?> |
|
| 114 | +<?php do_action('wpinv_after_user_invoices', $has_invoices); ?> |
|
@@ -1,34 +1,34 @@ 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_Billing_Details { |
| 8 | - public static function output( $post ) { |
|
| 8 | + public static function output($post) { |
|
| 9 | 9 | global $user_ID; |
| 10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 11 | + $invoice = new WPInv_Invoice($post_id); |
|
| 12 | 12 | ?> |
| 13 | 13 | <div class="gdmbx2-wrap form-table"> |
| 14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
| 15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
| 16 | 16 | <div class="gdmbx-th"> |
| 17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
| 17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
| 18 | 18 | </div> |
| 19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
| 20 | - <?php wpinv_dropdown_users( array( |
|
| 20 | + <?php wpinv_dropdown_users(array( |
|
| 21 | 21 | 'name' => 'post_author_override', |
| 22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
| 23 | 23 | 'include_selected' => true, |
| 24 | 24 | 'show' => 'user_email', |
| 25 | 25 | 'orderby' => 'user_email', |
| 26 | 26 | 'class' => 'gdmbx2-text-large' |
| 27 | - ) ); ?> |
|
| 27 | + )); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | </div> |
| 30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
| 31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
| 31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
| 32 | 32 | </div> |
| 33 | 33 | <div class="gdmbx-td"> |
| 34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
| 39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
| 39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
| 40 | 40 | </div> |
| 41 | 41 | <div class="gdmbx-td"> |
| 42 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
| 43 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
| 44 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
| 42 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
| 43 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
| 44 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
| 45 | 45 | </div> |
| 46 | 46 | </div> |
| 47 | 47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
| 48 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
| 48 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
| 49 | 49 | <div class="gdmbx-td"> |
| 50 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
| 50 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
| 51 | 51 | </div> |
| 52 | 52 | </div> |
| 53 | 53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
| 54 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
| 54 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
| 55 | 55 | <div class="gdmbx-td"> |
| 56 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
| 56 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
| 57 | 57 | </div> |
| 58 | 58 | </div> |
| 59 | 59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
| 60 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
| 60 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
| 61 | 61 | <div class="gdmbx-td"> |
| 62 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
| 62 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
| 63 | 63 | </div> |
| 64 | 64 | </div> |
| 65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
| 66 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
| 66 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
| 67 | 67 | <div class="gdmbx-td"> |
| 68 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
| 68 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
| 69 | 69 | </div> |
| 70 | 70 | </div> |
| 71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
| 72 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
| 72 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
| 73 | 73 | <div class="gdmbx-td"> |
| 74 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
| 74 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
| 75 | 75 | </div> |
| 76 | 76 | </div> |
| 77 | 77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
| 78 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
| 78 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
| 79 | 79 | <div class="gdmbx-td"> |
| 80 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
| 80 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
| 81 | 81 | </div> |
| 82 | 82 | </div> |
| 83 | 83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
| 84 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 84 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
| 85 | 85 | <div class="gdmbx-td"> |
| 86 | 86 | <?php |
| 87 | - echo wpinv_html_select( array( |
|
| 88 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
| 87 | + echo wpinv_html_select(array( |
|
| 88 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
| 89 | 89 | 'name' => 'wpinv_country', |
| 90 | 90 | 'id' => 'wpinv_country', |
| 91 | 91 | 'selected' => $invoice->country, |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | 'show_option_none' => false, |
| 94 | 94 | 'class' => 'gdmbx2-text-large', |
| 95 | 95 | 'chosen' => false, |
| 96 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
| 96 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
| 97 | 97 | 'required' => false, |
| 98 | - ) ); |
|
| 98 | + )); |
|
| 99 | 99 | ?> |
| 100 | 100 | </div> |
| 101 | 101 | </div> |
| 102 | 102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
| 103 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
| 103 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
| 104 | 104 | <div class="gdmbx-td"> |
| 105 | 105 | <?php |
| 106 | - $states = wpinv_get_country_states( $invoice->country ); |
|
| 107 | - if( !empty( $states ) ) { |
|
| 108 | - echo wpinv_html_select( array( |
|
| 109 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
| 106 | + $states = wpinv_get_country_states($invoice->country); |
|
| 107 | + if (!empty($states)) { |
|
| 108 | + echo wpinv_html_select(array( |
|
| 109 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
| 110 | 110 | 'name' => 'wpinv_state', |
| 111 | 111 | 'id' => 'wpinv_state', |
| 112 | 112 | 'selected' => $invoice->state, |
@@ -114,44 +114,44 @@ discard block |
||
| 114 | 114 | 'show_option_none' => false, |
| 115 | 115 | 'class' => 'gdmbx2-text-large', |
| 116 | 116 | 'chosen' => false, |
| 117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
| 117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
| 118 | 118 | 'required' => false, |
| 119 | - ) ); |
|
| 119 | + )); |
|
| 120 | 120 | } else { |
| 121 | - echo wpinv_html_text( array( |
|
| 121 | + echo wpinv_html_text(array( |
|
| 122 | 122 | 'name' => 'wpinv_state', |
| 123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
| 123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
| 124 | 124 | 'id' => 'wpinv_state', |
| 125 | 125 | 'class' => 'gdmbx2-text-large', |
| 126 | 126 | 'required' => false, |
| 127 | - ) ); |
|
| 127 | + )); |
|
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | </div> |
| 131 | 131 | </div> |
| 132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
| 133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
| 133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
| 134 | 134 | <div class="gdmbx-td"> |
| 135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
| 135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
| 136 | 136 | </div> |
| 137 | 137 | </div> |
| 138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
| 139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
| 139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
| 140 | 140 | <div class="gdmbx-td"> |
| 141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
| 141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
| 142 | 142 | </div> |
| 143 | 143 | </div> |
| 144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
| 145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
| 146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
| 146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
| 147 | 147 | <?php } ?></label></div> |
| 148 | 148 | <div class="gdmbx-td"> |
| 149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
| 149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
| 150 | 150 | </div> |
| 151 | 151 | </div> |
| 152 | 152 | </div> |
| 153 | 153 | </div> |
| 154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
| 154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
| 155 | 155 | <?php |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -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 save 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 save 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,29 +34,29 @@ 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 ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
| 40 | + <?php if (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 | 54 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
| 55 | 55 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
| 56 | 56 | <div class="gdmbx-td"> |
| 57 | 57 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
| 58 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
| 59 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
| 58 | + <?php foreach ($statuses as $value => $label) { ?> |
|
| 59 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
| 60 | 60 | <?php } ?> |
| 61 | 61 | </select> |
| 62 | 62 | </div> |
@@ -64,107 +64,107 @@ discard block |
||
| 64 | 64 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
| 65 | 65 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
| 66 | 66 | <div class="gdmbx-td"> |
| 67 | - <input type="text" placeholder="<?php echo esc_attr( wpinv_format_invoice_number( 1 ) ); ?>" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text"> |
|
| 67 | + <input type="text" placeholder="<?php echo esc_attr(wpinv_format_invoice_number(1)); ?>" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text"> |
|
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?> |
|
| 71 | - <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?> |
|
| 70 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); ?> |
|
| 71 | + <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?> |
|
| 72 | 72 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
| 73 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
| 73 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
| 74 | 74 | <div class="gdmbx-td"> |
| 75 | - <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 } ?> |
|
| 75 | + <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 | 76 | </div> |
| 77 | 77 | </div> |
| 78 | 78 | <?php } ?> |
| 79 | 79 | </div> |
| 80 | 80 | </div> |
| 81 | 81 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
| 82 | - <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> |
|
| 82 | + <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 | 83 | <select id="wpi_save_send" name="wpi_save_send"> |
| 84 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
| 85 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
| 84 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
| 85 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
| 86 | 86 | </select> |
| 87 | 87 | </p> |
| 88 | 88 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
| 89 | 89 | </div> |
| 90 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
| 90 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
| 91 | 91 | <?php |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public static function resend_invoice( $post ) { |
|
| 94 | + public static function resend_invoice($post) { |
|
| 95 | 95 | global $wpi_mb_invoice; |
| 96 | 96 | |
| 97 | - if ( empty( $wpi_mb_invoice ) ) { |
|
| 97 | + if (empty($wpi_mb_invoice)) { |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $text = array( |
| 102 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
| 103 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
| 102 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
| 103 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
| 107 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
| 107 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
| 108 | 108 | |
| 109 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
| 109 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
| 110 | 110 | $email_actions = array(); |
| 111 | - $email_actions['email_url'] = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ); |
|
| 112 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
| 111 | + $email_actions['email_url'] = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)); |
|
| 112 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
| 113 | 113 | |
| 114 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
| 114 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
| 115 | 115 | ?> |
| 116 | 116 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
| 117 | - <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> |
|
| 118 | - <?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() ) ) { ?> |
|
| 119 | - <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> |
|
| 117 | + <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> |
|
| 118 | + <?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())) { ?> |
|
| 119 | + <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> |
|
| 120 | 120 | <?php } ?> |
| 121 | 121 | <?php |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
| 124 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public static function subscriptions( $post ) { |
|
| 127 | + public static function subscriptions($post) { |
|
| 128 | 128 | global $wpi_mb_invoice; |
| 129 | 129 | |
| 130 | 130 | $invoice = $wpi_mb_invoice; |
| 131 | 131 | |
| 132 | - if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
| 132 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
| 133 | 133 | $payments = $invoice->get_child_payments(); |
| 134 | 134 | |
| 135 | 135 | $total_payments = (int)$invoice->get_total_payments(); |
| 136 | 136 | $subscription = $invoice->get_subscription_data(); |
| 137 | 137 | |
| 138 | - $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() ); |
|
| 139 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
| 138 | + $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()); |
|
| 139 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
| 140 | 140 | $subscription_status = $invoice->get_subscription_status(); |
| 141 | 141 | ?> |
| 142 | - <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p> |
|
| 143 | - <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?> |
|
| 144 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p> |
|
| 142 | + <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
|
| 143 | + <?php if ($subscription_id = $invoice->get_subscription_id()) { ?> |
|
| 144 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p> |
|
| 145 | 145 | <?php } ?> |
| 146 | - <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p> |
|
| 147 | - <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p> |
|
| 148 | - <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?> |
|
| 149 | - <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
| 150 | - <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
| 151 | - <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?> |
|
| 152 | - <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p> |
|
| 146 | + <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p> |
|
| 147 | + <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p> |
|
| 148 | + <?php if (!empty($payments) || $invoice->is_paid()) { ?> |
|
| 149 | + <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
| 150 | + <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
| 151 | + <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?> |
|
| 152 | + <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p> |
|
| 153 | 153 | <?php } ?> |
| 154 | - <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?> |
|
| 155 | - <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p> |
|
| 154 | + <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?> |
|
| 155 | + <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p> |
|
| 156 | 156 | <?php } ?> |
| 157 | - <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?> |
|
| 158 | - <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p> |
|
| 157 | + <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?> |
|
| 158 | + <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p> |
|
| 159 | 159 | <?php } ?> |
| 160 | - <?php if ( !empty( $payments ) ) { ?> |
|
| 161 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
| 160 | + <?php if (!empty($payments)) { ?> |
|
| 161 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
| 162 | 162 | <ul id="wpi-sub-payments"> |
| 163 | - <?php foreach ( $payments as $invoice_id ) { ?> |
|
| 163 | + <?php foreach ($payments as $invoice_id) { ?> |
|
| 164 | 164 | <li> |
| 165 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
| 166 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
| 167 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
| 165 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
| 166 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
| 167 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
| 168 | 168 | </li> |
| 169 | 169 | <?php } ?> |
| 170 | 170 | </ul> |
@@ -172,47 +172,47 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - public static function renewals( $post ) { |
|
| 175 | + public static function renewals($post) { |
|
| 176 | 176 | global $wpi_mb_invoice; |
| 177 | 177 | |
| 178 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
| 179 | - $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice ); |
|
| 180 | - $parent_id = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice ); |
|
| 178 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
| 179 | + $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice); |
|
| 180 | + $parent_id = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice); |
|
| 181 | 181 | ?> |
| 182 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
| 183 | - <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> |
|
| 182 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
| 183 | + <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> |
|
| 184 | 184 | <?php |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - public static function payment_meta( $post ) { |
|
| 188 | + public static function payment_meta($post) { |
|
| 189 | 189 | global $wpi_mb_invoice; |
| 190 | 190 | |
| 191 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
| 192 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) { |
|
| 191 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
| 192 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) { |
|
| 193 | 193 | $set_dateway = true; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | ?> |
| 197 | 197 | <p class="wpi-meta-row"> |
| 198 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
| 199 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
| 198 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
| 199 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
| 200 | 200 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
| 201 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
| 202 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
| 201 | + <?php foreach ($gateways as $name => $gateway) { |
|
| 202 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
| 203 | 203 | continue; |
| 204 | 204 | } |
| 205 | 205 | ?> |
| 206 | - <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> |
|
| 206 | + <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 | 207 | <?php } ?> |
| 208 | 208 | </select> |
| 209 | 209 | <?php } else { |
| 210 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) ); |
|
| 210 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway)); |
|
| 211 | 211 | } ?> |
| 212 | 212 | </p> |
| 213 | - <?php if ( $wpi_mb_invoice->is_paid() ) { ?> |
|
| 214 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p> |
|
| 215 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
| 213 | + <?php if ($wpi_mb_invoice->is_paid()) { ?> |
|
| 214 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p> |
|
| 215 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
| 216 | 216 | <?php } ?> |
| 217 | 217 | <?php |
| 218 | 218 | } |
@@ -1,70 +1,70 @@ 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 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
| 7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
| 8 | 8 | function wpinv_add_options_link() { |
| 9 | 9 | global $menu; |
| 10 | 10 | |
| 11 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 11 | + if (!current_user_can('manage_options')) { |
|
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 16 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
| 15 | + if (current_user_can('manage_options')) { |
|
| 16 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
| 19 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
| 20 | 20 | |
| 21 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
| 21 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
| 22 | 22 | |
| 23 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), 'manage_options', 'wpinv-settings', 'wpinv_options_page' ); |
|
| 23 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), 'manage_options', 'wpinv-settings', 'wpinv_options_page'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
| 26 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
| 27 | 27 | function wpinv_remove_admin_submenus() { |
| 28 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
| 28 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
| 32 | -function wpinv_discount_columns( $existing_columns ) { |
|
| 31 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
| 32 | +function wpinv_discount_columns($existing_columns) { |
|
| 33 | 33 | $columns = array(); |
| 34 | 34 | $columns['cb'] = $existing_columns['cb']; |
| 35 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
| 36 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
| 37 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
| 38 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
| 39 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
| 40 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
| 35 | + $columns['name'] = __('Name', 'invoicing'); |
|
| 36 | + $columns['code'] = __('Code', 'invoicing'); |
|
| 37 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
| 38 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
| 39 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
| 40 | + $columns['status'] = __('Status', 'invoicing'); |
|
| 41 | 41 | |
| 42 | 42 | return $columns; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
| 46 | -function wpinv_discount_custom_column( $column ) { |
|
| 45 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
| 46 | +function wpinv_discount_custom_column($column) { |
|
| 47 | 47 | global $post; |
| 48 | 48 | |
| 49 | 49 | $discount = $post; |
| 50 | 50 | |
| 51 | - switch ( $column ) { |
|
| 51 | + switch ($column) { |
|
| 52 | 52 | case 'name' : |
| 53 | - echo get_the_title( $discount->ID ); |
|
| 53 | + echo get_the_title($discount->ID); |
|
| 54 | 54 | break; |
| 55 | 55 | case 'code' : |
| 56 | - echo wpinv_get_discount_code( $discount->ID ); |
|
| 56 | + echo wpinv_get_discount_code($discount->ID); |
|
| 57 | 57 | break; |
| 58 | 58 | case 'amount' : |
| 59 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
| 59 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
| 60 | 60 | break; |
| 61 | 61 | case 'usage_limit' : |
| 62 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
| 62 | + echo wpinv_get_discount_uses($discount->ID); |
|
| 63 | 63 | break; |
| 64 | 64 | case 'usage' : |
| 65 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
| 66 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
| 67 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
| 65 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
| 66 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
| 67 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
| 68 | 68 | } else { |
| 69 | 69 | $usage .= ' ∞'; |
| 70 | 70 | } |
@@ -72,162 +72,162 @@ discard block |
||
| 72 | 72 | echo $usage; |
| 73 | 73 | break; |
| 74 | 74 | case 'expiry_date' : |
| 75 | - if ( wpinv_get_discount_expiration( $discount->ID ) ) { |
|
| 76 | - $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) ); |
|
| 75 | + if (wpinv_get_discount_expiration($discount->ID)) { |
|
| 76 | + $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID))); |
|
| 77 | 77 | } else { |
| 78 | - $expiration = __( 'Never', 'invoicing' ); |
|
| 78 | + $expiration = __('Never', 'invoicing'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | echo $expiration; |
| 82 | 82 | break; |
| 83 | 83 | case 'description' : |
| 84 | - echo wp_kses_post( $post->post_excerpt ); |
|
| 84 | + echo wp_kses_post($post->post_excerpt); |
|
| 85 | 85 | break; |
| 86 | 86 | case 'status' : |
| 87 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
| 87 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
| 88 | 88 | |
| 89 | - echo wpinv_discount_status( $status ); |
|
| 89 | + echo wpinv_discount_status($status); |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
| 95 | -function wpinv_post_row_actions( $actions, $post ) { |
|
| 96 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
| 94 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
| 95 | +function wpinv_post_row_actions($actions, $post) { |
|
| 96 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
| 97 | 97 | |
| 98 | - if ( $post_type == 'wpi_invoice' ) { |
|
| 98 | + if ($post_type == 'wpi_invoice') { |
|
| 99 | 99 | $actions = array(); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( $post_type == 'wpi_discount' ) { |
|
| 103 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
| 102 | + if ($post_type == 'wpi_discount') { |
|
| 103 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return $actions; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
| 110 | - $row_actions = array(); |
|
| 111 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
| 112 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
| 109 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
| 110 | + $row_actions = array(); |
|
| 111 | + $edit_link = get_edit_post_link($discount->ID); |
|
| 112 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
| 113 | 113 | |
| 114 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
| 115 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
| 116 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
| 117 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
| 114 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
| 115 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
| 116 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
| 117 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
| 121 | - if ( isset( $row_actions['delete'] ) ) { |
|
| 122 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
| 120 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
| 121 | + if (isset($row_actions['delete'])) { |
|
| 122 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
| 123 | 123 | } |
| 124 | 124 | } else { |
| 125 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
| 125 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
| 129 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
| 130 | 130 | |
| 131 | 131 | return $row_actions; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
| 135 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
| 136 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
| 134 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
| 135 | +function wpinv_table_primary_column($default, $screen_id) { |
|
| 136 | + if ('edit-wpi_invoice' === $screen_id) { |
|
| 137 | 137 | return 'name'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return $default; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
| 144 | - if ( !$display ) { |
|
| 143 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
| 144 | + if (!$display) { |
|
| 145 | 145 | return array(); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $actions = array( |
| 149 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
| 150 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
| 151 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
| 149 | + 'activate' => __('Activate', 'invoicing'), |
|
| 150 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
| 151 | + 'delete' => __('Delete', 'invoicing'), |
|
| 152 | 152 | ); |
| 153 | 153 | $two = ''; |
| 154 | 154 | $which = 'top'; |
| 155 | 155 | echo '</div><div class="alignleft actions bulkactions">'; |
| 156 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
| 157 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
| 158 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
| 156 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
| 157 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
| 158 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
| 159 | 159 | |
| 160 | - foreach ( $actions as $name => $title ) { |
|
| 160 | + foreach ($actions as $name => $title) { |
|
| 161 | 161 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
| 162 | 162 | |
| 163 | 163 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
| 164 | 164 | } |
| 165 | 165 | echo "</select>"; |
| 166 | 166 | |
| 167 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
| 167 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
| 168 | 168 | |
| 169 | 169 | echo '</div><div class="alignleft actions">'; |
| 170 | 170 | } |
| 171 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
| 171 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
| 172 | 172 | |
| 173 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
| 174 | - if ( $post_type == 'wpi_discount' ) { |
|
| 173 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
| 174 | + if ($post_type == 'wpi_discount') { |
|
| 175 | 175 | $disable = true; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $disable; |
| 179 | 179 | } |
| 180 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
| 180 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
| 181 | 181 | |
| 182 | 182 | function wpinv_restrict_manage_posts() { |
| 183 | 183 | global $typenow; |
| 184 | 184 | |
| 185 | - if( 'wpi_discount' == $typenow ) { |
|
| 185 | + if ('wpi_discount' == $typenow) { |
|
| 186 | 186 | wpinv_discount_filters(); |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
| 189 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
| 190 | 190 | |
| 191 | 191 | function wpinv_discount_filters() { |
| 192 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
| 192 | + echo wpinv_discount_bulk_actions(array(), true); |
|
| 193 | 193 | |
| 194 | 194 | ?> |
| 195 | 195 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
| 196 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
| 196 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
| 197 | 197 | <?php |
| 198 | 198 | $types = wpinv_get_discount_types(); |
| 199 | 199 | |
| 200 | - foreach ( $types as $name => $type ) { |
|
| 201 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
| 200 | + foreach ($types as $name => $type) { |
|
| 201 | + echo '<option value="' . esc_attr($name) . '"'; |
|
| 202 | 202 | |
| 203 | - if ( isset( $_GET['discount_type'] ) ) |
|
| 204 | - selected( $name, $_GET['discount_type'] ); |
|
| 203 | + if (isset($_GET['discount_type'])) |
|
| 204 | + selected($name, $_GET['discount_type']); |
|
| 205 | 205 | |
| 206 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
| 206 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
| 207 | 207 | } |
| 208 | 208 | ?> |
| 209 | 209 | </select> |
| 210 | 210 | <?php |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | -function wpinv_request( $vars ) { |
|
| 213 | +function wpinv_request($vars) { |
|
| 214 | 214 | global $typenow, $wp_query, $wp_post_statuses; |
| 215 | 215 | |
| 216 | - if ( 'wpi_invoice' === $typenow or 'wpi_quote' === $typenow ) { |
|
| 217 | - if ( !isset( $vars['post_status'] ) ) { |
|
| 216 | + if ('wpi_invoice' === $typenow or 'wpi_quote' === $typenow) { |
|
| 217 | + if (!isset($vars['post_status'])) { |
|
| 218 | 218 | $post_statuses = wpinv_get_invoice_statuses(); |
| 219 | 219 | |
| 220 | - foreach ( $post_statuses as $status => $value ) { |
|
| 221 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
| 222 | - unset( $post_statuses[ $status ] ); |
|
| 220 | + foreach ($post_statuses as $status => $value) { |
|
| 221 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
| 222 | + unset($post_statuses[$status]); |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
| 226 | + $vars['post_status'] = array_keys($post_statuses); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( isset( $vars['orderby'] ) ) { |
|
| 230 | - if ( 'amount' == $vars['orderby'] ) { |
|
| 229 | + if (isset($vars['orderby'])) { |
|
| 230 | + if ('amount' == $vars['orderby']) { |
|
| 231 | 231 | $vars = array_merge( |
| 232 | 232 | $vars, |
| 233 | 233 | array( |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | 'orderby' => 'meta_value_num' |
| 236 | 236 | ) |
| 237 | 237 | ); |
| 238 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
| 238 | + } else if ('customer' == $vars['orderby']) { |
|
| 239 | 239 | $vars = array_merge( |
| 240 | 240 | $vars, |
| 241 | 241 | array( |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | ); |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - } else if ( 'wpi_item' == $typenow ) { |
|
| 248 | + } else if ('wpi_item' == $typenow) { |
|
| 249 | 249 | // Check if 'orderby' is set to "price" |
| 250 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
| 250 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
| 251 | 251 | $vars = array_merge( |
| 252 | 252 | $vars, |
| 253 | 253 | array( |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Check if "orderby" is set to "vat_rule" |
| 261 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
| 261 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
| 262 | 262 | $vars = array_merge( |
| 263 | 263 | $vars, |
| 264 | 264 | array( |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Check if "orderby" is set to "vat_class" |
| 272 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
| 272 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
| 273 | 273 | $vars = array_merge( |
| 274 | 274 | $vars, |
| 275 | 275 | array( |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Check if "orderby" is set to "type" |
| 283 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
| 283 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
| 284 | 284 | $vars = array_merge( |
| 285 | 285 | $vars, |
| 286 | 286 | array( |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Check if "orderby" is set to "recurring" |
| 294 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
| 294 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
| 295 | 295 | $vars = array_merge( |
| 296 | 296 | $vars, |
| 297 | 297 | array( |
@@ -301,120 +301,120 @@ discard block |
||
| 301 | 301 | ); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 304 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 305 | 305 | // Filter vat rule type |
| 306 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
| 306 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
| 307 | 307 | $meta_query[] = array( |
| 308 | 308 | 'key' => '_wpinv_vat_rule', |
| 309 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
| 309 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
| 310 | 310 | 'compare' => '=' |
| 311 | 311 | ); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Filter vat class |
| 315 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
| 315 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
| 316 | 316 | $meta_query[] = array( |
| 317 | 317 | 'key' => '_wpinv_vat_class', |
| 318 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
| 318 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
| 319 | 319 | 'compare' => '=' |
| 320 | 320 | ); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Filter item type |
| 324 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
| 324 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
| 325 | 325 | $meta_query[] = array( |
| 326 | 326 | 'key' => '_wpinv_type', |
| 327 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
| 327 | + 'value' => sanitize_text_field($_GET['type']), |
|
| 328 | 328 | 'compare' => '=' |
| 329 | 329 | ); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if ( !empty( $meta_query ) ) { |
|
| 332 | + if (!empty($meta_query)) { |
|
| 333 | 333 | $vars['meta_query'] = $meta_query; |
| 334 | 334 | } |
| 335 | - } else if ( 'wpi_discount' == $typenow ) { |
|
| 336 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
| 335 | + } else if ('wpi_discount' == $typenow) { |
|
| 336 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
| 337 | 337 | // Filter vat rule type |
| 338 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
| 338 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
| 339 | 339 | $meta_query[] = array( |
| 340 | 340 | 'key' => '_wpi_discount_type', |
| 341 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
| 341 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
| 342 | 342 | 'compare' => '=' |
| 343 | 343 | ); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if ( !empty( $meta_query ) ) { |
|
| 346 | + if (!empty($meta_query)) { |
|
| 347 | 347 | $vars['meta_query'] = $meta_query; |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | return $vars; |
| 352 | 352 | } |
| 353 | -add_filter( 'request', 'wpinv_request' ); |
|
| 353 | +add_filter('request', 'wpinv_request'); |
|
| 354 | 354 | |
| 355 | 355 | function wpinv_options_page() { |
| 356 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 356 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 357 | 357 | |
| 358 | - if ( $page !== 'wpinv-settings' ) { |
|
| 358 | + if ($page !== 'wpinv-settings') { |
|
| 359 | 359 | return; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $settings_tabs = wpinv_get_settings_tabs(); |
| 363 | 363 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
| 364 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
| 365 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 364 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
| 365 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 366 | 366 | $key = 'main'; |
| 367 | 367 | |
| 368 | - if ( is_array( $sections ) ) { |
|
| 369 | - $key = key( $sections ); |
|
| 368 | + if (is_array($sections)) { |
|
| 369 | + $key = key($sections); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 373 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
| 372 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 373 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
| 374 | 374 | ob_start(); |
| 375 | 375 | ?> |
| 376 | 376 | <div class="wrap"> |
| 377 | 377 | <h1 class="nav-tab-wrapper"> |
| 378 | 378 | <?php |
| 379 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
| 380 | - $tab_url = add_query_arg( array( |
|
| 379 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
| 380 | + $tab_url = add_query_arg(array( |
|
| 381 | 381 | 'settings-updated' => false, |
| 382 | 382 | 'tab' => $tab_id, |
| 383 | - ) ); |
|
| 383 | + )); |
|
| 384 | 384 | |
| 385 | 385 | // Remove the section from the tabs so we always end up at the main section |
| 386 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
| 387 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 386 | + $tab_url = remove_query_arg('section', $tab_url); |
|
| 387 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 388 | 388 | |
| 389 | 389 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
| 390 | 390 | |
| 391 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
| 392 | - echo esc_html( $tab_name ); |
|
| 391 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
| 392 | + echo esc_html($tab_name); |
|
| 393 | 393 | echo '</a>'; |
| 394 | 394 | } |
| 395 | 395 | ?> |
| 396 | 396 | </h1> |
| 397 | 397 | <?php |
| 398 | - $number_of_sections = count( $sections ); |
|
| 398 | + $number_of_sections = count($sections); |
|
| 399 | 399 | $number = 0; |
| 400 | - if ( $number_of_sections > 1 ) { |
|
| 400 | + if ($number_of_sections > 1) { |
|
| 401 | 401 | echo '<div><ul class="subsubsub">'; |
| 402 | - foreach( $sections as $section_id => $section_name ) { |
|
| 402 | + foreach ($sections as $section_id => $section_name) { |
|
| 403 | 403 | echo '<li>'; |
| 404 | 404 | $number++; |
| 405 | - $tab_url = add_query_arg( array( |
|
| 405 | + $tab_url = add_query_arg(array( |
|
| 406 | 406 | 'settings-updated' => false, |
| 407 | 407 | 'tab' => $active_tab, |
| 408 | 408 | 'section' => $section_id |
| 409 | - ) ); |
|
| 410 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 409 | + )); |
|
| 410 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 411 | 411 | $class = ''; |
| 412 | - if ( $section == $section_id ) { |
|
| 412 | + if ($section == $section_id) { |
|
| 413 | 413 | $class = 'current'; |
| 414 | 414 | } |
| 415 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
| 415 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
| 416 | 416 | |
| 417 | - if ( $number != $number_of_sections ) { |
|
| 417 | + if ($number != $number_of_sections) { |
|
| 418 | 418 | echo ' | '; |
| 419 | 419 | } |
| 420 | 420 | echo '</li>'; |
@@ -426,19 +426,19 @@ discard block |
||
| 426 | 426 | <form method="post" action="options.php"> |
| 427 | 427 | <table class="form-table"> |
| 428 | 428 | <?php |
| 429 | - settings_fields( 'wpinv_settings' ); |
|
| 429 | + settings_fields('wpinv_settings'); |
|
| 430 | 430 | |
| 431 | - if ( 'main' === $section ) { |
|
| 432 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
| 431 | + if ('main' === $section) { |
|
| 432 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section ); |
|
| 436 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section ); |
|
| 437 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section ); |
|
| 435 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section); |
|
| 436 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section); |
|
| 437 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section); |
|
| 438 | 438 | |
| 439 | 439 | // For backwards compatibility |
| 440 | - if ( 'main' === $section ) { |
|
| 441 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
| 440 | + if ('main' === $section) { |
|
| 441 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
| 442 | 442 | } |
| 443 | 443 | ?> |
| 444 | 444 | </table> |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | echo $content; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
| 454 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
| 455 | 455 | global $pagenow, $typenow; |
| 456 | 456 | |
| 457 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
| 458 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
| 457 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && $type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
| 458 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
| 459 | 459 | } |
| 460 | 460 | return $classes; |
| 461 | 461 | } |
| 462 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
| 463 | 462 | \ No newline at end of file |
| 463 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
| 464 | 464 | \ No newline at end of file |
@@ -7,228 +7,228 @@ 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 | -function wpinv_columns( $columns ) { |
|
| 14 | +function wpinv_columns($columns) { |
|
| 15 | 15 | $columns = array( |
| 16 | 16 | 'cb' => $columns['cb'], |
| 17 | - 'ID' => __( 'ID', 'invoicing' ), |
|
| 18 | - 'details' => __( 'Details', 'invoicing' ), |
|
| 17 | + 'ID' => __('ID', 'invoicing'), |
|
| 18 | + 'details' => __('Details', 'invoicing'), |
|
| 19 | 19 | //'email' => __( 'Email', 'invoicing' ), |
| 20 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 21 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 22 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
| 23 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
| 20 | + 'customer' => __('Customer', 'invoicing'), |
|
| 21 | + 'amount' => __('Amount', 'invoicing'), |
|
| 22 | + 'invoice_date' => __('Date', 'invoicing'), |
|
| 23 | + 'status' => __('Status', 'invoicing'), |
|
| 24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 28 | 28 | } |
| 29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
| 29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
| 30 | 30 | |
| 31 | -function wpinv_bulk_actions( $actions ) { |
|
| 32 | - if ( isset( $actions['edit'] ) ) { |
|
| 33 | - unset( $actions['edit'] ); |
|
| 31 | +function wpinv_bulk_actions($actions) { |
|
| 32 | + if (isset($actions['edit'])) { |
|
| 33 | + unset($actions['edit']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $actions; |
| 37 | 37 | } |
| 38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 39 | 39 | |
| 40 | -function wpinv_sortable_columns( $columns ) { |
|
| 40 | +function wpinv_sortable_columns($columns) { |
|
| 41 | 41 | $columns = array( |
| 42 | - 'ID' => array( 'ID', true ), |
|
| 43 | - 'amount' => array( 'amount', false ), |
|
| 44 | - 'invoice_date' => array( 'date', false ), |
|
| 45 | - 'customer' => array( 'customer', false ), |
|
| 42 | + 'ID' => array('ID', true), |
|
| 43 | + 'amount' => array('amount', false), |
|
| 44 | + 'invoice_date' => array('date', false), |
|
| 45 | + 'customer' => array('customer', false), |
|
| 46 | 46 | ///'email' => array( 'email', false ), |
| 47 | - 'status' => array( 'status', false ), |
|
| 47 | + 'status' => array('status', false), |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
| 50 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
| 51 | 51 | } |
| 52 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
| 52 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
| 53 | 53 | |
| 54 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 55 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
| 54 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 55 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
| 56 | 56 | global $post, $wpi_invoice; |
| 57 | 57 | |
| 58 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
| 59 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
| 58 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
| 59 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $value = NULL; |
| 63 | 63 | |
| 64 | - switch ( $column_name ) { |
|
| 64 | + switch ($column_name) { |
|
| 65 | 65 | case 'email' : |
| 66 | - $value = $wpi_invoice->get_email(); |
|
| 66 | + $value = $wpi_invoice->get_email(); |
|
| 67 | 67 | break; |
| 68 | 68 | case 'customer' : |
| 69 | 69 | $customer_name = $wpi_invoice->get_user_full_name(); |
| 70 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
| 71 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
| 72 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 70 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
| 71 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
| 72 | + if ($email = $wpi_invoice->get_email()) { |
|
| 73 | 73 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
| 74 | 74 | } |
| 75 | 75 | break; |
| 76 | 76 | case 'amount' : |
| 77 | - echo $wpi_invoice->get_total( true ); |
|
| 77 | + echo $wpi_invoice->get_total(true); |
|
| 78 | 78 | break; |
| 79 | 79 | case 'invoice_date' : |
| 80 | - $date_format = get_option( 'date_format' ); |
|
| 81 | - $time_format = get_option( 'time_format' ); |
|
| 82 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 80 | + $date_format = get_option('date_format'); |
|
| 81 | + $time_format = get_option('time_format'); |
|
| 82 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 83 | 83 | |
| 84 | - $t_time = get_the_time( $date_time_format ); |
|
| 84 | + $t_time = get_the_time($date_time_format); |
|
| 85 | 85 | $m_time = $post->post_date; |
| 86 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 86 | + $h_time = mysql2date($date_format, $m_time); |
|
| 87 | 87 | |
| 88 | 88 | $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
| 89 | 89 | break; |
| 90 | 90 | case 'status' : |
| 91 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
| 91 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
| 92 | 92 | break; |
| 93 | 93 | case 'details' : |
| 94 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 95 | - $value = '<a href="' . esc_url( $edit_link ) . '">' . __( 'View Invoice Details', 'invoicing' ) . '</a>'; |
|
| 94 | + $edit_link = get_edit_post_link($post->ID); |
|
| 95 | + $value = '<a href="' . esc_url($edit_link) . '">' . __('View Invoice Details', 'invoicing') . '</a>'; |
|
| 96 | 96 | break; |
| 97 | 97 | case 'wpi_actions' : |
| 98 | 98 | $value = ''; |
| 99 | - if ( !empty( $post->post_name ) ) { |
|
| 100 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 99 | + if (!empty($post->post_name)) { |
|
| 100 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 104 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 103 | + if ($email = $wpi_invoice->get_email()) { |
|
| 104 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | break; |
| 108 | 108 | default: |
| 109 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
| 109 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
| 110 | 110 | break; |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
| 113 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
| 114 | 114 | |
| 115 | - if ( $value !== NULL ) { |
|
| 115 | + if ($value !== NULL) { |
|
| 116 | 116 | echo $value; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 120 | +function wpinv_admin_post_id($id = 0) { |
|
| 121 | 121 | global $post; |
| 122 | 122 | |
| 123 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 123 | + if (isset($id) && !empty($id)) { |
|
| 124 | 124 | return (int)$id; |
| 125 | - } else if ( get_the_ID() ) { |
|
| 126 | - return (int) get_the_ID(); |
|
| 127 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 128 | - return (int) $post->ID; |
|
| 129 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 130 | - return (int) $_GET['post']; |
|
| 131 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 132 | - return (int) $_GET['id']; |
|
| 133 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 134 | - return (int) $_POST['id']; |
|
| 125 | + } else if (get_the_ID()) { |
|
| 126 | + return (int)get_the_ID(); |
|
| 127 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 128 | + return (int)$post->ID; |
|
| 129 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 130 | + return (int)$_GET['post']; |
|
| 131 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 132 | + return (int)$_GET['id']; |
|
| 133 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 134 | + return (int)$_POST['id']; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return null; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 141 | - if ( !$id ) { |
|
| 140 | +function wpinv_admin_post_type($id = 0) { |
|
| 141 | + if (!$id) { |
|
| 142 | 142 | $id = wpinv_admin_post_id(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $type = get_post_type( $id ); |
|
| 145 | + $type = get_post_type($id); |
|
| 146 | 146 | |
| 147 | - if ( !$type ) { |
|
| 148 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 147 | + if (!$type) { |
|
| 148 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 151 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function wpinv_admin_messages() { |
| 155 | 155 | global $wpinv_options; |
| 156 | 156 | |
| 157 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 158 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 157 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 158 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 162 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 161 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 162 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 166 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 165 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 166 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 170 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 169 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 170 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 174 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 173 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 174 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 177 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 178 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 181 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 182 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 186 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 185 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 186 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 190 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
| 189 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 190 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 193 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 194 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 197 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 198 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 201 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 202 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - settings_errors( 'wpinv-notices' ); |
|
| 205 | + settings_errors('wpinv-notices'); |
|
| 206 | 206 | } |
| 207 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 207 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 208 | 208 | |
| 209 | -function wpinv_items_columns( $existing_columns ) { |
|
| 209 | +function wpinv_items_columns($existing_columns) { |
|
| 210 | 210 | global $wpinv_euvat; |
| 211 | 211 | |
| 212 | 212 | $columns = array(); |
| 213 | 213 | $columns['cb'] = $existing_columns['cb']; |
| 214 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
| 215 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
| 216 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 217 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
| 214 | + $columns['title'] = __('Title', 'invoicing'); |
|
| 215 | + $columns['price'] = __('Price', 'invoicing'); |
|
| 216 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 217 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
| 218 | 218 | } |
| 219 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 220 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
| 219 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 220 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
| 221 | 221 | } |
| 222 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
| 223 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
| 224 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
| 225 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
| 222 | + $columns['type'] = __('Type', 'invoicing'); |
|
| 223 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
| 224 | + $columns['date'] = __('Date', 'invoicing'); |
|
| 225 | + $columns['id'] = __('ID', 'invoicing'); |
|
| 226 | 226 | |
| 227 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
| 227 | + return apply_filters('wpinv_items_columns', $columns); |
|
| 228 | 228 | } |
| 229 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
| 229 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
| 230 | 230 | |
| 231 | -function wpinv_items_sortable_columns( $columns ) { |
|
| 231 | +function wpinv_items_sortable_columns($columns) { |
|
| 232 | 232 | $columns['price'] = 'price'; |
| 233 | 233 | $columns['vat_rule'] = 'vat_rule'; |
| 234 | 234 | $columns['vat_class'] = 'vat_class'; |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | return $columns; |
| 240 | 240 | } |
| 241 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
| 241 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
| 242 | 242 | |
| 243 | -function wpinv_item_quick_edit( $column_name, $post_type ) { |
|
| 244 | - if ( !( $post_type == 'wpi_item' && $column_name == 'price' ) ) { |
|
| 243 | +function wpinv_item_quick_edit($column_name, $post_type) { |
|
| 244 | + if (!($post_type == 'wpi_item' && $column_name == 'price')) { |
|
| 245 | 245 | return; |
| 246 | 246 | } |
| 247 | 247 | global $wpinv_euvat, $post; |
@@ -249,23 +249,23 @@ discard block |
||
| 249 | 249 | $symbol = wpinv_currency_symbol(); |
| 250 | 250 | $position = wpinv_currency_position(); |
| 251 | 251 | |
| 252 | - $price = wpinv_get_item_price( $post->ID ); |
|
| 253 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
| 252 | + $price = wpinv_get_item_price($post->ID); |
|
| 253 | + $item_type = wpinv_get_item_type($post->ID); |
|
| 254 | 254 | ?> |
| 255 | 255 | <fieldset class="inline-edit-col-right wpi-inline-item-col"> |
| 256 | 256 | <div class="inline-edit-col"> |
| 257 | 257 | <div class="inline-edit-group wp-clearfix"> |
| 258 | 258 | <label class="inline-edit-wpinv-price"> |
| 259 | - <span class="title"><?php _e( 'Item price', 'invoicing' );?></span> |
|
| 260 | - <span class="input-text-wrap"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID;?>"><?php echo ( $position == 'right' ? $symbol . ' ' : '' );?></span> |
|
| 259 | + <span class="title"><?php _e('Item price', 'invoicing'); ?></span> |
|
| 260 | + <span class="input-text-wrap"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID; ?>"><?php echo ($position == 'right' ? $symbol . ' ' : ''); ?></span> |
|
| 261 | 261 | </label> |
| 262 | 262 | </div> |
| 263 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); ?> |
|
| 263 | + <?php if ($wpinv_euvat->allow_vat_rules()) { $rule_type = $wpinv_euvat->get_item_rule($post->ID); ?> |
|
| 264 | 264 | <div class="inline-edit-group wp-clearfix"> |
| 265 | 265 | <label class="inline-edit-wpinv-vat-rate"> |
| 266 | - <span class="title"><?php _e( 'VAT rule type to use', 'invoicing' );?></span> |
|
| 266 | + <span class="title"><?php _e('VAT rule type to use', 'invoicing'); ?></span> |
|
| 267 | 267 | <span class="input-text-wrap"> |
| 268 | - <?php echo wpinv_html_select( array( |
|
| 268 | + <?php echo wpinv_html_select(array( |
|
| 269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
| 270 | 270 | 'name' => '_wpinv_vat_rules', |
| 271 | 271 | 'id' => 'wpinv_vat_rules-' . $post->ID, |
@@ -273,16 +273,16 @@ discard block |
||
| 273 | 273 | 'show_option_all' => false, |
| 274 | 274 | 'show_option_none' => false, |
| 275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
| 276 | - ) ); ?> |
|
| 276 | + )); ?> |
|
| 277 | 277 | </span> |
| 278 | 278 | </label> |
| 279 | 279 | </div> |
| 280 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { $vat_class = $wpinv_euvat->get_item_class( $post->ID ); ?> |
|
| 280 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { $vat_class = $wpinv_euvat->get_item_class($post->ID); ?> |
|
| 281 | 281 | <div class="inline-edit-group wp-clearfix"> |
| 282 | 282 | <label class="inline-edit-wpinv-vat-class"> |
| 283 | - <span class="title"><?php _e( 'VAT class to use', 'invoicing' );?></span> |
|
| 283 | + <span class="title"><?php _e('VAT class to use', 'invoicing'); ?></span> |
|
| 284 | 284 | <span class="input-text-wrap"> |
| 285 | - <?php echo wpinv_html_select( array( |
|
| 285 | + <?php echo wpinv_html_select(array( |
|
| 286 | 286 | 'options' => $wpinv_euvat->get_all_classes(), |
| 287 | 287 | 'name' => '_wpinv_vat_class', |
| 288 | 288 | 'id' => 'wpinv_vat_class-' . $post->ID, |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | 'show_option_all' => false, |
| 291 | 291 | 'show_option_none' => false, |
| 292 | 292 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
| 293 | - ) ); ?> |
|
| 293 | + )); ?> |
|
| 294 | 294 | </span> |
| 295 | 295 | </label> |
| 296 | 296 | </div> |
| 297 | 297 | <?php } ?> |
| 298 | 298 | <div class="inline-edit-group wp-clearfix"> |
| 299 | 299 | <label class="inline-edit-wpinv-type"> |
| 300 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
| 300 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
| 301 | 301 | <span class="input-text-wrap"> |
| 302 | - <?php echo wpinv_html_select( array( |
|
| 302 | + <?php echo wpinv_html_select(array( |
|
| 303 | 303 | 'options' => wpinv_get_item_types(), |
| 304 | 304 | 'name' => '_wpinv_item_type', |
| 305 | 305 | 'id' => 'wpinv_item_type-' . $post->ID, |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | 'show_option_all' => false, |
| 308 | 308 | 'show_option_none' => false, |
| 309 | 309 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
| 310 | - ) ); ?> |
|
| 310 | + )); ?> |
|
| 311 | 311 | </span> |
| 312 | 312 | </label> |
| 313 | 313 | </div> |
@@ -315,157 +315,157 @@ discard block |
||
| 315 | 315 | </fieldset> |
| 316 | 316 | <?php |
| 317 | 317 | } |
| 318 | -add_action( 'quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
| 319 | -add_action( 'bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
| 318 | +add_action('quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
| 319 | +add_action('bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
| 320 | 320 | |
| 321 | -function wpinv_items_table_custom_column( $column ) { |
|
| 321 | +function wpinv_items_table_custom_column($column) { |
|
| 322 | 322 | global $wpinv_euvat, $post, $wpi_item; |
| 323 | 323 | |
| 324 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
| 325 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
| 324 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
| 325 | + $wpi_item = new WPInv_Item($post->ID); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - switch ( $column ) { |
|
| 328 | + switch ($column) { |
|
| 329 | 329 | case 'price' : |
| 330 | - echo wpinv_item_price( $post->ID ); |
|
| 330 | + echo wpinv_item_price($post->ID); |
|
| 331 | 331 | break; |
| 332 | 332 | case 'vat_rule' : |
| 333 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
| 333 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
| 334 | 334 | break; |
| 335 | 335 | case 'vat_class' : |
| 336 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
| 336 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
| 337 | 337 | break; |
| 338 | 338 | case 'type' : |
| 339 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_cpt_singular_name() . '</span>'; |
|
| 339 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_cpt_singular_name() . '</span>'; |
|
| 340 | 340 | break; |
| 341 | 341 | case 'recurring' : |
| 342 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
| 342 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
| 343 | 343 | break; |
| 344 | 344 | case 'id' : |
| 345 | 345 | echo $post->ID; |
| 346 | 346 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
| 347 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
| 348 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 349 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
| 347 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
| 348 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 349 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
| 350 | 350 | } |
| 351 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 352 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
| 351 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 352 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
| 353 | 353 | } |
| 354 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
| 354 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
| 355 | 355 | </div>'; |
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
| 359 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
| 360 | 360 | } |
| 361 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
| 361 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
| 362 | 362 | |
| 363 | 363 | function wpinv_add_items_filters() { |
| 364 | 364 | global $wpinv_euvat, $typenow; |
| 365 | 365 | |
| 366 | 366 | // Checks if the current post type is 'item' |
| 367 | - if ( $typenow == 'wpi_item') { |
|
| 368 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 369 | - echo wpinv_html_select( array( |
|
| 370 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
| 367 | + if ($typenow == 'wpi_item') { |
|
| 368 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 369 | + echo wpinv_html_select(array( |
|
| 370 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
| 371 | 371 | 'name' => 'vat_rule', |
| 372 | 372 | 'id' => 'vat_rule', |
| 373 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
| 373 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
| 374 | 374 | 'show_option_all' => false, |
| 375 | 375 | 'show_option_none' => false, |
| 376 | 376 | 'class' => 'gdmbx2-text-medium', |
| 377 | - ) ); |
|
| 377 | + )); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 381 | - echo wpinv_html_select( array( |
|
| 382 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
| 380 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 381 | + echo wpinv_html_select(array( |
|
| 382 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
| 383 | 383 | 'name' => 'vat_class', |
| 384 | 384 | 'id' => 'vat_class', |
| 385 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
| 385 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
| 386 | 386 | 'show_option_all' => false, |
| 387 | 387 | 'show_option_none' => false, |
| 388 | 388 | 'class' => 'gdmbx2-text-medium', |
| 389 | - ) ); |
|
| 389 | + )); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - echo wpinv_html_select( array( |
|
| 393 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
| 392 | + echo wpinv_html_select(array( |
|
| 393 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
| 394 | 394 | 'name' => 'type', |
| 395 | 395 | 'id' => 'type', |
| 396 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
| 396 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
| 397 | 397 | 'show_option_all' => false, |
| 398 | 398 | 'show_option_none' => false, |
| 399 | 399 | 'class' => 'gdmbx2-text-medium', |
| 400 | - ) ); |
|
| 400 | + )); |
|
| 401 | 401 | |
| 402 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
| 402 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
| 403 | 403 | echo '<input type="hidden" name="all_posts" value="1" />'; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
| 407 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
| 408 | 408 | |
| 409 | -function wpinv_send_invoice_after_save( $post_id ) { |
|
| 409 | +function wpinv_send_invoice_after_save($post_id) { |
|
| 410 | 410 | // If this is just a revision, don't send the email. |
| 411 | - if ( wp_is_post_revision( $post_id ) ) { |
|
| 411 | + if (wp_is_post_revision($post_id)) { |
|
| 412 | 412 | return; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if ( !current_user_can( 'manage_options' ) || !(get_post_type( $post_id ) == 'wpi_invoice') ) { |
|
| 415 | + if (!current_user_can('manage_options') || !(get_post_type($post_id) == 'wpi_invoice')) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( !empty( $_POST['wpi_save_send'] ) ) { |
|
| 420 | - wpinv_user_invoice_notification( $post_id ); |
|
| 419 | + if (!empty($_POST['wpi_save_send'])) { |
|
| 420 | + wpinv_user_invoice_notification($post_id); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | -add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 423 | +add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 424 | 424 | |
| 425 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
| 426 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ($data['post_type'] == 'wpi_invoice' || $data['post_type'] == 'wpi_quote') ) { |
|
| 427 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
| 428 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
| 425 | +function wpinv_send_register_new_user($data, $postarr) { |
|
| 426 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ($data['post_type'] == 'wpi_invoice' || $data['post_type'] == 'wpi_quote')) { |
|
| 427 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
| 428 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
| 429 | 429 | |
| 430 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
| 431 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
| 432 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
| 433 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
| 434 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
| 435 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
| 430 | + if ($is_new_user && $email && !email_exists($email)) { |
|
| 431 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
| 432 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
| 433 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
| 434 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
| 435 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
| 436 | 436 | |
| 437 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
| 438 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 437 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
| 438 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 439 | 439 | $new_user_login = strstr($email, '@', true); |
| 440 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 441 | - $user_login = sanitize_user($new_user_login, true ); |
|
| 440 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 441 | + $user_login = sanitize_user($new_user_login, true); |
|
| 442 | 442 | } |
| 443 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 444 | - $user_append_text = rand(10,1000); |
|
| 445 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
| 443 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 444 | + $user_append_text = rand(10, 1000); |
|
| 445 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 448 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 449 | 449 | $user_login = $email; |
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $userdata = array( |
| 454 | 454 | 'user_login' => $user_login, |
| 455 | - 'user_pass' => wp_generate_password( 12, false ), |
|
| 456 | - 'user_email' => sanitize_text_field( $email ), |
|
| 455 | + 'user_pass' => wp_generate_password(12, false), |
|
| 456 | + 'user_email' => sanitize_text_field($email), |
|
| 457 | 457 | 'first_name' => $first_name, |
| 458 | 458 | 'last_name' => $last_name, |
| 459 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
| 459 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
| 460 | 460 | 'nickname' => $display_name, |
| 461 | 461 | 'display_name' => $display_name, |
| 462 | 462 | ); |
| 463 | 463 | |
| 464 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
| 464 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
| 465 | 465 | |
| 466 | - $new_user_id = wp_insert_user( $userdata ); |
|
| 466 | + $new_user_id = wp_insert_user($userdata); |
|
| 467 | 467 | |
| 468 | - if ( !is_wp_error( $new_user_id ) ) { |
|
| 468 | + if (!is_wp_error($new_user_id)) { |
|
| 469 | 469 | $data['post_author'] = $new_user_id; |
| 470 | 470 | $_POST['post_author'] = $new_user_id; |
| 471 | 471 | $_POST['post_author_override'] = $new_user_id; |
@@ -486,27 +486,27 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | $meta = array(); |
| 488 | 488 | ///$meta['_wpinv_user_id'] = $new_user_id; |
| 489 | - foreach ( $meta_fields as $field ) { |
|
| 490 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
| 489 | + foreach ($meta_fields as $field) { |
|
| 490 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
| 493 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
| 494 | 494 | |
| 495 | 495 | // Update user meta. |
| 496 | - foreach ( $meta as $key => $value ) { |
|
| 497 | - update_user_meta( $new_user_id, $key, $value ); |
|
| 496 | + foreach ($meta as $key => $value) { |
|
| 497 | + update_user_meta($new_user_id, $key, $value); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
| 500 | + if (function_exists('wp_send_new_user_notifications')) { |
|
| 501 | 501 | // Send email notifications related to the creation of new user. |
| 502 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
| 502 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
| 503 | 503 | } |
| 504 | 504 | } else { |
| 505 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
| 505 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | return $data; |
| 511 | 511 | } |
| 512 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
| 513 | 512 | \ No newline at end of file |
| 513 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
| 514 | 514 | \ No newline at end of file |
@@ -1,66 +1,66 @@ 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 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 7 | +function wpinv_get_option($key = '', $default = false) { |
|
| 8 | 8 | global $wpinv_options; |
| 9 | 9 | |
| 10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
| 11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
| 11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 12 | 12 | |
| 13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 16 | +function wpinv_update_option($key = '', $value = false) { |
|
| 17 | 17 | // If no key, exit |
| 18 | - if ( empty( $key ) ) { |
|
| 18 | + if (empty($key)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if ( empty( $value ) ) { |
|
| 23 | - $remove_option = wpinv_delete_option( $key ); |
|
| 22 | + if (empty($value)) { |
|
| 23 | + $remove_option = wpinv_delete_option($key); |
|
| 24 | 24 | return $remove_option; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // First let's grab the current settings |
| 28 | - $options = get_option( 'wpinv_settings' ); |
|
| 28 | + $options = get_option('wpinv_settings'); |
|
| 29 | 29 | |
| 30 | 30 | // Let's let devs alter that value coming in |
| 31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
| 32 | 32 | |
| 33 | 33 | // Next let's try to update the value |
| 34 | - $options[ $key ] = $value; |
|
| 35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 34 | + $options[$key] = $value; |
|
| 35 | + $did_update = update_option('wpinv_settings', $options); |
|
| 36 | 36 | |
| 37 | 37 | // If it updated, let's update the global variable |
| 38 | - if ( $did_update ) { |
|
| 38 | + if ($did_update) { |
|
| 39 | 39 | global $wpinv_options; |
| 40 | - $wpinv_options[ $key ] = $value; |
|
| 40 | + $wpinv_options[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $did_update; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function wpinv_delete_option( $key = '' ) { |
|
| 46 | +function wpinv_delete_option($key = '') { |
|
| 47 | 47 | // If no key, exit |
| 48 | - if ( empty( $key ) ) { |
|
| 48 | + if (empty($key)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // First let's grab the current settings |
| 53 | - $options = get_option( 'wpinv_settings' ); |
|
| 53 | + $options = get_option('wpinv_settings'); |
|
| 54 | 54 | |
| 55 | 55 | // Next let's try to update the value |
| 56 | - if( isset( $options[ $key ] ) ) { |
|
| 57 | - unset( $options[ $key ] ); |
|
| 56 | + if (isset($options[$key])) { |
|
| 57 | + unset($options[$key]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 60 | + $did_update = update_option('wpinv_settings', $options); |
|
| 61 | 61 | |
| 62 | 62 | // If it updated, let's update the global variable |
| 63 | - if ( $did_update ){ |
|
| 63 | + if ($did_update) { |
|
| 64 | 64 | global $wpinv_options; |
| 65 | 65 | $wpinv_options = $options; |
| 66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_get_settings() { |
| 72 | - $settings = get_option( 'wpinv_settings' ); |
|
| 72 | + $settings = get_option('wpinv_settings'); |
|
| 73 | 73 | |
| 74 | - if ( empty( $settings ) ) { |
|
| 74 | + if (empty($settings)) { |
|
| 75 | 75 | // Update old settings with new single option |
| 76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
| 77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
| 78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
| 79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
| 80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
| 81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
| 76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
| 77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
| 78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
| 79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
| 80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
| 81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
| 82 | 82 | |
| 83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
| 83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
| 84 | 84 | |
| 85 | - update_option( 'wpinv_settings', $settings ); |
|
| 85 | + update_option('wpinv_settings', $settings); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
| 88 | + return apply_filters('wpinv_get_settings', $settings); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_register_settings() { |
| 92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
| 93 | - add_option( 'wpinv_settings' ); |
|
| 92 | + if (false == get_option('wpinv_settings')) { |
|
| 93 | + add_option('wpinv_settings'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $register_settings = wpinv_get_registered_settings(); |
| 97 | 97 | |
| 98 | - foreach ( $register_settings as $tab => $sections ) { |
|
| 99 | - foreach ( $sections as $section => $settings) { |
|
| 98 | + foreach ($register_settings as $tab => $sections) { |
|
| 99 | + foreach ($sections as $section => $settings) { |
|
| 100 | 100 | // Check for backwards compatibility |
| 101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 103 | 103 | $section = 'main'; |
| 104 | 104 | $settings = $sections; |
| 105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
| 111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - foreach ( $settings as $option ) { |
|
| 114 | + foreach ($settings as $option) { |
|
| 115 | 115 | // For backwards compatibility |
| 116 | - if ( empty( $option['id'] ) ) { |
|
| 116 | + if (empty($option['id'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 121 | 121 | |
| 122 | 122 | add_settings_field( |
| 123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
| 124 | 124 | $name, |
| 125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
| 127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
| 128 | 128 | array( |
| 129 | 129 | 'section' => $section, |
| 130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
| 131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
| 132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
| 133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
| 138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
| 139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
| 140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
| 141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
| 147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
| 148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
| 131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
| 132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
| 133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
| 138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
| 139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
| 140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
| 141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
| 146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
| 147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
| 148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | } |
@@ -154,21 +154,21 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Creates our settings in the options table |
| 157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 158 | 158 | } |
| 159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 160 | 160 | |
| 161 | 161 | function wpinv_get_registered_settings() { |
| 162 | - $pages = wpinv_get_pages( true ); |
|
| 162 | + $pages = wpinv_get_pages(true); |
|
| 163 | 163 | |
| 164 | 164 | $due_payment_options = array(); |
| 165 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
| 166 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
| 165 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
| 166 | + for ($i = 1; $i <= 30; $i++) { |
|
| 167 | 167 | $due_payment_options[$i] = $i; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $invoice_number_padd_options = array(); |
| 171 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
| 171 | + for ($i = 0; $i <= 20; $i++) { |
|
| 172 | 172 | $invoice_number_padd_options[$i] = $i; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,141 +177,141 @@ discard block |
||
| 177 | 177 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 178 | 178 | $alert_wrapper_close = '</p>'; |
| 179 | 179 | $wpinv_settings = array( |
| 180 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 180 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 181 | 181 | array( |
| 182 | 182 | 'main' => array( |
| 183 | 183 | 'location_settings' => array( |
| 184 | 184 | 'id' => 'location_settings', |
| 185 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 185 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 186 | 186 | 'desc' => '', |
| 187 | 187 | 'type' => 'header', |
| 188 | 188 | ), |
| 189 | 189 | 'default_country' => array( |
| 190 | 190 | 'id' => 'default_country', |
| 191 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 192 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 191 | + 'name' => __('Default Country', 'invoicing'), |
|
| 192 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 193 | 193 | 'type' => 'select', |
| 194 | 194 | 'options' => wpinv_get_country_list(), |
| 195 | 195 | 'std' => 'GB', |
| 196 | 196 | 'chosen' => true, |
| 197 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 197 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 198 | 198 | ), |
| 199 | 199 | 'default_state' => array( |
| 200 | 200 | 'id' => 'default_state', |
| 201 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 201 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 202 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 203 | 203 | 'type' => 'country_states', |
| 204 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 204 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 205 | 205 | ), |
| 206 | 206 | 'store_name' => array( |
| 207 | 207 | 'id' => 'store_name', |
| 208 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 209 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 208 | + 'name' => __('Store Name', 'invoicing'), |
|
| 209 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 210 | 210 | 'std' => get_option('blogname'), |
| 211 | 211 | 'type' => 'text', |
| 212 | 212 | ), |
| 213 | 213 | 'logo' => array( |
| 214 | 214 | 'id' => 'logo', |
| 215 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 216 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 215 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 216 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 217 | 217 | 'type' => 'text', |
| 218 | 218 | ), |
| 219 | 219 | 'store_address' => array( |
| 220 | 220 | 'id' => 'store_address', |
| 221 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 222 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 221 | + 'name' => __('Store Address', 'invoicing'), |
|
| 222 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 223 | 223 | 'type' => 'textarea', |
| 224 | 224 | ), |
| 225 | 225 | 'page_settings' => array( |
| 226 | 226 | 'id' => 'page_settings', |
| 227 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | ), |
| 231 | 231 | 'checkout_page' => array( |
| 232 | 232 | 'id' => 'checkout_page', |
| 233 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 234 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 233 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 234 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 235 | 235 | 'type' => 'select', |
| 236 | 236 | 'options' => $pages, |
| 237 | 237 | 'chosen' => true, |
| 238 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 238 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 239 | 239 | ), |
| 240 | 240 | 'success_page' => array( |
| 241 | 241 | 'id' => 'success_page', |
| 242 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 243 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 242 | + 'name' => __('Success Page', 'invoicing'), |
|
| 243 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 244 | 244 | 'type' => 'select', |
| 245 | 245 | 'options' => $pages, |
| 246 | 246 | 'chosen' => true, |
| 247 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 247 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 248 | 248 | ), |
| 249 | 249 | 'failure_page' => array( |
| 250 | 250 | 'id' => 'failure_page', |
| 251 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 252 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ), |
|
| 251 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 252 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'), |
|
| 253 | 253 | 'type' => 'select', |
| 254 | 254 | 'options' => $pages, |
| 255 | 255 | 'chosen' => true, |
| 256 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 256 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 257 | 257 | ), |
| 258 | 258 | 'invoice_history_page' => array( |
| 259 | 259 | 'id' => 'invoice_history_page', |
| 260 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 261 | - 'desc' => __( 'This page shows a invoice history for the current user', 'invoicing' ), |
|
| 260 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 261 | + 'desc' => __('This page shows a invoice history for the current user', 'invoicing'), |
|
| 262 | 262 | 'type' => 'select', |
| 263 | 263 | 'options' => $pages, |
| 264 | 264 | 'chosen' => true, |
| 265 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 265 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 266 | 266 | ) |
| 267 | 267 | ), |
| 268 | 268 | 'currency_section' => array( |
| 269 | 269 | 'currency_settings' => array( |
| 270 | 270 | 'id' => 'currency_settings', |
| 271 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 271 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 272 | 272 | 'desc' => '', |
| 273 | 273 | 'type' => 'header', |
| 274 | 274 | ), |
| 275 | 275 | 'currency' => array( |
| 276 | 276 | 'id' => 'currency', |
| 277 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 278 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 277 | + 'name' => __('Currency', 'invoicing'), |
|
| 278 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 279 | 279 | 'type' => 'select', |
| 280 | 280 | 'options' => wpinv_get_currencies(), |
| 281 | 281 | 'chosen' => true, |
| 282 | 282 | ), |
| 283 | 283 | 'currency_position' => array( |
| 284 | 284 | 'id' => 'currency_position', |
| 285 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 286 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 285 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 286 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 287 | 287 | 'type' => 'select', |
| 288 | 288 | 'options' => array( |
| 289 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
| 290 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
| 291 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
| 292 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
| 289 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
| 290 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
| 291 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
| 292 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
| 293 | 293 | ) |
| 294 | 294 | ), |
| 295 | 295 | 'thousands_separator' => array( |
| 296 | 296 | 'id' => 'thousands_separator', |
| 297 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 298 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 297 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 298 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 299 | 299 | 'type' => 'text', |
| 300 | 300 | 'size' => 'small', |
| 301 | 301 | 'std' => ',', |
| 302 | 302 | ), |
| 303 | 303 | 'decimal_separator' => array( |
| 304 | 304 | 'id' => 'decimal_separator', |
| 305 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 306 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 305 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 306 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 307 | 307 | 'type' => 'text', |
| 308 | 308 | 'size' => 'small', |
| 309 | 309 | 'std' => '.', |
| 310 | 310 | ), |
| 311 | 311 | 'decimals' => array( |
| 312 | 312 | 'id' => 'decimals', |
| 313 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 314 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 313 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 314 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 315 | 315 | 'type' => 'number', |
| 316 | 316 | 'size' => 'small', |
| 317 | 317 | 'std' => '2', |
@@ -323,29 +323,29 @@ discard block |
||
| 323 | 323 | 'labels' => array( |
| 324 | 324 | 'labels' => array( |
| 325 | 325 | 'id' => 'labels_settings', |
| 326 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 326 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 327 | 327 | 'desc' => '', |
| 328 | 328 | 'type' => 'header', |
| 329 | 329 | ), |
| 330 | 330 | 'vat_name' => array( |
| 331 | 331 | 'id' => 'vat_name', |
| 332 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
| 333 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
| 332 | + 'name' => __('VAT Name', 'invoicing'), |
|
| 333 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
| 334 | 334 | 'type' => 'text', |
| 335 | 335 | 'size' => 'regular', |
| 336 | 336 | 'std' => 'VAT' |
| 337 | 337 | ), |
| 338 | 338 | 'vat_invoice_notice_label' => array( |
| 339 | 339 | 'id' => 'vat_invoice_notice_label', |
| 340 | - 'name' => __( 'Invoice notice label', 'invoicing' ), |
|
| 341 | - 'desc' => __( 'Use this to add a invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 340 | + 'name' => __('Invoice notice label', 'invoicing'), |
|
| 341 | + 'desc' => __('Use this to add a invoice notice section (label) to your invoices', 'invoicing'), |
|
| 342 | 342 | 'type' => 'text', |
| 343 | 343 | 'size' => 'regular', |
| 344 | 344 | ), |
| 345 | 345 | 'vat_invoice_notice' => array( |
| 346 | 346 | 'id' => 'vat_invoice_notice', |
| 347 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 348 | - 'desc' => __( 'Use this to add a invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 347 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 348 | + 'desc' => __('Use this to add a invoice notice section (description) to your invoices', 'invoicing'), |
|
| 349 | 349 | 'type' => 'text', |
| 350 | 350 | 'size' => 'regular', |
| 351 | 351 | ) |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | 'main' => array( |
| 358 | 358 | 'gateway_settings' => array( |
| 359 | 359 | 'id' => 'api_header', |
| 360 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 360 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 361 | 361 | 'desc' => '', |
| 362 | 362 | 'type' => 'header', |
| 363 | 363 | ), |
| 364 | 364 | 'gateways' => array( |
| 365 | 365 | 'id' => 'gateways', |
| 366 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 367 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 366 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 367 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 368 | 368 | 'type' => 'gateways', |
| 369 | 369 | 'std' => array('manual'=>1), |
| 370 | 370 | 'options' => wpinv_get_payment_gateways(), |
| 371 | 371 | ), |
| 372 | 372 | 'default_gateway' => array( |
| 373 | 373 | 'id' => 'default_gateway', |
| 374 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 375 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 374 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 375 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 376 | 376 | 'type' => 'gateway_select', |
| 377 | 377 | 'std' => 'manual', |
| 378 | 378 | 'options' => wpinv_get_payment_gateways(), |
@@ -386,19 +386,19 @@ discard block |
||
| 386 | 386 | 'main' => array( |
| 387 | 387 | 'tax_settings' => array( |
| 388 | 388 | 'id' => 'tax_settings', |
| 389 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 389 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 390 | 390 | 'type' => 'header', |
| 391 | 391 | ), |
| 392 | 392 | 'enable_taxes' => array( |
| 393 | 393 | 'id' => 'enable_taxes', |
| 394 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 395 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
| 394 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 395 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
| 396 | 396 | 'type' => 'checkbox', |
| 397 | 397 | ), |
| 398 | 398 | 'tax_rate' => array( |
| 399 | 399 | 'id' => 'tax_rate', |
| 400 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 401 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 400 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 401 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 402 | 402 | 'type' => 'number', |
| 403 | 403 | 'size' => 'small', |
| 404 | 404 | 'min' => '0', |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | 'rates' => array( |
| 411 | 411 | 'tax_rates' => array( |
| 412 | 412 | 'id' => 'tax_rates', |
| 413 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 414 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 413 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 414 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 415 | 415 | 'type' => 'tax_rates', |
| 416 | 416 | ), |
| 417 | 417 | ) |
@@ -423,62 +423,62 @@ discard block |
||
| 423 | 423 | 'main' => array( |
| 424 | 424 | 'email_settings_header' => array( |
| 425 | 425 | 'id' => 'email_settings_header', |
| 426 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 426 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 427 | 427 | 'type' => 'header', |
| 428 | 428 | ), |
| 429 | 429 | 'email_from_name' => array( |
| 430 | 430 | 'id' => 'email_from_name', |
| 431 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 432 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 433 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 431 | + 'name' => __('From Name', 'invoicing'), |
|
| 432 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 433 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 434 | 434 | 'type' => 'text', |
| 435 | 435 | ), |
| 436 | 436 | 'email_from' => array( |
| 437 | 437 | 'id' => 'email_from', |
| 438 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 439 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | - 'std' => get_option( 'admin_email' ), |
|
| 438 | + 'name' => __('From Email', 'invoicing'), |
|
| 439 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 440 | + 'std' => get_option('admin_email'), |
|
| 441 | 441 | 'type' => 'text', |
| 442 | 442 | ), |
| 443 | 443 | 'overdue_settings_header' => array( |
| 444 | 444 | 'id' => 'overdue_settings_header', |
| 445 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 445 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 446 | 446 | 'type' => 'header', |
| 447 | 447 | ), |
| 448 | 448 | 'overdue_active' => array( |
| 449 | 449 | 'id' => 'overdue_active', |
| 450 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 451 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 450 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 451 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 452 | 452 | 'type' => 'checkbox', |
| 453 | 453 | 'std' => false, |
| 454 | 454 | ), |
| 455 | 455 | 'overdue_days' => array( |
| 456 | 456 | 'id' => 'overdue_days', |
| 457 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
| 458 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
| 457 | + 'name' => __('Default Due Date', 'invoicing'), |
|
| 458 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
| 459 | 459 | 'type' => 'select', |
| 460 | 460 | 'options' => $due_payment_options, |
| 461 | 461 | 'chosen' => true, |
| 462 | 462 | 'std' => 0, |
| 463 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 463 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 464 | 464 | ), |
| 465 | 465 | 'email_template_header' => array( |
| 466 | 466 | 'id' => 'email_template_header', |
| 467 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 467 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 468 | 468 | 'type' => 'header', |
| 469 | 469 | ), |
| 470 | 470 | 'email_header_image' => array( |
| 471 | 471 | 'id' => 'email_header_image', |
| 472 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 473 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 472 | + 'name' => __('Header Image', 'invoicing'), |
|
| 473 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 474 | 474 | 'std' => '', |
| 475 | 475 | 'type' => 'text', |
| 476 | 476 | ), |
| 477 | 477 | 'email_footer_text' => array( |
| 478 | 478 | 'id' => 'email_footer_text', |
| 479 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 480 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 481 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
| 479 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 480 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 481 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
| 482 | 482 | 'type' => 'textarea', |
| 483 | 483 | 'class' => 'regular-text', |
| 484 | 484 | 'rows' => 2, |
@@ -486,29 +486,29 @@ discard block |
||
| 486 | 486 | ), |
| 487 | 487 | 'email_base_color' => array( |
| 488 | 488 | 'id' => 'email_base_color', |
| 489 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 490 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 489 | + 'name' => __('Base Color', 'invoicing'), |
|
| 490 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 491 | 491 | 'std' => '#557da2', |
| 492 | 492 | 'type' => 'color', |
| 493 | 493 | ), |
| 494 | 494 | 'email_background_color' => array( |
| 495 | 495 | 'id' => 'email_background_color', |
| 496 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 497 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 496 | + 'name' => __('Background Color', 'invoicing'), |
|
| 497 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 498 | 498 | 'std' => '#f5f5f5', |
| 499 | 499 | 'type' => 'color', |
| 500 | 500 | ), |
| 501 | 501 | 'email_body_background_color' => array( |
| 502 | 502 | 'id' => 'email_body_background_color', |
| 503 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 504 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 503 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 504 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 505 | 505 | 'std' => '#fdfdfd', |
| 506 | 506 | 'type' => 'color', |
| 507 | 507 | ), |
| 508 | 508 | 'email_text_color' => array( |
| 509 | 509 | 'id' => 'email_text_color', |
| 510 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 511 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 510 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 511 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 512 | 512 | 'std' => '#505050', |
| 513 | 513 | 'type' => 'color', |
| 514 | 514 | ), |
@@ -527,67 +527,67 @@ discard block |
||
| 527 | 527 | 'main' => array( |
| 528 | 528 | 'fields_settings' => array( |
| 529 | 529 | 'id' => 'fields_settings', |
| 530 | - 'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>', |
|
| 531 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
| 530 | + 'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>', |
|
| 531 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
| 532 | 532 | 'type' => 'header', |
| 533 | 533 | ), |
| 534 | 534 | 'fname_mandatory' => array( |
| 535 | 535 | 'id' => 'fname_mandatory', |
| 536 | - 'name' => __( 'First Name Mandatory?', 'invoicing' ), |
|
| 536 | + 'name' => __('First Name Mandatory?', 'invoicing'), |
|
| 537 | 537 | 'type' => 'checkbox', |
| 538 | 538 | 'std' => true, |
| 539 | 539 | ), |
| 540 | 540 | 'lname_mandatory' => array( |
| 541 | 541 | 'id' => 'lname_mandatory', |
| 542 | - 'name' => __( 'Last Name Mandatory?', 'invoicing' ), |
|
| 542 | + 'name' => __('Last Name Mandatory?', 'invoicing'), |
|
| 543 | 543 | 'type' => 'checkbox', |
| 544 | 544 | 'std' => true, |
| 545 | 545 | ), |
| 546 | 546 | 'address_mandatory' => array( |
| 547 | 547 | 'id' => 'address_mandatory', |
| 548 | - 'name' => __( 'Address Mandatory?', 'invoicing' ), |
|
| 548 | + 'name' => __('Address Mandatory?', 'invoicing'), |
|
| 549 | 549 | 'type' => 'checkbox', |
| 550 | 550 | 'std' => true, |
| 551 | 551 | ), |
| 552 | 552 | 'city_mandatory' => array( |
| 553 | 553 | 'id' => 'city_mandatory', |
| 554 | - 'name' => __( 'City Mandatory?', 'invoicing' ), |
|
| 554 | + 'name' => __('City Mandatory?', 'invoicing'), |
|
| 555 | 555 | 'type' => 'checkbox', |
| 556 | 556 | 'std' => true, |
| 557 | 557 | ), |
| 558 | 558 | 'country_mandatory' => array( |
| 559 | 559 | 'id' => 'country_mandatory', |
| 560 | - 'name' => __( 'Country Mandatory?', 'invoicing' ), |
|
| 560 | + 'name' => __('Country Mandatory?', 'invoicing'), |
|
| 561 | 561 | 'type' => 'checkbox', |
| 562 | 562 | 'std' => true, |
| 563 | 563 | ), |
| 564 | 564 | 'state_mandatory' => array( |
| 565 | 565 | 'id' => 'state_mandatory', |
| 566 | - 'name' => __( 'State / Province Mandatory?', 'invoicing' ), |
|
| 566 | + 'name' => __('State / Province Mandatory?', 'invoicing'), |
|
| 567 | 567 | 'type' => 'checkbox', |
| 568 | 568 | 'std' => true, |
| 569 | 569 | ), |
| 570 | 570 | 'zip_mandatory' => array( |
| 571 | 571 | 'id' => 'zip_mandatory', |
| 572 | - 'name' => __( 'ZIP / Postcode Mandatory?', 'invoicing' ), |
|
| 572 | + 'name' => __('ZIP / Postcode Mandatory?', 'invoicing'), |
|
| 573 | 573 | 'type' => 'checkbox', |
| 574 | 574 | 'std' => true, |
| 575 | 575 | ), |
| 576 | 576 | 'phone_mandatory' => array( |
| 577 | 577 | 'id' => 'phone_mandatory', |
| 578 | - 'name' => __( 'Phone No. Mandatory?', 'invoicing' ), |
|
| 578 | + 'name' => __('Phone No. Mandatory?', 'invoicing'), |
|
| 579 | 579 | 'type' => 'checkbox', |
| 580 | 580 | 'std' => true, |
| 581 | 581 | ), |
| 582 | 582 | 'invoice_number_format_settings' => array( |
| 583 | 583 | 'id' => 'invoice_number_format_settings', |
| 584 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 584 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 585 | 585 | 'type' => 'header', |
| 586 | 586 | ), |
| 587 | 587 | 'invoice_number_padd' => array( |
| 588 | 588 | 'id' => 'invoice_number_padd', |
| 589 | - 'name' => __( 'Minimum digits', 'invoicing' ), |
|
| 590 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 589 | + 'name' => __('Minimum digits', 'invoicing'), |
|
| 590 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 591 | 591 | 'type' => 'select', |
| 592 | 592 | 'options' => $invoice_number_padd_options, |
| 593 | 593 | 'std' => 5, |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | ), |
| 596 | 596 | 'invoice_number_prefix' => array( |
| 597 | 597 | 'id' => 'invoice_number_prefix', |
| 598 | - 'name' => __( 'Invoice Number prefix', 'invoicing' ), |
|
| 599 | - 'desc' => __( 'A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
| 598 | + 'name' => __('Invoice Number prefix', 'invoicing'), |
|
| 599 | + 'desc' => __('A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
| 600 | 600 | 'type' => 'text', |
| 601 | 601 | 'size' => 'regular', |
| 602 | 602 | 'std' => 'WPINV-', |
@@ -604,25 +604,25 @@ discard block |
||
| 604 | 604 | ), |
| 605 | 605 | 'invoice_number_postfix' => array( |
| 606 | 606 | 'id' => 'invoice_number_postfix', |
| 607 | - 'name' => __( 'Invoice Number postfix', 'invoicing' ), |
|
| 608 | - 'desc' => __( 'A postfix to append to all invoice numbers.', 'invoicing' ), |
|
| 607 | + 'name' => __('Invoice Number postfix', 'invoicing'), |
|
| 608 | + 'desc' => __('A postfix to append to all invoice numbers.', 'invoicing'), |
|
| 609 | 609 | 'type' => 'text', |
| 610 | 610 | 'size' => 'regular', |
| 611 | 611 | 'std' => '' |
| 612 | 612 | ), |
| 613 | 613 | 'guest_checkout_settings' => array( |
| 614 | 614 | 'id' => 'guest_checkout_settings', |
| 615 | - 'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>', |
|
| 615 | + 'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>', |
|
| 616 | 616 | 'type' => 'header', |
| 617 | 617 | ), |
| 618 | 618 | 'guest_checkout' => array( |
| 619 | 619 | 'type' => 'radio', |
| 620 | 620 | 'id' => 'guest_checkout', |
| 621 | - 'name' => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ), |
|
| 622 | - 'desc' => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing' ), |
|
| 621 | + 'name' => __('Pay via Invoice Link for non logged in user', 'invoicing'), |
|
| 622 | + 'desc' => __('Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing'), |
|
| 623 | 623 | 'options' => array( |
| 624 | - 0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ), |
|
| 625 | - 1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ), |
|
| 624 | + 0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'), |
|
| 625 | + 1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'), |
|
| 626 | 626 | ), |
| 627 | 627 | 'std' => 0, |
| 628 | 628 | ), |
@@ -635,8 +635,8 @@ discard block |
||
| 635 | 635 | 'main' => array( |
| 636 | 636 | 'tool_settings' => array( |
| 637 | 637 | 'id' => 'tool_settings', |
| 638 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 639 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 638 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 639 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 640 | 640 | 'type' => 'tools', |
| 641 | 641 | ), |
| 642 | 642 | ), |
@@ -644,135 +644,135 @@ discard block |
||
| 644 | 644 | ) |
| 645 | 645 | ); |
| 646 | 646 | |
| 647 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
| 647 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 650 | +function wpinv_settings_sanitize($input = array()) { |
|
| 651 | 651 | global $wpinv_options; |
| 652 | 652 | |
| 653 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
| 653 | + if (empty($_POST['_wp_http_referer'])) { |
|
| 654 | 654 | return $input; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
| 657 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
| 658 | 658 | |
| 659 | 659 | $settings = wpinv_get_registered_settings(); |
| 660 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 661 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 660 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 661 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 662 | 662 | |
| 663 | 663 | $input = $input ? $input : array(); |
| 664 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 665 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 664 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 665 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 666 | 666 | |
| 667 | 667 | // Loop through each setting being saved and pass it through a sanitization filter |
| 668 | - foreach ( $input as $key => $value ) { |
|
| 668 | + foreach ($input as $key => $value) { |
|
| 669 | 669 | // Get the setting type (checkbox, select, etc) |
| 670 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
| 670 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
| 671 | 671 | |
| 672 | - if ( $type ) { |
|
| 672 | + if ($type) { |
|
| 673 | 673 | // Field type specific filter |
| 674 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 674 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | // General filter |
| 678 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 678 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 682 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 683 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 682 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 683 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 684 | 684 | |
| 685 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 685 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 686 | 686 | |
| 687 | - if ( ! empty( $found_settings ) ) { |
|
| 688 | - foreach ( $found_settings as $key => $value ) { |
|
| 687 | + if (!empty($found_settings)) { |
|
| 688 | + foreach ($found_settings as $key => $value) { |
|
| 689 | 689 | |
| 690 | 690 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 691 | - if ( is_numeric( $key ) ) { |
|
| 691 | + if (is_numeric($key)) { |
|
| 692 | 692 | $key = $value['id']; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - if ( empty( $input[ $key ] ) ) { |
|
| 696 | - unset( $wpinv_options[ $key ] ); |
|
| 695 | + if (empty($input[$key])) { |
|
| 696 | + unset($wpinv_options[$key]); |
|
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | // Merge our new settings with the existing |
| 702 | - $output = array_merge( $wpinv_options, $input ); |
|
| 702 | + $output = array_merge($wpinv_options, $input); |
|
| 703 | 703 | |
| 704 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 704 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 705 | 705 | |
| 706 | 706 | return $output; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 709 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 710 | 710 | global $wpinv_options, $wpi_session; |
| 711 | 711 | |
| 712 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 712 | + if (!current_user_can('manage_options')) { |
|
| 713 | 713 | return $input; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 716 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 717 | 717 | // Shows an admin notice about upgrading previous order numbers |
| 718 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
| 718 | + $wpi_session->set('upgrade_sequential', '1'); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | return $input; |
| 722 | 722 | } |
| 723 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 723 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 724 | 724 | |
| 725 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 726 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 725 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 726 | + if (!current_user_can('manage_options')) { |
|
| 727 | 727 | return $input; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 730 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 731 | 731 | |
| 732 | 732 | $tax_rates = array(); |
| 733 | 733 | |
| 734 | - if ( !empty( $new_rates ) ) { |
|
| 735 | - foreach ( $new_rates as $rate ) { |
|
| 736 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
| 734 | + if (!empty($new_rates)) { |
|
| 735 | + foreach ($new_rates as $rate) { |
|
| 736 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
| 737 | 737 | continue; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 740 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
| 741 | 741 | |
| 742 | 742 | $tax_rates[] = $rate; |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 746 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 747 | 747 | |
| 748 | 748 | return $input; |
| 749 | 749 | } |
| 750 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 750 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 751 | 751 | |
| 752 | -function wpinv_sanitize_text_field( $input ) { |
|
| 753 | - return trim( $input ); |
|
| 752 | +function wpinv_sanitize_text_field($input) { |
|
| 753 | + return trim($input); |
|
| 754 | 754 | } |
| 755 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 755 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 756 | 756 | |
| 757 | 757 | function wpinv_get_settings_tabs() { |
| 758 | 758 | $tabs = array(); |
| 759 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 760 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 761 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 762 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 763 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 764 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 765 | - |
|
| 766 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 759 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 760 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 761 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 762 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 763 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 764 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 765 | + |
|
| 766 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 769 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 770 | 770 | $tabs = false; |
| 771 | 771 | $sections = wpinv_get_registered_settings_sections(); |
| 772 | 772 | |
| 773 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 774 | - $tabs = $sections[ $tab ]; |
|
| 775 | - } else if ( $tab ) { |
|
| 773 | + if ($tab && !empty($sections[$tab])) { |
|
| 774 | + $tabs = $sections[$tab]; |
|
| 775 | + } else if ($tab) { |
|
| 776 | 776 | $tabs = false; |
| 777 | 777 | } |
| 778 | 778 | |
@@ -782,135 +782,135 @@ discard block |
||
| 782 | 782 | function wpinv_get_registered_settings_sections() { |
| 783 | 783 | static $sections = false; |
| 784 | 784 | |
| 785 | - if ( false !== $sections ) { |
|
| 785 | + if (false !== $sections) { |
|
| 786 | 786 | return $sections; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | $sections = array( |
| 790 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 791 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 792 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 793 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 794 | - ) ), |
|
| 795 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 796 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 797 | - ) ), |
|
| 798 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 799 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 800 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 801 | - ) ), |
|
| 802 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 803 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 804 | - ) ), |
|
| 805 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 806 | - 'main' => __( 'Misc Settings', 'invoicing' ), |
|
| 807 | - ) ), |
|
| 808 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 809 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 810 | - ) ), |
|
| 790 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 791 | + 'main' => __('General Settings', 'invoicing'), |
|
| 792 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 793 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 794 | + )), |
|
| 795 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 796 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 797 | + )), |
|
| 798 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 799 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 800 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 801 | + )), |
|
| 802 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 803 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 804 | + )), |
|
| 805 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 806 | + 'main' => __('Misc Settings', 'invoicing'), |
|
| 807 | + )), |
|
| 808 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 809 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 810 | + )), |
|
| 811 | 811 | ); |
| 812 | 812 | |
| 813 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 813 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 814 | 814 | |
| 815 | 815 | return $sections; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 818 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 819 | 819 | $pages_options = array(); |
| 820 | 820 | |
| 821 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 822 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 821 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 822 | + $pages_options = array('' => $default_label); // Blank option |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | $pages = get_pages(); |
| 826 | - if ( $pages ) { |
|
| 827 | - foreach ( $pages as $page ) { |
|
| 826 | + if ($pages) { |
|
| 827 | + foreach ($pages as $page) { |
|
| 828 | 828 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 829 | - $pages_options[ $page->ID ] = $title; |
|
| 829 | + $pages_options[$page->ID] = $title; |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | return $pages_options; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | -function wpinv_header_callback( $args ) { |
|
| 837 | - if ( !empty( $args['desc'] ) ) { |
|
| 836 | +function wpinv_header_callback($args) { |
|
| 837 | + if (!empty($args['desc'])) { |
|
| 838 | 838 | echo $args['desc']; |
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | -function wpinv_hidden_callback( $args ) { |
|
| 842 | +function wpinv_hidden_callback($args) { |
|
| 843 | 843 | global $wpinv_options; |
| 844 | 844 | |
| 845 | - if ( isset( $args['set_value'] ) ) { |
|
| 845 | + if (isset($args['set_value'])) { |
|
| 846 | 846 | $value = $args['set_value']; |
| 847 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 848 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 847 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
| 848 | + $value = $wpinv_options[$args['id']]; |
|
| 849 | 849 | } else { |
| 850 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 850 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 853 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 854 | 854 | $args['readonly'] = true; |
| 855 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 855 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 856 | 856 | $name = ''; |
| 857 | 857 | } else { |
| 858 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 858 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 861 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 862 | 862 | |
| 863 | 863 | echo $html; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | -function wpinv_checkbox_callback( $args ) { |
|
| 866 | +function wpinv_checkbox_callback($args) { |
|
| 867 | 867 | global $wpinv_options; |
| 868 | 868 | |
| 869 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 869 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 870 | 870 | |
| 871 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 871 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 872 | 872 | $name = ''; |
| 873 | 873 | } else { |
| 874 | 874 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 877 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
| 878 | 878 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
| 879 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 879 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 880 | 880 | |
| 881 | 881 | echo $html; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | -function wpinv_multicheck_callback( $args ) { |
|
| 884 | +function wpinv_multicheck_callback($args) { |
|
| 885 | 885 | global $wpinv_options; |
| 886 | 886 | |
| 887 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 887 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 888 | 888 | |
| 889 | - if ( ! empty( $args['options'] ) ) { |
|
| 890 | - foreach( $args['options'] as $key => $option ): |
|
| 891 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 892 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 889 | + if (!empty($args['options'])) { |
|
| 890 | + foreach ($args['options'] as $key => $option): |
|
| 891 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 892 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
| 893 | 893 | $enabled = $sanitize_key; |
| 894 | 894 | } else { |
| 895 | 895 | $enabled = NULL; |
| 896 | 896 | } |
| 897 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 898 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 897 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 898 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
| 899 | 899 | endforeach; |
| 900 | 900 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 901 | 901 | } |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | -function wpinv_payment_icons_callback( $args ) { |
|
| 904 | +function wpinv_payment_icons_callback($args) { |
|
| 905 | 905 | global $wpinv_options; |
| 906 | 906 | |
| 907 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 907 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 908 | 908 | |
| 909 | - if ( ! empty( $args['options'] ) ) { |
|
| 910 | - foreach( $args['options'] as $key => $option ) { |
|
| 911 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 909 | + if (!empty($args['options'])) { |
|
| 910 | + foreach ($args['options'] as $key => $option) { |
|
| 911 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 912 | 912 | |
| 913 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 913 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
| 914 | 914 | $enabled = $option; |
| 915 | 915 | } else { |
| 916 | 916 | $enabled = NULL; |
@@ -918,194 +918,194 @@ discard block |
||
| 918 | 918 | |
| 919 | 919 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 920 | 920 | |
| 921 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 921 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 922 | 922 | |
| 923 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 924 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 923 | + if (wpinv_string_is_image_url($key)) { |
|
| 924 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 925 | 925 | } else { |
| 926 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 926 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 927 | 927 | |
| 928 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 929 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 928 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 929 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 930 | 930 | } else { |
| 931 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 931 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 932 | 932 | $content_dir = WP_CONTENT_DIR; |
| 933 | 933 | |
| 934 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 934 | + if (function_exists('wp_normalize_path')) { |
|
| 935 | 935 | // Replaces backslashes with forward slashes for Windows systems |
| 936 | - $image = wp_normalize_path( $image ); |
|
| 937 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 936 | + $image = wp_normalize_path($image); |
|
| 937 | + $content_dir = wp_normalize_path($content_dir); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 940 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 943 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 944 | 944 | } |
| 945 | 945 | echo $option . '</label>'; |
| 946 | 946 | } |
| 947 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 947 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | -function wpinv_radio_callback( $args ) { |
|
| 951 | +function wpinv_radio_callback($args) { |
|
| 952 | 952 | global $wpinv_options; |
| 953 | 953 | |
| 954 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 954 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 955 | 955 | |
| 956 | - foreach ( $args['options'] as $key => $option ) : |
|
| 957 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 956 | + foreach ($args['options'] as $key => $option) : |
|
| 957 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 958 | 958 | |
| 959 | 959 | $checked = false; |
| 960 | 960 | |
| 961 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 961 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
| 962 | 962 | $checked = true; |
| 963 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 963 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
| 964 | 964 | $checked = true; |
| 965 | 965 | |
| 966 | 966 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 967 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 967 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
| 968 | 968 | endforeach; |
| 969 | 969 | |
| 970 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 970 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | -function wpinv_gateways_callback( $args ) { |
|
| 973 | +function wpinv_gateways_callback($args) { |
|
| 974 | 974 | global $wpinv_options; |
| 975 | 975 | |
| 976 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 976 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 977 | 977 | |
| 978 | - foreach ( $args['options'] as $key => $option ) : |
|
| 979 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 978 | + foreach ($args['options'] as $key => $option) : |
|
| 979 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 980 | 980 | |
| 981 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 981 | + if (isset($wpinv_options['gateways'][$key])) |
|
| 982 | 982 | $enabled = '1'; |
| 983 | 983 | else |
| 984 | 984 | $enabled = null; |
| 985 | 985 | |
| 986 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 987 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 986 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 987 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
| 988 | 988 | endforeach; |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | function wpinv_gateway_select_callback($args) { |
| 992 | 992 | global $wpinv_options; |
| 993 | 993 | |
| 994 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 994 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 995 | 995 | |
| 996 | 996 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
| 997 | 997 | |
| 998 | - foreach ( $args['options'] as $key => $option ) : |
|
| 999 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1000 | - $selected = selected( $key, $args['selected'], false ); |
|
| 998 | + foreach ($args['options'] as $key => $option) : |
|
| 999 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1000 | + $selected = selected($key, $args['selected'], false); |
|
| 1001 | 1001 | } else { |
| 1002 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
| 1002 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
| 1003 | 1003 | } |
| 1004 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1004 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 1005 | 1005 | endforeach; |
| 1006 | 1006 | |
| 1007 | 1007 | echo '</select>'; |
| 1008 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1008 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | -function wpinv_text_callback( $args ) { |
|
| 1011 | +function wpinv_text_callback($args) { |
|
| 1012 | 1012 | global $wpinv_options; |
| 1013 | 1013 | |
| 1014 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1014 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1015 | 1015 | |
| 1016 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1017 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1016 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1017 | + $value = $wpinv_options[$args['id']]; |
|
| 1018 | 1018 | } else { |
| 1019 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1019 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1022 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1023 | 1023 | $args['readonly'] = true; |
| 1024 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1024 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1025 | 1025 | $name = ''; |
| 1026 | 1026 | } else { |
| 1027 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1027 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
| 1031 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1032 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1033 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1031 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1032 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
| 1033 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1034 | 1034 | |
| 1035 | 1035 | echo $html; |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | -function wpinv_number_callback( $args ) { |
|
| 1038 | +function wpinv_number_callback($args) { |
|
| 1039 | 1039 | global $wpinv_options; |
| 1040 | 1040 | |
| 1041 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1041 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1042 | 1042 | |
| 1043 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1044 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1043 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1044 | + $value = $wpinv_options[$args['id']]; |
|
| 1045 | 1045 | } else { |
| 1046 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1046 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1049 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1050 | 1050 | $args['readonly'] = true; |
| 1051 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1051 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1052 | 1052 | $name = ''; |
| 1053 | 1053 | } else { |
| 1054 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1054 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1058 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1059 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1057 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
| 1058 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
| 1059 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
| 1060 | 1060 | |
| 1061 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1062 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1063 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1061 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1062 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1063 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1064 | 1064 | |
| 1065 | 1065 | echo $html; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | -function wpinv_textarea_callback( $args ) { |
|
| 1068 | +function wpinv_textarea_callback($args) { |
|
| 1069 | 1069 | global $wpinv_options; |
| 1070 | 1070 | |
| 1071 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1071 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1072 | 1072 | |
| 1073 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1074 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1073 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1074 | + $value = $wpinv_options[$args['id']]; |
|
| 1075 | 1075 | } else { |
| 1076 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1076 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1080 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 1079 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1080 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 1081 | 1081 | |
| 1082 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1083 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1082 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1083 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1084 | 1084 | |
| 1085 | 1085 | echo $html; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | -function wpinv_password_callback( $args ) { |
|
| 1088 | +function wpinv_password_callback($args) { |
|
| 1089 | 1089 | global $wpinv_options; |
| 1090 | 1090 | |
| 1091 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1091 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1092 | 1092 | |
| 1093 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1094 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1093 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1094 | + $value = $wpinv_options[$args['id']]; |
|
| 1095 | 1095 | } else { |
| 1096 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1096 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1100 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1101 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1099 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1100 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 1101 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1102 | 1102 | |
| 1103 | 1103 | echo $html; |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | function wpinv_missing_callback($args) { |
| 1107 | 1107 | printf( |
| 1108 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1108 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 1109 | 1109 | '<strong>' . $args['id'] . '</strong>' |
| 1110 | 1110 | ); |
| 1111 | 1111 | } |
@@ -1113,137 +1113,137 @@ discard block |
||
| 1113 | 1113 | function wpinv_select_callback($args) { |
| 1114 | 1114 | global $wpinv_options; |
| 1115 | 1115 | |
| 1116 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1116 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1117 | 1117 | |
| 1118 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1119 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1118 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1119 | + $value = $wpinv_options[$args['id']]; |
|
| 1120 | 1120 | } else { |
| 1121 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1121 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1124 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1125 | 1125 | $value = $args['selected']; |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1128 | + if (isset($args['placeholder'])) { |
|
| 1129 | 1129 | $placeholder = $args['placeholder']; |
| 1130 | 1130 | } else { |
| 1131 | 1131 | $placeholder = ''; |
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | - if ( isset( $args['chosen'] ) ) { |
|
| 1134 | + if (isset($args['chosen'])) { |
|
| 1135 | 1135 | $chosen = 'class="wpinv-chosen"'; |
| 1136 | 1136 | } else { |
| 1137 | 1137 | $chosen = ''; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - if( !empty( $args['onchange'] ) ) { |
|
| 1141 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 1140 | + if (!empty($args['onchange'])) { |
|
| 1141 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 1142 | 1142 | } else { |
| 1143 | 1143 | $onchange = ''; |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1146 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
| 1147 | 1147 | |
| 1148 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1149 | - $selected = selected( $option, $value, false ); |
|
| 1150 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1148 | + foreach ($args['options'] as $option => $name) { |
|
| 1149 | + $selected = selected($option, $value, false); |
|
| 1150 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | $html .= '</select>'; |
| 1154 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1154 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1155 | 1155 | |
| 1156 | 1156 | echo $html; |
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | -function wpinv_color_select_callback( $args ) { |
|
| 1159 | +function wpinv_color_select_callback($args) { |
|
| 1160 | 1160 | global $wpinv_options; |
| 1161 | 1161 | |
| 1162 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1162 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1163 | 1163 | |
| 1164 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1165 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1164 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1165 | + $value = $wpinv_options[$args['id']]; |
|
| 1166 | 1166 | } else { |
| 1167 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1167 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1170 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 1171 | 1171 | |
| 1172 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1173 | - $selected = selected( $option, $value, false ); |
|
| 1174 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1172 | + foreach ($args['options'] as $option => $color) { |
|
| 1173 | + $selected = selected($option, $value, false); |
|
| 1174 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | $html .= '</select>'; |
| 1178 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1178 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1179 | 1179 | |
| 1180 | 1180 | echo $html; |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | -function wpinv_rich_editor_callback( $args ) { |
|
| 1183 | +function wpinv_rich_editor_callback($args) { |
|
| 1184 | 1184 | global $wpinv_options, $wp_version; |
| 1185 | 1185 | |
| 1186 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1186 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1187 | 1187 | |
| 1188 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1189 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1188 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1189 | + $value = $wpinv_options[$args['id']]; |
|
| 1190 | 1190 | |
| 1191 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1192 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1191 | + if (empty($args['allow_blank']) && empty($value)) { |
|
| 1192 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1193 | 1193 | } |
| 1194 | 1194 | } else { |
| 1195 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1195 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1198 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 1199 | 1199 | |
| 1200 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1200 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 1201 | 1201 | ob_start(); |
| 1202 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1202 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
| 1203 | 1203 | $html = ob_get_clean(); |
| 1204 | 1204 | } else { |
| 1205 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1205 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1208 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1209 | 1209 | |
| 1210 | 1210 | echo $html; |
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | -function wpinv_upload_callback( $args ) { |
|
| 1213 | +function wpinv_upload_callback($args) { |
|
| 1214 | 1214 | global $wpinv_options; |
| 1215 | 1215 | |
| 1216 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1216 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1217 | 1217 | |
| 1218 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1218 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1219 | 1219 | $value = $wpinv_options[$args['id']]; |
| 1220 | 1220 | } else { |
| 1221 | 1221 | $value = isset($args['std']) ? $args['std'] : ''; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1225 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1226 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1227 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1224 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1225 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1226 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 1227 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1228 | 1228 | |
| 1229 | 1229 | echo $html; |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | -function wpinv_color_callback( $args ) { |
|
| 1232 | +function wpinv_color_callback($args) { |
|
| 1233 | 1233 | global $wpinv_options; |
| 1234 | 1234 | |
| 1235 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1235 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1236 | 1236 | |
| 1237 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1238 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1237 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1238 | + $value = $wpinv_options[$args['id']]; |
|
| 1239 | 1239 | } else { |
| 1240 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1240 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1243 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
| 1244 | 1244 | |
| 1245 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1246 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1245 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
| 1246 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1247 | 1247 | |
| 1248 | 1248 | echo $html; |
| 1249 | 1249 | } |
@@ -1251,9 +1251,9 @@ discard block |
||
| 1251 | 1251 | function wpinv_country_states_callback($args) { |
| 1252 | 1252 | global $wpinv_options; |
| 1253 | 1253 | |
| 1254 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1254 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1255 | 1255 | |
| 1256 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1256 | + if (isset($args['placeholder'])) { |
|
| 1257 | 1257 | $placeholder = $args['placeholder']; |
| 1258 | 1258 | } else { |
| 1259 | 1259 | $placeholder = ''; |
@@ -1261,17 +1261,17 @@ discard block |
||
| 1261 | 1261 | |
| 1262 | 1262 | $states = wpinv_get_country_states(); |
| 1263 | 1263 | |
| 1264 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1265 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1266 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1264 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
| 1265 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1266 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 1267 | 1267 | |
| 1268 | - foreach ( $states as $option => $name ) { |
|
| 1269 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1270 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1268 | + foreach ($states as $option => $name) { |
|
| 1269 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
| 1270 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | $html .= '</select>'; |
| 1274 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1274 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1275 | 1275 | |
| 1276 | 1276 | echo $html; |
| 1277 | 1277 | } |
@@ -1286,25 +1286,25 @@ discard block |
||
| 1286 | 1286 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
| 1287 | 1287 | <thead> |
| 1288 | 1288 | <tr> |
| 1289 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 1290 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
| 1291 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 1292 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 1293 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
| 1294 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
| 1289 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
| 1290 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
| 1291 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 1292 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 1293 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
| 1294 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
| 1295 | 1295 | </tr> |
| 1296 | 1296 | </thead> |
| 1297 | 1297 | <tbody> |
| 1298 | - <?php if( !empty( $rates ) ) : ?> |
|
| 1299 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
| 1298 | + <?php if (!empty($rates)) : ?> |
|
| 1299 | + <?php foreach ($rates as $key => $rate) : ?> |
|
| 1300 | 1300 | <?php |
| 1301 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
| 1301 | + $sanitized_key = wpinv_sanitize_key($key); |
|
| 1302 | 1302 | ?> |
| 1303 | 1303 | <tr> |
| 1304 | 1304 | <td class="wpinv_tax_country"> |
| 1305 | 1305 | <?php |
| 1306 | - echo wpinv_html_select( array( |
|
| 1307 | - 'options' => wpinv_get_country_list( true ), |
|
| 1306 | + echo wpinv_html_select(array( |
|
| 1307 | + 'options' => wpinv_get_country_list(true), |
|
| 1308 | 1308 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1309 | 1309 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1310 | 1310 | 'selected' => $rate['country'], |
@@ -1312,72 +1312,72 @@ discard block |
||
| 1312 | 1312 | 'show_option_none' => false, |
| 1313 | 1313 | 'class' => 'wpinv-tax-country', |
| 1314 | 1314 | 'chosen' => false, |
| 1315 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1316 | - ) ); |
|
| 1315 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1316 | + )); |
|
| 1317 | 1317 | ?> |
| 1318 | 1318 | </td> |
| 1319 | 1319 | <td class="wpinv_tax_state"> |
| 1320 | 1320 | <?php |
| 1321 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1322 | - if( !empty( $states ) ) { |
|
| 1323 | - echo wpinv_html_select( array( |
|
| 1324 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1321 | + $states = wpinv_get_country_states($rate['country']); |
|
| 1322 | + if (!empty($states)) { |
|
| 1323 | + echo wpinv_html_select(array( |
|
| 1324 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1325 | 1325 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1326 | 1326 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1327 | 1327 | 'selected' => $rate['state'], |
| 1328 | 1328 | 'show_option_all' => false, |
| 1329 | 1329 | 'show_option_none' => false, |
| 1330 | 1330 | 'chosen' => false, |
| 1331 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1332 | - ) ); |
|
| 1331 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
| 1332 | + )); |
|
| 1333 | 1333 | } else { |
| 1334 | - echo wpinv_html_text( array( |
|
| 1334 | + echo wpinv_html_text(array( |
|
| 1335 | 1335 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
| 1336 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1336 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
| 1337 | 1337 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1338 | - ) ); |
|
| 1338 | + )); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | ?> |
| 1341 | 1341 | </td> |
| 1342 | 1342 | <td class="wpinv_tax_global"> |
| 1343 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
| 1344 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1343 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
| 1344 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1345 | 1345 | </td> |
| 1346 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
| 1347 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
| 1348 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1346 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
| 1347 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
| 1348 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1349 | 1349 | </tr> |
| 1350 | 1350 | <?php endforeach; ?> |
| 1351 | 1351 | <?php else : ?> |
| 1352 | 1352 | <tr> |
| 1353 | 1353 | <td class="wpinv_tax_country"> |
| 1354 | 1354 | <?php |
| 1355 | - echo wpinv_html_select( array( |
|
| 1356 | - 'options' => wpinv_get_country_list( true ), |
|
| 1355 | + echo wpinv_html_select(array( |
|
| 1356 | + 'options' => wpinv_get_country_list(true), |
|
| 1357 | 1357 | 'name' => 'tax_rates[0][country]', |
| 1358 | 1358 | 'show_option_all' => false, |
| 1359 | 1359 | 'show_option_none' => false, |
| 1360 | 1360 | 'class' => 'wpinv-tax-country', |
| 1361 | 1361 | 'chosen' => false, |
| 1362 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1363 | - ) ); ?> |
|
| 1362 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1363 | + )); ?> |
|
| 1364 | 1364 | </td> |
| 1365 | 1365 | <td class="wpinv_tax_state"> |
| 1366 | - <?php echo wpinv_html_text( array( |
|
| 1366 | + <?php echo wpinv_html_text(array( |
|
| 1367 | 1367 | 'name' => 'tax_rates[0][state]' |
| 1368 | - ) ); ?> |
|
| 1368 | + )); ?> |
|
| 1369 | 1369 | </td> |
| 1370 | 1370 | <td class="wpinv_tax_global"> |
| 1371 | 1371 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
| 1372 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1372 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1373 | 1373 | </td> |
| 1374 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
| 1374 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
| 1375 | 1375 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
| 1376 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1376 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1377 | 1377 | </tr> |
| 1378 | 1378 | <?php endif; ?> |
| 1379 | 1379 | </tbody> |
| 1380 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
| 1380 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
| 1381 | 1381 | </table> |
| 1382 | 1382 | <?php |
| 1383 | 1383 | echo ob_get_clean(); |
@@ -1388,44 +1388,44 @@ discard block |
||
| 1388 | 1388 | ob_start(); ?> |
| 1389 | 1389 | </td><tr> |
| 1390 | 1390 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 1391 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1392 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 1391 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1392 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 1393 | 1393 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 1394 | 1394 | <thead> |
| 1395 | 1395 | <tr> |
| 1396 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 1397 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 1398 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 1396 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 1397 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 1398 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 1399 | 1399 | </tr> |
| 1400 | 1400 | </thead> |
| 1401 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1401 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1402 | 1402 | <tbody> |
| 1403 | 1403 | </tbody> |
| 1404 | 1404 | </table> |
| 1405 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1405 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1406 | 1406 | <?php |
| 1407 | 1407 | echo ob_get_clean(); |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1411 | - echo wp_kses_post( $args['desc'] ); |
|
| 1410 | +function wpinv_descriptive_text_callback($args) { |
|
| 1411 | + echo wp_kses_post($args['desc']); |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | -function wpinv_hook_callback( $args ) { |
|
| 1415 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1414 | +function wpinv_hook_callback($args) { |
|
| 1415 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | function wpinv_set_settings_cap() { |
| 1419 | 1419 | return 'manage_options'; |
| 1420 | 1420 | } |
| 1421 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1421 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1422 | 1422 | |
| 1423 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
| 1424 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
| 1425 | - $value = wpinv_sanitize_amount( $value ); |
|
| 1423 | +function wpinv_settings_sanitize_input($value, $key) { |
|
| 1424 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
| 1425 | + $value = wpinv_sanitize_amount($value); |
|
| 1426 | 1426 | $value = $value >= 100 ? 99 : $value; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | 1429 | return $value; |
| 1430 | 1430 | } |
| 1431 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
| 1432 | 1431 | \ No newline at end of file |
| 1432 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
| 1433 | 1433 | \ No newline at end of file |
@@ -7,440 +7,440 @@ 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 | 14 | function wpinv_get_invoice_cart_id() { |
| 15 | 15 | $wpinv_checkout = wpinv_get_checkout_session(); |
| 16 | 16 | |
| 17 | - if ( !empty( $wpinv_checkout['invoice_id'] ) ) { |
|
| 17 | + if (!empty($wpinv_checkout['invoice_id'])) { |
|
| 18 | 18 | return $wpinv_checkout['invoice_id']; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | return NULL; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -function wpinv_get_invoice( $invoice_id = 0, $cart = false ) { |
|
| 25 | - if ( $cart && empty( $invoice_id ) ) { |
|
| 24 | +function wpinv_get_invoice($invoice_id = 0, $cart = false) { |
|
| 25 | + if ($cart && empty($invoice_id)) { |
|
| 26 | 26 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 29 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 30 | 30 | return $invoice; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | -function wpinv_get_invoice_cart( $invoice_id = 0 ) { |
|
| 34 | - return wpinv_get_invoice( $invoice_id, true ); |
|
| 33 | +function wpinv_get_invoice_cart($invoice_id = 0) { |
|
| 34 | + return wpinv_get_invoice($invoice_id, true); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -function wpinv_get_invoice_description( $invoice_id = 0 ) { |
|
| 38 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 37 | +function wpinv_get_invoice_description($invoice_id = 0) { |
|
| 38 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 39 | 39 | return $invoice->get_description(); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | -function wpinv_get_invoice_currency_code( $invoice_id = 0 ) { |
|
| 43 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 42 | +function wpinv_get_invoice_currency_code($invoice_id = 0) { |
|
| 43 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 44 | 44 | return $invoice->get_currency(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_get_payment_user_email( $invoice_id ) { |
|
| 48 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 47 | +function wpinv_get_payment_user_email($invoice_id) { |
|
| 48 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 49 | 49 | return $invoice->get_email(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -function wpinv_get_user_id( $invoice_id ) { |
|
| 53 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 52 | +function wpinv_get_user_id($invoice_id) { |
|
| 53 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 54 | 54 | return $invoice->get_user_id(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | -function wpinv_get_invoice_status( $invoice_id, $return_label = false ) { |
|
| 58 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 57 | +function wpinv_get_invoice_status($invoice_id, $return_label = false) { |
|
| 58 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 59 | 59 | |
| 60 | - return $invoice->get_status( $return_label ); |
|
| 60 | + return $invoice->get_status($return_label); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -function wpinv_get_payment_gateway( $invoice_id, $return_label = false ) { |
|
| 64 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 63 | +function wpinv_get_payment_gateway($invoice_id, $return_label = false) { |
|
| 64 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 65 | 65 | |
| 66 | - return $invoice->get_gateway( $return_label ); |
|
| 66 | + return $invoice->get_gateway($return_label); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -function wpinv_get_payment_gateway_name( $invoice_id ) { |
|
| 70 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 69 | +function wpinv_get_payment_gateway_name($invoice_id) { |
|
| 70 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 71 | 71 | |
| 72 | 72 | return $invoice->get_gateway_title(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | -function wpinv_get_payment_transaction_id( $invoice_id ) { |
|
| 76 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 75 | +function wpinv_get_payment_transaction_id($invoice_id) { |
|
| 76 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 77 | 77 | |
| 78 | 78 | return $invoice->get_transaction_id(); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -function wpinv_get_id_by_transaction_id( $key ) { |
|
| 81 | +function wpinv_get_id_by_transaction_id($key) { |
|
| 82 | 82 | global $wpdb; |
| 83 | 83 | |
| 84 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 84 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 85 | 85 | |
| 86 | - if ( $invoice_id != NULL ) |
|
| 86 | + if ($invoice_id != NULL) |
|
| 87 | 87 | return $invoice_id; |
| 88 | 88 | |
| 89 | 89 | return 0; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
| 93 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 92 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
| 93 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 94 | 94 | |
| 95 | - return $invoice->get_meta( $meta_key, $single ); |
|
| 95 | + return $invoice->get_meta($meta_key, $single); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 99 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 98 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 99 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 100 | 100 | |
| 101 | - return $invoice->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 101 | + return $invoice->update_meta($meta_key, $meta_value, $prev_value); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -function wpinv_get_items( $invoice_id = 0 ) { |
|
| 105 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 104 | +function wpinv_get_items($invoice_id = 0) { |
|
| 105 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 106 | 106 | |
| 107 | 107 | $items = $invoice->get_items(); |
| 108 | 108 | $invoice_currency = $invoice->get_currency(); |
| 109 | 109 | |
| 110 | - if ( !empty( $items ) && is_array( $items ) ) { |
|
| 111 | - foreach ( $items as $key => $item ) { |
|
| 110 | + if (!empty($items) && is_array($items)) { |
|
| 111 | + foreach ($items as $key => $item) { |
|
| 112 | 112 | $items[$key]['currency'] = $invoice_currency; |
| 113 | 113 | |
| 114 | - if ( !isset( $cart_item['subtotal'] ) ) { |
|
| 114 | + if (!isset($cart_item['subtotal'])) { |
|
| 115 | 115 | $items[$key]['subtotal'] = $items[$key]['amount'] * 1; |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - return apply_filters( 'wpinv_get_items', $items, $invoice_id ); |
|
| 120 | + return apply_filters('wpinv_get_items', $items, $invoice_id); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | -function wpinv_get_fees( $invoice_id = 0 ) { |
|
| 124 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 123 | +function wpinv_get_fees($invoice_id = 0) { |
|
| 124 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 125 | 125 | $fees = $invoice->get_fees(); |
| 126 | 126 | |
| 127 | - return apply_filters( 'wpinv_get_fees', $fees, $invoice_id ); |
|
| 127 | + return apply_filters('wpinv_get_fees', $fees, $invoice_id); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | -function wpinv_get_invoice_ip( $invoice_id ) { |
|
| 131 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 130 | +function wpinv_get_invoice_ip($invoice_id) { |
|
| 131 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 132 | 132 | return $invoice->get_ip(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -function wpinv_get_invoice_user_info( $invoice_id ) { |
|
| 136 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 135 | +function wpinv_get_invoice_user_info($invoice_id) { |
|
| 136 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 137 | 137 | return $invoice->get_user_info(); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function wpinv_subtotal( $invoice_id = 0, $currency = false ) { |
|
| 141 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 140 | +function wpinv_subtotal($invoice_id = 0, $currency = false) { |
|
| 141 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 142 | 142 | |
| 143 | - return $invoice->get_subtotal( $currency ); |
|
| 143 | + return $invoice->get_subtotal($currency); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -function wpinv_tax( $invoice_id = 0, $currency = false ) { |
|
| 147 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 146 | +function wpinv_tax($invoice_id = 0, $currency = false) { |
|
| 147 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 148 | 148 | |
| 149 | - return $invoice->get_tax( $currency ); |
|
| 149 | + return $invoice->get_tax($currency); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | -function wpinv_discount( $invoice_id = 0, $currency = false, $dash = false ) { |
|
| 153 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 152 | +function wpinv_discount($invoice_id = 0, $currency = false, $dash = false) { |
|
| 153 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 154 | 154 | |
| 155 | - return $invoice->get_discount( $currency, $dash ); |
|
| 155 | + return $invoice->get_discount($currency, $dash); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -function wpinv_discount_code( $invoice_id = 0 ) { |
|
| 159 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 158 | +function wpinv_discount_code($invoice_id = 0) { |
|
| 159 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 160 | 160 | |
| 161 | 161 | return $invoice->get_discount_code(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function wpinv_payment_total( $invoice_id = 0, $currency = false ) { |
|
| 165 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 164 | +function wpinv_payment_total($invoice_id = 0, $currency = false) { |
|
| 165 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 166 | 166 | |
| 167 | - return $invoice->get_total( $currency ); |
|
| 167 | + return $invoice->get_total($currency); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | -function wpinv_get_date_created( $invoice_id = 0 ) { |
|
| 171 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 170 | +function wpinv_get_date_created($invoice_id = 0) { |
|
| 171 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 172 | 172 | |
| 173 | 173 | $date_created = $invoice->get_created_date(); |
| 174 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ), strtotime( $date_created ) ) : ''; |
|
| 174 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format'), strtotime($date_created)) : ''; |
|
| 175 | 175 | |
| 176 | 176 | return $date_created; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | -function wpinv_get_invoice_date( $invoice_id = 0, $format = '' ) { |
|
| 180 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 179 | +function wpinv_get_invoice_date($invoice_id = 0, $format = '') { |
|
| 180 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 181 | 181 | |
| 182 | - $format = !empty( $format ) ? $format : get_option( 'date_format' ); |
|
| 182 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
| 183 | 183 | $date_completed = $invoice->get_completed_date(); |
| 184 | - $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_completed ) ) : ''; |
|
| 185 | - if ( $invoice_date == '' ) { |
|
| 184 | + $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_completed)) : ''; |
|
| 185 | + if ($invoice_date == '') { |
|
| 186 | 186 | $date_created = $invoice->get_created_date(); |
| 187 | - $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
| 187 | + $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_created)) : ''; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | return $invoice_date; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -function wpinv_get_invoice_vat_number( $invoice_id = 0 ) { |
|
| 194 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 193 | +function wpinv_get_invoice_vat_number($invoice_id = 0) { |
|
| 194 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 195 | 195 | |
| 196 | 196 | return $invoice->vat_number; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | -function wpinv_insert_payment_note( $invoice_id = 0, $note = '', $user_type = false, $added_by_user = false ) { |
|
| 200 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 199 | +function wpinv_insert_payment_note($invoice_id = 0, $note = '', $user_type = false, $added_by_user = false) { |
|
| 200 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 201 | 201 | |
| 202 | - return $invoice->add_note( $note, $user_type, $added_by_user ); |
|
| 202 | + return $invoice->add_note($note, $user_type, $added_by_user); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -function wpinv_get_invoice_notes( $invoice_id = 0, $type = '' ) { |
|
| 205 | +function wpinv_get_invoice_notes($invoice_id = 0, $type = '') { |
|
| 206 | 206 | global $invoicing; |
| 207 | 207 | |
| 208 | - if ( empty( $invoice_id ) ) { |
|
| 208 | + if (empty($invoice_id)) { |
|
| 209 | 209 | return NULL; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $notes = $invoicing->notes->get_invoice_notes( $invoice_id, $type ); |
|
| 212 | + $notes = $invoicing->notes->get_invoice_notes($invoice_id, $type); |
|
| 213 | 213 | |
| 214 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice_id, $type ); |
|
| 214 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice_id, $type); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -function wpinv_get_payment_key( $invoice_id = 0 ) { |
|
| 218 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 217 | +function wpinv_get_payment_key($invoice_id = 0) { |
|
| 218 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 219 | 219 | return $invoice->get_key(); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | -function wpinv_get_invoice_number( $invoice_id = 0 ) { |
|
| 223 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 222 | +function wpinv_get_invoice_number($invoice_id = 0) { |
|
| 223 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 224 | 224 | return $invoice->get_number(); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | -function wpinv_get_cart_discountable_subtotal( $code_id ) { |
|
| 227 | +function wpinv_get_cart_discountable_subtotal($code_id) { |
|
| 228 | 228 | $cart_items = wpinv_get_cart_content_details(); |
| 229 | 229 | $items = array(); |
| 230 | 230 | |
| 231 | - $excluded_items = wpinv_get_discount_excluded_items( $code_id ); |
|
| 231 | + $excluded_items = wpinv_get_discount_excluded_items($code_id); |
|
| 232 | 232 | |
| 233 | - if( $cart_items ) { |
|
| 233 | + if ($cart_items) { |
|
| 234 | 234 | |
| 235 | - foreach( $cart_items as $item ) { |
|
| 235 | + foreach ($cart_items as $item) { |
|
| 236 | 236 | |
| 237 | - if( ! in_array( $item['id'], $excluded_items ) ) { |
|
| 238 | - $items[] = $item; |
|
| 237 | + if (!in_array($item['id'], $excluded_items)) { |
|
| 238 | + $items[] = $item; |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
| 243 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
| 244 | 244 | |
| 245 | - return apply_filters( 'wpinv_get_cart_discountable_subtotal', $subtotal ); |
|
| 245 | + return apply_filters('wpinv_get_cart_discountable_subtotal', $subtotal); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | -function wpinv_get_cart_items_subtotal( $items ) { |
|
| 248 | +function wpinv_get_cart_items_subtotal($items) { |
|
| 249 | 249 | $subtotal = 0.00; |
| 250 | 250 | |
| 251 | - if ( is_array( $items ) && ! empty( $items ) ) { |
|
| 252 | - $prices = wp_list_pluck( $items, 'subtotal' ); |
|
| 251 | + if (is_array($items) && !empty($items)) { |
|
| 252 | + $prices = wp_list_pluck($items, 'subtotal'); |
|
| 253 | 253 | |
| 254 | - if( is_array( $prices ) ) { |
|
| 255 | - $subtotal = array_sum( $prices ); |
|
| 254 | + if (is_array($prices)) { |
|
| 255 | + $subtotal = array_sum($prices); |
|
| 256 | 256 | } else { |
| 257 | 257 | $subtotal = 0.00; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if( $subtotal < 0 ) { |
|
| 260 | + if ($subtotal < 0) { |
|
| 261 | 261 | $subtotal = 0.00; |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - return apply_filters( 'wpinv_get_cart_items_subtotal', $subtotal ); |
|
| 265 | + return apply_filters('wpinv_get_cart_items_subtotal', $subtotal); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | -function wpinv_get_cart_subtotal( $items = array() ) { |
|
| 269 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
| 270 | - $subtotal = wpinv_get_cart_items_subtotal( $items ); |
|
| 268 | +function wpinv_get_cart_subtotal($items = array()) { |
|
| 269 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
| 270 | + $subtotal = wpinv_get_cart_items_subtotal($items); |
|
| 271 | 271 | |
| 272 | - return apply_filters( 'wpinv_get_cart_subtotal', $subtotal ); |
|
| 272 | + return apply_filters('wpinv_get_cart_subtotal', $subtotal); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | -function wpinv_cart_subtotal( $items = array() ) { |
|
| 276 | - $price = wpinv_price( wpinv_format_amount( wpinv_get_cart_subtotal( $items ) ) ); |
|
| 275 | +function wpinv_cart_subtotal($items = array()) { |
|
| 276 | + $price = wpinv_price(wpinv_format_amount(wpinv_get_cart_subtotal($items))); |
|
| 277 | 277 | |
| 278 | 278 | // Todo - Show tax labels here (if needed) |
| 279 | 279 | |
| 280 | 280 | return $price; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | -function wpinv_get_cart_total( $items = array(), $discounts = false, $invoice = array() ) { |
|
| 284 | - $subtotal = (float)wpinv_get_cart_subtotal( $items ); |
|
| 285 | - $discounts = (float)wpinv_get_cart_discounted_amount( $items ); |
|
| 286 | - $cart_tax = (float)wpinv_get_cart_tax( $items ); |
|
| 283 | +function wpinv_get_cart_total($items = array(), $discounts = false, $invoice = array()) { |
|
| 284 | + $subtotal = (float)wpinv_get_cart_subtotal($items); |
|
| 285 | + $discounts = (float)wpinv_get_cart_discounted_amount($items); |
|
| 286 | + $cart_tax = (float)wpinv_get_cart_tax($items); |
|
| 287 | 287 | $fees = (float)wpinv_get_cart_fee_total(); |
| 288 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
| 288 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
| 289 | 289 | $total = 0; |
| 290 | 290 | } else { |
| 291 | - $total = $subtotal - $discounts + $cart_tax + $fees; |
|
| 291 | + $total = $subtotal - $discounts + $cart_tax + $fees; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if ( $total < 0 ) { |
|
| 294 | + if ($total < 0) { |
|
| 295 | 295 | $total = 0.00; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $total = (float)apply_filters( 'wpinv_get_cart_total', $total, $items ); |
|
| 298 | + $total = (float)apply_filters('wpinv_get_cart_total', $total, $items); |
|
| 299 | 299 | |
| 300 | - return wpinv_sanitize_amount( $total ); |
|
| 300 | + return wpinv_sanitize_amount($total); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -function wpinv_cart_total( $cart_items = array(), $echo = true, $invoice = array() ) { |
|
| 303 | +function wpinv_cart_total($cart_items = array(), $echo = true, $invoice = array()) { |
|
| 304 | 304 | global $cart_total; |
| 305 | - $total = wpinv_price( wpinv_format_amount( wpinv_get_cart_total( $cart_items, NULL, $invoice ) ) ); |
|
| 306 | - $total = apply_filters( 'wpinv_cart_total', $total, $cart_items, $invoice ); |
|
| 305 | + $total = wpinv_price(wpinv_format_amount(wpinv_get_cart_total($cart_items, NULL, $invoice))); |
|
| 306 | + $total = apply_filters('wpinv_cart_total', $total, $cart_items, $invoice); |
|
| 307 | 307 | |
| 308 | 308 | // Todo - Show tax labels here (if needed) |
| 309 | 309 | |
| 310 | 310 | $cart_total = $total; |
| 311 | 311 | |
| 312 | - if ( !$echo ) { |
|
| 312 | + if (!$echo) { |
|
| 313 | 313 | return $total; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | echo $total; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | -function wpinv_get_cart_tax( $items = array() ) { |
|
| 319 | +function wpinv_get_cart_tax($items = array()) { |
|
| 320 | 320 | $cart_tax = 0; |
| 321 | - $items = !empty( $items ) ? $items : wpinv_get_cart_content_details(); |
|
| 321 | + $items = !empty($items) ? $items : wpinv_get_cart_content_details(); |
|
| 322 | 322 | |
| 323 | - if ( $items ) { |
|
| 324 | - $taxes = wp_list_pluck( $items, 'tax' ); |
|
| 323 | + if ($items) { |
|
| 324 | + $taxes = wp_list_pluck($items, 'tax'); |
|
| 325 | 325 | |
| 326 | - if( is_array( $taxes ) ) { |
|
| 327 | - $cart_tax = array_sum( $taxes ); |
|
| 326 | + if (is_array($taxes)) { |
|
| 327 | + $cart_tax = array_sum($taxes); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | $cart_tax += wpinv_get_cart_fee_tax(); |
| 332 | 332 | |
| 333 | - return apply_filters( 'wpinv_get_cart_tax', wpinv_sanitize_amount( $cart_tax ) ); |
|
| 333 | + return apply_filters('wpinv_get_cart_tax', wpinv_sanitize_amount($cart_tax)); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | -function wpinv_cart_tax( $items = array(), $echo = false ) { |
|
| 337 | - $cart_tax = wpinv_get_cart_tax( $items ); |
|
| 338 | - $cart_tax = wpinv_price( wpinv_format_amount( $cart_tax ) ); |
|
| 336 | +function wpinv_cart_tax($items = array(), $echo = false) { |
|
| 337 | + $cart_tax = wpinv_get_cart_tax($items); |
|
| 338 | + $cart_tax = wpinv_price(wpinv_format_amount($cart_tax)); |
|
| 339 | 339 | |
| 340 | - $tax = apply_filters( 'wpinv_cart_tax', $cart_tax, $items ); |
|
| 340 | + $tax = apply_filters('wpinv_cart_tax', $cart_tax, $items); |
|
| 341 | 341 | |
| 342 | - if ( !$echo ) { |
|
| 342 | + if (!$echo) { |
|
| 343 | 343 | return $tax; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | echo $tax; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | -function wpinv_get_cart_discount_code( $items = array() ) { |
|
| 349 | +function wpinv_get_cart_discount_code($items = array()) { |
|
| 350 | 350 | $invoice = wpinv_get_invoice_cart(); |
| 351 | - $cart_discount_code = !empty( $invoice ) ? $invoice->get_discount_code() : ''; |
|
| 351 | + $cart_discount_code = !empty($invoice) ? $invoice->get_discount_code() : ''; |
|
| 352 | 352 | |
| 353 | - return apply_filters( 'wpinv_get_cart_discount_code', $cart_discount_code ); |
|
| 353 | + return apply_filters('wpinv_get_cart_discount_code', $cart_discount_code); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | -function wpinv_cart_discount_code( $items = array(), $echo = false ) { |
|
| 357 | - $cart_discount_code = wpinv_get_cart_discount_code( $items ); |
|
| 356 | +function wpinv_cart_discount_code($items = array(), $echo = false) { |
|
| 357 | + $cart_discount_code = wpinv_get_cart_discount_code($items); |
|
| 358 | 358 | |
| 359 | - if ( $cart_discount_code != '' ) { |
|
| 359 | + if ($cart_discount_code != '') { |
|
| 360 | 360 | $cart_discount_code = ' (' . $cart_discount_code . ')'; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $discount_code = apply_filters( 'wpinv_cart_discount_code', $cart_discount_code, $items ); |
|
| 363 | + $discount_code = apply_filters('wpinv_cart_discount_code', $cart_discount_code, $items); |
|
| 364 | 364 | |
| 365 | - if ( !$echo ) { |
|
| 365 | + if (!$echo) { |
|
| 366 | 366 | return $discount_code; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | echo $discount_code; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | -function wpinv_get_cart_discount( $items = array() ) { |
|
| 372 | +function wpinv_get_cart_discount($items = array()) { |
|
| 373 | 373 | $invoice = wpinv_get_invoice_cart(); |
| 374 | - $cart_discount = !empty( $invoice ) ? $invoice->get_discount() : 0; |
|
| 374 | + $cart_discount = !empty($invoice) ? $invoice->get_discount() : 0; |
|
| 375 | 375 | |
| 376 | - return apply_filters( 'wpinv_get_cart_discount', wpinv_sanitize_amount( $cart_discount ), $items ); |
|
| 376 | + return apply_filters('wpinv_get_cart_discount', wpinv_sanitize_amount($cart_discount), $items); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | -function wpinv_cart_discount( $items = array(), $echo = false ) { |
|
| 380 | - $cart_discount = wpinv_get_cart_discount( $items ); |
|
| 381 | - $cart_discount = wpinv_price( wpinv_format_amount( $cart_discount ) ); |
|
| 379 | +function wpinv_cart_discount($items = array(), $echo = false) { |
|
| 380 | + $cart_discount = wpinv_get_cart_discount($items); |
|
| 381 | + $cart_discount = wpinv_price(wpinv_format_amount($cart_discount)); |
|
| 382 | 382 | |
| 383 | - $discount = apply_filters( 'wpinv_cart_discount', $cart_discount, $items ); |
|
| 383 | + $discount = apply_filters('wpinv_cart_discount', $cart_discount, $items); |
|
| 384 | 384 | |
| 385 | - if ( !$echo ) { |
|
| 385 | + if (!$echo) { |
|
| 386 | 386 | return $discount; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | echo $discount; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | -function wpinv_get_cart_fees( $type = 'all', $item_id = 0 ) { |
|
| 393 | - $item = new WPInv_Item( $item_id ); |
|
| 392 | +function wpinv_get_cart_fees($type = 'all', $item_id = 0) { |
|
| 393 | + $item = new WPInv_Item($item_id); |
|
| 394 | 394 | |
| 395 | - return $item->get_fees( $type, $item_id ); |
|
| 395 | + return $item->get_fees($type, $item_id); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function wpinv_get_cart_fee_total() { |
| 399 | - $total = 0; |
|
| 399 | + $total = 0; |
|
| 400 | 400 | $fees = wpinv_get_cart_fees(); |
| 401 | 401 | |
| 402 | - if ( $fees ) { |
|
| 403 | - foreach ( $fees as $fee_id => $fee ) { |
|
| 402 | + if ($fees) { |
|
| 403 | + foreach ($fees as $fee_id => $fee) { |
|
| 404 | 404 | $total += $fee['amount']; |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - return apply_filters( 'wpinv_get_cart_fee_total', $total ); |
|
| 408 | + return apply_filters('wpinv_get_cart_fee_total', $total); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | function wpinv_get_cart_fee_tax() { |
| 412 | 412 | $tax = 0; |
| 413 | 413 | $fees = wpinv_get_cart_fees(); |
| 414 | 414 | |
| 415 | - if ( $fees ) { |
|
| 416 | - foreach ( $fees as $fee_id => $fee ) { |
|
| 417 | - if( ! empty( $fee['no_tax'] ) ) { |
|
| 415 | + if ($fees) { |
|
| 416 | + foreach ($fees as $fee_id => $fee) { |
|
| 417 | + if (!empty($fee['no_tax'])) { |
|
| 418 | 418 | continue; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $tax += wpinv_calculate_tax( $fee['amount'] ); |
|
| 421 | + $tax += wpinv_calculate_tax($fee['amount']); |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return apply_filters( 'wpinv_get_cart_fee_tax', $tax ); |
|
| 425 | + return apply_filters('wpinv_get_cart_fee_tax', $tax); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | function wpinv_cart_has_recurring_item() { |
| 429 | 429 | $cart_items = wpinv_get_cart_contents(); |
| 430 | 430 | |
| 431 | - if ( empty( $cart_items ) ) { |
|
| 431 | + if (empty($cart_items)) { |
|
| 432 | 432 | return false; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $has_subscription = false; |
| 436 | - foreach( $cart_items as $cart_item ) { |
|
| 437 | - if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
| 436 | + foreach ($cart_items as $cart_item) { |
|
| 437 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
| 438 | 438 | $has_subscription = true; |
| 439 | 439 | break; |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - return apply_filters( 'wpinv_cart_has_recurring_item', $has_subscription, $cart_items ); |
|
| 443 | + return apply_filters('wpinv_cart_has_recurring_item', $has_subscription, $cart_items); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | function wpinv_cart_has_free_trial() { |
@@ -448,85 +448,85 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | $free_trial = false; |
| 450 | 450 | |
| 451 | - if ( !empty( $invoice ) && $invoice->is_free_trial() ) { |
|
| 451 | + if (!empty($invoice) && $invoice->is_free_trial()) { |
|
| 452 | 452 | $free_trial = true; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - return apply_filters( 'wpinv_cart_has_free_trial', $free_trial, $invoice ); |
|
| 455 | + return apply_filters('wpinv_cart_has_free_trial', $free_trial, $invoice); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | function wpinv_get_cart_contents() { |
| 459 | 459 | $cart_details = wpinv_get_cart_details(); |
| 460 | 460 | |
| 461 | - return apply_filters( 'wpinv_get_cart_contents', $cart_details ); |
|
| 461 | + return apply_filters('wpinv_get_cart_contents', $cart_details); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | function wpinv_get_cart_content_details() { |
| 465 | 465 | global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpinv_is_last_cart_item, $wpinv_flat_discount_total; |
| 466 | 466 | $cart_items = wpinv_get_cart_contents(); |
| 467 | 467 | |
| 468 | - if ( empty( $cart_items ) ) { |
|
| 468 | + if (empty($cart_items)) { |
|
| 469 | 469 | return false; |
| 470 | 470 | } |
| 471 | 471 | $invoice = wpinv_get_invoice_cart(); |
| 472 | 472 | |
| 473 | 473 | $details = array(); |
| 474 | - $length = count( $cart_items ) - 1; |
|
| 474 | + $length = count($cart_items) - 1; |
|
| 475 | 475 | |
| 476 | - if ( empty( $_POST['country'] ) ) { |
|
| 476 | + if (empty($_POST['country'])) { |
|
| 477 | 477 | $_POST['country'] = $invoice->country; |
| 478 | 478 | } |
| 479 | - if ( !isset( $_POST['state'] ) ) { |
|
| 479 | + if (!isset($_POST['state'])) { |
|
| 480 | 480 | $_POST['state'] = $invoice->state; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - foreach( $cart_items as $key => $item ) { |
|
| 484 | - $item_id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
| 485 | - if ( empty( $item_id ) ) { |
|
| 483 | + foreach ($cart_items as $key => $item) { |
|
| 484 | + $item_id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
| 485 | + if (empty($item_id)) { |
|
| 486 | 486 | continue; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | $wpi_current_id = $invoice->ID; |
| 490 | 490 | $wpi_item_id = $item_id; |
| 491 | 491 | |
| 492 | - $item_price = wpinv_get_item_price( $item_id ); |
|
| 493 | - $discount = wpinv_get_cart_item_discount_amount( $item ); |
|
| 494 | - $discount = apply_filters( 'wpinv_get_cart_content_details_item_discount_amount', $discount, $item ); |
|
| 495 | - $quantity = wpinv_get_cart_item_quantity( $item ); |
|
| 496 | - $fees = wpinv_get_cart_fees( 'fee', $item_id ); |
|
| 492 | + $item_price = wpinv_get_item_price($item_id); |
|
| 493 | + $discount = wpinv_get_cart_item_discount_amount($item); |
|
| 494 | + $discount = apply_filters('wpinv_get_cart_content_details_item_discount_amount', $discount, $item); |
|
| 495 | + $quantity = wpinv_get_cart_item_quantity($item); |
|
| 496 | + $fees = wpinv_get_cart_fees('fee', $item_id); |
|
| 497 | 497 | |
| 498 | 498 | $subtotal = $item_price * $quantity; |
| 499 | - $tax_rate = wpinv_get_tax_rate( $_POST['country'], $_POST['state'], $wpi_item_id ); |
|
| 500 | - $tax_class = $wpinv_euvat->get_item_class( $item_id ); |
|
| 501 | - $tax = wpinv_get_cart_item_tax( $item_id, $subtotal - $discount ); |
|
| 499 | + $tax_rate = wpinv_get_tax_rate($_POST['country'], $_POST['state'], $wpi_item_id); |
|
| 500 | + $tax_class = $wpinv_euvat->get_item_class($item_id); |
|
| 501 | + $tax = wpinv_get_cart_item_tax($item_id, $subtotal - $discount); |
|
| 502 | 502 | |
| 503 | - if ( wpinv_prices_include_tax() ) { |
|
| 504 | - $subtotal -= wpinv_round_amount( $tax ); |
|
| 503 | + if (wpinv_prices_include_tax()) { |
|
| 504 | + $subtotal -= wpinv_round_amount($tax); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $total = $subtotal - $discount + $tax; |
|
| 507 | + $total = $subtotal - $discount + $tax; |
|
| 508 | 508 | |
| 509 | 509 | // Do not allow totals to go negatve |
| 510 | - if( $total < 0 ) { |
|
| 510 | + if ($total < 0) { |
|
| 511 | 511 | $total = 0; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $details[ $key ] = array( |
|
| 514 | + $details[$key] = array( |
|
| 515 | 515 | 'id' => $item_id, |
| 516 | - 'name' => !empty($item['name']) ? $item['name'] : get_the_title( $item_id ), |
|
| 517 | - 'item_price' => wpinv_round_amount( $item_price ), |
|
| 516 | + 'name' => !empty($item['name']) ? $item['name'] : get_the_title($item_id), |
|
| 517 | + 'item_price' => wpinv_round_amount($item_price), |
|
| 518 | 518 | 'quantity' => $quantity, |
| 519 | - 'discount' => wpinv_round_amount( $discount ), |
|
| 520 | - 'subtotal' => wpinv_round_amount( $subtotal ), |
|
| 521 | - 'tax' => wpinv_round_amount( $tax ), |
|
| 522 | - 'price' => wpinv_round_amount( $total ), |
|
| 519 | + 'discount' => wpinv_round_amount($discount), |
|
| 520 | + 'subtotal' => wpinv_round_amount($subtotal), |
|
| 521 | + 'tax' => wpinv_round_amount($tax), |
|
| 522 | + 'price' => wpinv_round_amount($total), |
|
| 523 | 523 | 'vat_rates_class' => $tax_class, |
| 524 | - 'vat_rate' => wpinv_round_amount( $tax_rate ), |
|
| 525 | - 'meta' => isset( $item['meta'] ) ? $item['meta'] : array(), |
|
| 524 | + 'vat_rate' => wpinv_round_amount($tax_rate), |
|
| 525 | + 'meta' => isset($item['meta']) ? $item['meta'] : array(), |
|
| 526 | 526 | 'fees' => $fees, |
| 527 | 527 | ); |
| 528 | 528 | |
| 529 | - if ( $wpinv_is_last_cart_item ) { |
|
| 529 | + if ($wpinv_is_last_cart_item) { |
|
| 530 | 530 | $wpinv_is_last_cart_item = false; |
| 531 | 531 | $wpinv_flat_discount_total = 0.00; |
| 532 | 532 | } |
@@ -535,60 +535,60 @@ discard block |
||
| 535 | 535 | return $details; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | -function wpinv_get_cart_details( $invoice_id = 0 ) { |
|
| 538 | +function wpinv_get_cart_details($invoice_id = 0) { |
|
| 539 | 539 | global $ajax_cart_details; |
| 540 | 540 | |
| 541 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
| 542 | - $cart_details = !empty( $ajax_cart_details ) ? $ajax_cart_details : $invoice->cart_details; |
|
| 541 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
| 542 | + $cart_details = !empty($ajax_cart_details) ? $ajax_cart_details : $invoice->cart_details; |
|
| 543 | 543 | |
| 544 | 544 | $invoice_currency = $invoice->currency; |
| 545 | 545 | |
| 546 | - if ( ! empty( $cart_details ) && is_array( $cart_details ) ) { |
|
| 547 | - foreach ( $cart_details as $key => $cart_item ) { |
|
| 548 | - $cart_details[ $key ]['currency'] = $invoice_currency; |
|
| 546 | + if (!empty($cart_details) && is_array($cart_details)) { |
|
| 547 | + foreach ($cart_details as $key => $cart_item) { |
|
| 548 | + $cart_details[$key]['currency'] = $invoice_currency; |
|
| 549 | 549 | |
| 550 | - if ( ! isset( $cart_item['subtotal'] ) ) { |
|
| 551 | - $cart_details[ $key ]['subtotal'] = $cart_item['price']; |
|
| 550 | + if (!isset($cart_item['subtotal'])) { |
|
| 551 | + $cart_details[$key]['subtotal'] = $cart_item['price']; |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - return apply_filters( 'wpinv_get_cart_details', $cart_details, $invoice_id ); |
|
| 556 | + return apply_filters('wpinv_get_cart_details', $cart_details, $invoice_id); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | -function wpinv_record_status_change( $invoice_id, $new_status, $old_status ) { |
|
| 560 | - if('wpi_invoice' != get_post_type($invoice_id)){ |
|
| 559 | +function wpinv_record_status_change($invoice_id, $new_status, $old_status) { |
|
| 560 | + if ('wpi_invoice' != get_post_type($invoice_id)) { |
|
| 561 | 561 | return; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 564 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 565 | 565 | |
| 566 | - $old_status = wpinv_status_nicename( $old_status ); |
|
| 567 | - $new_status = wpinv_status_nicename( $new_status ); |
|
| 566 | + $old_status = wpinv_status_nicename($old_status); |
|
| 567 | + $new_status = wpinv_status_nicename($new_status); |
|
| 568 | 568 | |
| 569 | - $status_change = sprintf( __( 'Invoice status changed from %s to %s', 'invoicing' ), $old_status, $new_status ); |
|
| 569 | + $status_change = sprintf(__('Invoice status changed from %s to %s', 'invoicing'), $old_status, $new_status); |
|
| 570 | 570 | |
| 571 | 571 | // Add note |
| 572 | - return $invoice->add_note( $status_change, false, false, true ); |
|
| 572 | + return $invoice->add_note($status_change, false, false, true); |
|
| 573 | 573 | } |
| 574 | -add_action( 'wpinv_update_status', 'wpinv_record_status_change', 100, 3 ); |
|
| 574 | +add_action('wpinv_update_status', 'wpinv_record_status_change', 100, 3); |
|
| 575 | 575 | |
| 576 | -function wpinv_complete_payment( $invoice_id, $new_status, $old_status ) { |
|
| 576 | +function wpinv_complete_payment($invoice_id, $new_status, $old_status) { |
|
| 577 | 577 | global $wpi_has_free_trial; |
| 578 | 578 | |
| 579 | 579 | $wpi_has_free_trial = false; |
| 580 | 580 | |
| 581 | - if ( $old_status == 'publish' ) { |
|
| 581 | + if ($old_status == 'publish') { |
|
| 582 | 582 | return; // Make sure that payments are only paid once |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | // Make sure the payment completion is only processed when new status is paid |
| 586 | - if ( $new_status != 'publish' ) { |
|
| 586 | + if ($new_status != 'publish') { |
|
| 587 | 587 | return; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 591 | - if ( empty( $invoice ) ) { |
|
| 590 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 591 | + if (empty($invoice)) { |
|
| 592 | 592 | return; |
| 593 | 593 | } |
| 594 | 594 | |
@@ -596,58 +596,58 @@ discard block |
||
| 596 | 596 | $completed_date = $invoice->completed_date; |
| 597 | 597 | $cart_details = $invoice->cart_details; |
| 598 | 598 | |
| 599 | - do_action( 'wpinv_pre_complete_payment', $invoice_id ); |
|
| 599 | + do_action('wpinv_pre_complete_payment', $invoice_id); |
|
| 600 | 600 | |
| 601 | - if ( is_array( $cart_details ) ) { |
|
| 601 | + if (is_array($cart_details)) { |
|
| 602 | 602 | // Increase purchase count and earnings |
| 603 | - foreach ( $cart_details as $cart_index => $item ) { |
|
| 603 | + foreach ($cart_details as $cart_index => $item) { |
|
| 604 | 604 | // Ensure these actions only run once, ever |
| 605 | - if ( empty( $completed_date ) ) { |
|
| 606 | - do_action( 'wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index ); |
|
| 605 | + if (empty($completed_date)) { |
|
| 606 | + do_action('wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index); |
|
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // Check for discount codes and increment their use counts |
| 612 | - if ( $discounts = $invoice->get_discounts( true ) ) { |
|
| 613 | - if( ! empty( $discounts ) ) { |
|
| 614 | - foreach( $discounts as $code ) { |
|
| 615 | - wpinv_increase_discount_usage( $code ); |
|
| 612 | + if ($discounts = $invoice->get_discounts(true)) { |
|
| 613 | + if (!empty($discounts)) { |
|
| 614 | + foreach ($discounts as $code) { |
|
| 615 | + wpinv_increase_discount_usage($code); |
|
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | // Ensure this action only runs once ever |
| 621 | - if( empty( $completed_date ) ) { |
|
| 621 | + if (empty($completed_date)) { |
|
| 622 | 622 | // Save the completed date |
| 623 | - $invoice->set( 'completed_date', current_time( 'mysql', 0 ) ); |
|
| 623 | + $invoice->set('completed_date', current_time('mysql', 0)); |
|
| 624 | 624 | $invoice->save(); |
| 625 | 625 | |
| 626 | - do_action( 'wpinv_complete_payment', $invoice_id ); |
|
| 626 | + do_action('wpinv_complete_payment', $invoice_id); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | // Empty the shopping cart |
| 630 | 630 | wpinv_empty_cart(); |
| 631 | 631 | } |
| 632 | -add_action( 'wpinv_update_status', 'wpinv_complete_payment', 100, 3 ); |
|
| 632 | +add_action('wpinv_update_status', 'wpinv_complete_payment', 100, 3); |
|
| 633 | 633 | |
| 634 | -function wpinv_update_payment_status( $invoice_id, $new_status = 'publish' ) { |
|
| 635 | - $invoice = !empty( $invoice_id ) && is_object( $invoice_id ) ? $invoice_id : wpinv_get_invoice( (int)$invoice_id ); |
|
| 634 | +function wpinv_update_payment_status($invoice_id, $new_status = 'publish') { |
|
| 635 | + $invoice = !empty($invoice_id) && is_object($invoice_id) ? $invoice_id : wpinv_get_invoice((int)$invoice_id); |
|
| 636 | 636 | |
| 637 | - if ( empty( $invoice ) ) { |
|
| 637 | + if (empty($invoice)) { |
|
| 638 | 638 | return false; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - return $invoice->update_status( $new_status ); |
|
| 641 | + return $invoice->update_status($new_status); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | -function wpinv_cart_has_fees( $type = 'all' ) { |
|
| 644 | +function wpinv_cart_has_fees($type = 'all') { |
|
| 645 | 645 | return false; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | function wpinv_validate_checkout_fields() { |
| 649 | 649 | // Check if there is $_POST |
| 650 | - if ( empty( $_POST ) ) { |
|
| 650 | + if (empty($_POST)) { |
|
| 651 | 651 | return false; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -659,11 +659,11 @@ discard block |
||
| 659 | 659 | ); |
| 660 | 660 | |
| 661 | 661 | // Validate agree to terms |
| 662 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
| 662 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
| 663 | 663 | wpinv_checkout_validate_agree_to_terms(); |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - $valid_data['logged_in_user'] = wpinv_checkout_validate_logged_in_user(); |
|
| 666 | + $valid_data['logged_in_user'] = wpinv_checkout_validate_logged_in_user(); |
|
| 667 | 667 | |
| 668 | 668 | // Return collected data |
| 669 | 669 | return $valid_data; |
@@ -674,26 +674,26 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | $invoice = wpinv_get_invoice_cart(); |
| 676 | 676 | $has_subscription = $invoice->is_recurring(); |
| 677 | - if ( empty( $invoice ) ) { |
|
| 678 | - wpinv_set_error( 'invalid_invoice', __( 'Your cart is empty.', 'invoicing' ) ); |
|
| 677 | + if (empty($invoice)) { |
|
| 678 | + wpinv_set_error('invalid_invoice', __('Your cart is empty.', 'invoicing')); |
|
| 679 | 679 | return $gateway; |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | // Check if a gateway value is present |
| 683 | - if ( !empty( $_REQUEST['wpi-gateway'] ) ) { |
|
| 684 | - $gateway = sanitize_text_field( $_REQUEST['wpi-gateway'] ); |
|
| 683 | + if (!empty($_REQUEST['wpi-gateway'])) { |
|
| 684 | + $gateway = sanitize_text_field($_REQUEST['wpi-gateway']); |
|
| 685 | 685 | |
| 686 | - if ( $invoice->is_free() ) { |
|
| 686 | + if ($invoice->is_free()) { |
|
| 687 | 687 | $gateway = 'manual'; |
| 688 | - } elseif ( !wpinv_is_gateway_active( $gateway ) ) { |
|
| 689 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'invoicing' ) ); |
|
| 690 | - } elseif ( $has_subscription && !wpinv_gateway_support_subscription( $gateway ) ) { |
|
| 691 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway doesnot support subscription payment', 'invoicing' ) ); |
|
| 688 | + } elseif (!wpinv_is_gateway_active($gateway)) { |
|
| 689 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'invoicing')); |
|
| 690 | + } elseif ($has_subscription && !wpinv_gateway_support_subscription($gateway)) { |
|
| 691 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway doesnot support subscription payment', 'invoicing')); |
|
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - if ( $has_subscription && count( wpinv_get_cart_contents() ) > 1 ) { |
|
| 696 | - wpinv_set_error( 'subscription_invalid', __( 'Only one subscription may be purchased through payment per checkout.', 'invoicing' ) ); |
|
| 695 | + if ($has_subscription && count(wpinv_get_cart_contents()) > 1) { |
|
| 696 | + wpinv_set_error('subscription_invalid', __('Only one subscription may be purchased through payment per checkout.', 'invoicing')); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | return $gateway; |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | $error = false; |
| 707 | 707 | // If we have discounts, loop through them |
| 708 | - if ( ! empty( $discounts ) ) { |
|
| 709 | - foreach ( $discounts as $discount ) { |
|
| 708 | + if (!empty($discounts)) { |
|
| 709 | + foreach ($discounts as $discount) { |
|
| 710 | 710 | // Check if valid |
| 711 | - if ( !wpinv_is_discount_valid( $discount, get_current_user_id() ) ) { |
|
| 711 | + if (!wpinv_is_discount_valid($discount, get_current_user_id())) { |
|
| 712 | 712 | // Discount is not valid |
| 713 | 713 | $error = true; |
| 714 | 714 | } |
@@ -718,20 +718,20 @@ discard block |
||
| 718 | 718 | return NULL; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - if ( $error && !wpinv_get_errors() ) { |
|
| 722 | - wpinv_set_error( 'invalid_discount', __( 'Discount code you entered is invalid', 'invoicing' ) ); |
|
| 721 | + if ($error && !wpinv_get_errors()) { |
|
| 722 | + wpinv_set_error('invalid_discount', __('Discount code you entered is invalid', 'invoicing')); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - return implode( ',', $discounts ); |
|
| 725 | + return implode(',', $discounts); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | function wpinv_checkout_validate_cc() { |
| 729 | 729 | $card_data = wpinv_checkout_get_cc_info(); |
| 730 | 730 | |
| 731 | 731 | // Validate the card zip |
| 732 | - if ( !empty( $card_data['wpinv_zip'] ) ) { |
|
| 733 | - if ( !wpinv_checkout_validate_cc_zip( $card_data['wpinv_zip'], $card_data['wpinv_country'] ) ) { |
|
| 734 | - wpinv_set_error( 'invalid_cc_zip', __( 'The zip / postcode you entered for your billing address is invalid', 'invoicing' ) ); |
|
| 732 | + if (!empty($card_data['wpinv_zip'])) { |
|
| 733 | + if (!wpinv_checkout_validate_cc_zip($card_data['wpinv_zip'], $card_data['wpinv_country'])) { |
|
| 734 | + wpinv_set_error('invalid_cc_zip', __('The zip / postcode you entered for your billing address is invalid', 'invoicing')); |
|
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
@@ -741,28 +741,28 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | function wpinv_checkout_get_cc_info() { |
| 743 | 743 | $cc_info = array(); |
| 744 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 745 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 746 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 747 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 748 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 749 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 750 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 751 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 752 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 753 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 744 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 745 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 746 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 747 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 748 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 749 | + $cc_info['card_address'] = isset($_POST['wpinv_address']) ? sanitize_text_field($_POST['wpinv_address']) : ''; |
|
| 750 | + $cc_info['card_city'] = isset($_POST['wpinv_city']) ? sanitize_text_field($_POST['wpinv_city']) : ''; |
|
| 751 | + $cc_info['card_state'] = isset($_POST['wpinv_state']) ? sanitize_text_field($_POST['wpinv_state']) : ''; |
|
| 752 | + $cc_info['card_country'] = isset($_POST['wpinv_country']) ? sanitize_text_field($_POST['wpinv_country']) : ''; |
|
| 753 | + $cc_info['card_zip'] = isset($_POST['wpinv_zip']) ? sanitize_text_field($_POST['wpinv_zip']) : ''; |
|
| 754 | 754 | |
| 755 | 755 | // Return cc info |
| 756 | 756 | return $cc_info; |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | -function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 759 | +function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 760 | 760 | $ret = false; |
| 761 | 761 | |
| 762 | - if ( empty( $zip ) || empty( $country_code ) ) |
|
| 762 | + if (empty($zip) || empty($country_code)) |
|
| 763 | 763 | return $ret; |
| 764 | 764 | |
| 765 | - $country_code = strtoupper( $country_code ); |
|
| 765 | + $country_code = strtoupper($country_code); |
|
| 766 | 766 | |
| 767 | 767 | $zip_regex = array( |
| 768 | 768 | "AD" => "AD\d{3}", |
@@ -922,17 +922,17 @@ discard block |
||
| 922 | 922 | "ZM" => "\d{5}" |
| 923 | 923 | ); |
| 924 | 924 | |
| 925 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) |
|
| 925 | + if (!isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip)) |
|
| 926 | 926 | $ret = true; |
| 927 | 927 | |
| 928 | - return apply_filters( 'wpinv_is_zip_valid', $ret, $zip, $country_code ); |
|
| 928 | + return apply_filters('wpinv_is_zip_valid', $ret, $zip, $country_code); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | function wpinv_checkout_validate_agree_to_terms() { |
| 932 | 932 | // Validate agree to terms |
| 933 | - if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) { |
|
| 933 | + if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) { |
|
| 934 | 934 | // User did not agree |
| 935 | - wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) ); |
|
| 935 | + wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing'))); |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | |
@@ -945,36 +945,36 @@ discard block |
||
| 945 | 945 | ); |
| 946 | 946 | |
| 947 | 947 | // Verify there is a user_ID |
| 948 | - if ( $user_ID > 0 ) { |
|
| 948 | + if ($user_ID > 0) { |
|
| 949 | 949 | // Get the logged in user data |
| 950 | - $user_data = get_userdata( $user_ID ); |
|
| 951 | - $required_fields = wpinv_checkout_required_fields(); |
|
| 950 | + $user_data = get_userdata($user_ID); |
|
| 951 | + $required_fields = wpinv_checkout_required_fields(); |
|
| 952 | 952 | |
| 953 | 953 | // Loop through required fields and show error messages |
| 954 | - if ( !empty( $required_fields ) ) { |
|
| 955 | - foreach ( $required_fields as $field_name => $value ) { |
|
| 956 | - if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
|
| 957 | - wpinv_set_error( $value['error_id'], $value['error_message'] ); |
|
| 954 | + if (!empty($required_fields)) { |
|
| 955 | + foreach ($required_fields as $field_name => $value) { |
|
| 956 | + if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) { |
|
| 957 | + wpinv_set_error($value['error_id'], $value['error_message']); |
|
| 958 | 958 | } |
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | // Verify data |
| 963 | - if ( $user_data ) { |
|
| 963 | + if ($user_data) { |
|
| 964 | 964 | // Collected logged in user data |
| 965 | 965 | $valid_user_data = array( |
| 966 | 966 | 'user_id' => $user_ID, |
| 967 | - 'email' => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email, |
|
| 968 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name, |
|
| 969 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name'] ) ? sanitize_text_field( $_POST['wpinv_last_name'] ) : $user_data->last_name, |
|
| 967 | + 'email' => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email, |
|
| 968 | + 'first_name' => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name, |
|
| 969 | + 'last_name' => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name, |
|
| 970 | 970 | ); |
| 971 | 971 | |
| 972 | - if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) { |
|
| 973 | - wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) ); |
|
| 972 | + if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) { |
|
| 973 | + wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing')); |
|
| 974 | 974 | } |
| 975 | 975 | } else { |
| 976 | 976 | // Set invalid user error |
| 977 | - wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) ); |
|
| 977 | + wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing')); |
|
| 978 | 978 | } |
| 979 | 979 | } |
| 980 | 980 | |
@@ -982,21 +982,21 @@ discard block |
||
| 982 | 982 | return $valid_user_data; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | -function wpinv_checkout_form_get_user( $valid_data = array() ) { |
|
| 985 | +function wpinv_checkout_form_get_user($valid_data = array()) { |
|
| 986 | 986 | // Initialize user |
| 987 | 987 | $user = false; |
| 988 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 988 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 989 | 989 | |
| 990 | 990 | /*if ( $is_ajax ) { |
| 991 | 991 | // Do not create or login the user during the ajax submission (check for errors only) |
| 992 | 992 | return true; |
| 993 | - } else */if ( is_user_logged_in() ) { |
|
| 993 | + } else */if (is_user_logged_in()) { |
|
| 994 | 994 | // Set the valid user as the logged in collected data |
| 995 | 995 | $user = $valid_data['logged_in_user']; |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | // Verify we have an user |
| 999 | - if ( false === $user || empty( $user ) ) { |
|
| 999 | + if (false === $user || empty($user)) { |
|
| 1000 | 1000 | // Return false |
| 1001 | 1001 | return false; |
| 1002 | 1002 | } |
@@ -1015,11 +1015,11 @@ discard block |
||
| 1015 | 1015 | 'zip', |
| 1016 | 1016 | ); |
| 1017 | 1017 | |
| 1018 | - foreach ( $address_fields as $field ) { |
|
| 1019 | - $user[$field] = !empty( $_POST['wpinv_' . $field] ) ? sanitize_text_field( $_POST['wpinv_' . $field] ) : false; |
|
| 1018 | + foreach ($address_fields as $field) { |
|
| 1019 | + $user[$field] = !empty($_POST['wpinv_' . $field]) ? sanitize_text_field($_POST['wpinv_' . $field]) : false; |
|
| 1020 | 1020 | |
| 1021 | - if ( !empty( $user['user_id'] ) ) { |
|
| 1022 | - update_user_meta( $user['user_id'], '_wpinv_' . $field, $user[$field] ); |
|
| 1021 | + if (!empty($user['user_id'])) { |
|
| 1022 | + update_user_meta($user['user_id'], '_wpinv_' . $field, $user[$field]); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | 1025 | |
@@ -1027,28 +1027,28 @@ discard block |
||
| 1027 | 1027 | return $user; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | -function wpinv_set_checkout_session( $invoice_data = array() ) { |
|
| 1030 | +function wpinv_set_checkout_session($invoice_data = array()) { |
|
| 1031 | 1031 | global $wpi_session; |
| 1032 | 1032 | |
| 1033 | - return $wpi_session->set( 'wpinv_checkout', $invoice_data ); |
|
| 1033 | + return $wpi_session->set('wpinv_checkout', $invoice_data); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | function wpinv_get_checkout_session() { |
| 1037 | 1037 | global $wpi_session; |
| 1038 | 1038 | |
| 1039 | - return $wpi_session->get( 'wpinv_checkout' ); |
|
| 1039 | + return $wpi_session->get('wpinv_checkout'); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | function wpinv_empty_cart() { |
| 1043 | 1043 | global $wpi_session; |
| 1044 | 1044 | |
| 1045 | 1045 | // Remove cart contents |
| 1046 | - $wpi_session->set( 'wpinv_checkout', NULL ); |
|
| 1046 | + $wpi_session->set('wpinv_checkout', NULL); |
|
| 1047 | 1047 | |
| 1048 | 1048 | // Remove all cart fees |
| 1049 | - $wpi_session->set( 'wpi_cart_fees', NULL ); |
|
| 1049 | + $wpi_session->set('wpi_cart_fees', NULL); |
|
| 1050 | 1050 | |
| 1051 | - do_action( 'wpinv_empty_cart' ); |
|
| 1051 | + do_action('wpinv_empty_cart'); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | function wpinv_process_checkout() { |
@@ -1060,42 +1060,42 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | $wpi_checkout_id = $invoice->ID; |
| 1062 | 1062 | |
| 1063 | - do_action( 'wpinv_pre_process_checkout' ); |
|
| 1063 | + do_action('wpinv_pre_process_checkout'); |
|
| 1064 | 1064 | |
| 1065 | - if ( !wpinv_get_cart_contents() ) { // Make sure the cart isn't empty |
|
| 1065 | + if (!wpinv_get_cart_contents()) { // Make sure the cart isn't empty |
|
| 1066 | 1066 | $valid_data = false; |
| 1067 | - wpinv_set_error( 'empty_cart', __( 'Your cart is empty', 'invoicing' ) ); |
|
| 1067 | + wpinv_set_error('empty_cart', __('Your cart is empty', 'invoicing')); |
|
| 1068 | 1068 | } else { |
| 1069 | 1069 | // Validate the form $_POST data |
| 1070 | 1070 | $valid_data = wpinv_validate_checkout_fields(); |
| 1071 | 1071 | |
| 1072 | 1072 | // Allow themes and plugins to hook to errors |
| 1073 | - do_action( 'wpinv_checkout_error_checks', $valid_data, $_POST ); |
|
| 1073 | + do_action('wpinv_checkout_error_checks', $valid_data, $_POST); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 1076 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 1077 | 1077 | |
| 1078 | 1078 | // Validate the user |
| 1079 | - $user = wpinv_checkout_form_get_user( $valid_data ); |
|
| 1079 | + $user = wpinv_checkout_form_get_user($valid_data); |
|
| 1080 | 1080 | |
| 1081 | 1081 | // Let extensions validate fields after user is logged in if user has used login/registration form |
| 1082 | - do_action( 'wpinv_checkout_user_error_checks', $user, $valid_data, $_POST ); |
|
| 1082 | + do_action('wpinv_checkout_user_error_checks', $user, $valid_data, $_POST); |
|
| 1083 | 1083 | |
| 1084 | - if ( false === $valid_data || wpinv_get_errors() || ! $user ) { |
|
| 1085 | - if ( $is_ajax ) { |
|
| 1086 | - do_action( 'wpinv_ajax_checkout_errors' ); |
|
| 1084 | + if (false === $valid_data || wpinv_get_errors() || !$user) { |
|
| 1085 | + if ($is_ajax) { |
|
| 1086 | + do_action('wpinv_ajax_checkout_errors'); |
|
| 1087 | 1087 | die(); |
| 1088 | 1088 | } else { |
| 1089 | 1089 | return false; |
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - if ( $is_ajax ) { |
|
| 1093 | + if ($is_ajax) { |
|
| 1094 | 1094 | // Save address fields. |
| 1095 | - $address_fields = array( 'first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company' ); |
|
| 1096 | - foreach ( $address_fields as $field ) { |
|
| 1097 | - if ( isset( $user[$field] ) ) { |
|
| 1098 | - $invoice->set( $field, $user[$field] ); |
|
| 1095 | + $address_fields = array('first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company'); |
|
| 1096 | + foreach ($address_fields as $field) { |
|
| 1097 | + if (isset($user[$field])) { |
|
| 1098 | + $invoice->set($field, $user[$field]); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | $invoice->save(); |
@@ -1103,15 +1103,15 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | $response['success'] = true; |
| 1105 | 1105 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
| 1106 | - $response['data']['subtotalf'] = $invoice->get_subtotal( true ); |
|
| 1106 | + $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
|
| 1107 | 1107 | $response['data']['discount'] = $invoice->get_discount(); |
| 1108 | - $response['data']['discountf'] = $invoice->get_discount( true ); |
|
| 1108 | + $response['data']['discountf'] = $invoice->get_discount(true); |
|
| 1109 | 1109 | $response['data']['tax'] = $invoice->get_tax(); |
| 1110 | - $response['data']['taxf'] = $invoice->get_tax( true ); |
|
| 1110 | + $response['data']['taxf'] = $invoice->get_tax(true); |
|
| 1111 | 1111 | $response['data']['total'] = $invoice->get_total(); |
| 1112 | - $response['data']['totalf'] = $invoice->get_total( true ); |
|
| 1112 | + $response['data']['totalf'] = $invoice->get_total(true); |
|
| 1113 | 1113 | |
| 1114 | - wp_send_json( $response ); |
|
| 1114 | + wp_send_json($response); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | $user_info = array( |
@@ -1133,42 +1133,42 @@ discard block |
||
| 1133 | 1133 | |
| 1134 | 1134 | // Setup invoice information |
| 1135 | 1135 | $invoice_data = array( |
| 1136 | - 'invoice_id' => !empty( $invoice ) ? $invoice->ID : 0, |
|
| 1136 | + 'invoice_id' => !empty($invoice) ? $invoice->ID : 0, |
|
| 1137 | 1137 | 'items' => $cart_items, |
| 1138 | 1138 | 'cart_discounts' => $discounts, |
| 1139 | - 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
| 1140 | - 'subtotal' => wpinv_get_cart_subtotal( $cart_items ), // Amount before taxes and discounts |
|
| 1141 | - 'discount' => wpinv_get_cart_items_discount_amount( $cart_items, $discounts ), // Discounted amount |
|
| 1142 | - 'tax' => wpinv_get_cart_tax( $cart_items ), // Taxed amount |
|
| 1143 | - 'price' => wpinv_get_cart_total( $cart_items, $discounts ), // Amount after taxes |
|
| 1139 | + 'fees' => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart |
|
| 1140 | + 'subtotal' => wpinv_get_cart_subtotal($cart_items), // Amount before taxes and discounts |
|
| 1141 | + 'discount' => wpinv_get_cart_items_discount_amount($cart_items, $discounts), // Discounted amount |
|
| 1142 | + 'tax' => wpinv_get_cart_tax($cart_items), // Taxed amount |
|
| 1143 | + 'price' => wpinv_get_cart_total($cart_items, $discounts), // Amount after taxes |
|
| 1144 | 1144 | 'invoice_key' => $invoice->get_key() ? $invoice->get_key() : $invoice->generate_key(), |
| 1145 | 1145 | 'user_email' => $user['email'], |
| 1146 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 1147 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 1146 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 1147 | + 'user_info' => stripslashes_deep($user_info), |
|
| 1148 | 1148 | 'post_data' => $_POST, |
| 1149 | 1149 | 'cart_details' => $cart_items, |
| 1150 | 1150 | 'gateway' => $valid_data['gateway'], |
| 1151 | 1151 | 'card_info' => $valid_data['cc_info'] |
| 1152 | 1152 | ); |
| 1153 | 1153 | |
| 1154 | - $vat_info = $wpinv_euvat->current_vat_data(); |
|
| 1155 | - if ( is_array( $vat_info ) ) { |
|
| 1154 | + $vat_info = $wpinv_euvat->current_vat_data(); |
|
| 1155 | + if (is_array($vat_info)) { |
|
| 1156 | 1156 | $invoice_data['user_info']['vat_number'] = $vat_info['number']; |
| 1157 | 1157 | $invoice_data['user_info']['vat_rate'] = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state']); |
| 1158 | - $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
| 1158 | + $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false; |
|
| 1159 | 1159 | |
| 1160 | 1160 | // Add the VAT rate to each item in the cart |
| 1161 | - foreach( $invoice_data['cart_details'] as $key => $item_data) { |
|
| 1161 | + foreach ($invoice_data['cart_details'] as $key => $item_data) { |
|
| 1162 | 1162 | $rate = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state'], $item_data['id']); |
| 1163 | - $invoice_data['cart_details'][$key]['vat_rate'] = round( $rate, 3 ); |
|
| 1163 | + $invoice_data['cart_details'][$key]['vat_rate'] = round($rate, 3); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | // Save vat fields. |
| 1168 | - $address_fields = array( 'vat_number', 'vat_rate', 'adddress_confirmed' ); |
|
| 1169 | - foreach ( $address_fields as $field ) { |
|
| 1170 | - if ( isset( $invoice_data['user_info'][$field] ) ) { |
|
| 1171 | - $invoice->set( $field, $invoice_data['user_info'][$field] ); |
|
| 1168 | + $address_fields = array('vat_number', 'vat_rate', 'adddress_confirmed'); |
|
| 1169 | + foreach ($address_fields as $field) { |
|
| 1170 | + if (isset($invoice_data['user_info'][$field])) { |
|
| 1171 | + $invoice->set($field, $invoice_data['user_info'][$field]); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | $invoice->save(); |
@@ -1178,49 +1178,49 @@ discard block |
||
| 1178 | 1178 | $valid_data['user'] = $user; |
| 1179 | 1179 | |
| 1180 | 1180 | // Allow themes and plugins to hook before the gateway |
| 1181 | - do_action( 'wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 1181 | + do_action('wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 1182 | 1182 | |
| 1183 | 1183 | // If the total amount in the cart is 0, send to the manual gateway. This emulates a free invoice |
| 1184 | - if ( !$invoice_data['price'] ) { |
|
| 1184 | + if (!$invoice_data['price']) { |
|
| 1185 | 1185 | // Revert to manual |
| 1186 | 1186 | $invoice_data['gateway'] = 'manual'; |
| 1187 | 1187 | $_POST['wpi-gateway'] = 'manual'; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | // Allow the invoice data to be modified before it is sent to the gateway |
| 1191 | - $invoice_data = apply_filters( 'wpinv_data_before_gateway', $invoice_data, $valid_data ); |
|
| 1191 | + $invoice_data = apply_filters('wpinv_data_before_gateway', $invoice_data, $valid_data); |
|
| 1192 | 1192 | |
| 1193 | 1193 | // Setup the data we're storing in the purchase session |
| 1194 | 1194 | $session_data = $invoice_data; |
| 1195 | 1195 | // Make sure credit card numbers are never stored in sessions |
| 1196 | - if ( !empty( $session_data['card_info']['card_number'] ) ) { |
|
| 1197 | - unset( $session_data['card_info']['card_number'] ); |
|
| 1196 | + if (!empty($session_data['card_info']['card_number'])) { |
|
| 1197 | + unset($session_data['card_info']['card_number']); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | // Used for showing item links to non logged-in users after purchase, and for other plugins needing purchase data. |
| 1201 | - wpinv_set_checkout_session( $invoice_data ); |
|
| 1201 | + wpinv_set_checkout_session($invoice_data); |
|
| 1202 | 1202 | |
| 1203 | 1203 | // Set gateway |
| 1204 | - $invoice->update_meta( '_wpinv_gateway', $invoice_data['gateway'] ); |
|
| 1205 | - $invoice->update_meta( '_wpinv_mode', ( wpinv_is_test_mode( $invoice_data['gateway'] ) ? 'test' : 'live' ) ); |
|
| 1206 | - $invoice->update_meta( '_wpinv_checkout', true ); |
|
| 1204 | + $invoice->update_meta('_wpinv_gateway', $invoice_data['gateway']); |
|
| 1205 | + $invoice->update_meta('_wpinv_mode', (wpinv_is_test_mode($invoice_data['gateway']) ? 'test' : 'live')); |
|
| 1206 | + $invoice->update_meta('_wpinv_checkout', true); |
|
| 1207 | 1207 | |
| 1208 | - do_action( 'wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data ); |
|
| 1208 | + do_action('wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data); |
|
| 1209 | 1209 | |
| 1210 | 1210 | // Send info to the gateway for payment processing |
| 1211 | - wpinv_send_to_gateway( $invoice_data['gateway'], $invoice_data ); |
|
| 1211 | + wpinv_send_to_gateway($invoice_data['gateway'], $invoice_data); |
|
| 1212 | 1212 | die(); |
| 1213 | 1213 | } |
| 1214 | -add_action( 'wpinv_payment', 'wpinv_process_checkout' ); |
|
| 1214 | +add_action('wpinv_payment', 'wpinv_process_checkout'); |
|
| 1215 | 1215 | |
| 1216 | -function wpinv_get_invoices( $args ) { |
|
| 1217 | - $args = wp_parse_args( $args, array( |
|
| 1218 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 1216 | +function wpinv_get_invoices($args) { |
|
| 1217 | + $args = wp_parse_args($args, array( |
|
| 1218 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 1219 | 1219 | 'type' => 'wpi_invoice', |
| 1220 | 1220 | 'parent' => null, |
| 1221 | 1221 | 'user' => null, |
| 1222 | 1222 | 'email' => '', |
| 1223 | - 'limit' => get_option( 'posts_per_page' ), |
|
| 1223 | + 'limit' => get_option('posts_per_page'), |
|
| 1224 | 1224 | 'offset' => null, |
| 1225 | 1225 | 'page' => 1, |
| 1226 | 1226 | 'exclude' => array(), |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | 'order' => 'DESC', |
| 1229 | 1229 | 'return' => 'objects', |
| 1230 | 1230 | 'paginate' => false, |
| 1231 | - ) ); |
|
| 1231 | + )); |
|
| 1232 | 1232 | |
| 1233 | 1233 | // Handle some BW compatibility arg names where wp_query args differ in naming. |
| 1234 | 1234 | $map_legacy = array( |
@@ -1241,20 +1241,20 @@ discard block |
||
| 1241 | 1241 | 'paged' => 'page', |
| 1242 | 1242 | ); |
| 1243 | 1243 | |
| 1244 | - foreach ( $map_legacy as $from => $to ) { |
|
| 1245 | - if ( isset( $args[ $from ] ) ) { |
|
| 1246 | - $args[ $to ] = $args[ $from ]; |
|
| 1244 | + foreach ($map_legacy as $from => $to) { |
|
| 1245 | + if (isset($args[$from])) { |
|
| 1246 | + $args[$to] = $args[$from]; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | - $wpinv_cpt = $_REQUEST[ 'wpinv-cpt' ]; |
|
| 1250 | + $wpinv_cpt = $_REQUEST['wpinv-cpt']; |
|
| 1251 | 1251 | |
| 1252 | - if ( get_query_var( 'paged' ) && 'wpi_invoice' == $wpinv_cpt ) |
|
| 1252 | + if (get_query_var('paged') && 'wpi_invoice' == $wpinv_cpt) |
|
| 1253 | 1253 | $args['page'] = get_query_var('paged'); |
| 1254 | - else if ( get_query_var( 'page' ) && 'wpi_invoice' == $wpinv_cpt ) |
|
| 1255 | - $args['page'] = get_query_var( 'page' ); |
|
| 1256 | - else if ( !empty( $args[ 'page' ] ) ) |
|
| 1257 | - $args['page'] = $args[ 'page' ]; |
|
| 1254 | + else if (get_query_var('page') && 'wpi_invoice' == $wpinv_cpt) |
|
| 1255 | + $args['page'] = get_query_var('page'); |
|
| 1256 | + else if (!empty($args['page'])) |
|
| 1257 | + $args['page'] = $args['page']; |
|
| 1258 | 1258 | else |
| 1259 | 1259 | $args['page'] = 1; |
| 1260 | 1260 | |
@@ -1267,47 +1267,47 @@ discard block |
||
| 1267 | 1267 | 'post_status' => $args['status'], |
| 1268 | 1268 | 'posts_per_page' => $args['limit'], |
| 1269 | 1269 | 'meta_query' => array(), |
| 1270 | - 'date_query' => !empty( $args['date_query'] ) ? $args['date_query'] : array(), |
|
| 1270 | + 'date_query' => !empty($args['date_query']) ? $args['date_query'] : array(), |
|
| 1271 | 1271 | 'fields' => 'ids', |
| 1272 | 1272 | 'orderby' => $args['orderby'], |
| 1273 | 1273 | 'order' => $args['order'], |
| 1274 | 1274 | ); |
| 1275 | 1275 | |
| 1276 | - if ( !empty( $args['user'] ) ) { |
|
| 1277 | - $wp_query_args['author'] = absint( $args['user'] ); |
|
| 1276 | + if (!empty($args['user'])) { |
|
| 1277 | + $wp_query_args['author'] = absint($args['user']); |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | - if ( ! is_null( $args['parent'] ) ) { |
|
| 1281 | - $wp_query_args['post_parent'] = absint( $args['parent'] ); |
|
| 1280 | + if (!is_null($args['parent'])) { |
|
| 1281 | + $wp_query_args['post_parent'] = absint($args['parent']); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | - if ( ! is_null( $args['offset'] ) ) { |
|
| 1285 | - $wp_query_args['offset'] = absint( $args['offset'] ); |
|
| 1284 | + if (!is_null($args['offset'])) { |
|
| 1285 | + $wp_query_args['offset'] = absint($args['offset']); |
|
| 1286 | 1286 | } else { |
| 1287 | - $wp_query_args['paged'] = absint( $args['page'] ); |
|
| 1287 | + $wp_query_args['paged'] = absint($args['page']); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | - if ( ! empty( $args['exclude'] ) ) { |
|
| 1291 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
| 1290 | + if (!empty($args['exclude'])) { |
|
| 1291 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - if ( ! $args['paginate' ] ) { |
|
| 1294 | + if (!$args['paginate']) { |
|
| 1295 | 1295 | $wp_query_args['no_found_rows'] = true; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | // Get results. |
| 1299 | - $invoices = new WP_Query( $wp_query_args ); |
|
| 1299 | + $invoices = new WP_Query($wp_query_args); |
|
| 1300 | 1300 | |
| 1301 | - if ( 'objects' === $args['return'] ) { |
|
| 1302 | - $return = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
| 1303 | - } elseif ( 'self' === $args['return'] ) { |
|
| 1301 | + if ('objects' === $args['return']) { |
|
| 1302 | + $return = array_map('wpinv_get_invoice', $invoices->posts); |
|
| 1303 | + } elseif ('self' === $args['return']) { |
|
| 1304 | 1304 | return $invoices; |
| 1305 | 1305 | } else { |
| 1306 | 1306 | $return = $invoices->posts; |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | - if ( $args['paginate' ] ) { |
|
| 1310 | - return (object) array( |
|
| 1309 | + if ($args['paginate']) { |
|
| 1310 | + return (object)array( |
|
| 1311 | 1311 | 'invoices' => $return, |
| 1312 | 1312 | 'total' => $invoices->found_posts, |
| 1313 | 1313 | 'max_num_pages' => $invoices->max_num_pages, |
@@ -1319,21 +1319,21 @@ discard block |
||
| 1319 | 1319 | |
| 1320 | 1320 | function wpinv_get_user_invoices_columns() { |
| 1321 | 1321 | $columns = array( |
| 1322 | - 'invoice-number' => array( 'title' => __( 'ID', 'invoicing' ), 'class' => 'text-left' ), |
|
| 1323 | - 'invoice-date' => array( 'title' => __( 'Date', 'invoicing' ), 'class' => 'text-left' ), |
|
| 1324 | - 'invoice-status' => array( 'title' => __( 'Status', 'invoicing' ), 'class' => 'text-center' ), |
|
| 1325 | - 'invoice-total' => array( 'title' => __( 'Total', 'invoicing' ), 'class' => 'text-right' ), |
|
| 1326 | - 'invoice-actions' => array( 'title' => ' ', 'class' => 'text-center' ), |
|
| 1322 | + 'invoice-number' => array('title' => __('ID', 'invoicing'), 'class' => 'text-left'), |
|
| 1323 | + 'invoice-date' => array('title' => __('Date', 'invoicing'), 'class' => 'text-left'), |
|
| 1324 | + 'invoice-status' => array('title' => __('Status', 'invoicing'), 'class' => 'text-center'), |
|
| 1325 | + 'invoice-total' => array('title' => __('Total', 'invoicing'), 'class' => 'text-right'), |
|
| 1326 | + 'invoice-actions' => array('title' => ' ', 'class' => 'text-center'), |
|
| 1327 | 1327 | ); |
| 1328 | 1328 | |
| 1329 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
| 1329 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | -function wpinv_payment_receipt( $atts, $content = null ) { |
|
| 1332 | +function wpinv_payment_receipt($atts, $content = null) { |
|
| 1333 | 1333 | global $wpinv_receipt_args; |
| 1334 | 1334 | |
| 1335 | - $wpinv_receipt_args = shortcode_atts( array( |
|
| 1336 | - 'error' => __( 'Sorry, trouble retrieving payment receipt.', 'invoicing' ), |
|
| 1335 | + $wpinv_receipt_args = shortcode_atts(array( |
|
| 1336 | + 'error' => __('Sorry, trouble retrieving payment receipt.', 'invoicing'), |
|
| 1337 | 1337 | 'price' => true, |
| 1338 | 1338 | 'discount' => true, |
| 1339 | 1339 | 'items' => true, |
@@ -1342,185 +1342,185 @@ discard block |
||
| 1342 | 1342 | 'invoice_key' => false, |
| 1343 | 1343 | 'payment_method' => true, |
| 1344 | 1344 | 'invoice_id' => true |
| 1345 | - ), $atts, 'wpinv_receipt' ); |
|
| 1345 | + ), $atts, 'wpinv_receipt'); |
|
| 1346 | 1346 | |
| 1347 | 1347 | $session = wpinv_get_checkout_session(); |
| 1348 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
| 1349 | - $invoice_key = urldecode( $_GET['invoice_key'] ); |
|
| 1350 | - } else if ( $session && isset( $session['invoice_key'] ) ) { |
|
| 1348 | + if (isset($_GET['invoice_key'])) { |
|
| 1349 | + $invoice_key = urldecode($_GET['invoice_key']); |
|
| 1350 | + } else if ($session && isset($session['invoice_key'])) { |
|
| 1351 | 1351 | $invoice_key = $session['invoice_key']; |
| 1352 | - } elseif ( isset( $wpinv_receipt_args['invoice_key'] ) && $wpinv_receipt_args['invoice_key'] ) { |
|
| 1352 | + } elseif (isset($wpinv_receipt_args['invoice_key']) && $wpinv_receipt_args['invoice_key']) { |
|
| 1353 | 1353 | $invoice_key = $wpinv_receipt_args['invoice_key']; |
| 1354 | - } else if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1355 | - $invoice_key = wpinv_get_payment_key( (int)$_GET['invoice-id'] ); |
|
| 1354 | + } else if (isset($_GET['invoice-id'])) { |
|
| 1355 | + $invoice_key = wpinv_get_payment_key((int)$_GET['invoice-id']); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | // No key found |
| 1359 | - if ( ! isset( $invoice_key ) ) { |
|
| 1359 | + if (!isset($invoice_key)) { |
|
| 1360 | 1360 | return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>'; |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1364 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
| 1365 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
| 1363 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 1364 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
| 1365 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
| 1366 | 1366 | $invoice_id = (int)$_GET['invoice-id']; |
| 1367 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
| 1367 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false; |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt |
| 1371 | - if ( ! $user_can_view && ! empty( $invoice_key ) && ! is_user_logged_in() ) { |
|
| 1371 | + if (!$user_can_view && !empty($invoice_key) && !is_user_logged_in()) { |
|
| 1372 | 1372 | // login redirect |
| 1373 | - return '<p class="alert alert-error">' . __( 'You are not allowed to access this section', 'invoicing' ) . '</p>'; |
|
| 1373 | + return '<p class="alert alert-error">' . __('You are not allowed to access this section', 'invoicing') . '</p>'; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - if ( ! apply_filters( 'wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args ) ) { |
|
| 1376 | + if (!apply_filters('wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args)) { |
|
| 1377 | 1377 | return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>'; |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | ob_start(); |
| 1381 | 1381 | |
| 1382 | - wpinv_get_template_part( 'wpinv-invoice-receipt' ); |
|
| 1382 | + wpinv_get_template_part('wpinv-invoice-receipt'); |
|
| 1383 | 1383 | |
| 1384 | 1384 | $display = ob_get_clean(); |
| 1385 | 1385 | |
| 1386 | 1386 | return $display; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | -function wpinv_get_invoice_id_by_key( $key ) { |
|
| 1389 | +function wpinv_get_invoice_id_by_key($key) { |
|
| 1390 | 1390 | global $wpdb; |
| 1391 | 1391 | |
| 1392 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1392 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key)); |
|
| 1393 | 1393 | |
| 1394 | - if ( $invoice_id != NULL ) |
|
| 1394 | + if ($invoice_id != NULL) |
|
| 1395 | 1395 | return $invoice_id; |
| 1396 | 1396 | |
| 1397 | 1397 | return 0; |
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | -function wpinv_can_view_receipt( $invoice_key = '' ) { |
|
| 1400 | +function wpinv_can_view_receipt($invoice_key = '') { |
|
| 1401 | 1401 | $return = false; |
| 1402 | 1402 | |
| 1403 | - if ( empty( $invoice_key ) ) { |
|
| 1403 | + if (empty($invoice_key)) { |
|
| 1404 | 1404 | return $return; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | 1407 | global $wpinv_receipt_args; |
| 1408 | 1408 | |
| 1409 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1410 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1411 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1409 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 1410 | + if (isset($_GET['invoice-id'])) { |
|
| 1411 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? (int)$_GET['invoice-id'] : 0; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | - $user_id = (int) wpinv_get_user_id( $wpinv_receipt_args['id'] ); |
|
| 1415 | - $invoice_meta = wpinv_get_invoice_meta( $wpinv_receipt_args['id'] ); |
|
| 1414 | + $user_id = (int)wpinv_get_user_id($wpinv_receipt_args['id']); |
|
| 1415 | + $invoice_meta = wpinv_get_invoice_meta($wpinv_receipt_args['id']); |
|
| 1416 | 1416 | |
| 1417 | - if ( is_user_logged_in() ) { |
|
| 1418 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 1417 | + if (is_user_logged_in()) { |
|
| 1418 | + if ($user_id === (int)get_current_user_id()) { |
|
| 1419 | 1419 | $return = true; |
| 1420 | 1420 | } |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | $session = wpinv_get_checkout_session(); |
| 1424 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 1425 | - if ( $session['invoice_key'] === $invoice_meta['key'] ) { |
|
| 1424 | + if (!empty($session) && !is_user_logged_in()) { |
|
| 1425 | + if ($session['invoice_key'] === $invoice_meta['key']) { |
|
| 1426 | 1426 | $return = true; |
| 1427 | 1427 | } |
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1430 | + return (bool)apply_filters('wpinv_can_view_receipt', $return, $invoice_key); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | function wpinv_pay_for_invoice() { |
| 1434 | 1434 | global $wpinv_euvat; |
| 1435 | 1435 | |
| 1436 | - if ( isset( $_GET['invoice_key'] ) ) { |
|
| 1436 | + if (isset($_GET['invoice_key'])) { |
|
| 1437 | 1437 | $checkout_uri = wpinv_get_checkout_uri(); |
| 1438 | - $invoice_key = sanitize_text_field( $_GET['invoice_key'] ); |
|
| 1438 | + $invoice_key = sanitize_text_field($_GET['invoice_key']); |
|
| 1439 | 1439 | |
| 1440 | - if ( empty( $invoice_key ) ) { |
|
| 1441 | - wpinv_set_error( 'invalid_invoice', __( 'Invoice not found', 'invoicing' ) ); |
|
| 1442 | - wp_redirect( $checkout_uri ); |
|
| 1440 | + if (empty($invoice_key)) { |
|
| 1441 | + wpinv_set_error('invalid_invoice', __('Invoice not found', 'invoicing')); |
|
| 1442 | + wp_redirect($checkout_uri); |
|
| 1443 | 1443 | wpinv_die(); |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - do_action( 'wpinv_check_pay_for_invoice', $invoice_key ); |
|
| 1446 | + do_action('wpinv_check_pay_for_invoice', $invoice_key); |
|
| 1447 | 1447 | |
| 1448 | - $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1449 | - $user_can_view = wpinv_can_view_receipt( $invoice_key ); |
|
| 1450 | - if ( $user_can_view && isset( $_GET['invoice-id'] ) ) { |
|
| 1448 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 1449 | + $user_can_view = wpinv_can_view_receipt($invoice_key); |
|
| 1450 | + if ($user_can_view && isset($_GET['invoice-id'])) { |
|
| 1451 | 1451 | $invoice_id = (int)$_GET['invoice-id']; |
| 1452 | - $user_can_view = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false; |
|
| 1452 | + $user_can_view = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false; |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | - if ( $invoice_id && $user_can_view && ( $invoice = wpinv_get_invoice( $invoice_id ) ) ) { |
|
| 1456 | - if ( $invoice->needs_payment() ) { |
|
| 1455 | + if ($invoice_id && $user_can_view && ($invoice = wpinv_get_invoice($invoice_id))) { |
|
| 1456 | + if ($invoice->needs_payment()) { |
|
| 1457 | 1457 | $data = array(); |
| 1458 | 1458 | $data['invoice_id'] = $invoice_id; |
| 1459 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
| 1459 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
| 1460 | 1460 | |
| 1461 | - wpinv_set_checkout_session( $data ); |
|
| 1461 | + wpinv_set_checkout_session($data); |
|
| 1462 | 1462 | |
| 1463 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 1463 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 1464 | 1464 | $_POST['country'] = $wpinv_euvat->get_country_by_ip(); |
| 1465 | 1465 | $_POST['state'] = $_POST['country'] == $invoice->country ? $invoice->state : ''; |
| 1466 | 1466 | |
| 1467 | - wpinv_recalculate_tax( true ); |
|
| 1467 | + wpinv_recalculate_tax(true); |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | } else { |
| 1471 | 1471 | $checkout_uri = $invoice->get_view_url(); |
| 1472 | 1472 | } |
| 1473 | 1473 | } else { |
| 1474 | - wpinv_set_error( 'invalid_invoice', __( 'You are not allowed to view this invoice', 'invoicing' ) ); |
|
| 1474 | + wpinv_set_error('invalid_invoice', __('You are not allowed to view this invoice', 'invoicing')); |
|
| 1475 | 1475 | |
| 1476 | - $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() ); |
|
| 1476 | + $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink()); |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | - wp_redirect( $checkout_uri ); |
|
| 1479 | + wp_redirect($checkout_uri); |
|
| 1480 | 1480 | wpinv_die(); |
| 1481 | 1481 | } |
| 1482 | 1482 | } |
| 1483 | -add_action( 'wpinv_pay_for_invoice', 'wpinv_pay_for_invoice' ); |
|
| 1483 | +add_action('wpinv_pay_for_invoice', 'wpinv_pay_for_invoice'); |
|
| 1484 | 1484 | |
| 1485 | -function wpinv_handle_pay_via_invoice_link( $invoice_key ) { |
|
| 1486 | - if ( !empty( $invoice_key ) && !empty( $_REQUEST['_wpipay'] ) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ) ) { |
|
| 1487 | - if ( $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
| 1485 | +function wpinv_handle_pay_via_invoice_link($invoice_key) { |
|
| 1486 | + if (!empty($invoice_key) && !empty($_REQUEST['_wpipay']) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key($invoice_key)) { |
|
| 1487 | + if ($invoice = wpinv_get_invoice($invoice_id)) { |
|
| 1488 | 1488 | $user_id = $invoice->get_user_id(); |
| 1489 | - $secret = sanitize_text_field( $_GET['_wpipay'] ); |
|
| 1489 | + $secret = sanitize_text_field($_GET['_wpipay']); |
|
| 1490 | 1490 | |
| 1491 | - if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice_key ) ) { // valid invoice link |
|
| 1492 | - $redirect_to = remove_query_arg( '_wpipay', get_permalink() ); |
|
| 1491 | + if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice_key)) { // valid invoice link |
|
| 1492 | + $redirect_to = remove_query_arg('_wpipay', get_permalink()); |
|
| 1493 | 1493 | |
| 1494 | - wpinv_guest_redirect( $redirect_to, $user_id ); |
|
| 1494 | + wpinv_guest_redirect($redirect_to, $user_id); |
|
| 1495 | 1495 | wpinv_die(); |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
| 1498 | 1498 | } |
| 1499 | 1499 | } |
| 1500 | -add_action( 'wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link' ); |
|
| 1500 | +add_action('wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link'); |
|
| 1501 | 1501 | |
| 1502 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
| 1503 | - $invoice_id = is_object( $invoice_id ) && !empty( $invoice_id->ID ) ? $invoice_id : $invoice_id; |
|
| 1502 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
| 1503 | + $invoice_id = is_object($invoice_id) && !empty($invoice_id->ID) ? $invoice_id : $invoice_id; |
|
| 1504 | 1504 | |
| 1505 | - if ( empty( $invoice_id ) && $invoice_id > 0 ) { |
|
| 1505 | + if (empty($invoice_id) && $invoice_id > 0) { |
|
| 1506 | 1506 | return false; |
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | - if ( empty( $transaction_id ) ) { |
|
| 1509 | + if (empty($transaction_id)) { |
|
| 1510 | 1510 | $transaction_id = $invoice_id; |
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | - $transaction_id = apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice_id ); |
|
| 1513 | + $transaction_id = apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice_id); |
|
| 1514 | 1514 | |
| 1515 | - return wpinv_update_invoice_meta( $invoice_id, '_wpinv_transaction_id', $transaction_id ); |
|
| 1515 | + return wpinv_update_invoice_meta($invoice_id, '_wpinv_transaction_id', $transaction_id); |
|
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
| 1519 | - if ( empty( $status_display ) ) { |
|
| 1520 | - $status_display = wpinv_status_nicename( $status ); |
|
| 1518 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
| 1519 | + if (empty($status_display)) { |
|
| 1520 | + $status_display = wpinv_status_nicename($status); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | - switch ( $status ) { |
|
| 1523 | + switch ($status) { |
|
| 1524 | 1524 | case 'publish' : |
| 1525 | 1525 | case 'wpi-renewal' : |
| 1526 | 1526 | $class = 'label-success'; |
@@ -1545,28 +1545,28 @@ discard block |
||
| 1545 | 1545 | |
| 1546 | 1546 | $label = '<span class="label label-inv-' . $status . ' ' . $class . '">' . $status_display . '</span>'; |
| 1547 | 1547 | |
| 1548 | - return apply_filters( 'wpinv_invoice_status_label', $label, $status, $status_display ); |
|
| 1548 | + return apply_filters('wpinv_invoice_status_label', $label, $status, $status_display); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | -function wpinv_format_invoice_number( $number ) { |
|
| 1552 | - $padd = wpinv_get_option( 'invoice_number_padd' ); |
|
| 1551 | +function wpinv_format_invoice_number($number) { |
|
| 1552 | + $padd = wpinv_get_option('invoice_number_padd'); |
|
| 1553 | 1553 | |
| 1554 | 1554 | // TODO maintain old invoice numbers if invoice number settings not saved. Should be removed before stable release. |
| 1555 | - if ( $padd === '' || $padd === false || $padd === NULL ) { |
|
| 1556 | - return wp_sprintf( __( 'WPINV-%d', 'invoicing' ), $number ); |
|
| 1555 | + if ($padd === '' || $padd === false || $padd === NULL) { |
|
| 1556 | + return wp_sprintf(__('WPINV-%d', 'invoicing'), $number); |
|
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | - $prefix = wpinv_get_option( 'invoice_number_prefix' ); |
|
| 1560 | - $postfix = wpinv_get_option( 'invoice_number_postfix' ); |
|
| 1559 | + $prefix = wpinv_get_option('invoice_number_prefix'); |
|
| 1560 | + $postfix = wpinv_get_option('invoice_number_postfix'); |
|
| 1561 | 1561 | |
| 1562 | - $padd = absint( $padd ); |
|
| 1563 | - $formatted_number = absint( $number ); |
|
| 1562 | + $padd = absint($padd); |
|
| 1563 | + $formatted_number = absint($number); |
|
| 1564 | 1564 | |
| 1565 | - if ( $padd > 0 ) { |
|
| 1566 | - $formatted_number = zeroise( $formatted_number, $padd ); |
|
| 1565 | + if ($padd > 0) { |
|
| 1566 | + $formatted_number = zeroise($formatted_number, $padd); |
|
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | $formatted_number = $prefix . $formatted_number . $postfix; |
| 1570 | 1570 | |
| 1571 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
| 1571 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
| 1572 | 1572 | } |
| 1573 | 1573 | \ No newline at end of file |
@@ -83,8 +83,9 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
| 85 | 85 | |
| 86 | - if ( $invoice_id != NULL ) |
|
| 87 | - return $invoice_id; |
|
| 86 | + if ( $invoice_id != NULL ) { |
|
| 87 | + return $invoice_id; |
|
| 88 | + } |
|
| 88 | 89 | |
| 89 | 90 | return 0; |
| 90 | 91 | } |
@@ -759,8 +760,9 @@ discard block |
||
| 759 | 760 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
| 760 | 761 | $ret = false; |
| 761 | 762 | |
| 762 | - if ( empty( $zip ) || empty( $country_code ) ) |
|
| 763 | - return $ret; |
|
| 763 | + if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 764 | + return $ret; |
|
| 765 | + } |
|
| 764 | 766 | |
| 765 | 767 | $country_code = strtoupper( $country_code ); |
| 766 | 768 | |
@@ -922,8 +924,9 @@ discard block |
||
| 922 | 924 | "ZM" => "\d{5}" |
| 923 | 925 | ); |
| 924 | 926 | |
| 925 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) |
|
| 926 | - $ret = true; |
|
| 927 | + if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
| 928 | + $ret = true; |
|
| 929 | + } |
|
| 927 | 930 | |
| 928 | 931 | return apply_filters( 'wpinv_is_zip_valid', $ret, $zip, $country_code ); |
| 929 | 932 | } |
@@ -1249,14 +1252,15 @@ discard block |
||
| 1249 | 1252 | |
| 1250 | 1253 | $wpinv_cpt = $_REQUEST[ 'wpinv-cpt' ]; |
| 1251 | 1254 | |
| 1252 | - if ( get_query_var( 'paged' ) && 'wpi_invoice' == $wpinv_cpt ) |
|
| 1253 | - $args['page'] = get_query_var('paged'); |
|
| 1254 | - else if ( get_query_var( 'page' ) && 'wpi_invoice' == $wpinv_cpt ) |
|
| 1255 | - $args['page'] = get_query_var( 'page' ); |
|
| 1256 | - else if ( !empty( $args[ 'page' ] ) ) |
|
| 1257 | - $args['page'] = $args[ 'page' ]; |
|
| 1258 | - else |
|
| 1259 | - $args['page'] = 1; |
|
| 1255 | + if ( get_query_var( 'paged' ) && 'wpi_invoice' == $wpinv_cpt ) { |
|
| 1256 | + $args['page'] = get_query_var('paged'); |
|
| 1257 | + } else if ( get_query_var( 'page' ) && 'wpi_invoice' == $wpinv_cpt ) { |
|
| 1258 | + $args['page'] = get_query_var( 'page' ); |
|
| 1259 | + } else if ( !empty( $args[ 'page' ] ) ) { |
|
| 1260 | + $args['page'] = $args[ 'page' ]; |
|
| 1261 | + } else { |
|
| 1262 | + $args['page'] = 1; |
|
| 1263 | + } |
|
| 1260 | 1264 | |
| 1261 | 1265 | /** |
| 1262 | 1266 | * Generate WP_Query args. This logic will change if orders are moved to |
@@ -1391,8 +1395,9 @@ discard block |
||
| 1391 | 1395 | |
| 1392 | 1396 | $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
| 1393 | 1397 | |
| 1394 | - if ( $invoice_id != NULL ) |
|
| 1395 | - return $invoice_id; |
|
| 1398 | + if ( $invoice_id != NULL ) { |
|
| 1399 | + return $invoice_id; |
|
| 1400 | + } |
|
| 1396 | 1401 | |
| 1397 | 1402 | return 0; |
| 1398 | 1403 | } |
@@ -1,28 +1,28 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -function wpinv_user_invoices( $current_page = 1 ) { |
|
| 5 | +function wpinv_user_invoices($current_page = 1) { |
|
| 6 | 6 | global $current_page; |
| 7 | - do_action( 'wpinv_before_user_invoices_template', $current_page ); |
|
| 8 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
| 9 | - do_action( 'wpinv_after_user_invoices_template', $current_page ); |
|
| 7 | + do_action('wpinv_before_user_invoices_template', $current_page); |
|
| 8 | + wpinv_get_template_part('wpinv-invoice-history'); |
|
| 9 | + do_action('wpinv_after_user_invoices_template', $current_page); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish' ) { |
|
| 13 | - if ( empty( $user ) ) { |
|
| 12 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish') { |
|
| 13 | + if (empty($user)) { |
|
| 14 | 14 | $user = get_current_user_id(); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - if ( 0 === $user ) { |
|
| 17 | + if (0 === $user) { |
|
| 18 | 18 | return false; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - if ( $pagination ) { |
|
| 22 | - if ( get_query_var( 'paged' ) ) |
|
| 21 | + if ($pagination) { |
|
| 22 | + if (get_query_var('paged')) |
|
| 23 | 23 | $paged = get_query_var('paged'); |
| 24 | - else if ( get_query_var( 'page' ) ) |
|
| 25 | - $paged = get_query_var( 'page' ); |
|
| 24 | + else if (get_query_var('page')) |
|
| 25 | + $paged = get_query_var('page'); |
|
| 26 | 26 | else |
| 27 | 27 | $paged = 1; |
| 28 | 28 | } |
@@ -31,21 +31,21 @@ discard block |
||
| 31 | 31 | 'post_type' => 'wpi_invoice', |
| 32 | 32 | 'posts_per_page' => 2, |
| 33 | 33 | 'paged' => null, |
| 34 | - 'post_status' => array( 'publish', 'pending' ), |
|
| 34 | + 'post_status' => array('publish', 'pending'), |
|
| 35 | 35 | 'user' => $user, |
| 36 | 36 | 'order' => 'date', |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - $invoices = get_posts( $args ); |
|
| 39 | + $invoices = get_posts($args); |
|
| 40 | 40 | |
| 41 | 41 | // No invoices |
| 42 | - if ( ! $invoices ) |
|
| 42 | + if (!$invoices) |
|
| 43 | 43 | return false; |
| 44 | 44 | |
| 45 | 45 | return $invoices; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 48 | +function wpinv_dropdown_users($args = '') { |
|
| 49 | 49 | $defaults = array( |
| 50 | 50 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
| 51 | 51 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | 'option_none_value' => -1 |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
| 59 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
| 60 | 60 | |
| 61 | - $r = wp_parse_args( $args, $defaults ); |
|
| 61 | + $r = wp_parse_args($args, $defaults); |
|
| 62 | 62 | |
| 63 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
| 63 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
| 64 | 64 | |
| 65 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
| 65 | + $fields = array('ID', 'user_login', 'user_email'); |
|
| 66 | 66 | |
| 67 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
| 68 | - if ( 'display_name_with_login' === $show ) { |
|
| 67 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
| 68 | + if ('display_name_with_login' === $show) { |
|
| 69 | 69 | $fields[] = 'display_name'; |
| 70 | - } else if ( 'display_name_with_email' === $show ) { |
|
| 70 | + } else if ('display_name_with_email' === $show) { |
|
| 71 | 71 | $fields[] = 'display_name'; |
| 72 | 72 | } else { |
| 73 | 73 | $fields[] = $show; |
@@ -79,99 +79,99 @@ discard block |
||
| 79 | 79 | $show_option_none = $r['show_option_none']; |
| 80 | 80 | $option_none_value = $r['option_none_value']; |
| 81 | 81 | |
| 82 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
| 82 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
| 83 | 83 | |
| 84 | - $users = get_users( $query_args ); |
|
| 84 | + $users = get_users($query_args); |
|
| 85 | 85 | |
| 86 | 86 | $output = ''; |
| 87 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
| 88 | - $name = esc_attr( $r['name'] ); |
|
| 89 | - if ( $r['multi'] && ! $r['id'] ) { |
|
| 87 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
| 88 | + $name = esc_attr($r['name']); |
|
| 89 | + if ($r['multi'] && !$r['id']) { |
|
| 90 | 90 | $id = ''; |
| 91 | 91 | } else { |
| 92 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
| 92 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
| 93 | 93 | } |
| 94 | 94 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
| 95 | 95 | |
| 96 | - if ( $show_option_all ) { |
|
| 96 | + if ($show_option_all) { |
|
| 97 | 97 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( $show_option_none ) { |
|
| 101 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
| 102 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
| 100 | + if ($show_option_none) { |
|
| 101 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
| 102 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
| 105 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
| 106 | 106 | $found_selected = false; |
| 107 | - $r['selected'] = (int) $r['selected']; |
|
| 108 | - foreach ( (array) $users as $user ) { |
|
| 109 | - $user->ID = (int) $user->ID; |
|
| 110 | - if ( $user->ID === $r['selected'] ) { |
|
| 107 | + $r['selected'] = (int)$r['selected']; |
|
| 108 | + foreach ((array)$users as $user) { |
|
| 109 | + $user->ID = (int)$user->ID; |
|
| 110 | + if ($user->ID === $r['selected']) { |
|
| 111 | 111 | $found_selected = true; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( ! $found_selected ) { |
|
| 116 | - $users[] = get_userdata( $r['selected'] ); |
|
| 115 | + if (!$found_selected) { |
|
| 116 | + $users[] = get_userdata($r['selected']); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach ( (array) $users as $user ) { |
|
| 121 | - if ( 'display_name_with_login' === $show ) { |
|
| 120 | + foreach ((array)$users as $user) { |
|
| 121 | + if ('display_name_with_login' === $show) { |
|
| 122 | 122 | /* translators: 1: display name, 2: user_login */ |
| 123 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
| 124 | - } elseif ( 'display_name_with_email' === $show ) { |
|
| 123 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
| 124 | + } elseif ('display_name_with_email' === $show) { |
|
| 125 | 125 | /* translators: 1: display name, 2: user_email */ |
| 126 | - if ( $user->display_name == $user->user_email ) { |
|
| 126 | + if ($user->display_name == $user->user_email) { |
|
| 127 | 127 | $display = $user->display_name; |
| 128 | 128 | } else { |
| 129 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
| 129 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
| 130 | 130 | } |
| 131 | - } elseif ( ! empty( $user->$show ) ) { |
|
| 131 | + } elseif (!empty($user->$show)) { |
|
| 132 | 132 | $display = $user->$show; |
| 133 | 133 | } else { |
| 134 | 134 | $display = '(' . $user->user_login . ')'; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
| 138 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
| 137 | + $_selected = selected($user->ID, $r['selected'], false); |
|
| 138 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $output .= "</select>"; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
| 144 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
| 145 | 145 | |
| 146 | - if ( $r['echo'] ) { |
|
| 146 | + if ($r['echo']) { |
|
| 147 | 147 | echo $html; |
| 148 | 148 | } |
| 149 | 149 | return $html; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
| 153 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
| 154 | - wpinv_login_user( $user_id ); |
|
| 152 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
| 153 | + if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
| 154 | + wpinv_login_user($user_id); |
|
| 155 | 155 | } else { |
| 156 | - $redirect_to = wp_login_url( $redirect_to ); |
|
| 156 | + $redirect_to = wp_login_url($redirect_to); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
| 159 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
| 160 | 160 | |
| 161 | - wp_redirect( $redirect_to ); |
|
| 161 | + wp_redirect($redirect_to); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function wpinv_login_user( $user_id ) { |
|
| 165 | - if ( is_user_logged_in() ) { |
|
| 164 | +function wpinv_login_user($user_id) { |
|
| 165 | + if (is_user_logged_in()) { |
|
| 166 | 166 | return true; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $user = get_user_by( 'id', $user_id ); |
|
| 169 | + $user = get_user_by('id', $user_id); |
|
| 170 | 170 | |
| 171 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
| 172 | - wp_set_current_user( $user_id, $user->user_login ); |
|
| 173 | - wp_set_auth_cookie( $user_id ); |
|
| 174 | - do_action( 'wp_login', $user->user_login ); |
|
| 171 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
| 172 | + wp_set_current_user($user_id, $user->user_login); |
|
| 173 | + wp_set_auth_cookie($user_id); |
|
| 174 | + do_action('wp_login', $user->user_login); |
|
| 175 | 175 | |
| 176 | 176 | return true; |
| 177 | 177 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -21,68 +21,68 @@ discard block |
||
| 21 | 21 | public function init() { |
| 22 | 22 | global $wp_filesystem; |
| 23 | 23 | |
| 24 | - if ( empty( $wp_filesystem ) ) { |
|
| 25 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
| 24 | + if (empty($wp_filesystem)) { |
|
| 25 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
| 26 | 26 | WP_Filesystem(); |
| 27 | 27 | global $wp_filesystem; |
| 28 | 28 | } |
| 29 | 29 | $this->wp_filesystem = $wp_filesystem; |
| 30 | 30 | |
| 31 | 31 | $this->export_dir = $this->export_location(); |
| 32 | - $this->export_url = $this->export_location( true ); |
|
| 32 | + $this->export_url = $this->export_location(true); |
|
| 33 | 33 | $this->export = 'invoicing'; |
| 34 | 34 | $this->filetype = 'csv'; |
| 35 | 35 | $this->per_page = 20; |
| 36 | 36 | |
| 37 | - do_action( 'wpinv_class_reports_init', $this ); |
|
| 37 | + do_action('wpinv_class_reports_init', $this); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function includes() { |
| 41 | - do_action( 'wpinv_class_reports_includes', $this ); |
|
| 41 | + do_action('wpinv_class_reports_includes', $this); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function actions() { |
| 45 | - if ( is_admin() ) { |
|
| 46 | - add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 ); |
|
| 47 | - add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) ); |
|
| 48 | - add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) ); |
|
| 45 | + if (is_admin()) { |
|
| 46 | + add_action('admin_menu', array($this, 'add_submenu'), 10); |
|
| 47 | + add_action('wpinv_reports_tab_export', array($this, 'export')); |
|
| 48 | + add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export')); |
|
| 49 | 49 | |
| 50 | 50 | // Export Invoices. |
| 51 | - add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) ); |
|
| 52 | - add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) ); |
|
| 53 | - add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) ); |
|
| 54 | - add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) ); |
|
| 51 | + add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export')); |
|
| 52 | + add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns')); |
|
| 53 | + add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data')); |
|
| 54 | + add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status')); |
|
| 55 | 55 | } |
| 56 | - do_action( 'wpinv_class_reports_actions', $this ); |
|
| 56 | + do_action('wpinv_class_reports_actions', $this); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function add_submenu() { |
| 60 | 60 | global $wpi_reports_page; |
| 61 | - $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), 'manage_options', 'wpinv-reports', array( $this, 'reports_page' ) ); |
|
| 61 | + $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), 'manage_options', 'wpinv-reports', array($this, 'reports_page')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function reports_page() { |
| 65 | - if ( !wp_script_is( 'postbox', 'enqueued' ) ) { |
|
| 66 | - wp_enqueue_script( 'postbox' ); |
|
| 65 | + if (!wp_script_is('postbox', 'enqueued')) { |
|
| 66 | + wp_enqueue_script('postbox'); |
|
| 67 | 67 | } |
| 68 | - if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
|
| 69 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 68 | + if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) { |
|
| 69 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $current_page = admin_url( 'admin.php?page=wpinv-reports' ); |
|
| 73 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export'; |
|
| 72 | + $current_page = admin_url('admin.php?page=wpinv-reports'); |
|
| 73 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export'; |
|
| 74 | 74 | ?> |
| 75 | 75 | <div class="wrap wpi-reports-wrap"> |
| 76 | - <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1> |
|
| 76 | + <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1> |
|
| 77 | 77 | <h2 class="nav-tab-wrapper wp-clearfix"> |
| 78 | - <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a> |
|
| 79 | - <?php do_action( 'wpinv_reports_page_tabs' ); ;?> |
|
| 78 | + <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a> |
|
| 79 | + <?php do_action('wpinv_reports_page_tabs'); ;?> |
|
| 80 | 80 | </h2> |
| 81 | 81 | <div class="wpi-reports-content wpi-reports-<?php echo $active_tab; ?>"> |
| 82 | 82 | <?php |
| 83 | - do_action( 'wpinv_reports_page_top' ); |
|
| 84 | - do_action( 'wpinv_reports_tab_' . $active_tab ); |
|
| 85 | - do_action( 'wpinv_reports_page_bottom' ); |
|
| 83 | + do_action('wpinv_reports_page_top'); |
|
| 84 | + do_action('wpinv_reports_tab_' . $active_tab); |
|
| 85 | + do_action('wpinv_reports_page_bottom'); |
|
| 86 | 86 | ?> |
| 87 | 87 | </div> |
| 88 | 88 | <?php |
@@ -90,97 +90,97 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | public function export() { |
| 92 | 92 | $statuses = wpinv_get_invoice_statuses(); |
| 93 | - $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses ); |
|
| 93 | + $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses); |
|
| 94 | 94 | ?> |
| 95 | 95 | <div class="metabox-holder"> |
| 96 | 96 | <div id="post-body"> |
| 97 | 97 | <div id="post-body-content"> |
| 98 | - <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?> |
|
| 98 | + <?php do_action('wpinv_reports_tab_export_content_top'); ?> |
|
| 99 | 99 | |
| 100 | 100 | <div class="postbox wpi-export-invoices"> |
| 101 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2> |
|
| 101 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2> |
|
| 102 | 102 | <div class="inside"> |
| 103 | - <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p> |
|
| 103 | + <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p> |
|
| 104 | 104 | <form id="wpi-export-invoices" class="wpi-export-form" method="post"> |
| 105 | - <?php echo wpinv_html_date_field( array( |
|
| 105 | + <?php echo wpinv_html_date_field(array( |
|
| 106 | 106 | 'id' => 'wpi_export_from_date', |
| 107 | 107 | 'name' => 'from_date', |
| 108 | 108 | 'data' => array( |
| 109 | 109 | 'dateFormat' => 'yy-mm-dd' |
| 110 | 110 | ), |
| 111 | - 'placeholder' => __( 'From date', 'invoicing' ) ) |
|
| 111 | + 'placeholder' => __('From date', 'invoicing') ) |
|
| 112 | 112 | ); ?> |
| 113 | - <?php echo wpinv_html_date_field( array( |
|
| 113 | + <?php echo wpinv_html_date_field(array( |
|
| 114 | 114 | 'id' => 'wpi_export_to_date', |
| 115 | 115 | 'name' => 'to_date', |
| 116 | 116 | 'data' => array( |
| 117 | 117 | 'dateFormat' => 'yy-mm-dd' |
| 118 | 118 | ), |
| 119 | - 'placeholder' => __( 'To date', 'invoicing' ) ) |
|
| 119 | + 'placeholder' => __('To date', 'invoicing') ) |
|
| 120 | 120 | ); ?> |
| 121 | 121 | <span id="wpinv-status-wrap"> |
| 122 | - <?php echo wpinv_html_select( array( |
|
| 122 | + <?php echo wpinv_html_select(array( |
|
| 123 | 123 | 'options' => $statuses, |
| 124 | 124 | 'name' => 'status', |
| 125 | 125 | 'id' => 'wpi_export_status', |
| 126 | 126 | 'show_option_all' => false, |
| 127 | 127 | 'show_option_none' => false, |
| 128 | 128 | 'class' => '', |
| 129 | - ) ); ?> |
|
| 130 | - <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?> |
|
| 129 | + )); ?> |
|
| 130 | + <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?> |
|
| 131 | 131 | </span> |
| 132 | 132 | <span id="wpinv-submit-wrap"> |
| 133 | 133 | <input type="hidden" value="invoices" name="export" /> |
| 134 | - <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" /> |
|
| 134 | + <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" /> |
|
| 135 | 135 | </span> |
| 136 | 136 | </form> |
| 137 | 137 | </div> |
| 138 | 138 | </div> |
| 139 | 139 | |
| 140 | - <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?> |
|
| 140 | + <?php do_action('wpinv_reports_tab_export_content_bottom'); ?> |
|
| 141 | 141 | </div> |
| 142 | 142 | </div> |
| 143 | 143 | </div> |
| 144 | 144 | <?php |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function export_location( $relative = false ) { |
|
| 147 | + public function export_location($relative = false) { |
|
| 148 | 148 | $upload_dir = wp_upload_dir(); |
| 149 | - $export_location = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache'; |
|
| 150 | - $export_location = apply_filters( 'wpinv_export_location', $export_location, $relative ); |
|
| 149 | + $export_location = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache'; |
|
| 150 | + $export_location = apply_filters('wpinv_export_location', $export_location, $relative); |
|
| 151 | 151 | |
| 152 | - return trailingslashit( $export_location ); |
|
| 152 | + return trailingslashit($export_location); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function check_export_location() { |
| 156 | 156 | try { |
| 157 | - if ( empty( $this->wp_filesystem ) ) { |
|
| 158 | - return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' ); |
|
| 157 | + if (empty($this->wp_filesystem)) { |
|
| 158 | + return __('Filesystem ERROR: Could not access filesystem.', 'invoicing'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( is_wp_error( $this->wp_filesystem ) ) { |
|
| 162 | - return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' ); |
|
| 161 | + if (is_wp_error($this->wp_filesystem)) { |
|
| 162 | + return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing'); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $is_dir = $this->wp_filesystem->is_dir( $this->export_dir ); |
|
| 166 | - $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
|
| 165 | + $is_dir = $this->wp_filesystem->is_dir($this->export_dir); |
|
| 166 | + $is_writeable = $is_dir && is_writeable($this->export_dir); |
|
| 167 | 167 | |
| 168 | - if ( $is_dir && $is_writeable ) { |
|
| 168 | + if ($is_dir && $is_writeable) { |
|
| 169 | 169 | return true; |
| 170 | - } else if ( $is_dir && !$is_writeable ) { |
|
| 171 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
| 172 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
| 170 | + } else if ($is_dir && !$is_writeable) { |
|
| 171 | + if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) { |
|
| 172 | + return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return true; |
| 176 | 176 | } else { |
| 177 | - if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
| 178 | - return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
|
| 177 | + if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) { |
|
| 178 | + return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return true; |
| 182 | 182 | } |
| 183 | - } catch ( Exception $e ) { |
|
| 183 | + } catch (Exception $e) { |
|
| 184 | 184 | return $e->getMessage(); |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -188,130 +188,130 @@ discard block |
||
| 188 | 188 | public function ajax_export() { |
| 189 | 189 | $response = array(); |
| 190 | 190 | $response['success'] = false; |
| 191 | - $response['msg'] = __( 'Invalid export request found.', 'invoicing' ); |
|
| 191 | + $response['msg'] = __('Invalid export request found.', 'invoicing'); |
|
| 192 | 192 | |
| 193 | - if ( empty( $_POST['data'] ) || !current_user_can( 'manage_options' ) ) { |
|
| 194 | - wp_send_json( $response ); |
|
| 193 | + if (empty($_POST['data']) || !current_user_can('manage_options')) { |
|
| 194 | + wp_send_json($response); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - parse_str( $_POST['data'], $data ); |
|
| 197 | + parse_str($_POST['data'], $data); |
|
| 198 | 198 | |
| 199 | - $data['step'] = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; |
|
| 199 | + $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1; |
|
| 200 | 200 | |
| 201 | 201 | $_REQUEST = (array)$data; |
| 202 | - if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) { |
|
| 203 | - $response['msg'] = __( 'Security check failed.', 'invoicing' ); |
|
| 204 | - wp_send_json( $response ); |
|
| 202 | + if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) { |
|
| 203 | + $response['msg'] = __('Security check failed.', 'invoicing'); |
|
| 204 | + wp_send_json($response); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( ( $error = $this->check_export_location( true ) ) !== true ) { |
|
| 208 | - $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' ); |
|
| 209 | - wp_send_json( $response ); |
|
| 207 | + if (($error = $this->check_export_location(true)) !== true) { |
|
| 208 | + $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing'); |
|
| 209 | + wp_send_json($response); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $this->set_export_params( $_REQUEST ); |
|
| 212 | + $this->set_export_params($_REQUEST); |
|
| 213 | 213 | |
| 214 | 214 | $return = $this->process_export_step(); |
| 215 | 215 | $done = $this->get_export_status(); |
| 216 | 216 | |
| 217 | - if ( $return ) { |
|
| 217 | + if ($return) { |
|
| 218 | 218 | $this->step += 1; |
| 219 | 219 | |
| 220 | 220 | $response['success'] = true; |
| 221 | 221 | $response['msg'] = ''; |
| 222 | 222 | |
| 223 | - if ( $done >= 100 ) { |
|
| 223 | + if ($done >= 100) { |
|
| 224 | 224 | $this->step = 'done'; |
| 225 | - $new_filename = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype; |
|
| 225 | + $new_filename = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype; |
|
| 226 | 226 | $new_file = $this->export_dir . $new_filename; |
| 227 | 227 | |
| 228 | - if ( file_exists( $this->file ) ) { |
|
| 229 | - $this->wp_filesystem->move( $this->file, $new_file, true ); |
|
| 228 | + if (file_exists($this->file)) { |
|
| 229 | + $this->wp_filesystem->move($this->file, $new_file, true); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ( file_exists( $new_file ) ) { |
|
| 233 | - $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) ); |
|
| 232 | + if (file_exists($new_file)) { |
|
| 233 | + $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2)); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $response['data']['step'] = $this->step; |
| 238 | 238 | $response['data']['done'] = $done; |
| 239 | 239 | } else { |
| 240 | - $response['msg'] = __( 'No data found for export.', 'invoicing' ); |
|
| 240 | + $response['msg'] = __('No data found for export.', 'invoicing'); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - wp_send_json( $response ); |
|
| 243 | + wp_send_json($response); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - public function set_export_params( $request ) { |
|
| 246 | + public function set_export_params($request) { |
|
| 247 | 247 | $this->empty = false; |
| 248 | - $this->step = !empty( $request['step'] ) ? absint( $request['step'] ) : 1; |
|
| 249 | - $this->export = !empty( $request['export'] ) ? $request['export'] : $this->export; |
|
| 248 | + $this->step = !empty($request['step']) ? absint($request['step']) : 1; |
|
| 249 | + $this->export = !empty($request['export']) ? $request['export'] : $this->export; |
|
| 250 | 250 | $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype; |
| 251 | 251 | $this->file = $this->export_dir . $this->filename; |
| 252 | 252 | |
| 253 | - do_action( 'wpinv_export_set_params_' . $this->export, $request ); |
|
| 253 | + do_action('wpinv_export_set_params_' . $this->export, $request); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | public function get_columns() { |
| 257 | 257 | $columns = array( |
| 258 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 259 | - 'date' => __( 'Date', 'invoicing' ) |
|
| 258 | + 'id' => __('ID', 'invoicing'), |
|
| 259 | + 'date' => __('Date', 'invoicing') |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns ); |
|
| 262 | + return apply_filters('wpinv_export_get_columns_' . $this->export, $columns); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | protected function get_export_file() { |
| 266 | 266 | $file = ''; |
| 267 | 267 | |
| 268 | - if ( $this->wp_filesystem->exists( $this->file ) ) { |
|
| 269 | - $file = $this->wp_filesystem->get_contents( $this->file ); |
|
| 268 | + if ($this->wp_filesystem->exists($this->file)) { |
|
| 269 | + $file = $this->wp_filesystem->get_contents($this->file); |
|
| 270 | 270 | } else { |
| 271 | - $this->wp_filesystem->put_contents( $this->file, '' ); |
|
| 271 | + $this->wp_filesystem->put_contents($this->file, ''); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | return $file; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - protected function attach_export_data( $data = '' ) { |
|
| 278 | - $filedata = $this->get_export_file(); |
|
| 279 | - $filedata .= $data; |
|
| 277 | + protected function attach_export_data($data = '') { |
|
| 278 | + $filedata = $this->get_export_file(); |
|
| 279 | + $filedata .= $data; |
|
| 280 | 280 | |
| 281 | - $this->wp_filesystem->put_contents( $this->file, $filedata ); |
|
| 281 | + $this->wp_filesystem->put_contents($this->file, $filedata); |
|
| 282 | 282 | |
| 283 | - $rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
| 283 | + $rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
| 284 | 284 | $columns = $this->get_columns(); |
| 285 | - $columns = empty( $columns ) ? 0 : 1; |
|
| 285 | + $columns = empty($columns) ? 0 : 1; |
|
| 286 | 286 | |
| 287 | - $this->empty = count( $rows ) == $columns ? true : false; |
|
| 287 | + $this->empty = count($rows) == $columns ? true : false; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | public function print_columns() { |
| 291 | 291 | $column_data = ''; |
| 292 | 292 | $columns = $this->get_columns(); |
| 293 | 293 | $i = 1; |
| 294 | - foreach( $columns as $key => $column ) { |
|
| 295 | - $column_data .= '"' . addslashes( $column ) . '"'; |
|
| 296 | - $column_data .= $i == count( $columns ) ? '' : ','; |
|
| 294 | + foreach ($columns as $key => $column) { |
|
| 295 | + $column_data .= '"' . addslashes($column) . '"'; |
|
| 296 | + $column_data .= $i == count($columns) ? '' : ','; |
|
| 297 | 297 | $i++; |
| 298 | 298 | } |
| 299 | 299 | $column_data .= "\r\n"; |
| 300 | 300 | |
| 301 | - $this->attach_export_data( $column_data ); |
|
| 301 | + $this->attach_export_data($column_data); |
|
| 302 | 302 | |
| 303 | 303 | return $column_data; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | public function process_export_step() { |
| 307 | - if ( $this->step < 2 ) { |
|
| 308 | - @unlink( $this->file ); |
|
| 307 | + if ($this->step < 2) { |
|
| 308 | + @unlink($this->file); |
|
| 309 | 309 | $this->print_columns(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $return = $this->print_rows(); |
| 313 | 313 | |
| 314 | - if ( $return ) { |
|
| 314 | + if ($return) { |
|
| 315 | 315 | return true; |
| 316 | 316 | } else { |
| 317 | 317 | return false; |
@@ -320,23 +320,23 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | public function get_export_status() { |
| 322 | 322 | $status = 100; |
| 323 | - return apply_filters( 'wpinv_get_export_status_' . $this->export, $status ); |
|
| 323 | + return apply_filters('wpinv_get_export_status_' . $this->export, $status); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | public function get_export_data() { |
| 327 | 327 | $data = array( |
| 328 | 328 | 0 => array( |
| 329 | 329 | 'id' => '', |
| 330 | - 'data' => date( 'F j, Y' ) |
|
| 330 | + 'data' => date('F j, Y') |
|
| 331 | 331 | ), |
| 332 | 332 | 1 => array( |
| 333 | 333 | 'id' => '', |
| 334 | - 'data' => date( 'F j, Y' ) |
|
| 334 | + 'data' => date('F j, Y') |
|
| 335 | 335 | ) |
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | - $data = apply_filters( 'wpinv_export_get_data', $data ); |
|
| 339 | - $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data ); |
|
| 338 | + $data = apply_filters('wpinv_export_get_data', $data); |
|
| 339 | + $data = apply_filters('wpinv_export_get_data_' . $this->export, $data); |
|
| 340 | 340 | |
| 341 | 341 | return $data; |
| 342 | 342 | } |
@@ -346,20 +346,20 @@ discard block |
||
| 346 | 346 | $data = $this->get_export_data(); |
| 347 | 347 | $columns = $this->get_columns(); |
| 348 | 348 | |
| 349 | - if ( $data ) { |
|
| 350 | - foreach ( $data as $row ) { |
|
| 349 | + if ($data) { |
|
| 350 | + foreach ($data as $row) { |
|
| 351 | 351 | $i = 1; |
| 352 | - foreach ( $row as $key => $column ) { |
|
| 353 | - if ( array_key_exists( $key, $columns ) ) { |
|
| 354 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
| 355 | - $row_data .= $i == count( $columns ) ? '' : ','; |
|
| 352 | + foreach ($row as $key => $column) { |
|
| 353 | + if (array_key_exists($key, $columns)) { |
|
| 354 | + $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"'; |
|
| 355 | + $row_data .= $i == count($columns) ? '' : ','; |
|
| 356 | 356 | $i++; |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | $row_data .= "\r\n"; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $this->attach_export_data( $row_data ); |
|
| 362 | + $this->attach_export_data($row_data); |
|
| 363 | 363 | |
| 364 | 364 | return $row_data; |
| 365 | 365 | } |
@@ -368,46 +368,46 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | // Export Invoices. |
| 371 | - public function set_invoices_export( $request ) { |
|
| 372 | - $this->from_date = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : ''; |
|
| 373 | - $this->to_date = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : ''; |
|
| 374 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish'; |
|
| 371 | + public function set_invoices_export($request) { |
|
| 372 | + $this->from_date = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : ''; |
|
| 373 | + $this->to_date = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : ''; |
|
| 374 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish'; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - public function get_invoices_columns( $columns = array() ) { |
|
| 377 | + public function get_invoices_columns($columns = array()) { |
|
| 378 | 378 | $columns = array( |
| 379 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 380 | - 'number' => __( 'Number', 'invoicing' ), |
|
| 381 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 382 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 383 | - 'status_nicename' => __( 'Status Nicename', 'invoicing' ), |
|
| 384 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 385 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 386 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 387 | - 'user_id' => __( 'User ID', 'invoicing' ), |
|
| 388 | - 'email' => __( 'Email', 'invoicing' ), |
|
| 389 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
| 390 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
| 391 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 392 | - 'city' => __( 'City', 'invoicing' ), |
|
| 393 | - 'state' => __( 'State', 'invoicing' ), |
|
| 394 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 395 | - 'zip' => __( 'Zipcode', 'invoicing' ), |
|
| 396 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 397 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 398 | - 'vat_number' => __( 'Vat Number', 'invoicing' ), |
|
| 399 | - 'ip' => __( 'IP', 'invoicing' ), |
|
| 400 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
| 401 | - 'gateway_nicename' => __( 'Gateway Nicename', 'invoicing' ), |
|
| 402 | - 'transaction_id'=> __( 'Transaction ID', 'invoicing' ), |
|
| 403 | - 'currency' => __( 'Currency', 'invoicing' ), |
|
| 404 | - 'due_date' => __( 'Due Date', 'invoicing' ), |
|
| 379 | + 'id' => __('ID', 'invoicing'), |
|
| 380 | + 'number' => __('Number', 'invoicing'), |
|
| 381 | + 'date' => __('Date', 'invoicing'), |
|
| 382 | + 'amount' => __('Amount', 'invoicing'), |
|
| 383 | + 'status_nicename' => __('Status Nicename', 'invoicing'), |
|
| 384 | + 'status' => __('Status', 'invoicing'), |
|
| 385 | + 'tax' => __('Tax', 'invoicing'), |
|
| 386 | + 'discount' => __('Discount', 'invoicing'), |
|
| 387 | + 'user_id' => __('User ID', 'invoicing'), |
|
| 388 | + 'email' => __('Email', 'invoicing'), |
|
| 389 | + 'first_name' => __('First Name', 'invoicing'), |
|
| 390 | + 'last_name' => __('Last Name', 'invoicing'), |
|
| 391 | + 'address' => __('Address', 'invoicing'), |
|
| 392 | + 'city' => __('City', 'invoicing'), |
|
| 393 | + 'state' => __('State', 'invoicing'), |
|
| 394 | + 'country' => __('Country', 'invoicing'), |
|
| 395 | + 'zip' => __('Zipcode', 'invoicing'), |
|
| 396 | + 'phone' => __('Phone', 'invoicing'), |
|
| 397 | + 'company' => __('Company', 'invoicing'), |
|
| 398 | + 'vat_number' => __('Vat Number', 'invoicing'), |
|
| 399 | + 'ip' => __('IP', 'invoicing'), |
|
| 400 | + 'gateway' => __('Gateway', 'invoicing'), |
|
| 401 | + 'gateway_nicename' => __('Gateway Nicename', 'invoicing'), |
|
| 402 | + 'transaction_id'=> __('Transaction ID', 'invoicing'), |
|
| 403 | + 'currency' => __('Currency', 'invoicing'), |
|
| 404 | + 'due_date' => __('Due Date', 'invoicing'), |
|
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | 407 | return $columns; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - public function get_invoices_data( $response = array() ) { |
|
| 410 | + public function get_invoices_data($response = array()) { |
|
| 411 | 411 | $args = array( |
| 412 | 412 | 'limit' => $this->per_page, |
| 413 | 413 | 'page' => $this->step, |
@@ -415,35 +415,35 @@ discard block |
||
| 415 | 415 | 'orderby' => 'date', |
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | - if ( $this->status != 'any' ) { |
|
| 418 | + if ($this->status != 'any') { |
|
| 419 | 419 | $args['status'] = $this->status; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
| 422 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
| 423 | 423 | $args['date_query'] = array( |
| 424 | 424 | array( |
| 425 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
| 426 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
| 425 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
| 426 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
| 427 | 427 | 'inclusive' => true |
| 428 | 428 | ) |
| 429 | 429 | ); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - $invoices = wpinv_get_invoices( $args ); |
|
| 432 | + $invoices = wpinv_get_invoices($args); |
|
| 433 | 433 | |
| 434 | 434 | $data = array(); |
| 435 | 435 | |
| 436 | - if ( !empty( $invoices ) ) { |
|
| 437 | - foreach ( $invoices as $invoice ) { |
|
| 436 | + if (!empty($invoices)) { |
|
| 437 | + foreach ($invoices as $invoice) { |
|
| 438 | 438 | $row = array( |
| 439 | 439 | 'id' => $invoice->ID, |
| 440 | 440 | 'number' => $invoice->get_number(), |
| 441 | - 'date' => $invoice->get_invoice_date( false ), |
|
| 442 | - 'amount' => wpinv_round_amount( $invoice->get_total() ), |
|
| 443 | - 'status_nicename' => $invoice->get_status( true ), |
|
| 441 | + 'date' => $invoice->get_invoice_date(false), |
|
| 442 | + 'amount' => wpinv_round_amount($invoice->get_total()), |
|
| 443 | + 'status_nicename' => $invoice->get_status(true), |
|
| 444 | 444 | 'status' => $invoice->get_status(), |
| 445 | - 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '', |
|
| 446 | - 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '', |
|
| 445 | + 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '', |
|
| 446 | + 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '', |
|
| 447 | 447 | 'user_id' => $invoice->get_user_id(), |
| 448 | 448 | 'email' => $invoice->get_email(), |
| 449 | 449 | 'first_name' => $invoice->get_first_name(), |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | 'due_date' => $invoice->needs_payment() ? $invoice->get_due_date() : '', |
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | - $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice ); |
|
| 467 | + $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | return $data; |
@@ -480,29 +480,29 @@ discard block |
||
| 480 | 480 | 'return' => 'ids', |
| 481 | 481 | ); |
| 482 | 482 | |
| 483 | - if ( $this->status != 'any' ) { |
|
| 483 | + if ($this->status != 'any') { |
|
| 484 | 484 | $args['status'] = $this->status; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
| 487 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
| 488 | 488 | $args['date_query'] = array( |
| 489 | 489 | array( |
| 490 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
| 491 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
| 490 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
| 491 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
| 492 | 492 | 'inclusive' => true |
| 493 | 493 | ) |
| 494 | 494 | ); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $invoices = wpinv_get_invoices( $args ); |
|
| 498 | - $total = !empty( $invoices ) ? count( $invoices ) : 0; |
|
| 497 | + $invoices = wpinv_get_invoices($args); |
|
| 498 | + $total = !empty($invoices) ? count($invoices) : 0; |
|
| 499 | 499 | $status = 100; |
| 500 | 500 | |
| 501 | - if ( $total > 0 ) { |
|
| 502 | - $status = ( ( $this->per_page * $this->step ) / $total ) * 100; |
|
| 501 | + if ($total > 0) { |
|
| 502 | + $status = (($this->per_page * $this->step) / $total) * 100; |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - if ( $status > 100 ) { |
|
| 505 | + if ($status > 100) { |
|
| 506 | 506 | $status = 100; |
| 507 | 507 | } |
| 508 | 508 | |