@@ -2,11 +2,11 @@ |
||
2 | 2 | global $wpi_invoice; |
3 | 3 | |
4 | 4 | $success_page_uri = wpinv_get_success_page_uri(); |
5 | -if ( !empty( $wpi_invoice ) ) { |
|
6 | - $success_page_uri = add_query_arg( 'invoice_key', $wpi_invoice->get_key(), $success_page_uri ); |
|
5 | +if (!empty($wpi_invoice)) { |
|
6 | + $success_page_uri = add_query_arg('invoice_key', $wpi_invoice->get_key(), $success_page_uri); |
|
7 | 7 | } |
8 | 8 | ?> |
9 | 9 | <div id="wpinv-payment-processing"> |
10 | - <p><?php echo wp_sprintf( __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), $success_page_uri ); ?> <i class="fa fa-spin fa-refresh"></i></p> |
|
10 | + <p><?php echo wp_sprintf(__('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), $success_page_uri); ?> <i class="fa fa-spin fa-refresh"></i></p> |
|
11 | 11 | <script type="text/javascript">setTimeout(function(){ window.location = '<?php echo $success_page_uri; ?>'; }, 10000);</script> |
12 | 12 | </div> |
13 | 13 | \ No newline at end of file |
@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | */ |
5 | 5 | global $wpinv_receipt_args; |
6 | 6 | |
7 | -$invoice = get_post( $wpinv_receipt_args['id'] ); |
|
7 | +$invoice = get_post($wpinv_receipt_args['id']); |
|
8 | 8 | |
9 | -if( empty( $invoice ) ) { |
|
9 | +if (empty($invoice)) { |
|
10 | 10 | ?> |
11 | 11 | <div class="wpinv_errors alert wpi-alert-error"> |
12 | - <?php _e( 'The specified receipt ID appears to be invalid', 'invoicing' ); ?> |
|
12 | + <?php _e('The specified receipt ID appears to be invalid', 'invoicing'); ?> |
|
13 | 13 | </div> |
14 | 14 | <?php |
15 | 15 | return; |
16 | 16 | } |
17 | -$invoice = wpinv_get_invoice( $invoice->ID ); |
|
17 | +$invoice = wpinv_get_invoice($invoice->ID); |
|
18 | 18 | |
19 | 19 | global $ajax_cart_details; |
20 | 20 | $ajax_cart_details = $invoice->get_cart_details(); |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $quantities_enabled = wpinv_item_quantities_enabled(); |
25 | 25 | $use_taxes = wpinv_use_taxes(); |
26 | 26 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
27 | -$tax_label = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? __( '(Tax Incl.)', 'invoicing' ) : __( '(Tax Excl.)', 'invoicing' ) ) : ''; |
|
27 | +$tax_label = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? __('(Tax Incl.)', 'invoicing') : __('(Tax Excl.)', 'invoicing')) : ''; |
|
28 | 28 | ?> |
29 | -<?php do_action( 'wpinv_before_receipt', $invoice ); ?> |
|
29 | +<?php do_action('wpinv_before_receipt', $invoice); ?> |
|
30 | 30 | <div class="wpinv-receipt"> |
31 | - <?php do_action( 'wpinv_receipt_start', $invoice ); ?> |
|
32 | - <div class="wpinv-receipt-message"><?php _e( 'Thank you for your payment!', 'invoicing' ); ?></div> |
|
33 | - <?php do_action( 'wpinv_before_receipt_details', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_receipt_start', $invoice); ?> |
|
32 | + <div class="wpinv-receipt-message"><?php _e('Thank you for your payment!', 'invoicing'); ?></div> |
|
33 | + <?php do_action('wpinv_before_receipt_details', $invoice); ?> |
|
34 | 34 | <div class="wpinv-receipt-details"> |
35 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ) ); ?></h3> |
|
36 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
35 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing')); ?></h3> |
|
36 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
37 | 37 | </div> |
38 | - <?php do_action( 'wpinv_after_receipt_details', $invoice ); ?> |
|
39 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
38 | + <?php do_action('wpinv_after_receipt_details', $invoice); ?> |
|
39 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
40 | 40 | </div> |
41 | -<?php do_action( 'wpinv_after_receipt', $invoice ); ?> |
|
42 | 41 | \ No newline at end of file |
42 | +<?php do_action('wpinv_after_receipt', $invoice); ?> |
|
43 | 43 | \ No newline at end of file |
@@ -348,7 +348,7 @@ |
||
348 | 348 | |
349 | 349 | $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
350 | 350 | if ( !empty( $status ) && $status != 'all' ) { |
351 | - $query_args['status'] = $status; |
|
351 | + $query_args['status'] = $status; |
|
352 | 352 | } |
353 | 353 | $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
354 | 354 |
@@ -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 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,58 +133,58 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <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> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <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> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <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'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <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']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?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' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?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'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
159 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
158 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
159 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
162 | - <?php echo $invoice->get_total( true ); ?> |
|
161 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
162 | + <?php echo $invoice->get_total(true); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
164 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
165 | 165 | <?php |
166 | 166 | $actions = array( |
167 | 167 | 'pay' => array( |
168 | 168 | 'url' => $invoice->get_checkout_payment_url(), |
169 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
169 | + 'name' => __('Pay Now', 'invoicing'), |
|
170 | 170 | 'class' => 'btn-success' |
171 | 171 | ), |
172 | 172 | 'print' => array( |
173 | 173 | 'url' => $invoice->get_view_url(), |
174 | - 'name' => __( 'Print', 'invoicing' ), |
|
174 | + 'name' => __('Print', 'invoicing'), |
|
175 | 175 | 'class' => 'btn-primary', |
176 | 176 | 'attrs' => 'target="_blank"' |
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | |
180 | - if ( ! $invoice->needs_payment() ) { |
|
181 | - unset( $actions['pay'] ); |
|
180 | + if (!$invoice->needs_payment()) { |
|
181 | + unset($actions['pay']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
185 | - foreach ( $actions as $key => $action ) { |
|
184 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
185 | + foreach ($actions as $key => $action) { |
|
186 | 186 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
187 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
187 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | ?> |
@@ -212,64 +212,64 @@ discard block |
||
212 | 212 | </div> |
213 | 213 | <?php |
214 | 214 | |
215 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
215 | + do_action('wpinv_bp_invoices_after_content'); |
|
216 | 216 | } else { |
217 | 217 | ?> |
218 | 218 | <div id="message" class="info"> |
219 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
219 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
220 | 220 | </div> |
221 | 221 | <?php |
222 | 222 | } |
223 | 223 | |
224 | - if ( defined( 'DOING_AJAX' ) ) { |
|
224 | + if (defined('DOING_AJAX')) { |
|
225 | 225 | exit; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - public function has_invoices( $args = '' ) { |
|
229 | + public function has_invoices($args = '') { |
|
230 | 230 | global $invoices_template; |
231 | 231 | |
232 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
232 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
233 | 233 | // Parse arguments. |
234 | - $r = bp_parse_args( $args, array( |
|
234 | + $r = bp_parse_args($args, array( |
|
235 | 235 | 'status' => 'all', |
236 | 236 | 'page_arg' => 'bpage', |
237 | 237 | 'page' => 1, |
238 | 238 | 'per_page' => $per_page > 0 ? $per_page : 20, |
239 | 239 | 'max' => false, |
240 | 240 | 'user_id' => bp_loggedin_user_id(), |
241 | - ), 'has_invoices' ); |
|
241 | + ), 'has_invoices'); |
|
242 | 242 | |
243 | 243 | |
244 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
244 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
245 | 245 | $r['per_page'] = (int)$r['max']; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Get the invoices. |
249 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
249 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
250 | 250 | |
251 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
251 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | public function setup_invoice_count() { |
255 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
256 | - $invoices = wpinv_get_invoices( $query ); |
|
255 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
256 | + $invoices = wpinv_get_invoices($query); |
|
257 | 257 | |
258 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
258 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | public function pagination_count() { |
262 | 262 | global $invoices_template; |
263 | 263 | |
264 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
265 | - $from_num = bp_core_number_format( $start_num ); |
|
266 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
267 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
264 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
265 | + $from_num = bp_core_number_format($start_num); |
|
266 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
267 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
268 | 268 | |
269 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
270 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
269 | + if (1 == $invoices_template->total_invoice_count) { |
|
270 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
271 | 271 | } else { |
272 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
272 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $message; |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | function pagination_links() { |
279 | 279 | global $invoices_template; |
280 | 280 | |
281 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
281 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
282 | 282 | } |
283 | 283 | |
284 | - public function bp_section( $settings = array() ) { |
|
285 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
284 | + public function bp_section($settings = array()) { |
|
285 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
286 | 286 | return $settings; |
287 | 287 | } |
288 | 288 | |
289 | - public function bp_settings( $settings = array() ) { |
|
289 | + public function bp_settings($settings = array()) { |
|
290 | 290 | $settings['wpinv_bp'] = array( |
291 | 291 | 'wpinv_bp_labels' => array( |
292 | 292 | 'id' => 'wpinv_bp_settings', |
293 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
293 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
294 | 294 | 'desc' => '', |
295 | 295 | 'type' => 'header', |
296 | 296 | ), |
297 | 297 | 'wpinv_bp_hide_menu' => array( |
298 | 298 | 'id' => 'wpinv_bp_hide_menu', |
299 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
300 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
299 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
300 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
301 | 301 | 'type' => 'checkbox', |
302 | 302 | ), |
303 | 303 | 'wpinv_menu_position' => array( |
304 | 304 | 'id' => 'wpinv_menu_position', |
305 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
306 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
305 | + 'name' => __('Menu position', 'invoicing'), |
|
306 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
307 | 307 | 'type' => 'number', |
308 | 308 | 'size' => 'small', |
309 | 309 | 'min' => '1', |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | ), |
314 | 314 | 'wpinv_bp_per_page' => array( |
315 | 315 | 'id' => 'wpinv_bp_per_page', |
316 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
317 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
316 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
317 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
318 | 318 | 'type' => 'number', |
319 | 319 | 'size' => 'small', |
320 | 320 | 'min' => '1', |
@@ -339,25 +339,25 @@ discard block |
||
339 | 339 | public $pag_links = ''; |
340 | 340 | public $total_invoice_count = 0; |
341 | 341 | |
342 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
343 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
342 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
343 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
344 | 344 | |
345 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
346 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
347 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
345 | + $this->pag_arg = sanitize_key($page_arg); |
|
346 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
347 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
348 | 348 | |
349 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
350 | - if ( !empty( $status ) && $status != 'all' ) { |
|
349 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
350 | + if (!empty($status) && $status != 'all') { |
|
351 | 351 | $query_args['status'] = $status; |
352 | 352 | } |
353 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
353 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
354 | 354 | |
355 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
356 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
355 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
356 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
357 | 357 | $this->invoices['total'] = $invoices->found_posts; |
358 | 358 | } |
359 | 359 | |
360 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
360 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
361 | 361 | $this->total_invoice_count = (int)$this->invoices['total']; |
362 | 362 | } else { |
363 | 363 | $this->total_invoice_count = (int)$max; |
@@ -365,52 +365,52 @@ discard block |
||
365 | 365 | |
366 | 366 | $this->invoices = $this->invoices['invoices']; |
367 | 367 | |
368 | - $invoice_count = count( $this->invoices ); |
|
368 | + $invoice_count = count($this->invoices); |
|
369 | 369 | |
370 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
370 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
371 | 371 | $this->invoice_count = (int)$invoice_count; |
372 | 372 | } else { |
373 | 373 | $this->invoice_count = (int)$max; |
374 | 374 | } |
375 | 375 | |
376 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
377 | - $this->pag_links = paginate_links( array( |
|
378 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
376 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
377 | + $this->pag_links = paginate_links(array( |
|
378 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
379 | 379 | 'format' => '', |
380 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
380 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
381 | 381 | 'current' => (int)$this->pag_page, |
382 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
383 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
382 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
383 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
384 | 384 | 'mid_size' => 1, |
385 | 385 | 'add_args' => array(), |
386 | - ) ); |
|
386 | + )); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | 390 | public function has_invoices() { |
391 | - return (bool) ! empty( $this->invoice_count ); |
|
391 | + return (bool)!empty($this->invoice_count); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | public function next_invoice() { |
395 | 395 | $this->current_invoice++; |
396 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
396 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
397 | 397 | |
398 | 398 | return $this->invoice; |
399 | 399 | } |
400 | 400 | |
401 | 401 | public function rewind_invoices() { |
402 | 402 | $this->current_invoice = -1; |
403 | - if ( $this->invoice_count > 0 ) { |
|
403 | + if ($this->invoice_count > 0) { |
|
404 | 404 | $this->invoice = $this->invoices[0]; |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | 408 | public function invoices() { |
409 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
409 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
410 | 410 | return true; |
411 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
411 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
412 | 412 | |
413 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
413 | + do_action('wpinv_bp_invoice_loop_end'); |
|
414 | 414 | |
415 | 415 | $this->rewind_invoices(); |
416 | 416 | } |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | $this->in_the_loop = true; |
425 | 425 | $this->invoice = $this->next_invoice(); |
426 | 426 | |
427 | - if ( 0 === $this->current_invoice ) { |
|
428 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
427 | + if (0 === $this->current_invoice) { |
|
428 | + do_action('wpinv_bp_invoice_loop_start'); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | } |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | |
436 | 436 | $bp->invoicing = new WPInv_BP_Component(); |
437 | 437 | |
438 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
439 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
440 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
441 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
438 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
439 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
440 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
441 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
442 | 442 | } |
443 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
444 | 443 | \ No newline at end of file |
444 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
445 | 445 | \ No newline at end of file |
@@ -30,40 +30,40 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | - $can_checkout = true; // Always true for now |
|
33 | + $can_checkout = true; // Always true for now |
|
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | + $page_id = absint( $page_id ); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | + $page_id = absint( $page_id ); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | + $ret = $ret ? is_page( $ret ) : false; |
|
62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | function wpinv_send_to_success_page( $args = null ) { |
66 | - $redirect = wpinv_get_success_page_uri(); |
|
66 | + $redirect = wpinv_get_success_page_uri(); |
|
67 | 67 | |
68 | 68 | if ( !empty( $args ) ) { |
69 | 69 | // Check for backward compatibility |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
@@ -103,72 +103,72 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
110 | - // Check for backward compatibility |
|
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
109 | + if ( !empty( $args ) ) { |
|
110 | + // Check for backward compatibility |
|
111 | + if ( is_string( $args ) ) |
|
112 | + $args = str_replace( '?', '', $args ); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args( $args ); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
117 | - } |
|
116 | + $uri = add_query_arg( $args, $uri ); |
|
117 | + } |
|
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | - } |
|
123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | + } |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function wpinv_send_back_to_checkout( $args = array() ) { |
131 | - $redirect = wpinv_get_checkout_uri(); |
|
131 | + $redirect = wpinv_get_checkout_uri(); |
|
132 | 132 | |
133 | - if ( ! empty( $args ) ) { |
|
134 | - // Check for backward compatibility |
|
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
133 | + if ( ! empty( $args ) ) { |
|
134 | + // Check for backward compatibility |
|
135 | + if ( is_string( $args ) ) |
|
136 | + $args = str_replace( '?', '', $args ); |
|
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args( $args ); |
|
139 | 139 | |
140 | - $redirect = add_query_arg( $args, $redirect ); |
|
141 | - } |
|
140 | + $redirect = add_query_arg( $args, $redirect ); |
|
141 | + } |
|
142 | 142 | |
143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
144 | - exit; |
|
143 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
144 | + exit; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | function wpinv_get_success_page_url( $query_string = null ) { |
148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | - $success_page = get_permalink( $success_page ); |
|
148 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | + $success_page = get_permalink( $success_page ); |
|
150 | 150 | |
151 | - if ( $query_string ) |
|
152 | - $success_page .= $query_string; |
|
151 | + if ( $query_string ) |
|
152 | + $success_page .= $query_string; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
154 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
158 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
160 | 160 | |
161 | - if ( $extras ) |
|
162 | - $uri .= $extras; |
|
161 | + if ( $extras ) |
|
162 | + $uri .= $extras; |
|
163 | 163 | |
164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
164 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_is_failed_transaction_page() { |
168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
168 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
170 | 170 | |
171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
171 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -7,195 +7,195 @@ 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_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $is_checkout = is_page( wpinv_get_option( 'checkout_page' ) ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $is_checkout = is_page(wpinv_get_option('checkout_page')); |
|
20 | 20 | |
21 | - if ( !$is_object_set ) { |
|
22 | - unset( $wp_query->queried_object ); |
|
21 | + if (!$is_object_set) { |
|
22 | + unset($wp_query->queried_object); |
|
23 | 23 | } |
24 | 24 | |
25 | - if ( !$is_object_id_set ) { |
|
26 | - unset( $wp_query->queried_object_id ); |
|
25 | + if (!$is_object_id_set) { |
|
26 | + unset($wp_query->queried_object_id); |
|
27 | 27 | } |
28 | 28 | |
29 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
29 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | 33 | $can_checkout = true; // Always true for now |
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool)apply_filters('wpinv_can_checkout', $can_checkout); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option('success_page', 0); |
|
40 | + $page_id = absint($page_id); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
47 | + $page_id = absint($page_id); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option('success_page', false); |
|
54 | + $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
61 | + $ret = $ret ? is_page($ret) : false; |
|
62 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
63 | 63 | } |
64 | 64 | |
65 | -function wpinv_send_to_success_page( $args = null ) { |
|
65 | +function wpinv_send_to_success_page($args = null) { |
|
66 | 66 | $redirect = wpinv_get_success_page_uri(); |
67 | 67 | |
68 | - if ( !empty( $args ) ) { |
|
68 | + if (!empty($args)) { |
|
69 | 69 | // Check for backward compatibility |
70 | - if ( is_string( $args ) ) |
|
71 | - $args = str_replace( '?', '', $args ); |
|
70 | + if (is_string($args)) |
|
71 | + $args = str_replace('?', '', $args); |
|
72 | 72 | |
73 | - $args = wp_parse_args( $args ); |
|
73 | + $args = wp_parse_args($args); |
|
74 | 74 | |
75 | - $redirect = add_query_arg( $args, $redirect ); |
|
75 | + $redirect = add_query_arg($args, $redirect); |
|
76 | 76 | } |
77 | 77 | |
78 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
78 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
79 | 79 | |
80 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
81 | - wp_redirect( $redirect ); |
|
80 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
130 | +function wpinv_send_back_to_checkout($args = array()) { |
|
131 | 131 | $redirect = wpinv_get_checkout_uri(); |
132 | 132 | |
133 | - if ( ! empty( $args ) ) { |
|
133 | + if (!empty($args)) { |
|
134 | 134 | // Check for backward compatibility |
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
135 | + if (is_string($args)) |
|
136 | + $args = str_replace('?', '', $args); |
|
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args($args); |
|
139 | 139 | |
140 | - $redirect = add_query_arg( $args, $redirect ); |
|
140 | + $redirect = add_query_arg($args, $redirect); |
|
141 | 141 | } |
142 | 142 | |
143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
143 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
144 | 144 | exit; |
145 | 145 | } |
146 | 146 | |
147 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | - $success_page = get_permalink( $success_page ); |
|
147 | +function wpinv_get_success_page_url($query_string = null) { |
|
148 | + $success_page = wpinv_get_option('success_page', 0); |
|
149 | + $success_page = get_permalink($success_page); |
|
150 | 150 | |
151 | - if ( $query_string ) |
|
151 | + if ($query_string) |
|
152 | 152 | $success_page .= $query_string; |
153 | 153 | |
154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
154 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
157 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
158 | + $uri = wpinv_get_option('failure_page', ''); |
|
159 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
160 | 160 | |
161 | - if ( $extras ) |
|
161 | + if ($extras) |
|
162 | 162 | $uri .= $extras; |
163 | 163 | |
164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
164 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_is_failed_transaction_page() { |
168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
168 | + $ret = wpinv_get_option('failure_page', false); |
|
169 | + $ret = isset($ret) ? is_page($ret) : false; |
|
170 | 170 | |
171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
171 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
172 | 172 | } |
173 | 173 | |
174 | -function wpinv_transaction_query( $type = 'start' ) { |
|
174 | +function wpinv_transaction_query($type = 'start') { |
|
175 | 175 | global $wpdb; |
176 | 176 | |
177 | 177 | $wpdb->hide_errors(); |
178 | 178 | |
179 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
180 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
179 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
180 | + define('WPINV_USE_TRANSACTIONS', true); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
184 | - switch ( $type ) { |
|
183 | + if (WPINV_USE_TRANSACTIONS) { |
|
184 | + switch ($type) { |
|
185 | 185 | case 'commit' : |
186 | - $wpdb->query( 'COMMIT' ); |
|
186 | + $wpdb->query('COMMIT'); |
|
187 | 187 | break; |
188 | 188 | case 'rollback' : |
189 | - $wpdb->query( 'ROLLBACK' ); |
|
189 | + $wpdb->query('ROLLBACK'); |
|
190 | 190 | break; |
191 | 191 | default : |
192 | - $wpdb->query( 'START TRANSACTION' ); |
|
192 | + $wpdb->query('START TRANSACTION'); |
|
193 | 193 | break; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | -function wpinv_create_invoice( $args = array(), $data = array() ) { |
|
198 | +function wpinv_create_invoice($args = array(), $data = array()) { |
|
199 | 199 | $default_args = array( |
200 | 200 | 'status' => '', |
201 | 201 | 'user_id' => null, |
@@ -205,191 +205,191 @@ discard block |
||
205 | 205 | 'parent' => 0 |
206 | 206 | ); |
207 | 207 | |
208 | - $args = wp_parse_args( $args, $default_args ); |
|
208 | + $args = wp_parse_args($args, $default_args); |
|
209 | 209 | $invoice_data = array(); |
210 | 210 | |
211 | - if ( $args['invoice_id'] > 0 ) { |
|
212 | - $updating = true; |
|
211 | + if ($args['invoice_id'] > 0) { |
|
212 | + $updating = true; |
|
213 | 213 | $invoice_data['post_type'] = 'wpi_invoice'; |
214 | 214 | $invoice_data['ID'] = $args['invoice_id']; |
215 | 215 | } else { |
216 | 216 | $updating = false; |
217 | 217 | $invoice_data['post_type'] = 'wpi_invoice'; |
218 | - $invoice_data['post_status'] = apply_filters( 'wpinv_default_invoice_status', 'pending' ); |
|
218 | + $invoice_data['post_status'] = apply_filters('wpinv_default_invoice_status', 'pending'); |
|
219 | 219 | $invoice_data['ping_status'] = 'closed'; |
220 | - $invoice_data['post_author'] = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
221 | - $invoice_data['post_title'] = wpinv_format_invoice_number( '0' ); |
|
222 | - $invoice_data['post_parent'] = absint( $args['parent'] ); |
|
223 | - if ( !empty( $args['created_date'] ) ) { |
|
220 | + $invoice_data['post_author'] = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
221 | + $invoice_data['post_title'] = wpinv_format_invoice_number('0'); |
|
222 | + $invoice_data['post_parent'] = absint($args['parent']); |
|
223 | + if (!empty($args['created_date'])) { |
|
224 | 224 | $invoice_data['post_date'] = $args['created_date']; |
225 | - $invoice_data['post_date_gmt'] = get_gmt_from_date( $args['created_date'] ); |
|
225 | + $invoice_data['post_date_gmt'] = get_gmt_from_date($args['created_date']); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if ( $args['status'] ) { |
|
230 | - if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
231 | - return new WP_Error( 'wpinv_invalid_invoice_status', __( 'Invalid invoice status', 'invoicing' ) ); |
|
229 | + if ($args['status']) { |
|
230 | + if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) { |
|
231 | + return new WP_Error('wpinv_invalid_invoice_status', __('Invalid invoice status', 'invoicing')); |
|
232 | 232 | } |
233 | - $invoice_data['post_status'] = $args['status']; |
|
233 | + $invoice_data['post_status'] = $args['status']; |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( ! is_null( $args['user_note'] ) ) { |
|
237 | - $invoice_data['post_excerpt'] = $args['user_note']; |
|
236 | + if (!is_null($args['user_note'])) { |
|
237 | + $invoice_data['post_excerpt'] = $args['user_note']; |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( $updating ) { |
|
241 | - $invoice_id = wp_update_post( $invoice_data ); |
|
240 | + if ($updating) { |
|
241 | + $invoice_id = wp_update_post($invoice_data); |
|
242 | 242 | } else { |
243 | - $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true ); |
|
243 | + $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ( is_wp_error( $invoice_id ) ) { |
|
246 | + if (is_wp_error($invoice_id)) { |
|
247 | 247 | return $invoice_id; |
248 | 248 | } else { |
249 | - if ( !$updating ) { |
|
250 | - $invoice_number = wpinv_format_invoice_number( $invoice_id ); |
|
249 | + if (!$updating) { |
|
250 | + $invoice_number = wpinv_format_invoice_number($invoice_id); |
|
251 | 251 | |
252 | - $update = array( 'ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title( $invoice_number ) ); |
|
253 | - wp_update_post( $update ); |
|
252 | + $update = array('ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title($invoice_number)); |
|
253 | + wp_update_post($update); |
|
254 | 254 | |
255 | - update_post_meta( $invoice_id, '_wpinv_number', $invoice_number ); |
|
255 | + update_post_meta($invoice_id, '_wpinv_number', $invoice_number); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( !$updating ) { |
|
260 | - update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) ); |
|
261 | - update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() ); |
|
262 | - update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) ); |
|
263 | - update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() ); |
|
264 | - update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() ); |
|
259 | + if (!$updating) { |
|
260 | + update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_'))); |
|
261 | + update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency()); |
|
262 | + update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax')); |
|
263 | + update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip()); |
|
264 | + update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent()); |
|
265 | 265 | ///update_post_meta( $invoice_id, '_wpinv_user_id', 0 ); |
266 | - update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) ); |
|
266 | + update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via'])); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | ///if ( is_numeric( $args['user_id'] ) ) { |
270 | 270 | ///update_post_meta( $invoice_id, '_wpinv_user_id', $args['user_id'] ); |
271 | 271 | ///} |
272 | 272 | |
273 | - update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION ); |
|
273 | + update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION); |
|
274 | 274 | |
275 | - return wpinv_get_invoice( $invoice_id ); |
|
275 | + return wpinv_get_invoice($invoice_id); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_get_prefix() { |
279 | 279 | $invoice_prefix = 'INV-'; |
280 | 280 | |
281 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
281 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | function wpinv_get_business_logo() { |
285 | - $business_logo = wpinv_get_option( 'logo' ); |
|
286 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
285 | + $business_logo = wpinv_get_option('logo'); |
|
286 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | function wpinv_get_business_name() { |
290 | 290 | $business_name = wpinv_get_option('store_name'); |
291 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
291 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | function wpinv_get_blogname() { |
295 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
295 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | function wpinv_get_admin_email() { |
299 | - $admin_email = get_option( 'admin_email' ); |
|
300 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
299 | + $admin_email = get_option('admin_email'); |
|
300 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | function wpinv_get_business_website() { |
304 | - $business_website = home_url( '/' ); |
|
305 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
304 | + $business_website = home_url('/'); |
|
305 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
306 | 306 | } |
307 | 307 | |
308 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
308 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
309 | 309 | $terms_text = ''; |
310 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
310 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | function wpinv_get_business_footer() { |
314 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
315 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
316 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
314 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
315 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
316 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | function wpinv_checkout_required_fields() { |
320 | 320 | $required_fields = array(); |
321 | 321 | |
322 | 322 | // Let payment gateways and other extensions determine if address fields should be required |
323 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
323 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
324 | 324 | |
325 | - if ( $require_billing_details ) { |
|
325 | + if ($require_billing_details) { |
|
326 | 326 | ///$required_fields['email'] = array( |
327 | 327 | ///'error_id' => 'invalid_email', |
328 | 328 | ///'error_message' => __( 'Please enter a valid email address', 'invoicing' ) |
329 | 329 | ///); |
330 | 330 | $required_fields['first_name'] = array( |
331 | 331 | 'error_id' => 'invalid_first_name', |
332 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
332 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
333 | 333 | ); |
334 | 334 | $required_fields['address'] = array( |
335 | 335 | 'error_id' => 'invalid_address', |
336 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
336 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
337 | 337 | ); |
338 | 338 | $required_fields['city'] = array( |
339 | 339 | 'error_id' => 'invalid_city', |
340 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
340 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
341 | 341 | ); |
342 | 342 | $required_fields['state'] = array( |
343 | 343 | 'error_id' => 'invalid_state', |
344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
344 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
345 | 345 | ); |
346 | 346 | $required_fields['country'] = array( |
347 | 347 | 'error_id' => 'invalid_country', |
348 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
348 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
349 | 349 | ); |
350 | 350 | } |
351 | 351 | |
352 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
352 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | function wpinv_is_ssl_enforced() { |
356 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
357 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
356 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
357 | + return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_user_can_print_invoice( $post ) { |
|
360 | +function wpinv_user_can_print_invoice($post) { |
|
361 | 361 | $allow = false; |
362 | 362 | |
363 | - if ( !( $user_id = get_current_user_id() ) ) { |
|
363 | + if (!($user_id = get_current_user_id())) { |
|
364 | 364 | return $allow; |
365 | 365 | } |
366 | 366 | |
367 | - if ( is_int( $post ) ) { |
|
368 | - $post = get_post( $post ); |
|
367 | + if (is_int($post)) { |
|
368 | + $post = get_post($post); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | // Allow to owner. |
372 | - if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) { |
|
372 | + if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) { |
|
373 | 373 | $allow = true; |
374 | 374 | } |
375 | 375 | |
376 | 376 | // Allow to admin user. |
377 | - if ( current_user_can( 'manage_options' ) ) { |
|
377 | + if (current_user_can('manage_options')) { |
|
378 | 378 | $allow = true; |
379 | 379 | } |
380 | 380 | |
381 | - return apply_filters( 'wpinv_can_print_invoice', $allow, $post ); |
|
381 | + return apply_filters('wpinv_can_print_invoice', $allow, $post); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | function wpinv_schedule_events() { |
385 | 385 | // hourly, daily and twicedaily |
386 | - if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) { |
|
387 | - wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' ); |
|
386 | + if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) { |
|
387 | + wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily'); |
|
388 | 388 | } |
389 | 389 | } |
390 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
390 | +add_action('wp', 'wpinv_schedule_events'); |
|
391 | 391 | |
392 | 392 | function wpinv_schedule_event_twicedaily() { |
393 | 393 | wpinv_email_payment_reminders(); |
394 | 394 | } |
395 | -add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' ); |
|
396 | 395 | \ No newline at end of file |
396 | +add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily'); |
|
397 | 397 | \ No newline at end of file |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | if ( !empty( $args ) ) { |
69 | 69 | // Check for backward compatibility |
70 | - if ( is_string( $args ) ) |
|
71 | - $args = str_replace( '?', '', $args ); |
|
70 | + if ( is_string( $args ) ) { |
|
71 | + $args = str_replace( '?', '', $args ); |
|
72 | + } |
|
72 | 73 | |
73 | 74 | $args = wp_parse_args( $args ); |
74 | 75 | |
@@ -87,8 +88,9 @@ discard block |
||
87 | 88 | |
88 | 89 | if ( !empty( $args ) ) { |
89 | 90 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
91 | + if ( is_string( $args ) ) { |
|
92 | + $args = str_replace( '?', '', $args ); |
|
93 | + } |
|
92 | 94 | |
93 | 95 | $args = wp_parse_args( $args ); |
94 | 96 | |
@@ -108,8 +110,9 @@ discard block |
||
108 | 110 | |
109 | 111 | if ( !empty( $args ) ) { |
110 | 112 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
113 | + if ( is_string( $args ) ) { |
|
114 | + $args = str_replace( '?', '', $args ); |
|
115 | + } |
|
113 | 116 | |
114 | 117 | $args = wp_parse_args( $args ); |
115 | 118 | |
@@ -132,8 +135,9 @@ discard block |
||
132 | 135 | |
133 | 136 | if ( ! empty( $args ) ) { |
134 | 137 | // Check for backward compatibility |
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
138 | + if ( is_string( $args ) ) { |
|
139 | + $args = str_replace( '?', '', $args ); |
|
140 | + } |
|
137 | 141 | |
138 | 142 | $args = wp_parse_args( $args ); |
139 | 143 | |
@@ -148,8 +152,9 @@ discard block |
||
148 | 152 | $success_page = wpinv_get_option( 'success_page', 0 ); |
149 | 153 | $success_page = get_permalink( $success_page ); |
150 | 154 | |
151 | - if ( $query_string ) |
|
152 | - $success_page .= $query_string; |
|
155 | + if ( $query_string ) { |
|
156 | + $success_page .= $query_string; |
|
157 | + } |
|
153 | 158 | |
154 | 159 | return apply_filters( 'wpinv_success_page_url', $success_page ); |
155 | 160 | } |
@@ -158,8 +163,9 @@ discard block |
||
158 | 163 | $uri = wpinv_get_option( 'failure_page', '' ); |
159 | 164 | $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
160 | 165 | |
161 | - if ( $extras ) |
|
162 | - $uri .= $extras; |
|
166 | + if ( $extras ) { |
|
167 | + $uri .= $extras; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
165 | 171 | } |
@@ -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 | |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
15 | 15 | ); |
16 | 16 | |
17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
17 | + foreach ($shortcodes as $shortcode => $function) { |
|
18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
19 | 19 | } |
20 | 20 | |
21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function shortcode_wrapper( |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | ) { |
33 | 33 | ob_start(); |
34 | 34 | |
35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
36 | - call_user_func( $function, $atts ); |
|
37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
36 | + call_user_func($function, $atts); |
|
37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
38 | 38 | |
39 | 39 | return ob_get_clean(); |
40 | 40 | } |
41 | 41 | |
42 | - public static function checkout( $atts = array(), $content = null ) { |
|
43 | - return wpinv_checkout_form( $atts, $content ); |
|
42 | + public static function checkout($atts = array(), $content = null) { |
|
43 | + return wpinv_checkout_form($atts, $content); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function messages( $atts, $content = null ) { |
|
46 | + public static function messages($atts, $content = null) { |
|
47 | 47 | ob_start(); |
48 | 48 | wpinv_print_errors(); |
49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
50 | 50 | } |
51 | 51 | |
52 | - public static function history( $atts, $content = null ) { |
|
52 | + public static function history($atts, $content = null) { |
|
53 | 53 | ob_start(); |
54 | 54 | |
55 | 55 | wpinv_user_invoices(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return ob_get_clean(); |
58 | 58 | } |
59 | 59 | |
60 | - public static function receipt( $atts, $content = null ) { |
|
61 | - return wpinv_payment_receipt( $atts, $content ); |
|
60 | + public static function receipt($atts, $content = null) { |
|
61 | + return wpinv_payment_receipt($atts, $content); |
|
62 | 62 | } |
63 | 63 | } |
@@ -1,39 +1,39 @@ |
||
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_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } else { |
21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '</ul>'; |
25 | 25 | ?> |
26 | 26 | <div class="add_note"> |
27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
28 | 28 | <p> |
29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
30 | 30 | </p> |
31 | 31 | <p> |
32 | 32 | <select name="invoice_note_type" id="invoice_note_type"> |
33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
35 | 35 | </select> |
36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
37 | 37 | </p> |
38 | 38 | </div> |
39 | 39 | <?php |
@@ -196,8 +196,9 @@ |
||
196 | 196 | foreach ( $types as $name => $type ) { |
197 | 197 | echo '<option value="' . esc_attr( $name ) . '"'; |
198 | 198 | |
199 | - if ( isset( $_GET['discount_type'] ) ) |
|
200 | - selected( $name, $_GET['discount_type'] ); |
|
199 | + if ( isset( $_GET['discount_type'] ) ) { |
|
200 | + selected( $name, $_GET['discount_type'] ); |
|
201 | + } |
|
201 | 202 | |
202 | 203 | echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
203 | 204 | } |
@@ -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 |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | -register_activation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_activation' ); |
|
3 | -register_deactivation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation' ); |
|
2 | +register_activation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_activation'); |
|
3 | +register_deactivation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation'); |
|
4 | 4 | |
5 | -function wpinv_plugin_activation( $network_wide = false ) { |
|
6 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
7 | - wpinv_install( $network_wide ); |
|
5 | +function wpinv_plugin_activation($network_wide = false) { |
|
6 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
7 | + wpinv_install($network_wide); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | function wpinv_plugin_deactivation() { |
11 | 11 | // plugin deactivation stuff |
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_install( $network_wide = false ) { |
|
14 | +function wpinv_install($network_wide = false) { |
|
15 | 15 | global $wpdb; |
16 | 16 | |
17 | - if ( is_multisite() && $network_wide ) { |
|
18 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
19 | - switch_to_blog( $blog_id ); |
|
17 | + if (is_multisite() && $network_wide) { |
|
18 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
19 | + switch_to_blog($blog_id); |
|
20 | 20 | wpinv_run_install(); |
21 | 21 | restore_current_blog(); |
22 | 22 | } |
@@ -32,75 +32,75 @@ discard block |
||
32 | 32 | wpinv_register_post_types(); |
33 | 33 | |
34 | 34 | // Clear the permalinks |
35 | - flush_rewrite_rules( false ); |
|
35 | + flush_rewrite_rules(false); |
|
36 | 36 | |
37 | 37 | // Add Upgraded From Option |
38 | - $current_version = get_option( 'wpinv_version' ); |
|
39 | - if ( $current_version ) { |
|
40 | - update_option( 'wpinv_version_upgraded_from', $current_version ); |
|
38 | + $current_version = get_option('wpinv_version'); |
|
39 | + if ($current_version) { |
|
40 | + update_option('wpinv_version_upgraded_from', $current_version); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Pull options from WP, not GD Invoice's global |
44 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
44 | + $current_options = get_option('wpinv_settings', array()); |
|
45 | 45 | |
46 | 46 | // Setup some default options |
47 | 47 | $options = wpinv_create_pages(); |
48 | 48 | |
49 | 49 | // Populate some default values |
50 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
51 | - foreach( $sections as $section => $settings) { |
|
50 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
51 | + foreach ($sections as $section => $settings) { |
|
52 | 52 | // Check for backwards compatibility |
53 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
54 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
53 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
54 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
55 | 55 | $section = 'main'; |
56 | 56 | $settings = $sections; |
57 | 57 | } |
58 | 58 | |
59 | - foreach ( $settings as $option ) { |
|
60 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
61 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
62 | - $options[ $option['id'] ] = '1'; |
|
63 | - } else if ( !empty( $option['std'] ) ) { |
|
64 | - $options[ $option['id'] ] = $option['std']; |
|
59 | + foreach ($settings as $option) { |
|
60 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
61 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
62 | + $options[$option['id']] = '1'; |
|
63 | + } else if (!empty($option['std'])) { |
|
64 | + $options[$option['id']] = $option['std']; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - $merged_options = array_merge( $wpinv_options, $options ); |
|
71 | + $merged_options = array_merge($wpinv_options, $options); |
|
72 | 72 | $wpinv_options = $merged_options; |
73 | 73 | |
74 | - update_option( 'wpinv_settings', $merged_options ); |
|
75 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
74 | + update_option('wpinv_settings', $merged_options); |
|
75 | + update_option('wpinv_version', WPINV_VERSION); |
|
76 | 76 | |
77 | 77 | // Check for PHP Session support, and enable if available |
78 | 78 | $wpi_session->use_php_sessions(); |
79 | 79 | |
80 | 80 | // Add a temporary option to note that GD Invoice pages have been created |
81 | - set_transient( '_wpinv_installed', $merged_options, 30 ); |
|
81 | + set_transient('_wpinv_installed', $merged_options, 30); |
|
82 | 82 | |
83 | 83 | // Bail if activating from network, or bulk |
84 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
84 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Add the transient to redirect |
89 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
89 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * When a new Blog is created in multisite, see if Invoicing is network activated, and run the installer. |
94 | 94 | * |
95 | 95 | */ |
96 | -function wpinv_new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
97 | - if ( is_plugin_active_for_network( plugin_basename( WPINV_PLUGIN_FILE ) ) ) { |
|
98 | - switch_to_blog( $blog_id ); |
|
96 | +function wpinv_new_blog_created($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
97 | + if (is_plugin_active_for_network(plugin_basename(WPINV_PLUGIN_FILE))) { |
|
98 | + switch_to_blog($blog_id); |
|
99 | 99 | wpinv_run_install(); |
100 | 100 | restore_current_blog(); |
101 | 101 | } |
102 | 102 | } |
103 | -add_action( 'wpmu_new_blog', 'wpinv_new_blog_created', 10, 6 ); |
|
103 | +add_action('wpmu_new_blog', 'wpinv_new_blog_created', 10, 6); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Post-installation. |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | * Runs just after plugin installation and exposes the wpinv_after_install hook. |
109 | 109 | */ |
110 | 110 | function wpinv_after_install() { |
111 | - if ( ! is_admin() ) { |
|
111 | + if (!is_admin()) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - $wpinv_options = get_transient( '_wpinv_installed' ); |
|
116 | - $wpinv_table_check = get_option( '_wpinv_table_check', false ); |
|
115 | + $wpinv_options = get_transient('_wpinv_installed'); |
|
116 | + $wpinv_table_check = get_option('_wpinv_table_check', false); |
|
117 | 117 | |
118 | - if ( false === $wpinv_table_check || current_time( 'timestamp' ) > $wpinv_table_check ) { |
|
119 | - update_option( '_wpinv_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
118 | + if (false === $wpinv_table_check || current_time('timestamp') > $wpinv_table_check) { |
|
119 | + update_option('_wpinv_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
120 | 120 | } |
121 | 121 | |
122 | - if ( false !== $wpinv_options ) { |
|
122 | + if (false !== $wpinv_options) { |
|
123 | 123 | // Delete the transient |
124 | - delete_transient( '_wpinv_installed' ); |
|
124 | + delete_transient('_wpinv_installed'); |
|
125 | 125 | } |
126 | 126 | } |
127 | -add_action( 'admin_init', 'wpinv_after_install' ); |
|
127 | +add_action('admin_init', 'wpinv_after_install'); |
|
128 | 128 | |
129 | 129 | function wpinv_create_pages() { |
130 | 130 | global $wpinv_options; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | $options = array(); |
133 | 133 | |
134 | 134 | // Checks if the purchase page option exists |
135 | - if ( ! array_key_exists( 'checkout_page', $wpinv_options ) ) { |
|
135 | + if (!array_key_exists('checkout_page', $wpinv_options)) { |
|
136 | 136 | // Checkout Page |
137 | 137 | $checkout = wp_insert_post( |
138 | 138 | array( |
139 | - 'post_title' => __( 'Checkout', 'invoicing' ), |
|
139 | + 'post_title' => __('Checkout', 'invoicing'), |
|
140 | 140 | 'post_content' => '[wpinv_checkout]', |
141 | 141 | 'post_status' => 'publish', |
142 | 142 | 'post_author' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | // Invoice History (History) Page |
151 | 151 | $history = wp_insert_post( |
152 | 152 | array( |
153 | - 'post_title' => __( 'Invoice History', 'invoicing' ), |
|
153 | + 'post_title' => __('Invoice History', 'invoicing'), |
|
154 | 154 | 'post_content' => '[wpinv_history]', |
155 | 155 | 'post_status' => 'publish', |
156 | 156 | 'post_author' => 1, |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | // Payment Confirmation (Success) Page |
165 | 165 | $success = wp_insert_post( |
166 | 166 | array( |
167 | - 'post_title' => __( 'Payment Confirmation', 'invoicing' ), |
|
168 | - 'post_content' => __( '[wpinv_receipt]', 'invoicing' ), |
|
167 | + 'post_title' => __('Payment Confirmation', 'invoicing'), |
|
168 | + 'post_content' => __('[wpinv_receipt]', 'invoicing'), |
|
169 | 169 | 'post_status' => 'publish', |
170 | 170 | 'post_author' => 1, |
171 | 171 | 'post_parent' => $checkout, |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | // Failed Payment Page |
179 | 179 | $failed = wp_insert_post( |
180 | 180 | array( |
181 | - 'post_title' => __( 'Transaction Failed', 'invoicing' ), |
|
182 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
181 | + 'post_title' => __('Transaction Failed', 'invoicing'), |
|
182 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
183 | 183 | 'post_status' => 'publish', |
184 | 184 | 'post_author' => 1, |
185 | 185 | 'post_type' => 'page', |
@@ -770,326 +770,326 @@ discard block |
||
770 | 770 | } |
771 | 771 | |
772 | 772 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
773 | - $pages_options = array(); |
|
773 | + $pages_options = array(); |
|
774 | 774 | |
775 | - if( $default_label !== NULL && $default_label !== false ) { |
|
776 | - $pages_options = array( '' => $default_label ); // Blank option |
|
777 | - } |
|
775 | + if( $default_label !== NULL && $default_label !== false ) { |
|
776 | + $pages_options = array( '' => $default_label ); // Blank option |
|
777 | + } |
|
778 | 778 | |
779 | - $pages = get_pages(); |
|
780 | - if ( $pages ) { |
|
781 | - foreach ( $pages as $page ) { |
|
782 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
779 | + $pages = get_pages(); |
|
780 | + if ( $pages ) { |
|
781 | + foreach ( $pages as $page ) { |
|
782 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
783 | 783 | $pages_options[ $page->ID ] = $title; |
784 | - } |
|
785 | - } |
|
784 | + } |
|
785 | + } |
|
786 | 786 | |
787 | - return $pages_options; |
|
787 | + return $pages_options; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | function wpinv_header_callback( $args ) { |
791 | - if ( !empty( $args['desc'] ) ) { |
|
791 | + if ( !empty( $args['desc'] ) ) { |
|
792 | 792 | echo $args['desc']; |
793 | 793 | } |
794 | 794 | } |
795 | 795 | |
796 | 796 | function wpinv_hidden_callback( $args ) { |
797 | - global $wpinv_options; |
|
798 | - |
|
799 | - if ( isset( $args['set_value'] ) ) { |
|
800 | - $value = $args['set_value']; |
|
801 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
802 | - $value = $wpinv_options[ $args['id'] ]; |
|
803 | - } else { |
|
804 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
805 | - } |
|
806 | - |
|
807 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
808 | - $args['readonly'] = true; |
|
809 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
810 | - $name = ''; |
|
811 | - } else { |
|
812 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
813 | - } |
|
814 | - |
|
815 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
797 | + global $wpinv_options; |
|
798 | + |
|
799 | + if ( isset( $args['set_value'] ) ) { |
|
800 | + $value = $args['set_value']; |
|
801 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
802 | + $value = $wpinv_options[ $args['id'] ]; |
|
803 | + } else { |
|
804 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
805 | + } |
|
806 | + |
|
807 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
808 | + $args['readonly'] = true; |
|
809 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
810 | + $name = ''; |
|
811 | + } else { |
|
812 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
813 | + } |
|
814 | + |
|
815 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
816 | 816 | |
817 | - echo $html; |
|
817 | + echo $html; |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | function wpinv_checkbox_callback( $args ) { |
821 | - global $wpinv_options; |
|
821 | + global $wpinv_options; |
|
822 | 822 | |
823 | 823 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
824 | 824 | |
825 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
826 | - $name = ''; |
|
827 | - } else { |
|
828 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
829 | - } |
|
825 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
826 | + $name = ''; |
|
827 | + } else { |
|
828 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
829 | + } |
|
830 | 830 | |
831 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
832 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
833 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
831 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
832 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
833 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
834 | 834 | |
835 | - echo $html; |
|
835 | + echo $html; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | function wpinv_multicheck_callback( $args ) { |
839 | - global $wpinv_options; |
|
839 | + global $wpinv_options; |
|
840 | 840 | |
841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
841 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
842 | 842 | |
843 | - if ( ! empty( $args['options'] ) ) { |
|
844 | - foreach( $args['options'] as $key => $option ): |
|
845 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
846 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
847 | - $enabled = $sanitize_key; |
|
848 | - } else { |
|
849 | - $enabled = NULL; |
|
850 | - } |
|
851 | - 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 ) . '/> '; |
|
852 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
853 | - endforeach; |
|
854 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
855 | - } |
|
843 | + if ( ! empty( $args['options'] ) ) { |
|
844 | + foreach( $args['options'] as $key => $option ): |
|
845 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
846 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
847 | + $enabled = $sanitize_key; |
|
848 | + } else { |
|
849 | + $enabled = NULL; |
|
850 | + } |
|
851 | + 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 ) . '/> '; |
|
852 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
853 | + endforeach; |
|
854 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
855 | + } |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | function wpinv_payment_icons_callback( $args ) { |
859 | - global $wpinv_options; |
|
859 | + global $wpinv_options; |
|
860 | 860 | |
861 | 861 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
862 | 862 | |
863 | - if ( ! empty( $args['options'] ) ) { |
|
864 | - foreach( $args['options'] as $key => $option ) { |
|
863 | + if ( ! empty( $args['options'] ) ) { |
|
864 | + foreach( $args['options'] as $key => $option ) { |
|
865 | 865 | $sanitize_key = wpinv_sanitize_key( $key ); |
866 | 866 | |
867 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
868 | - $enabled = $option; |
|
869 | - } else { |
|
870 | - $enabled = NULL; |
|
871 | - } |
|
872 | - |
|
873 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
874 | - |
|
875 | - 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 ) . '/> '; |
|
876 | - |
|
877 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
878 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
879 | - } else { |
|
880 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
881 | - |
|
882 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
883 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
884 | - } else { |
|
885 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
886 | - $content_dir = WP_CONTENT_DIR; |
|
887 | - |
|
888 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
889 | - // Replaces backslashes with forward slashes for Windows systems |
|
890 | - $image = wp_normalize_path( $image ); |
|
891 | - $content_dir = wp_normalize_path( $content_dir ); |
|
892 | - } |
|
893 | - |
|
894 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
895 | - } |
|
896 | - |
|
897 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
898 | - } |
|
899 | - echo $option . '</label>'; |
|
900 | - } |
|
901 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
902 | - } |
|
867 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
868 | + $enabled = $option; |
|
869 | + } else { |
|
870 | + $enabled = NULL; |
|
871 | + } |
|
872 | + |
|
873 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
874 | + |
|
875 | + 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 ) . '/> '; |
|
876 | + |
|
877 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
878 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
879 | + } else { |
|
880 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
881 | + |
|
882 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
883 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
884 | + } else { |
|
885 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
886 | + $content_dir = WP_CONTENT_DIR; |
|
887 | + |
|
888 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
889 | + // Replaces backslashes with forward slashes for Windows systems |
|
890 | + $image = wp_normalize_path( $image ); |
|
891 | + $content_dir = wp_normalize_path( $content_dir ); |
|
892 | + } |
|
893 | + |
|
894 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
895 | + } |
|
896 | + |
|
897 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
898 | + } |
|
899 | + echo $option . '</label>'; |
|
900 | + } |
|
901 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
902 | + } |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | function wpinv_radio_callback( $args ) { |
906 | - global $wpinv_options; |
|
906 | + global $wpinv_options; |
|
907 | 907 | |
908 | 908 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
909 | 909 | |
910 | 910 | foreach ( $args['options'] as $key => $option ) : |
911 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
911 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
912 | 912 | |
913 | 913 | $checked = false; |
914 | 914 | |
915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
916 | - $checked = true; |
|
917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
918 | - $checked = true; |
|
915 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
916 | + $checked = true; |
|
917 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
918 | + $checked = true; |
|
919 | 919 | |
920 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
921 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
922 | - endforeach; |
|
920 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
921 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
922 | + endforeach; |
|
923 | 923 | |
924 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
924 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | function wpinv_gateways_callback( $args ) { |
928 | - global $wpinv_options; |
|
928 | + global $wpinv_options; |
|
929 | 929 | |
930 | 930 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
931 | 931 | |
932 | - foreach ( $args['options'] as $key => $option ) : |
|
933 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
932 | + foreach ( $args['options'] as $key => $option ) : |
|
933 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
934 | 934 | |
935 | 935 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
936 | - $enabled = '1'; |
|
937 | - else |
|
938 | - $enabled = null; |
|
936 | + $enabled = '1'; |
|
937 | + else |
|
938 | + $enabled = null; |
|
939 | 939 | |
940 | - 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) . '/> '; |
|
941 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
942 | - endforeach; |
|
940 | + 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) . '/> '; |
|
941 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
942 | + endforeach; |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | function wpinv_gateway_select_callback($args) { |
946 | - global $wpinv_options; |
|
946 | + global $wpinv_options; |
|
947 | 947 | |
948 | 948 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
949 | 949 | |
950 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
950 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
951 | 951 | |
952 | - foreach ( $args['options'] as $key => $option ) : |
|
953 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
952 | + foreach ( $args['options'] as $key => $option ) : |
|
953 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
954 | 954 | $selected = selected( $key, $args['selected'], false ); |
955 | 955 | } else { |
956 | 956 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
957 | 957 | } |
958 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
959 | - endforeach; |
|
958 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
959 | + endforeach; |
|
960 | 960 | |
961 | - echo '</select>'; |
|
962 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
961 | + echo '</select>'; |
|
962 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | function wpinv_text_callback( $args ) { |
966 | - global $wpinv_options; |
|
966 | + global $wpinv_options; |
|
967 | 967 | |
968 | 968 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
969 | 969 | |
970 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
971 | - $value = $wpinv_options[ $args['id'] ]; |
|
972 | - } else { |
|
973 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
974 | - } |
|
975 | - |
|
976 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
977 | - $args['readonly'] = true; |
|
978 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
979 | - $name = ''; |
|
980 | - } else { |
|
981 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
982 | - } |
|
983 | - |
|
984 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
985 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
986 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
987 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
988 | - |
|
989 | - echo $html; |
|
970 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
971 | + $value = $wpinv_options[ $args['id'] ]; |
|
972 | + } else { |
|
973 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
974 | + } |
|
975 | + |
|
976 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
977 | + $args['readonly'] = true; |
|
978 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
979 | + $name = ''; |
|
980 | + } else { |
|
981 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
982 | + } |
|
983 | + |
|
984 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
985 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
986 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
987 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
988 | + |
|
989 | + echo $html; |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | function wpinv_number_callback( $args ) { |
993 | - global $wpinv_options; |
|
993 | + global $wpinv_options; |
|
994 | 994 | |
995 | 995 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
996 | 996 | |
997 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
998 | - $value = $wpinv_options[ $args['id'] ]; |
|
999 | - } else { |
|
1000 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1001 | - } |
|
1002 | - |
|
1003 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1004 | - $args['readonly'] = true; |
|
1005 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1006 | - $name = ''; |
|
1007 | - } else { |
|
1008 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1009 | - } |
|
1010 | - |
|
1011 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1012 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1013 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1014 | - |
|
1015 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1016 | - $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 ) ) . '"/>'; |
|
1017 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1018 | - |
|
1019 | - echo $html; |
|
997 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
998 | + $value = $wpinv_options[ $args['id'] ]; |
|
999 | + } else { |
|
1000 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1001 | + } |
|
1002 | + |
|
1003 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1004 | + $args['readonly'] = true; |
|
1005 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1006 | + $name = ''; |
|
1007 | + } else { |
|
1008 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1009 | + } |
|
1010 | + |
|
1011 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1012 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1013 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1014 | + |
|
1015 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1016 | + $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 ) ) . '"/>'; |
|
1017 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1018 | + |
|
1019 | + echo $html; |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | function wpinv_textarea_callback( $args ) { |
1023 | - global $wpinv_options; |
|
1023 | + global $wpinv_options; |
|
1024 | 1024 | |
1025 | 1025 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1026 | 1026 | |
1027 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1028 | - $value = $wpinv_options[ $args['id'] ]; |
|
1029 | - } else { |
|
1030 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1031 | - } |
|
1027 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1028 | + $value = $wpinv_options[ $args['id'] ]; |
|
1029 | + } else { |
|
1030 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1031 | + } |
|
1032 | 1032 | |
1033 | 1033 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
1034 | 1034 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
1035 | 1035 | |
1036 | - $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>'; |
|
1037 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1036 | + $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>'; |
|
1037 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1038 | 1038 | |
1039 | - echo $html; |
|
1039 | + echo $html; |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | function wpinv_password_callback( $args ) { |
1043 | - global $wpinv_options; |
|
1043 | + global $wpinv_options; |
|
1044 | 1044 | |
1045 | 1045 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1046 | 1046 | |
1047 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1048 | - $value = $wpinv_options[ $args['id'] ]; |
|
1049 | - } else { |
|
1050 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1051 | - } |
|
1047 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1048 | + $value = $wpinv_options[ $args['id'] ]; |
|
1049 | + } else { |
|
1050 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1051 | + } |
|
1052 | 1052 | |
1053 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1054 | - $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 ) . '"/>'; |
|
1055 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1053 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1054 | + $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 ) . '"/>'; |
|
1055 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1056 | 1056 | |
1057 | - echo $html; |
|
1057 | + echo $html; |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | function wpinv_missing_callback($args) { |
1061 | - printf( |
|
1062 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1063 | - '<strong>' . $args['id'] . '</strong>' |
|
1064 | - ); |
|
1061 | + printf( |
|
1062 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1063 | + '<strong>' . $args['id'] . '</strong>' |
|
1064 | + ); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | function wpinv_select_callback($args) { |
1068 | - global $wpinv_options; |
|
1068 | + global $wpinv_options; |
|
1069 | 1069 | |
1070 | 1070 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1071 | 1071 | |
1072 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1073 | - $value = $wpinv_options[ $args['id'] ]; |
|
1074 | - } else { |
|
1075 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1076 | - } |
|
1072 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1073 | + $value = $wpinv_options[ $args['id'] ]; |
|
1074 | + } else { |
|
1075 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1076 | + } |
|
1077 | 1077 | |
1078 | 1078 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
1079 | 1079 | $value = $args['selected']; |
1080 | 1080 | } |
1081 | 1081 | |
1082 | - if ( isset( $args['placeholder'] ) ) { |
|
1083 | - $placeholder = $args['placeholder']; |
|
1084 | - } else { |
|
1085 | - $placeholder = ''; |
|
1086 | - } |
|
1087 | - |
|
1088 | - if ( isset( $args['chosen'] ) ) { |
|
1089 | - $chosen = 'class="wpinv-chosen"'; |
|
1090 | - } else { |
|
1091 | - $chosen = ''; |
|
1092 | - } |
|
1082 | + if ( isset( $args['placeholder'] ) ) { |
|
1083 | + $placeholder = $args['placeholder']; |
|
1084 | + } else { |
|
1085 | + $placeholder = ''; |
|
1086 | + } |
|
1087 | + |
|
1088 | + if ( isset( $args['chosen'] ) ) { |
|
1089 | + $chosen = 'class="wpinv-chosen"'; |
|
1090 | + } else { |
|
1091 | + $chosen = ''; |
|
1092 | + } |
|
1093 | 1093 | |
1094 | 1094 | if( !empty( $args['onchange'] ) ) { |
1095 | 1095 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1097,143 +1097,143 @@ discard block |
||
1097 | 1097 | $onchange = ''; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1100 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1101 | 1101 | |
1102 | - foreach ( $args['options'] as $option => $name ) { |
|
1103 | - $selected = selected( $option, $value, false ); |
|
1104 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1105 | - } |
|
1102 | + foreach ( $args['options'] as $option => $name ) { |
|
1103 | + $selected = selected( $option, $value, false ); |
|
1104 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1105 | + } |
|
1106 | 1106 | |
1107 | - $html .= '</select>'; |
|
1108 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1107 | + $html .= '</select>'; |
|
1108 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1109 | 1109 | |
1110 | - echo $html; |
|
1110 | + echo $html; |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | function wpinv_color_select_callback( $args ) { |
1114 | - global $wpinv_options; |
|
1114 | + global $wpinv_options; |
|
1115 | 1115 | |
1116 | 1116 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1117 | 1117 | |
1118 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1119 | - $value = $wpinv_options[ $args['id'] ]; |
|
1120 | - } else { |
|
1121 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1122 | - } |
|
1118 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1119 | + $value = $wpinv_options[ $args['id'] ]; |
|
1120 | + } else { |
|
1121 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1122 | + } |
|
1123 | 1123 | |
1124 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1124 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1125 | 1125 | |
1126 | - foreach ( $args['options'] as $option => $color ) { |
|
1127 | - $selected = selected( $option, $value, false ); |
|
1128 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1129 | - } |
|
1126 | + foreach ( $args['options'] as $option => $color ) { |
|
1127 | + $selected = selected( $option, $value, false ); |
|
1128 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1129 | + } |
|
1130 | 1130 | |
1131 | - $html .= '</select>'; |
|
1132 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1131 | + $html .= '</select>'; |
|
1132 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1133 | 1133 | |
1134 | - echo $html; |
|
1134 | + echo $html; |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | function wpinv_rich_editor_callback( $args ) { |
1138 | - global $wpinv_options, $wp_version; |
|
1138 | + global $wpinv_options, $wp_version; |
|
1139 | 1139 | |
1140 | 1140 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1141 | 1141 | |
1142 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1143 | - $value = $wpinv_options[ $args['id'] ]; |
|
1142 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1143 | + $value = $wpinv_options[ $args['id'] ]; |
|
1144 | 1144 | |
1145 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1146 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1147 | - } |
|
1148 | - } else { |
|
1149 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1150 | - } |
|
1145 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1146 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1147 | + } |
|
1148 | + } else { |
|
1149 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1150 | + } |
|
1151 | 1151 | |
1152 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1152 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1153 | 1153 | |
1154 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1155 | - ob_start(); |
|
1156 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1157 | - $html = ob_get_clean(); |
|
1158 | - } else { |
|
1159 | - $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>'; |
|
1160 | - } |
|
1154 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1155 | + ob_start(); |
|
1156 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1157 | + $html = ob_get_clean(); |
|
1158 | + } else { |
|
1159 | + $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>'; |
|
1160 | + } |
|
1161 | 1161 | |
1162 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1162 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1163 | 1163 | |
1164 | - echo $html; |
|
1164 | + echo $html; |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | function wpinv_upload_callback( $args ) { |
1168 | - global $wpinv_options; |
|
1168 | + global $wpinv_options; |
|
1169 | 1169 | |
1170 | 1170 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1171 | 1171 | |
1172 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1173 | - $value = $wpinv_options[$args['id']]; |
|
1174 | - } else { |
|
1175 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
1176 | - } |
|
1172 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1173 | + $value = $wpinv_options[$args['id']]; |
|
1174 | + } else { |
|
1175 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1176 | + } |
|
1177 | 1177 | |
1178 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1179 | - $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 ) ) . '"/>'; |
|
1180 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1181 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1178 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1179 | + $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 ) ) . '"/>'; |
|
1180 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1181 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1182 | 1182 | |
1183 | - echo $html; |
|
1183 | + echo $html; |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | function wpinv_color_callback( $args ) { |
1187 | - global $wpinv_options; |
|
1187 | + global $wpinv_options; |
|
1188 | 1188 | |
1189 | 1189 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1190 | 1190 | |
1191 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1192 | - $value = $wpinv_options[ $args['id'] ]; |
|
1193 | - } else { |
|
1194 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1195 | - } |
|
1191 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1192 | + $value = $wpinv_options[ $args['id'] ]; |
|
1193 | + } else { |
|
1194 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1195 | + } |
|
1196 | 1196 | |
1197 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1197 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1198 | 1198 | |
1199 | - $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 ) . '" />'; |
|
1200 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1199 | + $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 ) . '" />'; |
|
1200 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1201 | 1201 | |
1202 | - echo $html; |
|
1202 | + echo $html; |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | function wpinv_country_states_callback($args) { |
1206 | - global $wpinv_options; |
|
1206 | + global $wpinv_options; |
|
1207 | 1207 | |
1208 | 1208 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1209 | 1209 | |
1210 | - if ( isset( $args['placeholder'] ) ) { |
|
1211 | - $placeholder = $args['placeholder']; |
|
1212 | - } else { |
|
1213 | - $placeholder = ''; |
|
1214 | - } |
|
1210 | + if ( isset( $args['placeholder'] ) ) { |
|
1211 | + $placeholder = $args['placeholder']; |
|
1212 | + } else { |
|
1213 | + $placeholder = ''; |
|
1214 | + } |
|
1215 | 1215 | |
1216 | - $states = wpinv_get_country_states(); |
|
1216 | + $states = wpinv_get_country_states(); |
|
1217 | 1217 | |
1218 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
1219 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1220 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1218 | + $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
1219 | + $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
1220 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1221 | 1221 | |
1222 | - foreach ( $states as $option => $name ) { |
|
1223 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1224 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1225 | - } |
|
1222 | + foreach ( $states as $option => $name ) { |
|
1223 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1224 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1225 | + } |
|
1226 | 1226 | |
1227 | - $html .= '</select>'; |
|
1228 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1227 | + $html .= '</select>'; |
|
1228 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1229 | 1229 | |
1230 | - echo $html; |
|
1230 | + echo $html; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | function wpinv_tax_rates_callback($args) { |
1234 | - global $wpinv_options; |
|
1235 | - $rates = wpinv_get_tax_rates(); |
|
1236 | - ob_start(); ?> |
|
1234 | + global $wpinv_options; |
|
1235 | + $rates = wpinv_get_tax_rates(); |
|
1236 | + ob_start(); ?> |
|
1237 | 1237 | </td><tr> |
1238 | 1238 | <td colspan="2" class="wpinv_tax_tdbox"> |
1239 | 1239 | <p><?php echo $args['desc']; ?></p> |
@@ -1257,41 +1257,41 @@ discard block |
||
1257 | 1257 | <tr> |
1258 | 1258 | <td class="wpinv_tax_country"> |
1259 | 1259 | <?php |
1260 | - echo wpinv_html_select( array( |
|
1261 | - 'options' => wpinv_get_country_list( true ), |
|
1262 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1260 | + echo wpinv_html_select( array( |
|
1261 | + 'options' => wpinv_get_country_list( true ), |
|
1262 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1263 | 1263 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1264 | - 'selected' => $rate['country'], |
|
1265 | - 'show_option_all' => false, |
|
1266 | - 'show_option_none' => false, |
|
1267 | - 'class' => 'wpinv-tax-country', |
|
1268 | - 'chosen' => false, |
|
1269 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1270 | - ) ); |
|
1271 | - ?> |
|
1264 | + 'selected' => $rate['country'], |
|
1265 | + 'show_option_all' => false, |
|
1266 | + 'show_option_none' => false, |
|
1267 | + 'class' => 'wpinv-tax-country', |
|
1268 | + 'chosen' => false, |
|
1269 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1270 | + ) ); |
|
1271 | + ?> |
|
1272 | 1272 | </td> |
1273 | 1273 | <td class="wpinv_tax_state"> |
1274 | 1274 | <?php |
1275 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1276 | - if( !empty( $states ) ) { |
|
1277 | - echo wpinv_html_select( array( |
|
1278 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1279 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1275 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
1276 | + if( !empty( $states ) ) { |
|
1277 | + echo wpinv_html_select( array( |
|
1278 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1279 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1280 | 1280 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1281 | - 'selected' => $rate['state'], |
|
1282 | - 'show_option_all' => false, |
|
1283 | - 'show_option_none' => false, |
|
1284 | - 'chosen' => false, |
|
1285 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1286 | - ) ); |
|
1287 | - } else { |
|
1288 | - echo wpinv_html_text( array( |
|
1289 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1290 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1281 | + 'selected' => $rate['state'], |
|
1282 | + 'show_option_all' => false, |
|
1283 | + 'show_option_none' => false, |
|
1284 | + 'chosen' => false, |
|
1285 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1286 | + ) ); |
|
1287 | + } else { |
|
1288 | + echo wpinv_html_text( array( |
|
1289 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1290 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1291 | 1291 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1292 | - ) ); |
|
1293 | - } |
|
1294 | - ?> |
|
1292 | + ) ); |
|
1293 | + } |
|
1294 | + ?> |
|
1295 | 1295 | </td> |
1296 | 1296 | <td class="wpinv_tax_global"> |
1297 | 1297 | <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'] ) ); ?>/> |
@@ -1306,20 +1306,20 @@ discard block |
||
1306 | 1306 | <tr> |
1307 | 1307 | <td class="wpinv_tax_country"> |
1308 | 1308 | <?php |
1309 | - echo wpinv_html_select( array( |
|
1310 | - 'options' => wpinv_get_country_list( true ), |
|
1311 | - 'name' => 'tax_rates[0][country]', |
|
1312 | - 'show_option_all' => false, |
|
1313 | - 'show_option_none' => false, |
|
1314 | - 'class' => 'wpinv-tax-country', |
|
1315 | - 'chosen' => false, |
|
1316 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1317 | - ) ); ?> |
|
1309 | + echo wpinv_html_select( array( |
|
1310 | + 'options' => wpinv_get_country_list( true ), |
|
1311 | + 'name' => 'tax_rates[0][country]', |
|
1312 | + 'show_option_all' => false, |
|
1313 | + 'show_option_none' => false, |
|
1314 | + 'class' => 'wpinv-tax-country', |
|
1315 | + 'chosen' => false, |
|
1316 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1317 | + ) ); ?> |
|
1318 | 1318 | </td> |
1319 | 1319 | <td class="wpinv_tax_state"> |
1320 | 1320 | <?php echo wpinv_html_text( array( |
1321 | - 'name' => 'tax_rates[0][state]' |
|
1322 | - ) ); ?> |
|
1321 | + 'name' => 'tax_rates[0][state]' |
|
1322 | + ) ); ?> |
|
1323 | 1323 | </td> |
1324 | 1324 | <td class="wpinv_tax_global"> |
1325 | 1325 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | <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> |
1335 | 1335 | </table> |
1336 | 1336 | <?php |
1337 | - echo ob_get_clean(); |
|
1337 | + echo ob_get_clean(); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | function wpinv_tools_callback($args) { |
@@ -1362,14 +1362,14 @@ discard block |
||
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | function wpinv_descriptive_text_callback( $args ) { |
1365 | - echo wp_kses_post( $args['desc'] ); |
|
1365 | + echo wp_kses_post( $args['desc'] ); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | function wpinv_hook_callback( $args ) { |
1369 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1369 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | function wpinv_set_settings_cap() { |
1373 | - return 'manage_options'; |
|
1373 | + return 'manage_options'; |
|
1374 | 1374 | } |
1375 | 1375 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
@@ -912,10 +912,11 @@ discard block |
||
912 | 912 | |
913 | 913 | $checked = false; |
914 | 914 | |
915 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
916 | - $checked = true; |
|
917 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
918 | - $checked = true; |
|
915 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) { |
|
916 | + $checked = true; |
|
917 | + } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) { |
|
918 | + $checked = true; |
|
919 | + } |
|
919 | 920 | |
920 | 921 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
921 | 922 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
@@ -932,10 +933,11 @@ discard block |
||
932 | 933 | foreach ( $args['options'] as $key => $option ) : |
933 | 934 | $sanitize_key = wpinv_sanitize_key( $key ); |
934 | 935 | |
935 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
936 | - $enabled = '1'; |
|
937 | - else |
|
938 | - $enabled = null; |
|
936 | + if ( isset( $wpinv_options['gateways'][ $key ] ) ) { |
|
937 | + $enabled = '1'; |
|
938 | + } else { |
|
939 | + $enabled = null; |
|
940 | + } |
|
939 | 941 | |
940 | 942 | 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) . '/> '; |
941 | 943 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
@@ -1302,7 +1304,8 @@ discard block |
||
1302 | 1304 | <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
1303 | 1305 | </tr> |
1304 | 1306 | <?php endforeach; ?> |
1305 | - <?php else : ?> |
|
1307 | + <?php else { |
|
1308 | + : ?> |
|
1306 | 1309 | <tr> |
1307 | 1310 | <td class="wpinv_tax_country"> |
1308 | 1311 | <?php |
@@ -1314,7 +1317,9 @@ discard block |
||
1314 | 1317 | 'class' => 'wpinv-tax-country', |
1315 | 1318 | 'chosen' => false, |
1316 | 1319 | 'placeholder' => __( 'Choose a country', 'invoicing' ) |
1317 | - ) ); ?> |
|
1320 | + ) ); |
|
1321 | +} |
|
1322 | +?> |
|
1318 | 1323 | </td> |
1319 | 1324 | <td class="wpinv_tax_state"> |
1320 | 1325 | <?php echo wpinv_html_text( array( |
@@ -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 |