@@ -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'], 4 ); |
|
740 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
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, 4 ); |
|
1423 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1424 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1425 | + $value = wpinv_sanitize_amount($value, 4); |
|
1426 | 1426 | $value = $value >= 100 ? 99 : $value; |
1427 | 1427 | } |
1428 | 1428 | |
1429 | 1429 | return $value; |
1430 | 1430 | } |
1431 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1432 | 1431 | \ No newline at end of file |
1432 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1433 | 1433 | \ No newline at end of file |
@@ -7,228 +7,228 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'ID' => __( 'ID', 'invoicing' ), |
|
18 | - 'details' => __( 'Details', 'invoicing' ), |
|
17 | + 'ID' => __('ID', 'invoicing'), |
|
18 | + 'details' => __('Details', 'invoicing'), |
|
19 | 19 | //'email' => __( 'Email', 'invoicing' ), |
20 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
21 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
22 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
23 | - 'status' => __( 'Status', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
20 | + 'customer' => __('Customer', 'invoicing'), |
|
21 | + 'amount' => __('Amount', 'invoicing'), |
|
22 | + 'invoice_date' => __('Date', 'invoicing'), |
|
23 | + 'status' => __('Status', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | 39 | |
40 | -function wpinv_sortable_columns( $columns ) { |
|
40 | +function wpinv_sortable_columns($columns) { |
|
41 | 41 | $columns = array( |
42 | - 'ID' => array( 'ID', true ), |
|
43 | - 'amount' => array( 'amount', false ), |
|
44 | - 'invoice_date' => array( 'date', false ), |
|
45 | - 'customer' => array( 'customer', false ), |
|
42 | + 'ID' => array('ID', true), |
|
43 | + 'amount' => array('amount', false), |
|
44 | + 'invoice_date' => array('date', false), |
|
45 | + 'customer' => array('customer', false), |
|
46 | 46 | ///'email' => array( 'email', false ), |
47 | - 'status' => array( 'status', false ), |
|
47 | + 'status' => array('status', false), |
|
48 | 48 | ); |
49 | 49 | |
50 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
50 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
51 | 51 | } |
52 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
52 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
53 | 53 | |
54 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
55 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
54 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
55 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
56 | 56 | global $post, $wpi_invoice; |
57 | 57 | |
58 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
59 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
58 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
59 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $value = NULL; |
63 | 63 | |
64 | - switch ( $column_name ) { |
|
64 | + switch ($column_name) { |
|
65 | 65 | case 'email' : |
66 | - $value = $wpi_invoice->get_email(); |
|
66 | + $value = $wpi_invoice->get_email(); |
|
67 | 67 | break; |
68 | 68 | case 'customer' : |
69 | 69 | $customer_name = $wpi_invoice->get_user_full_name(); |
70 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
71 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
72 | - if ( $email = $wpi_invoice->get_email() ) { |
|
70 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
71 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
72 | + if ($email = $wpi_invoice->get_email()) { |
|
73 | 73 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
74 | 74 | } |
75 | 75 | break; |
76 | 76 | case 'amount' : |
77 | - echo $wpi_invoice->get_total( true ); |
|
77 | + echo $wpi_invoice->get_total(true); |
|
78 | 78 | break; |
79 | 79 | case 'invoice_date' : |
80 | - $date_format = get_option( 'date_format' ); |
|
81 | - $time_format = get_option( 'time_format' ); |
|
82 | - $date_time_format = $date_format . ' '. $time_format; |
|
80 | + $date_format = get_option('date_format'); |
|
81 | + $time_format = get_option('time_format'); |
|
82 | + $date_time_format = $date_format . ' ' . $time_format; |
|
83 | 83 | |
84 | - $t_time = get_the_time( $date_time_format ); |
|
84 | + $t_time = get_the_time($date_time_format); |
|
85 | 85 | $m_time = $post->post_date; |
86 | - $h_time = mysql2date( $date_format, $m_time ); |
|
86 | + $h_time = mysql2date($date_format, $m_time); |
|
87 | 87 | |
88 | 88 | $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
89 | 89 | break; |
90 | 90 | case 'status' : |
91 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
91 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
92 | 92 | break; |
93 | 93 | case 'details' : |
94 | - $edit_link = get_edit_post_link( $post->ID ); |
|
95 | - $value = '<a href="' . esc_url( $edit_link ) . '">' . __( 'View Invoice Details', 'invoicing' ) . '</a>'; |
|
94 | + $edit_link = get_edit_post_link($post->ID); |
|
95 | + $value = '<a href="' . esc_url($edit_link) . '">' . __('View Invoice Details', 'invoicing') . '</a>'; |
|
96 | 96 | break; |
97 | 97 | case 'wpi_actions' : |
98 | 98 | $value = ''; |
99 | - if ( !empty( $post->post_name ) ) { |
|
100 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
99 | + if (!empty($post->post_name)) { |
|
100 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $email = $wpi_invoice->get_email() ) { |
|
104 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
103 | + if ($email = $wpi_invoice->get_email()) { |
|
104 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | break; |
108 | 108 | default: |
109 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
109 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
110 | 110 | break; |
111 | 111 | |
112 | 112 | } |
113 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
113 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
114 | 114 | |
115 | - if ( $value !== NULL ) { |
|
115 | + if ($value !== NULL) { |
|
116 | 116 | echo $value; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | -function wpinv_admin_post_id( $id = 0 ) { |
|
120 | +function wpinv_admin_post_id($id = 0) { |
|
121 | 121 | global $post; |
122 | 122 | |
123 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
123 | + if (isset($id) && !empty($id)) { |
|
124 | 124 | return (int)$id; |
125 | - } else if ( get_the_ID() ) { |
|
126 | - return (int) get_the_ID(); |
|
127 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
128 | - return (int) $post->ID; |
|
129 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
130 | - return (int) $_GET['post']; |
|
131 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
132 | - return (int) $_GET['id']; |
|
133 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
134 | - return (int) $_POST['id']; |
|
125 | + } else if (get_the_ID()) { |
|
126 | + return (int)get_the_ID(); |
|
127 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
128 | + return (int)$post->ID; |
|
129 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
130 | + return (int)$_GET['post']; |
|
131 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
132 | + return (int)$_GET['id']; |
|
133 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
134 | + return (int)$_POST['id']; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return null; |
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_admin_post_type( $id = 0 ) { |
|
141 | - if ( !$id ) { |
|
140 | +function wpinv_admin_post_type($id = 0) { |
|
141 | + if (!$id) { |
|
142 | 142 | $id = wpinv_admin_post_id(); |
143 | 143 | } |
144 | 144 | |
145 | - $type = get_post_type( $id ); |
|
145 | + $type = get_post_type($id); |
|
146 | 146 | |
147 | - if ( !$type ) { |
|
148 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
147 | + if (!$type) { |
|
148 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
149 | 149 | } |
150 | 150 | |
151 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
151 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | function wpinv_admin_messages() { |
155 | 155 | global $wpinv_options; |
156 | 156 | |
157 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
158 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
157 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
158 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
162 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
161 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
162 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
163 | 163 | } |
164 | 164 | |
165 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
166 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
165 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
166 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
170 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
169 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
170 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
171 | 171 | } |
172 | 172 | |
173 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
174 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
173 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
174 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
175 | 175 | } |
176 | 176 | |
177 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
178 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
177 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
178 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
179 | 179 | } |
180 | 180 | |
181 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
182 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
181 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
182 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
186 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
185 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
186 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
190 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
189 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
190 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
194 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
193 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
194 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
198 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
197 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
198 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
199 | 199 | } |
200 | 200 | |
201 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
202 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
201 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
202 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
203 | 203 | } |
204 | 204 | |
205 | - settings_errors( 'wpinv-notices' ); |
|
205 | + settings_errors('wpinv-notices'); |
|
206 | 206 | } |
207 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
207 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
208 | 208 | |
209 | -function wpinv_items_columns( $existing_columns ) { |
|
209 | +function wpinv_items_columns($existing_columns) { |
|
210 | 210 | global $wpinv_euvat; |
211 | 211 | |
212 | 212 | $columns = array(); |
213 | 213 | $columns['cb'] = $existing_columns['cb']; |
214 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
215 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
216 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
217 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
214 | + $columns['title'] = __('Title', 'invoicing'); |
|
215 | + $columns['price'] = __('Price', 'invoicing'); |
|
216 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
217 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
218 | 218 | } |
219 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
220 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
219 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
220 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
221 | 221 | } |
222 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
223 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
224 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
225 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
222 | + $columns['type'] = __('Type', 'invoicing'); |
|
223 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
224 | + $columns['date'] = __('Date', 'invoicing'); |
|
225 | + $columns['id'] = __('ID', 'invoicing'); |
|
226 | 226 | |
227 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
227 | + return apply_filters('wpinv_items_columns', $columns); |
|
228 | 228 | } |
229 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
229 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
230 | 230 | |
231 | -function wpinv_items_sortable_columns( $columns ) { |
|
231 | +function wpinv_items_sortable_columns($columns) { |
|
232 | 232 | $columns['price'] = 'price'; |
233 | 233 | $columns['vat_rule'] = 'vat_rule'; |
234 | 234 | $columns['vat_class'] = 'vat_class'; |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | |
239 | 239 | return $columns; |
240 | 240 | } |
241 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
241 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
242 | 242 | |
243 | -function wpinv_item_quick_edit( $column_name, $post_type ) { |
|
244 | - if ( !( $post_type == 'wpi_item' && $column_name == 'price' ) ) { |
|
243 | +function wpinv_item_quick_edit($column_name, $post_type) { |
|
244 | + if (!($post_type == 'wpi_item' && $column_name == 'price')) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | global $wpinv_euvat, $post; |
@@ -249,23 +249,23 @@ discard block |
||
249 | 249 | $symbol = wpinv_currency_symbol(); |
250 | 250 | $position = wpinv_currency_position(); |
251 | 251 | |
252 | - $price = wpinv_get_item_price( $post->ID ); |
|
253 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
252 | + $price = wpinv_get_item_price($post->ID); |
|
253 | + $item_type = wpinv_get_item_type($post->ID); |
|
254 | 254 | ?> |
255 | 255 | <fieldset class="inline-edit-col-right wpi-inline-item-col"> |
256 | 256 | <div class="inline-edit-col"> |
257 | 257 | <div class="inline-edit-group wp-clearfix"> |
258 | 258 | <label class="inline-edit-wpinv-price"> |
259 | - <span class="title"><?php _e( 'Item price', 'invoicing' );?></span> |
|
260 | - <span class="input-text-wrap"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID;?>"><?php echo ( $position == 'right' ? $symbol . ' ' : '' );?></span> |
|
259 | + <span class="title"><?php _e('Item price', 'invoicing'); ?></span> |
|
260 | + <span class="input-text-wrap"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID; ?>"><?php echo ($position == 'right' ? $symbol . ' ' : ''); ?></span> |
|
261 | 261 | </label> |
262 | 262 | </div> |
263 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); ?> |
|
263 | + <?php if ($wpinv_euvat->allow_vat_rules()) { $rule_type = $wpinv_euvat->get_item_rule($post->ID); ?> |
|
264 | 264 | <div class="inline-edit-group wp-clearfix"> |
265 | 265 | <label class="inline-edit-wpinv-vat-rate"> |
266 | - <span class="title"><?php _e( 'VAT rule type to use', 'invoicing' );?></span> |
|
266 | + <span class="title"><?php _e('VAT rule type to use', 'invoicing'); ?></span> |
|
267 | 267 | <span class="input-text-wrap"> |
268 | - <?php echo wpinv_html_select( array( |
|
268 | + <?php echo wpinv_html_select(array( |
|
269 | 269 | 'options' => $wpinv_euvat->get_rules(), |
270 | 270 | 'name' => '_wpinv_vat_rules', |
271 | 271 | 'id' => 'wpinv_vat_rules-' . $post->ID, |
@@ -273,16 +273,16 @@ discard block |
||
273 | 273 | 'show_option_all' => false, |
274 | 274 | 'show_option_none' => false, |
275 | 275 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules', |
276 | - ) ); ?> |
|
276 | + )); ?> |
|
277 | 277 | </span> |
278 | 278 | </label> |
279 | 279 | </div> |
280 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { $vat_class = $wpinv_euvat->get_item_class( $post->ID ); ?> |
|
280 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { $vat_class = $wpinv_euvat->get_item_class($post->ID); ?> |
|
281 | 281 | <div class="inline-edit-group wp-clearfix"> |
282 | 282 | <label class="inline-edit-wpinv-vat-class"> |
283 | - <span class="title"><?php _e( 'VAT class to use', 'invoicing' );?></span> |
|
283 | + <span class="title"><?php _e('VAT class to use', 'invoicing'); ?></span> |
|
284 | 284 | <span class="input-text-wrap"> |
285 | - <?php echo wpinv_html_select( array( |
|
285 | + <?php echo wpinv_html_select(array( |
|
286 | 286 | 'options' => $wpinv_euvat->get_all_classes(), |
287 | 287 | 'name' => '_wpinv_vat_class', |
288 | 288 | 'id' => 'wpinv_vat_class-' . $post->ID, |
@@ -290,16 +290,16 @@ discard block |
||
290 | 290 | 'show_option_all' => false, |
291 | 291 | 'show_option_none' => false, |
292 | 292 | 'class' => 'gdmbx2-text-medium wpinv-vat-class', |
293 | - ) ); ?> |
|
293 | + )); ?> |
|
294 | 294 | </span> |
295 | 295 | </label> |
296 | 296 | </div> |
297 | 297 | <?php } ?> |
298 | 298 | <div class="inline-edit-group wp-clearfix"> |
299 | 299 | <label class="inline-edit-wpinv-type"> |
300 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
300 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
301 | 301 | <span class="input-text-wrap"> |
302 | - <?php echo wpinv_html_select( array( |
|
302 | + <?php echo wpinv_html_select(array( |
|
303 | 303 | 'options' => wpinv_get_item_types(), |
304 | 304 | 'name' => '_wpinv_item_type', |
305 | 305 | 'id' => 'wpinv_item_type-' . $post->ID, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | 'show_option_all' => false, |
308 | 308 | 'show_option_none' => false, |
309 | 309 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
310 | - ) ); ?> |
|
310 | + )); ?> |
|
311 | 311 | </span> |
312 | 312 | </label> |
313 | 313 | </div> |
@@ -315,157 +315,157 @@ discard block |
||
315 | 315 | </fieldset> |
316 | 316 | <?php |
317 | 317 | } |
318 | -add_action( 'quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
319 | -add_action( 'bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 ); |
|
318 | +add_action('quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
319 | +add_action('bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2); |
|
320 | 320 | |
321 | -function wpinv_items_table_custom_column( $column ) { |
|
321 | +function wpinv_items_table_custom_column($column) { |
|
322 | 322 | global $wpinv_euvat, $post, $wpi_item; |
323 | 323 | |
324 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
325 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
324 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
325 | + $wpi_item = new WPInv_Item($post->ID); |
|
326 | 326 | } |
327 | 327 | |
328 | - switch ( $column ) { |
|
328 | + switch ($column) { |
|
329 | 329 | case 'price' : |
330 | - echo wpinv_item_price( $post->ID ); |
|
330 | + echo wpinv_item_price($post->ID); |
|
331 | 331 | break; |
332 | 332 | case 'vat_rule' : |
333 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
333 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
334 | 334 | break; |
335 | 335 | case 'vat_class' : |
336 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
336 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
337 | 337 | break; |
338 | 338 | case 'type' : |
339 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
339 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
340 | 340 | break; |
341 | 341 | case 'recurring' : |
342 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
342 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
343 | 343 | break; |
344 | 344 | case 'id' : |
345 | 345 | echo $post->ID; |
346 | 346 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
347 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
348 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
349 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
347 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
348 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
349 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
350 | 350 | } |
351 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
352 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
351 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
352 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
353 | 353 | } |
354 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
354 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
355 | 355 | </div>'; |
356 | 356 | break; |
357 | 357 | } |
358 | 358 | |
359 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
359 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
360 | 360 | } |
361 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
361 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
362 | 362 | |
363 | 363 | function wpinv_add_items_filters() { |
364 | 364 | global $wpinv_euvat, $typenow; |
365 | 365 | |
366 | 366 | // Checks if the current post type is 'item' |
367 | - if ( $typenow == 'wpi_item') { |
|
368 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
369 | - echo wpinv_html_select( array( |
|
370 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
367 | + if ($typenow == 'wpi_item') { |
|
368 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
369 | + echo wpinv_html_select(array( |
|
370 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
371 | 371 | 'name' => 'vat_rule', |
372 | 372 | 'id' => 'vat_rule', |
373 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
373 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
374 | 374 | 'show_option_all' => false, |
375 | 375 | 'show_option_none' => false, |
376 | 376 | 'class' => 'gdmbx2-text-medium', |
377 | - ) ); |
|
377 | + )); |
|
378 | 378 | } |
379 | 379 | |
380 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
381 | - echo wpinv_html_select( array( |
|
382 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
380 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
381 | + echo wpinv_html_select(array( |
|
382 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
383 | 383 | 'name' => 'vat_class', |
384 | 384 | 'id' => 'vat_class', |
385 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
385 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
386 | 386 | 'show_option_all' => false, |
387 | 387 | 'show_option_none' => false, |
388 | 388 | 'class' => 'gdmbx2-text-medium', |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | } |
391 | 391 | |
392 | - echo wpinv_html_select( array( |
|
393 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
392 | + echo wpinv_html_select(array( |
|
393 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
394 | 394 | 'name' => 'type', |
395 | 395 | 'id' => 'type', |
396 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
396 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
397 | 397 | 'show_option_all' => false, |
398 | 398 | 'show_option_none' => false, |
399 | 399 | 'class' => 'gdmbx2-text-medium', |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | |
402 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
402 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
403 | 403 | echo '<input type="hidden" name="all_posts" value="1" />'; |
404 | 404 | } |
405 | 405 | } |
406 | 406 | } |
407 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
407 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
408 | 408 | |
409 | -function wpinv_send_invoice_after_save( $post_id ) { |
|
409 | +function wpinv_send_invoice_after_save($post_id) { |
|
410 | 410 | // If this is just a revision, don't send the email. |
411 | - if ( wp_is_post_revision( $post_id ) ) { |
|
411 | + if (wp_is_post_revision($post_id)) { |
|
412 | 412 | return; |
413 | 413 | } |
414 | 414 | |
415 | - if ( !current_user_can( 'manage_options' ) || !(get_post_type( $post_id ) == 'wpi_invoice') ) { |
|
415 | + if (!current_user_can('manage_options') || !(get_post_type($post_id) == 'wpi_invoice')) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( !empty( $_POST['wpi_save_send'] ) ) { |
|
420 | - wpinv_user_invoice_notification( $post_id ); |
|
419 | + if (!empty($_POST['wpi_save_send'])) { |
|
420 | + wpinv_user_invoice_notification($post_id); |
|
421 | 421 | } |
422 | 422 | } |
423 | -add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
423 | +add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1); |
|
424 | 424 | |
425 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
426 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ($data['post_type'] == 'wpi_invoice' || $data['post_type'] == 'wpi_quote') ) { |
|
427 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
428 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
425 | +function wpinv_send_register_new_user($data, $postarr) { |
|
426 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ($data['post_type'] == 'wpi_invoice' || $data['post_type'] == 'wpi_quote')) { |
|
427 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
428 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
429 | 429 | |
430 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
431 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
432 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
433 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
434 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
435 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
430 | + if ($is_new_user && $email && !email_exists($email)) { |
|
431 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
432 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
433 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
434 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
435 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
436 | 436 | |
437 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
438 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
437 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
438 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
439 | 439 | $new_user_login = strstr($email, '@', true); |
440 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
441 | - $user_login = sanitize_user($new_user_login, true ); |
|
440 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
441 | + $user_login = sanitize_user($new_user_login, true); |
|
442 | 442 | } |
443 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
444 | - $user_append_text = rand(10,1000); |
|
445 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
443 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
444 | + $user_append_text = rand(10, 1000); |
|
445 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
446 | 446 | } |
447 | 447 | |
448 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
448 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
449 | 449 | $user_login = $email; |
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | 453 | $userdata = array( |
454 | 454 | 'user_login' => $user_login, |
455 | - 'user_pass' => wp_generate_password( 12, false ), |
|
456 | - 'user_email' => sanitize_text_field( $email ), |
|
455 | + 'user_pass' => wp_generate_password(12, false), |
|
456 | + 'user_email' => sanitize_text_field($email), |
|
457 | 457 | 'first_name' => $first_name, |
458 | 458 | 'last_name' => $last_name, |
459 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
459 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
460 | 460 | 'nickname' => $display_name, |
461 | 461 | 'display_name' => $display_name, |
462 | 462 | ); |
463 | 463 | |
464 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
464 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
465 | 465 | |
466 | - $new_user_id = wp_insert_user( $userdata ); |
|
466 | + $new_user_id = wp_insert_user($userdata); |
|
467 | 467 | |
468 | - if ( !is_wp_error( $new_user_id ) ) { |
|
468 | + if (!is_wp_error($new_user_id)) { |
|
469 | 469 | $data['post_author'] = $new_user_id; |
470 | 470 | $_POST['post_author'] = $new_user_id; |
471 | 471 | $_POST['post_author_override'] = $new_user_id; |
@@ -486,27 +486,27 @@ discard block |
||
486 | 486 | |
487 | 487 | $meta = array(); |
488 | 488 | ///$meta['_wpinv_user_id'] = $new_user_id; |
489 | - foreach ( $meta_fields as $field ) { |
|
490 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
489 | + foreach ($meta_fields as $field) { |
|
490 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
491 | 491 | } |
492 | 492 | |
493 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
493 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
494 | 494 | |
495 | 495 | // Update user meta. |
496 | - foreach ( $meta as $key => $value ) { |
|
497 | - update_user_meta( $new_user_id, $key, $value ); |
|
496 | + foreach ($meta as $key => $value) { |
|
497 | + update_user_meta($new_user_id, $key, $value); |
|
498 | 498 | } |
499 | 499 | |
500 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
500 | + if (function_exists('wp_send_new_user_notifications')) { |
|
501 | 501 | // Send email notifications related to the creation of new user. |
502 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
502 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
503 | 503 | } |
504 | 504 | } else { |
505 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
505 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
510 | 510 | return $data; |
511 | 511 | } |
512 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
513 | 512 | \ No newline at end of file |
513 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
514 | 514 | \ No newline at end of file |
@@ -7,28 +7,28 @@ 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 | class WPInv_Ajax { |
15 | 15 | public static function init() { |
16 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
17 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
16 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
17 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
18 | 18 | self::add_ajax_events(); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function define_ajax() { |
22 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
23 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
24 | - define( 'DOING_AJAX', true ); |
|
22 | + if (!empty($_GET['wpinv-ajax'])) { |
|
23 | + if (!defined('DOING_AJAX')) { |
|
24 | + define('DOING_AJAX', true); |
|
25 | 25 | } |
26 | - if ( ! defined( 'WC_DOING_AJAX' ) ) { |
|
27 | - define( 'WC_DOING_AJAX', true ); |
|
26 | + if (!defined('WC_DOING_AJAX')) { |
|
27 | + define('WC_DOING_AJAX', true); |
|
28 | 28 | } |
29 | 29 | // Turn off display_errors during AJAX events to prevent malformed JSON |
30 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
31 | - @ini_set( 'display_errors', 0 ); |
|
30 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
31 | + @ini_set('display_errors', 0); |
|
32 | 32 | } |
33 | 33 | $GLOBALS['wpdb']->hide_errors(); |
34 | 34 | } |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | public static function do_wpinv_ajax() { |
38 | 38 | global $wp_query; |
39 | 39 | |
40 | - if ( !empty( $_GET['wpinv-ajax'] ) ) { |
|
41 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) ); |
|
40 | + if (!empty($_GET['wpinv-ajax'])) { |
|
41 | + $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax'])); |
|
42 | 42 | } |
43 | 43 | |
44 | - if ( $action = $wp_query->get( 'wpinv-ajax' ) ) { |
|
44 | + if ($action = $wp_query->get('wpinv-ajax')) { |
|
45 | 45 | self::wpinv_ajax_headers(); |
46 | - do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) ); |
|
46 | + do_action('wpinv_ajax_' . sanitize_text_field($action)); |
|
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | 51 | private static function wpinv_ajax_headers() { |
52 | 52 | send_origin_headers(); |
53 | - @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
54 | - @header( 'X-Robots-Tag: noindex' ); |
|
53 | + @header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
54 | + @header('X-Robots-Tag: noindex'); |
|
55 | 55 | send_nosniff_header(); |
56 | 56 | nocache_headers(); |
57 | - status_header( 200 ); |
|
57 | + status_header(200); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function add_ajax_events() { |
@@ -76,39 +76,39 @@ discard block |
||
76 | 76 | 'remove_discount' => false, |
77 | 77 | ); |
78 | 78 | |
79 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
80 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
79 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
80 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
81 | 81 | |
82 | - if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) { |
|
83 | - define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 ); |
|
82 | + if (!defined('WPI_AJAX_' . strtoupper($nopriv))) { |
|
83 | + define('WPI_AJAX_' . strtoupper($nopriv), 1); |
|
84 | 84 | } |
85 | 85 | |
86 | - if ( $nopriv ) { |
|
87 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
86 | + if ($nopriv) { |
|
87 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
88 | 88 | |
89 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
89 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function add_note() { |
95 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
95 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
96 | 96 | |
97 | - if ( !current_user_can( 'manage_options' ) ) { |
|
97 | + if (!current_user_can('manage_options')) { |
|
98 | 98 | die(-1); |
99 | 99 | } |
100 | 100 | |
101 | - $post_id = absint( $_POST['post_id'] ); |
|
102 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
103 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
101 | + $post_id = absint($_POST['post_id']); |
|
102 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
103 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
104 | 104 | |
105 | 105 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
106 | 106 | |
107 | - if ( $post_id > 0 ) { |
|
108 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
107 | + if ($post_id > 0) { |
|
108 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
109 | 109 | |
110 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
111 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
110 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
111 | + wpinv_get_invoice_note_line_item($note_id); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function delete_note() { |
119 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
119 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
120 | 120 | |
121 | - if ( !current_user_can( 'manage_options' ) ) { |
|
121 | + if (!current_user_can('manage_options')) { |
|
122 | 122 | die(-1); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $note_id = (int)$_POST['note_id']; |
126 | 126 | |
127 | - if ( $note_id > 0 ) { |
|
128 | - wp_delete_comment( $note_id, true ); |
|
127 | + if ($note_id > 0) { |
|
128 | + wp_delete_comment($note_id, true); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | die(); |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | public static function checkout() { |
141 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
142 | - define( 'WPINV_CHECKOUT', true ); |
|
141 | + if (!defined('WPINV_CHECKOUT')) { |
|
142 | + define('WPINV_CHECKOUT', true); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | wpinv_process_checkout(); |
@@ -148,53 +148,53 @@ discard block |
||
148 | 148 | |
149 | 149 | public static function add_invoice_item() { |
150 | 150 | global $wpi_userID, $wpinv_ip_address_country; |
151 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
152 | - if ( !current_user_can( 'manage_options' ) ) { |
|
151 | + check_ajax_referer('invoice-item', '_nonce'); |
|
152 | + if (!current_user_can('manage_options')) { |
|
153 | 153 | die(-1); |
154 | 154 | } |
155 | 155 | |
156 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
157 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
156 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
157 | + $invoice_id = absint($_POST['invoice_id']); |
|
158 | 158 | |
159 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
159 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
160 | 160 | die(); |
161 | 161 | } |
162 | 162 | |
163 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
164 | - if ( empty( $invoice ) ) { |
|
163 | + $invoice = wpinv_get_invoice($invoice_id); |
|
164 | + if (empty($invoice)) { |
|
165 | 165 | die(); |
166 | 166 | } |
167 | 167 | |
168 | - if ( $invoice->is_paid() ) { |
|
168 | + if ($invoice->is_paid()) { |
|
169 | 169 | die(); // Don't allow modify items for paid invoice. |
170 | 170 | } |
171 | 171 | |
172 | - if ( !empty( $_POST['user_id'] ) ) { |
|
173 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
172 | + if (!empty($_POST['user_id'])) { |
|
173 | + $wpi_userID = absint($_POST['user_id']); |
|
174 | 174 | } |
175 | 175 | |
176 | - $item = new WPInv_Item( $item_id ); |
|
177 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
176 | + $item = new WPInv_Item($item_id); |
|
177 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
178 | 178 | die(); |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Validate item before adding to invoice because recurring item must be paid individually. |
182 | - if ( !empty( $invoice->cart_details ) ) { |
|
182 | + if (!empty($invoice->cart_details)) { |
|
183 | 183 | $valid = true; |
184 | 184 | |
185 | - if ( $recurring_item = $invoice->get_recurring() ) { |
|
186 | - if ( $recurring_item != $item_id ) { |
|
185 | + if ($recurring_item = $invoice->get_recurring()) { |
|
186 | + if ($recurring_item != $item_id) { |
|
187 | 187 | $valid = false; |
188 | 188 | } |
189 | - } else if ( wpinv_is_recurring_item( $item_id ) ) { |
|
189 | + } else if (wpinv_is_recurring_item($item_id)) { |
|
190 | 190 | $valid = false; |
191 | 191 | } |
192 | 192 | |
193 | - if ( !$valid ) { |
|
193 | + if (!$valid) { |
|
194 | 194 | $response = array(); |
195 | 195 | $response['success'] = false; |
196 | - $response['msg'] = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' ); |
|
197 | - wp_send_json( $response ); |
|
196 | + $response['msg'] = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing'); |
|
197 | + wp_send_json($response); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | |
203 | 203 | $data = array(); |
204 | 204 | $data['invoice_id'] = $invoice_id; |
205 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
205 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
206 | 206 | |
207 | - wpinv_set_checkout_session( $data ); |
|
207 | + wpinv_set_checkout_session($data); |
|
208 | 208 | |
209 | 209 | $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1; |
210 | 210 | |
@@ -219,21 +219,21 @@ discard block |
||
219 | 219 | 'fees' => array() |
220 | 220 | ); |
221 | 221 | |
222 | - $invoice->add_item( $item_id, $args ); |
|
222 | + $invoice->add_item($item_id, $args); |
|
223 | 223 | $invoice->save(); |
224 | 224 | |
225 | - if ( empty( $_POST['country'] ) ) { |
|
225 | + if (empty($_POST['country'])) { |
|
226 | 226 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
227 | 227 | } |
228 | - if ( empty( $_POST['state'] ) ) { |
|
228 | + if (empty($_POST['state'])) { |
|
229 | 229 | $_POST['state'] = $invoice->state; |
230 | 230 | } |
231 | 231 | |
232 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
233 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
232 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
233 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
234 | 234 | |
235 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
236 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
235 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
236 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
237 | 237 | |
238 | 238 | $wpinv_ip_address_country = $invoice->country; |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $response = array(); |
243 | 243 | $response['success'] = true; |
244 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
244 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
245 | 245 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
246 | 246 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
247 | 247 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -253,40 +253,40 @@ discard block |
||
253 | 253 | |
254 | 254 | wpinv_set_checkout_session($checkout_session); |
255 | 255 | |
256 | - wp_send_json( $response ); |
|
256 | + wp_send_json($response); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | public static function remove_invoice_item() { |
260 | 260 | global $wpi_userID, $wpinv_ip_address_country; |
261 | 261 | |
262 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
263 | - if ( !current_user_can( 'manage_options' ) ) { |
|
262 | + check_ajax_referer('invoice-item', '_nonce'); |
|
263 | + if (!current_user_can('manage_options')) { |
|
264 | 264 | die(-1); |
265 | 265 | } |
266 | 266 | |
267 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
268 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
269 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
267 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
268 | + $invoice_id = absint($_POST['invoice_id']); |
|
269 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
270 | 270 | |
271 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
271 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
272 | 272 | die(); |
273 | 273 | } |
274 | 274 | |
275 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
276 | - if ( empty( $invoice ) ) { |
|
275 | + $invoice = wpinv_get_invoice($invoice_id); |
|
276 | + if (empty($invoice)) { |
|
277 | 277 | die(); |
278 | 278 | } |
279 | 279 | |
280 | - if ( $invoice->is_paid() ) { |
|
280 | + if ($invoice->is_paid()) { |
|
281 | 281 | die(); // Don't allow modify items for paid invoice. |
282 | 282 | } |
283 | 283 | |
284 | - if ( !empty( $_POST['user_id'] ) ) { |
|
285 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
284 | + if (!empty($_POST['user_id'])) { |
|
285 | + $wpi_userID = absint($_POST['user_id']); |
|
286 | 286 | } |
287 | 287 | |
288 | - $item = new WPInv_Item( $item_id ); |
|
289 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
288 | + $item = new WPInv_Item($item_id); |
|
289 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
290 | 290 | die(); |
291 | 291 | } |
292 | 292 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | $data = array(); |
296 | 296 | $data['invoice_id'] = $invoice_id; |
297 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
297 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
298 | 298 | |
299 | - wpinv_set_checkout_session( $data ); |
|
299 | + wpinv_set_checkout_session($data); |
|
300 | 300 | |
301 | 301 | $args = array( |
302 | 302 | 'id' => $item_id, |
@@ -304,21 +304,21 @@ discard block |
||
304 | 304 | 'cart_index' => $cart_index |
305 | 305 | ); |
306 | 306 | |
307 | - $invoice->remove_item( $item_id, $args ); |
|
307 | + $invoice->remove_item($item_id, $args); |
|
308 | 308 | $invoice->save(); |
309 | 309 | |
310 | - if ( empty( $_POST['country'] ) ) { |
|
310 | + if (empty($_POST['country'])) { |
|
311 | 311 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
312 | 312 | } |
313 | - if ( empty( $_POST['state'] ) ) { |
|
313 | + if (empty($_POST['state'])) { |
|
314 | 314 | $_POST['state'] = $invoice->state; |
315 | 315 | } |
316 | 316 | |
317 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
318 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
317 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
318 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
319 | 319 | |
320 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
321 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
320 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
321 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
322 | 322 | |
323 | 323 | $wpinv_ip_address_country = $invoice->country; |
324 | 324 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | $response = array(); |
328 | 328 | $response['success'] = true; |
329 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
329 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
330 | 330 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
331 | 331 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
332 | 332 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -338,40 +338,40 @@ discard block |
||
338 | 338 | |
339 | 339 | wpinv_set_checkout_session($checkout_session); |
340 | 340 | |
341 | - wp_send_json( $response ); |
|
341 | + wp_send_json($response); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | public static function create_invoice_item() { |
345 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
346 | - if ( !current_user_can( 'manage_options' ) ) { |
|
345 | + check_ajax_referer('invoice-item', '_nonce'); |
|
346 | + if (!current_user_can('manage_options')) { |
|
347 | 347 | die(-1); |
348 | 348 | } |
349 | 349 | |
350 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
350 | + $invoice_id = absint($_POST['invoice_id']); |
|
351 | 351 | |
352 | 352 | // Find the item |
353 | - if ( !is_numeric( $invoice_id ) ) { |
|
353 | + if (!is_numeric($invoice_id)) { |
|
354 | 354 | die(); |
355 | 355 | } |
356 | 356 | |
357 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
358 | - if ( empty( $invoice ) ) { |
|
357 | + $invoice = wpinv_get_invoice($invoice_id); |
|
358 | + if (empty($invoice)) { |
|
359 | 359 | die(); |
360 | 360 | } |
361 | 361 | |
362 | 362 | // Validate item before adding to invoice because recurring item must be paid individually. |
363 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
363 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
364 | 364 | $response = array(); |
365 | 365 | $response['success'] = false; |
366 | - $response['msg'] = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' ); |
|
367 | - wp_send_json( $response ); |
|
366 | + $response['msg'] = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing'); |
|
367 | + wp_send_json($response); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | $save_item = $_POST['_wpinv_quick']; |
371 | 371 | |
372 | 372 | $meta = array(); |
373 | 373 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
374 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
374 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
375 | 375 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
376 | 376 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
377 | 377 | |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | $data['meta'] = $meta; |
382 | 382 | |
383 | 383 | $item = new WPInv_Item(); |
384 | - $item->create( $data ); |
|
384 | + $item->create($data); |
|
385 | 385 | |
386 | - if ( !empty( $item ) ) { |
|
386 | + if (!empty($item)) { |
|
387 | 387 | $_POST['item_id'] = $item->ID; |
388 | 388 | $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
389 | 389 | |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | public static function get_billing_details() { |
396 | - check_ajax_referer( 'get-billing-details', '_nonce' ); |
|
396 | + check_ajax_referer('get-billing-details', '_nonce'); |
|
397 | 397 | |
398 | - if ( !current_user_can( 'manage_options' ) ) { |
|
398 | + if (!current_user_can('manage_options')) { |
|
399 | 399 | die(-1); |
400 | 400 | } |
401 | 401 | |
402 | 402 | $user_id = (int)$_POST['user_id']; |
403 | 403 | $billing_details = wpinv_get_user_address($user_id); |
404 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
404 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
405 | 405 | |
406 | 406 | if (isset($billing_details['user_id'])) { |
407 | 407 | unset($billing_details['user_id']); |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | $response['success'] = true; |
416 | 416 | $response['data']['billing_details'] = $billing_details; |
417 | 417 | |
418 | - wp_send_json( $response ); |
|
418 | + wp_send_json($response); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | public static function admin_recalculate_totals() { |
422 | 422 | global $wpi_userID, $wpinv_ip_address_country; |
423 | 423 | |
424 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
425 | - if ( !current_user_can( 'manage_options' ) ) { |
|
424 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
425 | + if (!current_user_can('manage_options')) { |
|
426 | 426 | die(-1); |
427 | 427 | } |
428 | 428 | |
429 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
430 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
431 | - if ( empty( $invoice ) ) { |
|
429 | + $invoice_id = absint($_POST['invoice_id']); |
|
430 | + $invoice = wpinv_get_invoice($invoice_id); |
|
431 | + if (empty($invoice)) { |
|
432 | 432 | die(); |
433 | 433 | } |
434 | 434 | |
@@ -436,23 +436,23 @@ discard block |
||
436 | 436 | |
437 | 437 | $data = array(); |
438 | 438 | $data['invoice_id'] = $invoice_id; |
439 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
439 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
440 | 440 | |
441 | - wpinv_set_checkout_session( $data ); |
|
441 | + wpinv_set_checkout_session($data); |
|
442 | 442 | |
443 | - if ( !empty( $_POST['user_id'] ) ) { |
|
444 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
443 | + if (!empty($_POST['user_id'])) { |
|
444 | + $wpi_userID = absint($_POST['user_id']); |
|
445 | 445 | } |
446 | 446 | |
447 | - if ( empty( $_POST['country'] ) ) { |
|
447 | + if (empty($_POST['country'])) { |
|
448 | 448 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
449 | 449 | } |
450 | 450 | |
451 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
452 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
453 | - if ( isset( $_POST['state'] ) ) { |
|
454 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
455 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
451 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
452 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
453 | + if (isset($_POST['state'])) { |
|
454 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
455 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $wpinv_ip_address_country = $invoice->country; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | $response = array(); |
463 | 463 | $response['success'] = true; |
464 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
464 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
465 | 465 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
466 | 466 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
467 | 467 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -473,25 +473,25 @@ discard block |
||
473 | 473 | |
474 | 474 | wpinv_set_checkout_session($checkout_session); |
475 | 475 | |
476 | - wp_send_json( $response ); |
|
476 | + wp_send_json($response); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | public static function admin_apply_discount() { |
480 | 480 | global $wpi_userID; |
481 | 481 | |
482 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
483 | - if ( !current_user_can( 'manage_options' ) ) { |
|
482 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
483 | + if (!current_user_can('manage_options')) { |
|
484 | 484 | die(-1); |
485 | 485 | } |
486 | 486 | |
487 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
488 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
489 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
487 | + $invoice_id = absint($_POST['invoice_id']); |
|
488 | + $discount_code = sanitize_text_field($_POST['code']); |
|
489 | + if (empty($invoice_id) || empty($discount_code)) { |
|
490 | 490 | die(); |
491 | 491 | } |
492 | 492 | |
493 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
494 | - if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) { |
|
493 | + $invoice = wpinv_get_invoice($invoice_id); |
|
494 | + if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) { |
|
495 | 495 | die(); |
496 | 496 | } |
497 | 497 | |
@@ -499,49 +499,49 @@ discard block |
||
499 | 499 | |
500 | 500 | $data = array(); |
501 | 501 | $data['invoice_id'] = $invoice_id; |
502 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
502 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
503 | 503 | |
504 | - wpinv_set_checkout_session( $data ); |
|
504 | + wpinv_set_checkout_session($data); |
|
505 | 505 | |
506 | 506 | $response = array(); |
507 | 507 | $response['success'] = false; |
508 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
508 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
509 | 509 | $response['data']['code'] = $discount_code; |
510 | 510 | |
511 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
512 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
511 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
512 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
513 | 513 | |
514 | 514 | $response['success'] = true; |
515 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
516 | - } else { |
|
515 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
516 | + } else { |
|
517 | 517 | $errors = wpinv_get_errors(); |
518 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
518 | + if (!empty($errors['wpinv-discount-error'])) { |
|
519 | 519 | $response['msg'] = $errors['wpinv-discount-error']; |
520 | 520 | } |
521 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
521 | + wpinv_unset_error('wpinv-discount-error'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | wpinv_set_checkout_session($checkout_session); |
525 | 525 | |
526 | - wp_send_json( $response ); |
|
526 | + wp_send_json($response); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | public static function admin_remove_discount() { |
530 | 530 | global $wpi_userID; |
531 | 531 | |
532 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
533 | - if ( !current_user_can( 'manage_options' ) ) { |
|
532 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
533 | + if (!current_user_can('manage_options')) { |
|
534 | 534 | die(-1); |
535 | 535 | } |
536 | 536 | |
537 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
538 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
539 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
537 | + $invoice_id = absint($_POST['invoice_id']); |
|
538 | + $discount_code = sanitize_text_field($_POST['code']); |
|
539 | + if (empty($invoice_id) || empty($discount_code)) { |
|
540 | 540 | die(); |
541 | 541 | } |
542 | 542 | |
543 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
544 | - if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) { |
|
543 | + $invoice = wpinv_get_invoice($invoice_id); |
|
544 | + if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) { |
|
545 | 545 | die(); |
546 | 546 | } |
547 | 547 | |
@@ -549,38 +549,38 @@ discard block |
||
549 | 549 | |
550 | 550 | $data = array(); |
551 | 551 | $data['invoice_id'] = $invoice_id; |
552 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
552 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
553 | 553 | |
554 | - wpinv_set_checkout_session( $data ); |
|
554 | + wpinv_set_checkout_session($data); |
|
555 | 555 | |
556 | 556 | $response = array(); |
557 | 557 | $response['success'] = false; |
558 | 558 | $response['msg'] = NULL; |
559 | 559 | |
560 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
560 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
561 | 561 | $response['success'] = true; |
562 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
562 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
563 | 563 | |
564 | 564 | wpinv_set_checkout_session($checkout_session); |
565 | 565 | |
566 | - wp_send_json( $response ); |
|
566 | + wp_send_json($response); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | public static function check_email() { |
570 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
571 | - if ( !current_user_can( 'manage_options' ) ) { |
|
570 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
571 | + if (!current_user_can('manage_options')) { |
|
572 | 572 | die(-1); |
573 | 573 | } |
574 | 574 | |
575 | - $email = sanitize_text_field( $_POST['email'] ); |
|
575 | + $email = sanitize_text_field($_POST['email']); |
|
576 | 576 | |
577 | 577 | $response = array(); |
578 | - if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) { |
|
578 | + if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) { |
|
579 | 579 | $user_id = $user_data->ID; |
580 | 580 | $user_login = $user_data->user_login; |
581 | 581 | $display_name = $user_data->display_name ? $user_data->display_name : $user_login; |
582 | 582 | $billing_details = wpinv_get_user_address($user_id); |
583 | - $billing_details = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id ); |
|
583 | + $billing_details = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id); |
|
584 | 584 | |
585 | 585 | if (isset($billing_details['user_id'])) { |
586 | 586 | unset($billing_details['user_id']); |
@@ -596,31 +596,31 @@ discard block |
||
596 | 596 | $response['data']['billing_details'] = $billing_details; |
597 | 597 | } |
598 | 598 | |
599 | - wp_send_json( $response ); |
|
599 | + wp_send_json($response); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | public static function run_tool() { |
603 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
604 | - if ( !current_user_can( 'manage_options' ) ) { |
|
603 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
604 | + if (!current_user_can('manage_options')) { |
|
605 | 605 | die(-1); |
606 | 606 | } |
607 | 607 | |
608 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
608 | + $tool = sanitize_text_field($_POST['tool']); |
|
609 | 609 | |
610 | - do_action( 'wpinv_run_tool' ); |
|
610 | + do_action('wpinv_run_tool'); |
|
611 | 611 | |
612 | - if ( !empty( $tool ) ) { |
|
613 | - do_action( 'wpinv_tool_' . $tool ); |
|
612 | + if (!empty($tool)) { |
|
613 | + do_action('wpinv_tool_' . $tool); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | public static function apply_discount() { |
618 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
618 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
619 | 619 | |
620 | 620 | $response = array(); |
621 | 621 | |
622 | - if ( isset( $_POST['code'] ) ) { |
|
623 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
622 | + if (isset($_POST['code'])) { |
|
623 | + $discount_code = sanitize_text_field($_POST['code']); |
|
624 | 624 | |
625 | 625 | $response['success'] = false; |
626 | 626 | $response['msg'] = ''; |
@@ -628,14 +628,14 @@ discard block |
||
628 | 628 | |
629 | 629 | $user = is_user_logged_in() ? get_current_user_id() : ''; |
630 | 630 | |
631 | - if ( wpinv_is_discount_valid( $discount_code, $user ) ) { |
|
632 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
633 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
634 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
635 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
636 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
631 | + if (wpinv_is_discount_valid($discount_code, $user)) { |
|
632 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
633 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
634 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
635 | + $total = wpinv_get_cart_total(null, $discounts); |
|
636 | + $cart_totals = wpinv_recalculate_tax(true); |
|
637 | 637 | |
638 | - if ( !empty( $cart_totals ) ) { |
|
638 | + if (!empty($cart_totals)) { |
|
639 | 639 | $response['success'] = true; |
640 | 640 | $response['data'] = $cart_totals; |
641 | 641 | $response['data']['code'] = $discount_code; |
@@ -644,29 +644,29 @@ discard block |
||
644 | 644 | } |
645 | 645 | } else { |
646 | 646 | $errors = wpinv_get_errors(); |
647 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
648 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
647 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
648 | + wpinv_unset_error('wpinv-discount-error'); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | // Allow for custom discount code handling |
652 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
652 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
653 | 653 | } |
654 | 654 | |
655 | - wp_send_json( $response ); |
|
655 | + wp_send_json($response); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | public static function remove_discount() { |
659 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
659 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
660 | 660 | |
661 | 661 | $response = array(); |
662 | 662 | |
663 | - if ( isset( $_POST['code'] ) ) { |
|
664 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
665 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
666 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
667 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
663 | + if (isset($_POST['code'])) { |
|
664 | + $discount_code = sanitize_text_field($_POST['code']); |
|
665 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
666 | + $total = wpinv_get_cart_total(null, $discounts); |
|
667 | + $cart_totals = wpinv_recalculate_tax(true); |
|
668 | 668 | |
669 | - if ( !empty( $cart_totals ) ) { |
|
669 | + if (!empty($cart_totals)) { |
|
670 | 670 | $response['success'] = true; |
671 | 671 | $response['data'] = $cart_totals; |
672 | 672 | $response['data']['code'] = $discount_code; |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | } |
676 | 676 | |
677 | 677 | // Allow for custom discount code handling |
678 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
678 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
679 | 679 | } |
680 | 680 | |
681 | - wp_send_json( $response ); |
|
681 | + wp_send_json($response); |
|
682 | 682 | } |
683 | 683 | } |
684 | 684 |