@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | class WPInv_Item { |
6 | 6 | public $ID = 0; |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | public $filter; |
50 | 50 | |
51 | 51 | |
52 | - public function __construct( $_id = false, $_args = array() ) { |
|
53 | - $item = WP_Post::get_instance( $_id ); |
|
54 | - return $this->setup_item( $item ); |
|
52 | + public function __construct($_id = false, $_args = array()) { |
|
53 | + $item = WP_Post::get_instance($_id); |
|
54 | + return $this->setup_item($item); |
|
55 | 55 | } |
56 | 56 | |
57 | - private function setup_item( $item ) { |
|
58 | - if( ! is_object( $item ) ) { |
|
57 | + private function setup_item($item) { |
|
58 | + if (!is_object($item)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - if( ! is_a( $item, 'WP_Post' ) ) { |
|
62 | + if (!is_a($item, 'WP_Post')) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | - if( 'wpi_item' !== $item->post_type ) { |
|
66 | + if ('wpi_item' !== $item->post_type) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
70 | - foreach ( $item as $key => $value ) { |
|
71 | - switch ( $key ) { |
|
70 | + foreach ($item as $key => $value) { |
|
71 | + switch ($key) { |
|
72 | 72 | default: |
73 | 73 | $this->$key = $value; |
74 | 74 | break; |
@@ -78,38 +78,38 @@ discard block |
||
78 | 78 | return true; |
79 | 79 | } |
80 | 80 | |
81 | - public function __get( $key ) { |
|
82 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
83 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
81 | + public function __get($key) { |
|
82 | + if (method_exists($this, 'get_' . $key)) { |
|
83 | + return call_user_func(array($this, 'get_' . $key)); |
|
84 | 84 | } else { |
85 | - return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
85 | + return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key)); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - public function create( $data = array(), $wp_error = false ) { |
|
90 | - if ( $this->ID != 0 ) { |
|
89 | + public function create($data = array(), $wp_error = false) { |
|
90 | + if ($this->ID != 0) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | 94 | $defaults = array( |
95 | 95 | 'post_type' => 'wpi_item', |
96 | 96 | 'post_status' => 'draft', |
97 | - 'post_title' => __( 'New Invoice Item', 'invoicing' ) |
|
97 | + 'post_title' => __('New Invoice Item', 'invoicing') |
|
98 | 98 | ); |
99 | 99 | |
100 | - $args = wp_parse_args( $data, $defaults ); |
|
100 | + $args = wp_parse_args($data, $defaults); |
|
101 | 101 | |
102 | - do_action( 'wpinv_item_pre_create', $args ); |
|
102 | + do_action('wpinv_item_pre_create', $args); |
|
103 | 103 | |
104 | - $id = wp_insert_post( $args, $wp_error ); |
|
104 | + $id = wp_insert_post($args, $wp_error); |
|
105 | 105 | if ($wp_error && is_wp_error($id)) { |
106 | 106 | return $id; |
107 | 107 | } |
108 | - if ( !$id ) { |
|
108 | + if (!$id) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | - $item = WP_Post::get_instance( $id ); |
|
112 | + $item = WP_Post::get_instance($id); |
|
113 | 113 | |
114 | 114 | if (!empty($item) && !empty($data['meta'])) { |
115 | 115 | $this->ID = $item->ID; |
@@ -117,47 +117,47 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | // Set custom id if not set. |
120 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
121 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
120 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
121 | + $this->save_metas(array('custom_id' => $id)); |
|
122 | 122 | } |
123 | 123 | |
124 | - do_action( 'wpinv_item_create', $id, $args ); |
|
124 | + do_action('wpinv_item_create', $id, $args); |
|
125 | 125 | |
126 | - return $this->setup_item( $item ); |
|
126 | + return $this->setup_item($item); |
|
127 | 127 | } |
128 | 128 | |
129 | - public function update( $data = array(), $wp_error = false ) { |
|
130 | - if ( !$this->ID > 0 ) { |
|
129 | + public function update($data = array(), $wp_error = false) { |
|
130 | + if (!$this->ID > 0) { |
|
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $data['ID'] = $this->ID; |
135 | 135 | |
136 | - do_action( 'wpinv_item_pre_update', $data ); |
|
136 | + do_action('wpinv_item_pre_update', $data); |
|
137 | 137 | |
138 | - $id = wp_update_post( $data, $wp_error ); |
|
138 | + $id = wp_update_post($data, $wp_error); |
|
139 | 139 | if ($wp_error && is_wp_error($id)) { |
140 | 140 | return $id; |
141 | 141 | } |
142 | 142 | |
143 | - if ( !$id ) { |
|
143 | + if (!$id) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - $item = WP_Post::get_instance( $id ); |
|
147 | + $item = WP_Post::get_instance($id); |
|
148 | 148 | if (!empty($item) && !empty($data['meta'])) { |
149 | 149 | $this->ID = $item->ID; |
150 | 150 | $this->save_metas($data['meta']); |
151 | 151 | } |
152 | 152 | |
153 | 153 | // Set custom id if not set. |
154 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
155 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
154 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
155 | + $this->save_metas(array('custom_id' => $id)); |
|
156 | 156 | } |
157 | 157 | |
158 | - do_action( 'wpinv_item_update', $id, $data ); |
|
158 | + do_action('wpinv_item_update', $id, $data); |
|
159 | 159 | |
160 | - return $this->setup_item( $item ); |
|
160 | + return $this->setup_item($item); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function get_ID() { |
@@ -165,111 +165,111 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | public function get_name() { |
168 | - return get_the_title( $this->ID ); |
|
168 | + return get_the_title($this->ID); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | public function get_title() { |
172 | - return get_the_title( $this->ID ); |
|
172 | + return get_the_title($this->ID); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | public function get_status() { |
176 | - return get_post_status( $this->ID ); |
|
176 | + return get_post_status($this->ID); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | public function get_summary() { |
180 | - $post = get_post( $this->ID ); |
|
181 | - return !empty( $post->post_excerpt ) ? $post->post_excerpt : ''; |
|
180 | + $post = get_post($this->ID); |
|
181 | + return !empty($post->post_excerpt) ? $post->post_excerpt : ''; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | public function get_price() { |
185 | - if ( ! isset( $this->price ) ) { |
|
186 | - $this->price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
185 | + if (!isset($this->price)) { |
|
186 | + $this->price = get_post_meta($this->ID, '_wpinv_price', true); |
|
187 | 187 | |
188 | - if ( $this->price ) { |
|
189 | - $this->price = wpinv_sanitize_amount( $this->price ); |
|
188 | + if ($this->price) { |
|
189 | + $this->price = wpinv_sanitize_amount($this->price); |
|
190 | 190 | } else { |
191 | 191 | $this->price = 0; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID ); |
|
195 | + return apply_filters('wpinv_get_item_price', $this->price, $this->ID); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | public function get_vat_rule() { |
199 | 199 | global $wpinv_euvat; |
200 | 200 | |
201 | - if( !isset( $this->vat_rule ) ) { |
|
202 | - $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true ); |
|
201 | + if (!isset($this->vat_rule)) { |
|
202 | + $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true); |
|
203 | 203 | |
204 | - if ( empty( $this->vat_rule ) ) { |
|
204 | + if (empty($this->vat_rule)) { |
|
205 | 205 | $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical'; |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID ); |
|
209 | + return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | public function get_vat_class() { |
213 | - if( !isset( $this->vat_class ) ) { |
|
214 | - $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true ); |
|
213 | + if (!isset($this->vat_class)) { |
|
214 | + $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true); |
|
215 | 215 | |
216 | - if ( empty( $this->vat_class ) ) { |
|
216 | + if (empty($this->vat_class)) { |
|
217 | 217 | $this->vat_class = '_standard'; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID ); |
|
221 | + return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | public function get_type() { |
225 | - if( ! isset( $this->type ) ) { |
|
226 | - $this->type = get_post_meta( $this->ID, '_wpinv_type', true ); |
|
225 | + if (!isset($this->type)) { |
|
226 | + $this->type = get_post_meta($this->ID, '_wpinv_type', true); |
|
227 | 227 | |
228 | - if ( empty( $this->type ) ) { |
|
228 | + if (empty($this->type)) { |
|
229 | 229 | $this->type = 'custom'; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID ); |
|
233 | + return apply_filters('wpinv_get_item_type', $this->type, $this->ID); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | public function get_custom_id() { |
237 | - $custom_id = get_post_meta( $this->ID, '_wpinv_custom_id', true ); |
|
237 | + $custom_id = get_post_meta($this->ID, '_wpinv_custom_id', true); |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_get_item_custom_id', $custom_id, $this->ID ); |
|
239 | + return apply_filters('wpinv_get_item_custom_id', $custom_id, $this->ID); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | public function get_custom_name() { |
243 | - $custom_name = get_post_meta( $this->ID, '_wpinv_custom_name', true ); |
|
243 | + $custom_name = get_post_meta($this->ID, '_wpinv_custom_name', true); |
|
244 | 244 | |
245 | - return apply_filters( 'wpinv_get_item_custom_name', $custom_name, $this->ID ); |
|
245 | + return apply_filters('wpinv_get_item_custom_name', $custom_name, $this->ID); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | public function get_custom_singular_name() { |
249 | - $custom_singular_name = get_post_meta( $this->ID, '_wpinv_custom_singular_name', true ); |
|
249 | + $custom_singular_name = get_post_meta($this->ID, '_wpinv_custom_singular_name', true); |
|
250 | 250 | |
251 | - return apply_filters( 'wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID ); |
|
251 | + return apply_filters('wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | public function get_editable() { |
255 | - $editable = get_post_meta( $this->ID, '_wpinv_editable', true ); |
|
255 | + $editable = get_post_meta($this->ID, '_wpinv_editable', true); |
|
256 | 256 | |
257 | - return apply_filters( 'wpinv_item_get_editable', $editable, $this->ID ); |
|
257 | + return apply_filters('wpinv_item_get_editable', $editable, $this->ID); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | public function get_excerpt() { |
261 | - $excerpt = get_the_excerpt( $this->ID ); |
|
261 | + $excerpt = get_the_excerpt($this->ID); |
|
262 | 262 | |
263 | - return apply_filters( 'wpinv_item_get_excerpt', $excerpt, $this->ID ); |
|
263 | + return apply_filters('wpinv_item_get_excerpt', $excerpt, $this->ID); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | 267 | * Checks whether the item allows a user to set their own price |
268 | 268 | */ |
269 | 269 | public function get_is_dynamic_pricing() { |
270 | - $is_dynamic_pricing = get_post_meta( $this->ID, '_wpinv_dynamic_pricing', true ); |
|
270 | + $is_dynamic_pricing = get_post_meta($this->ID, '_wpinv_dynamic_pricing', true); |
|
271 | 271 | |
272 | - return (int) apply_filters( 'wpinv_item_get_is_dynamic_pricing', $is_dynamic_pricing, $this->ID ); |
|
272 | + return (int)apply_filters('wpinv_item_get_is_dynamic_pricing', $is_dynamic_pricing, $this->ID); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 | |
@@ -279,32 +279,32 @@ discard block |
||
279 | 279 | public function get_minimum_price() { |
280 | 280 | |
281 | 281 | //Fetch the minimum price and cast it to a float |
282 | - $price = (float) get_post_meta( $this->ID, '_minimum_price', true ); |
|
282 | + $price = (float)get_post_meta($this->ID, '_minimum_price', true); |
|
283 | 283 | |
284 | 284 | //Sanitize it |
285 | - $price = wpinv_sanitize_amount( $price ); |
|
285 | + $price = wpinv_sanitize_amount($price); |
|
286 | 286 | |
287 | 287 | //Filter then return it |
288 | - return apply_filters( 'wpinv_item_get_minimum_price', $price, $this->ID ); |
|
288 | + return apply_filters('wpinv_item_get_minimum_price', $price, $this->ID); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
292 | 292 | public function get_is_recurring() { |
293 | - $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true ); |
|
293 | + $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true); |
|
294 | 294 | |
295 | - return apply_filters( 'wpinv_item_get_is_recurring', $is_recurring, $this->ID ); |
|
295 | + return apply_filters('wpinv_item_get_is_recurring', $is_recurring, $this->ID); |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | - public function get_recurring_period( $full = false ) { |
|
300 | - $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true ); |
|
299 | + public function get_recurring_period($full = false) { |
|
300 | + $period = get_post_meta($this->ID, '_wpinv_recurring_period', true); |
|
301 | 301 | |
302 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
302 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
303 | 303 | $period = 'D'; |
304 | 304 | } |
305 | 305 | |
306 | - if ( $full ) { |
|
307 | - switch( $period ) { |
|
306 | + if ($full) { |
|
307 | + switch ($period) { |
|
308 | 308 | case 'D': |
309 | 309 | $period = 'day'; |
310 | 310 | break; |
@@ -320,40 +320,40 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID ); |
|
323 | + return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | public function get_recurring_interval() { |
327 | - $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true ); |
|
327 | + $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true); |
|
328 | 328 | |
329 | - if ( !$interval > 0 ) { |
|
329 | + if (!$interval > 0) { |
|
330 | 330 | $interval = 1; |
331 | 331 | } |
332 | 332 | |
333 | - return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID ); |
|
333 | + return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | public function get_recurring_limit() { |
337 | - $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true ); |
|
337 | + $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true); |
|
338 | 338 | |
339 | - return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID ); |
|
339 | + return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | public function get_free_trial() { |
343 | - $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true ); |
|
343 | + $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true); |
|
344 | 344 | |
345 | - return apply_filters( 'wpinv_item_get_free_trial', $free_trial, $this->ID ); |
|
345 | + return apply_filters('wpinv_item_get_free_trial', $free_trial, $this->ID); |
|
346 | 346 | } |
347 | 347 | |
348 | - public function get_trial_period( $full = false ) { |
|
349 | - $period = get_post_meta( $this->ID, '_wpinv_trial_period', true ); |
|
348 | + public function get_trial_period($full = false) { |
|
349 | + $period = get_post_meta($this->ID, '_wpinv_trial_period', true); |
|
350 | 350 | |
351 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
351 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
352 | 352 | $period = 'D'; |
353 | 353 | } |
354 | 354 | |
355 | - if ( $full ) { |
|
356 | - switch( $period ) { |
|
355 | + if ($full) { |
|
356 | + switch ($period) { |
|
357 | 357 | case 'D': |
358 | 358 | $period = 'day'; |
359 | 359 | break; |
@@ -369,47 +369,47 @@ discard block |
||
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID ); |
|
372 | + return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | public function get_trial_interval() { |
376 | - $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) ); |
|
376 | + $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true)); |
|
377 | 377 | |
378 | - if ( !$interval > 0 ) { |
|
378 | + if (!$interval > 0) { |
|
379 | 379 | $interval = 1; |
380 | 380 | } |
381 | 381 | |
382 | - return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID ); |
|
382 | + return apply_filters('wpinv_item_trial_interval', $interval, $this->ID); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function get_the_price() { |
386 | - $item_price = wpinv_price( wpinv_format_amount( $this->get_price() ) ); |
|
386 | + $item_price = wpinv_price(wpinv_format_amount($this->get_price())); |
|
387 | 387 | |
388 | - return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID ); |
|
388 | + return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | public function is_recurring() { |
392 | 392 | $is_recurring = $this->get_is_recurring(); |
393 | 393 | |
394 | - return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID ); |
|
394 | + return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | public function has_free_trial() { |
398 | 398 | $free_trial = $this->is_recurring() && $this->get_free_trial() ? true : false; |
399 | 399 | |
400 | - return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID ); |
|
400 | + return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | public function is_free() { |
404 | 404 | $is_free = false; |
405 | 405 | |
406 | - $price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
406 | + $price = get_post_meta($this->ID, '_wpinv_price', true); |
|
407 | 407 | |
408 | - if ( (float)$price == 0 ) { |
|
408 | + if ((float)$price == 0) { |
|
409 | 409 | $is_free = true; |
410 | 410 | } |
411 | 411 | |
412 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID ); |
|
412 | + return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | |
419 | 419 | $is_editable = $editable === 0 || $editable === '0' ? false : true; |
420 | 420 | |
421 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID ); |
|
421 | + return (bool)apply_filters('wpinv_item_is_editable', $is_editable, $this->ID); |
|
422 | 422 | } |
423 | 423 | |
424 | - public function save_metas( $metas = array() ) { |
|
425 | - if ( empty( $metas ) ) { |
|
424 | + public function save_metas($metas = array()) { |
|
425 | + if (empty($metas)) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | |
429 | - foreach ( $metas as $meta_key => $meta_value ) { |
|
429 | + foreach ($metas as $meta_key => $meta_value) { |
|
430 | 430 | $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key; |
431 | 431 | |
432 | 432 | $this->update_meta($meta_key, $meta_value); |
@@ -435,73 +435,73 @@ discard block |
||
435 | 435 | return true; |
436 | 436 | } |
437 | 437 | |
438 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
439 | - if ( empty( $meta_key ) ) { |
|
438 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
439 | + if (empty($meta_key)) { |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 | |
443 | - $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID ); |
|
443 | + $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID); |
|
444 | 444 | |
445 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
445 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
446 | 446 | } |
447 | 447 | |
448 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
448 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
449 | 449 | global $wpi_session; |
450 | 450 | |
451 | - $fees = $wpi_session->get( 'wpi_cart_fees' ); |
|
451 | + $fees = $wpi_session->get('wpi_cart_fees'); |
|
452 | 452 | |
453 | - if ( ! wpinv_get_cart_contents() ) { |
|
453 | + if (!wpinv_get_cart_contents()) { |
|
454 | 454 | // We can only get item type fees when the cart is empty |
455 | 455 | $type = 'custom'; |
456 | 456 | } |
457 | 457 | |
458 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
459 | - foreach( $fees as $key => $fee ) { |
|
460 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
461 | - unset( $fees[ $key ] ); |
|
458 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
459 | + foreach ($fees as $key => $fee) { |
|
460 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
461 | + unset($fees[$key]); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
466 | + if (!empty($fees) && !empty($item_id)) { |
|
467 | 467 | // Remove fees that don't belong to the specified Item |
468 | - foreach ( $fees as $key => $fee ) { |
|
469 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
470 | - unset( $fees[ $key ] ); |
|
468 | + foreach ($fees as $key => $fee) { |
|
469 | + if ((int)$item_id !== (int)$fee['custom_id']) { |
|
470 | + unset($fees[$key]); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | - if ( ! empty( $fees ) ) { |
|
475 | + if (!empty($fees)) { |
|
476 | 476 | // Remove fees that belong to a specific item but are not in the cart |
477 | - foreach( $fees as $key => $fee ) { |
|
478 | - if( empty( $fee['custom_id'] ) ) { |
|
477 | + foreach ($fees as $key => $fee) { |
|
478 | + if (empty($fee['custom_id'])) { |
|
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | |
482 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
483 | - unset( $fees[ $key ] ); |
|
482 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
483 | + unset($fees[$key]); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | - return ! empty( $fees ) ? $fees : array(); |
|
488 | + return !empty($fees) ? $fees : array(); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | public function can_purchase() { |
492 | 492 | $can_purchase = true; |
493 | 493 | |
494 | - if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
494 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
495 | 495 | $can_purchase = false; |
496 | 496 | } |
497 | 497 | |
498 | - return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
498 | + return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Checks whether this item supports dynamic pricing or not |
503 | 503 | */ |
504 | 504 | public function supports_dynamic_pricing() { |
505 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
505 | + return (bool)apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
506 | 506 | } |
507 | 507 | } |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -74,45 +74,45 @@ discard block |
||
74 | 74 | <td class="id"> |
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
77 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,90 +183,90 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | 192 | 'class' => 'wpi_select2', |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | ?> |
195 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
196 | 196 | <?php } ?> |
197 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
198 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
197 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
198 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
199 | 199 | </div> |
200 | 200 | </div> |
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | |
204 | - public static function prices( $post ) { |
|
204 | + public static function prices($post) { |
|
205 | 205 | $symbol = wpinv_currency_symbol(); |
206 | 206 | $position = wpinv_currency_position(); |
207 | - $item = new WPInv_Item( $post->ID ); |
|
207 | + $item = new WPInv_Item($post->ID); |
|
208 | 208 | |
209 | 209 | $price = $item->get_price(); |
210 | 210 | $is_dynamic_pricing = $item->get_is_dynamic_pricing(); |
211 | 211 | $minimum_price = $item->get_minimum_price(); |
212 | 212 | $is_recurring = $item->is_recurring(); |
213 | 213 | $period = $item->get_recurring_period(); |
214 | - $interval = absint( $item->get_recurring_interval() ); |
|
215 | - $times = absint( $item->get_recurring_limit() ); |
|
214 | + $interval = absint($item->get_recurring_interval()); |
|
215 | + $times = absint($item->get_recurring_limit()); |
|
216 | 216 | $free_trial = $item->has_free_trial(); |
217 | 217 | $trial_interval = $item->get_trial_interval(); |
218 | 218 | $trial_period = $item->get_trial_period(); |
219 | 219 | |
220 | 220 | $intervals = array(); |
221 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
221 | + for ($i = 1; $i <= 90; $i++) { |
|
222 | 222 | $intervals[$i] = $i; |
223 | 223 | } |
224 | 224 | |
225 | - $interval = $interval > 0 ? $interval : 1; |
|
225 | + $interval = $interval > 0 ? $interval : 1; |
|
226 | 226 | |
227 | 227 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
228 | 228 | |
229 | 229 | $minimum_price_style = 'margin-left: 24px;'; |
230 | - if(! $is_dynamic_pricing ) { |
|
230 | + if (!$is_dynamic_pricing) { |
|
231 | 231 | $minimum_price_style .= 'display: none;'; |
232 | 232 | } |
233 | 233 | |
234 | 234 | ?> |
235 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
236 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
235 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
236 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
237 | 237 | </p> |
238 | 238 | |
239 | - <?php if( $item->supports_dynamic_pricing() ) { ?> |
|
239 | + <?php if ($item->supports_dynamic_pricing()) { ?> |
|
240 | 240 | |
241 | 241 | <p class="wpinv-row-name-your-price"> |
242 | 242 | <label> |
243 | - <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> /> |
|
244 | - <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?> |
|
243 | + <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> /> |
|
244 | + <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?> |
|
245 | 245 | </label> |
246 | - <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?> |
|
246 | + <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?> |
|
247 | 247 | </p> |
248 | 248 | |
249 | 249 | <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>"> |
250 | 250 | <label> |
251 | - <?php _e( 'Minimum Price', 'invoicing' ); ?> |
|
252 | - <?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?> |
|
251 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
252 | + <?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?> |
|
253 | 253 | </label> |
254 | 254 | |
255 | - <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?> |
|
255 | + <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?> |
|
256 | 256 | </p> |
257 | 257 | |
258 | 258 | <?php } ?> |
259 | 259 | |
260 | 260 | <p class="wpinv-row-is-recurring"> |
261 | 261 | <label for="wpinv_is_recurring"> |
262 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
263 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
262 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
263 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
264 | 264 | </label> |
265 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
265 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
266 | 266 | </p> |
267 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
268 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
269 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
267 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
268 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
269 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
270 | 270 | 'options' => $intervals, |
271 | 271 | 'name' => 'wpinv_recurring_interval', |
272 | 272 | 'id' => 'wpinv_recurring_interval', |
@@ -274,30 +274,30 @@ discard block |
||
274 | 274 | 'show_option_all' => false, |
275 | 275 | 'show_option_none' => false, |
276 | 276 | 'class' => 'wpi_select2', |
277 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
278 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
277 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
278 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
279 | 279 | <span class="clear wpi-trial-clr"></span> |
280 | 280 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
281 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
282 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
281 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
282 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
283 | 283 | </label> |
284 | 284 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
285 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
285 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
286 | 286 | </label> |
287 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
287 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
288 | 288 | </p> |
289 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
290 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
289 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
290 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
291 | 291 | <?php |
292 | 292 | } |
293 | 293 | |
294 | - public static function vat_rules( $post ) { |
|
294 | + public static function vat_rules($post) { |
|
295 | 295 | global $wpinv_euvat; |
296 | 296 | |
297 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
297 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
298 | 298 | ?> |
299 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
300 | - <?php echo wpinv_html_select( array( |
|
299 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
300 | + <?php echo wpinv_html_select(array( |
|
301 | 301 | 'options' => $wpinv_euvat->get_rules(), |
302 | 302 | 'name' => 'wpinv_vat_rules', |
303 | 303 | 'id' => 'wpinv_vat_rules', |
@@ -305,19 +305,19 @@ discard block |
||
305 | 305 | 'show_option_all' => false, |
306 | 306 | 'show_option_none' => false, |
307 | 307 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2', |
308 | - ) ); ?> |
|
308 | + )); ?> |
|
309 | 309 | </p> |
310 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
311 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
310 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
311 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
312 | 312 | <?php |
313 | 313 | } |
314 | 314 | |
315 | - public static function vat_classes( $post ) { |
|
315 | + public static function vat_classes($post) { |
|
316 | 316 | global $wpinv_euvat; |
317 | 317 | |
318 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
318 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
319 | 319 | ?> |
320 | - <p><?php echo wpinv_html_select( array( |
|
320 | + <p><?php echo wpinv_html_select(array( |
|
321 | 321 | 'options' => $wpinv_euvat->get_all_classes(), |
322 | 322 | 'name' => 'wpinv_vat_class', |
323 | 323 | 'id' => 'wpinv_vat_class', |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false, |
327 | 327 | 'class' => 'gdmbx2-text-medium wpinv-vat-class wpi_select2', |
328 | - ) ); ?> |
|
328 | + )); ?> |
|
329 | 329 | </p> |
330 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
330 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
331 | 331 | <?php |
332 | 332 | } |
333 | 333 | |
334 | - public static function item_info( $post ) { |
|
335 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
336 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
334 | + public static function item_info($post) { |
|
335 | + $item_type = wpinv_get_item_type($post->ID); |
|
336 | + do_action('wpinv_item_info_metabox_before', $post); |
|
337 | 337 | ?> |
338 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
339 | - <?php echo wpinv_html_select( array( |
|
338 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
339 | + <?php echo wpinv_html_select(array( |
|
340 | 340 | 'options' => wpinv_get_item_types(), |
341 | 341 | 'name' => 'wpinv_item_type', |
342 | 342 | 'id' => 'wpinv_item_type', |
@@ -344,114 +344,114 @@ discard block |
||
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false, |
346 | 346 | 'class' => 'gdmbx2-text-medium wpinv-item-type wpi_select2', |
347 | - ) ); ?> |
|
347 | + )); ?> |
|
348 | 348 | </p> |
349 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
349 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
350 | 350 | <?php |
351 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
351 | + do_action('wpinv_item_info_metabox_after', $post); |
|
352 | 352 | } |
353 | 353 | |
354 | - public static function meta_values( $post ) { |
|
355 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
354 | + public static function meta_values($post) { |
|
355 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
356 | 356 | 'type', |
357 | 357 | 'custom_id' |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - if ( empty( $meta_keys ) ) { |
|
360 | + if (empty($meta_keys)) { |
|
361 | 361 | return; |
362 | 362 | } |
363 | 363 | |
364 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
364 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
365 | 365 | |
366 | - foreach ( $meta_keys as $meta_key ) { |
|
366 | + foreach ($meta_keys as $meta_key) { |
|
367 | 367 | ?> |
368 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
368 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
369 | 369 | <?php |
370 | 370 | } |
371 | 371 | |
372 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
372 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
373 | 373 | } |
374 | 374 | |
375 | - public static function save( $post_id, $data, $post ) { |
|
376 | - $invoice = new WPInv_Invoice( $post_id ); |
|
375 | + public static function save($post_id, $data, $post) { |
|
376 | + $invoice = new WPInv_Invoice($post_id); |
|
377 | 377 | |
378 | 378 | // Billing |
379 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
380 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
381 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
382 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
383 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
384 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
385 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
386 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
387 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
388 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
379 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
380 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
381 | + $company = sanitize_text_field($data['wpinv_company']); |
|
382 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
383 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
384 | + $address = sanitize_text_field($data['wpinv_address']); |
|
385 | + $city = sanitize_text_field($data['wpinv_city']); |
|
386 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
387 | + $country = sanitize_text_field($data['wpinv_country']); |
|
388 | + $state = sanitize_text_field($data['wpinv_state']); |
|
389 | 389 | |
390 | 390 | // Details |
391 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
392 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
393 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
394 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
391 | + $status = sanitize_text_field($data['wpinv_status']); |
|
392 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
393 | + $number = sanitize_text_field($data['wpinv_number']); |
|
394 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
395 | 395 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
396 | 396 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
397 | 397 | |
398 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
399 | - |
|
400 | - $invoice->set( 'due_date', $due_date ); |
|
401 | - $invoice->set( 'first_name', $first_name ); |
|
402 | - $invoice->set( 'last_name', $last_name ); |
|
403 | - $invoice->set( 'company', $company ); |
|
404 | - $invoice->set( 'vat_number', $vat_number ); |
|
405 | - $invoice->set( 'phone', $phone ); |
|
406 | - $invoice->set( 'address', $address ); |
|
407 | - $invoice->set( 'city', $city ); |
|
408 | - $invoice->set( 'zip', $zip ); |
|
409 | - $invoice->set( 'country', $country ); |
|
410 | - $invoice->set( 'state', $state ); |
|
411 | - $invoice->set( 'status', $status ); |
|
398 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
399 | + |
|
400 | + $invoice->set('due_date', $due_date); |
|
401 | + $invoice->set('first_name', $first_name); |
|
402 | + $invoice->set('last_name', $last_name); |
|
403 | + $invoice->set('company', $company); |
|
404 | + $invoice->set('vat_number', $vat_number); |
|
405 | + $invoice->set('phone', $phone); |
|
406 | + $invoice->set('address', $address); |
|
407 | + $invoice->set('city', $city); |
|
408 | + $invoice->set('zip', $zip); |
|
409 | + $invoice->set('country', $country); |
|
410 | + $invoice->set('state', $state); |
|
411 | + $invoice->set('status', $status); |
|
412 | 412 | //$invoice->set( 'number', $number ); |
413 | 413 | //$invoice->set( 'discounts', $discounts ); |
414 | 414 | //$invoice->set( 'discount', $discount ); |
415 | - $invoice->set( 'ip', $ip ); |
|
415 | + $invoice->set('ip', $ip); |
|
416 | 416 | $invoice->old_status = $_POST['original_post_status']; |
417 | 417 | $invoice->currency = wpinv_get_currency(); |
418 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
419 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
418 | + if (!empty($data['wpinv_gateway'])) { |
|
419 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
420 | 420 | } |
421 | 421 | $saved = $invoice->save(); |
422 | 422 | |
423 | 423 | // Check for payment notes |
424 | - if ( !empty( $data['invoice_note'] ) ) { |
|
425 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
426 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
424 | + if (!empty($data['invoice_note'])) { |
|
425 | + $note = wp_kses($data['invoice_note'], array()); |
|
426 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
427 | 427 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
428 | 428 | |
429 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
429 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Update user address if empty. |
433 | - if ( $saved && !empty( $invoice ) ) { |
|
434 | - if ( $user_id = $invoice->get_user_id() ) { |
|
435 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
433 | + if ($saved && !empty($invoice)) { |
|
434 | + if ($user_id = $invoice->get_user_id()) { |
|
435 | + $user_address = wpinv_get_user_address($user_id, false); |
|
436 | 436 | |
437 | 437 | if (empty($user_address['first_name'])) { |
438 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
439 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
438 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
439 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
440 | 440 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
441 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
441 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
445 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
446 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
447 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
448 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
449 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
450 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
445 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
446 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
447 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
448 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
449 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
450 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
454 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | return $saved; |
@@ -1,67 +1,67 @@ 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_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | |
32 | 32 | remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
33 | 33 | } |
34 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
34 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
35 | 35 | |
36 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
37 | - remove_action( 'save_post', __FUNCTION__ ); |
|
36 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
37 | + remove_action('save_post', __FUNCTION__); |
|
38 | 38 | |
39 | 39 | // $post_id and $post are required |
40 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
40 | + if (empty($post_id) || empty($post)) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
44 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // Dont' save meta boxes for revisions or autosaves |
49 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
49 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
53 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
54 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
53 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
54 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
59 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
58 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
59 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
60 | 60 | } |
61 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
61 | + } else if ($post->post_type == 'wpi_item') { |
|
62 | 62 | // verify nonce |
63 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
64 | - $fields = array(); |
|
63 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
64 | + $fields = array(); |
|
65 | 65 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
66 | 66 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
67 | 67 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -76,96 +76,96 @@ discard block |
||
76 | 76 | $fields['_wpinv_dynamic_pricing'] = 'wpinv_name_your_price'; |
77 | 77 | $fields['_minimum_price'] = 'wpinv_minimum_price'; |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_is_recurring'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - if ( !isset( $_POST['wpinv_name_your_price'] ) ) { |
|
83 | + if (!isset($_POST['wpinv_name_your_price'])) { |
|
84 | 84 | $_POST['wpinv_name_your_price'] = 0; |
85 | 85 | } |
86 | 86 | |
87 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
87 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
88 | 88 | $_POST['wpinv_free_trial'] = 0; |
89 | 89 | } |
90 | 90 | |
91 | - foreach ( $fields as $field => $name ) { |
|
92 | - if ( isset( $_POST[ $name ] ) ) { |
|
93 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
91 | + foreach ($fields as $field => $name) { |
|
92 | + if (isset($_POST[$name])) { |
|
93 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
94 | 94 | |
95 | - if ( !$allowed ) { |
|
95 | + if (!$allowed) { |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if ( $field == '_wpinv_price' ) { |
|
100 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
99 | + if ($field == '_wpinv_price') { |
|
100 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
101 | 101 | } else { |
102 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
102 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
103 | 103 | } |
104 | 104 | |
105 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
106 | - update_post_meta( $post_id, $field, $value ); |
|
105 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
106 | + update_post_meta($post_id, $field, $value); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
111 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
110 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
111 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
116 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
117 | 117 | |
118 | 118 | function wpinv_register_item_meta_boxes() { |
119 | 119 | global $wpinv_euvat; |
120 | 120 | |
121 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
121 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
122 | 122 | |
123 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
124 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
123 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
124 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
128 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
127 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
128 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
132 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
131 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
132 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | function wpinv_register_discount_meta_boxes() { |
136 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
136 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_discount_metabox_details( $post ) { |
|
139 | +function wpinv_discount_metabox_details($post) { |
|
140 | 140 | $discount_id = $post->ID; |
141 | - $discount = wpinv_get_discount( $discount_id ); |
|
141 | + $discount = wpinv_get_discount($discount_id); |
|
142 | 142 | |
143 | - $type = wpinv_get_discount_type( $discount_id ); |
|
144 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
145 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
146 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
147 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
148 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
149 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
150 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
151 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
152 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
143 | + $type = wpinv_get_discount_type($discount_id); |
|
144 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
145 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
146 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
147 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
148 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
149 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
150 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
151 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
152 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
153 | 153 | |
154 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
155 | - $start_time = strtotime( $start_date ); |
|
156 | - $start_h = date_i18n( 'H', $start_time ); |
|
157 | - $start_m = date_i18n( 'i', $start_time ); |
|
158 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
154 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
155 | + $start_time = strtotime($start_date); |
|
156 | + $start_h = date_i18n('H', $start_time); |
|
157 | + $start_m = date_i18n('i', $start_time); |
|
158 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
159 | 159 | } else { |
160 | 160 | $start_h = '00'; |
161 | 161 | $start_m = '00'; |
162 | 162 | } |
163 | 163 | |
164 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
165 | - $expiration_time = strtotime( $expiration_date ); |
|
166 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
167 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
168 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
164 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
165 | + $expiration_time = strtotime($expiration_date); |
|
166 | + $expiration_h = date_i18n('H', $expiration_time); |
|
167 | + $expiration_m = date_i18n('i', $expiration_time); |
|
168 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
169 | 169 | } else { |
170 | 170 | $expiration_h = '23'; |
171 | 171 | $expiration_m = '59'; |
@@ -175,207 +175,207 @@ discard block |
||
175 | 175 | $max_total = $max_total > 0 ? $max_total : ''; |
176 | 176 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
177 | 177 | ?> |
178 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
179 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
178 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
179 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
180 | 180 | <table class="form-table wpi-form-table"> |
181 | 181 | <tbody> |
182 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
183 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
182 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
183 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
184 | 184 | <tr> |
185 | 185 | <th valign="top" scope="row"> |
186 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
186 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
187 | 187 | </th> |
188 | 188 | <td> |
189 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
190 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
189 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
190 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
191 | 191 | </td> |
192 | 192 | </tr> |
193 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
193 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
194 | 194 | <tr> |
195 | 195 | <th valign="top" scope="row"> |
196 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
196 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
197 | 197 | </th> |
198 | 198 | <td> |
199 | 199 | <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2"> |
200 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
201 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
200 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
201 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
202 | 202 | <?php } ?> |
203 | 203 | </select> |
204 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
204 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
205 | 205 | </td> |
206 | 206 | </tr> |
207 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
207 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
208 | 208 | <tr> |
209 | 209 | <th valign="top" scope="row"> |
210 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
210 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
211 | 211 | </th> |
212 | 212 | <td> |
213 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
214 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
215 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
213 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
214 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
215 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
216 | 216 | </td> |
217 | 217 | </tr> |
218 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
218 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
219 | 219 | <tr> |
220 | 220 | <th valign="top" scope="row"> |
221 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
221 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
222 | 222 | </th> |
223 | 223 | <td> |
224 | - <p><?php echo wpinv_item_dropdown( array( |
|
224 | + <p><?php echo wpinv_item_dropdown(array( |
|
225 | 225 | 'name' => 'items[]', |
226 | 226 | 'id' => 'items', |
227 | 227 | 'selected' => $item_reqs, |
228 | 228 | 'multiple' => true, |
229 | 229 | 'class' => 'medium-text wpi_select2', |
230 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
230 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
231 | 231 | 'show_recurring' => true, |
232 | - ) ); ?> |
|
232 | + )); ?> |
|
233 | 233 | </p> |
234 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
234 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
235 | 235 | </td> |
236 | 236 | </tr> |
237 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
237 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
238 | 238 | <tr> |
239 | 239 | <th valign="top" scope="row"> |
240 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
240 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
241 | 241 | </th> |
242 | 242 | <td> |
243 | - <p><?php echo wpinv_item_dropdown( array( |
|
243 | + <p><?php echo wpinv_item_dropdown(array( |
|
244 | 244 | 'name' => 'excluded_items[]', |
245 | 245 | 'id' => 'excluded_items', |
246 | 246 | 'selected' => $excluded_items, |
247 | 247 | 'multiple' => true, |
248 | 248 | 'class' => 'medium-text wpi_select2', |
249 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
249 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
250 | 250 | 'show_recurring' => true, |
251 | - ) ); ?> |
|
251 | + )); ?> |
|
252 | 252 | </p> |
253 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
253 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
254 | 254 | </td> |
255 | 255 | </tr> |
256 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
256 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
257 | 257 | <tr> |
258 | 258 | <th valign="top" scope="row"> |
259 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
259 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
260 | 260 | </th> |
261 | 261 | <td> |
262 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
263 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
264 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
262 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
263 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
264 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
265 | 265 | <?php } ?> |
266 | 266 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
267 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
268 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
267 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
268 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
269 | 269 | <?php } ?> |
270 | 270 | </select> |
271 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
271 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
272 | 272 | </td> |
273 | 273 | </tr> |
274 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
274 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
275 | 275 | <tr> |
276 | 276 | <th valign="top" scope="row"> |
277 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
277 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
278 | 278 | </th> |
279 | 279 | <td> |
280 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
281 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
282 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
280 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
281 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
282 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
283 | 283 | <?php } ?> |
284 | 284 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
285 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
286 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
285 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
286 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
287 | 287 | <?php } ?> |
288 | 288 | </select> |
289 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
289 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
290 | 290 | </td> |
291 | 291 | </tr> |
292 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
292 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
293 | 293 | <tr> |
294 | 294 | <th valign="top" scope="row"> |
295 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
295 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
296 | 296 | </th> |
297 | 297 | <td> |
298 | 298 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
299 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
299 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
300 | 300 | </td> |
301 | 301 | </tr> |
302 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
302 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
303 | 303 | <tr> |
304 | 304 | <th valign="top" scope="row"> |
305 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
305 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
306 | 306 | </th> |
307 | 307 | <td> |
308 | 308 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
309 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
309 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
310 | 310 | </td> |
311 | 311 | </tr> |
312 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
312 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
313 | 313 | <tr> |
314 | 314 | <th valign="top" scope="row"> |
315 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
315 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
316 | 316 | </th> |
317 | 317 | <td> |
318 | 318 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2"> |
319 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
320 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
319 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
320 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
321 | 321 | </select> |
322 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
322 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
323 | 323 | </td> |
324 | 324 | </tr> |
325 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
325 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
326 | 326 | <tr> |
327 | 327 | <th valign="top" scope="row"> |
328 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
328 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
329 | 329 | </th> |
330 | 330 | <td> |
331 | 331 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
332 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
332 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
333 | 333 | </td> |
334 | 334 | </tr> |
335 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
335 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
336 | 336 | <tr> |
337 | 337 | <th valign="top" scope="row"> |
338 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
338 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
339 | 339 | </th> |
340 | 340 | <td> |
341 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
342 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
341 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
342 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
343 | 343 | </td> |
344 | 344 | </tr> |
345 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
345 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
346 | 346 | </tbody> |
347 | 347 | </table> |
348 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
348 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
349 | 349 | <?php |
350 | 350 | } |
351 | 351 | |
352 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
353 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
352 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
353 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
354 | 354 | |
355 | - if ( $post_type != 'wpi_discount' ) { |
|
355 | + if ($post_type != 'wpi_discount') { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
359 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
363 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
364 | 364 | return; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
367 | + if (!current_user_can('manage_options', $post_id)) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
371 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
372 | 372 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
373 | 373 | } |
374 | 374 | |
375 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
375 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
376 | 376 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
377 | 377 | } |
378 | 378 | |
379 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
379 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
380 | 380 | } |
381 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
382 | 381 | \ No newline at end of file |
382 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
383 | 383 | \ No newline at end of file |
@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
7 | +function wpinv_get_option($key = '', $default = false) { |
|
8 | 8 | global $wpinv_options; |
9 | 9 | |
10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
12 | 12 | |
13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
14 | 14 | } |
15 | 15 | |
16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
16 | +function wpinv_update_option($key = '', $value = false) { |
|
17 | 17 | // If no key, exit |
18 | - if ( empty( $key ) ) { |
|
18 | + if (empty($key)) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | - if ( empty( $value ) ) { |
|
23 | - $remove_option = wpinv_delete_option( $key ); |
|
22 | + if (empty($value)) { |
|
23 | + $remove_option = wpinv_delete_option($key); |
|
24 | 24 | return $remove_option; |
25 | 25 | } |
26 | 26 | |
27 | 27 | // First let's grab the current settings |
28 | - $options = get_option( 'wpinv_settings' ); |
|
28 | + $options = get_option('wpinv_settings'); |
|
29 | 29 | |
30 | 30 | // Let other plugin alter the value |
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's 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, $email_settings, $tax_settings, $misc_settings, $tool_settings ); |
|
83 | + $settings = array_merge($general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_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,41 +111,41 @@ 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 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
141 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
142 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
143 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
144 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
145 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
146 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
147 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
148 | - '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 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
141 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
142 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
143 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
144 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
145 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
146 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
147 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
148 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
@@ -153,203 +153,203 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | // Creates our settings in the options table |
156 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
156 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
157 | 157 | } |
158 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
158 | +add_action('admin_init', 'wpinv_register_settings'); |
|
159 | 159 | |
160 | 160 | function wpinv_get_registered_settings() { |
161 | - $pages = wpinv_get_pages( true ); |
|
161 | + $pages = wpinv_get_pages(true); |
|
162 | 162 | |
163 | 163 | $currencies = wpinv_get_currencies(); |
164 | 164 | |
165 | 165 | $currency_code_options = array(); |
166 | - foreach ( $currencies as $code => $name ) { |
|
167 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
166 | + foreach ($currencies as $code => $name) { |
|
167 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $due_payment_options = array(); |
171 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
172 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
171 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
172 | + for ($i = 1; $i <= 30; $i++) { |
|
173 | 173 | $due_payment_options[$i] = $i; |
174 | 174 | } |
175 | 175 | |
176 | 176 | $invoice_number_padd_options = array(); |
177 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
177 | + for ($i = 0; $i <= 20; $i++) { |
|
178 | 178 | $invoice_number_padd_options[$i] = $i; |
179 | 179 | } |
180 | 180 | |
181 | 181 | $currency_symbol = wpinv_currency_symbol(); |
182 | 182 | |
183 | 183 | $last_number = $reset_number = ''; |
184 | - if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
185 | - $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number ); |
|
184 | + if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
185 | + $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number); |
|
186 | 186 | |
187 | - if ( !empty( $last_invoice_number ) ) { |
|
188 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
187 | + if (!empty($last_invoice_number)) { |
|
188 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $nonce = wp_create_nonce('reset_invoice_count'); |
192 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
192 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $alert_wrapper_start = '<p style="color: #F00">'; |
196 | 196 | $alert_wrapper_close = '</p>'; |
197 | 197 | $wpinv_settings = array( |
198 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
198 | + 'general' => apply_filters('wpinv_settings_general', |
|
199 | 199 | array( |
200 | 200 | 'main' => array( |
201 | 201 | 'location_settings' => array( |
202 | 202 | 'id' => 'location_settings', |
203 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
203 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
204 | 204 | 'desc' => '', |
205 | 205 | 'type' => 'header', |
206 | 206 | ), |
207 | 207 | 'default_country' => array( |
208 | 208 | 'id' => 'default_country', |
209 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
210 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
209 | + 'name' => __('Default Country', 'invoicing'), |
|
210 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
211 | 211 | 'type' => 'select', |
212 | 212 | 'options' => wpinv_get_country_list(), |
213 | 213 | 'std' => 'GB', |
214 | 214 | 'class' => 'wpi_select2', |
215 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
215 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
216 | 216 | ), |
217 | 217 | 'default_state' => array( |
218 | 218 | 'id' => 'default_state', |
219 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
220 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
219 | + 'name' => __('Default State / Province', 'invoicing'), |
|
220 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
221 | 221 | 'type' => 'country_states', |
222 | 222 | 'class' => 'wpi_select2', |
223 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
223 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
224 | 224 | ), |
225 | 225 | 'store_name' => array( |
226 | 226 | 'id' => 'store_name', |
227 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
228 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
227 | + 'name' => __('Store Name', 'invoicing'), |
|
228 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
229 | 229 | 'std' => get_option('blogname'), |
230 | 230 | 'type' => 'text', |
231 | 231 | ), |
232 | 232 | 'logo' => array( |
233 | 233 | 'id' => 'logo', |
234 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
235 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
234 | + 'name' => __('Logo URL', 'invoicing'), |
|
235 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
236 | 236 | 'type' => 'text', |
237 | 237 | ), |
238 | 238 | 'store_address' => array( |
239 | 239 | 'id' => 'store_address', |
240 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
241 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
240 | + 'name' => __('Store Address', 'invoicing'), |
|
241 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
242 | 242 | 'type' => 'textarea', |
243 | 243 | ), |
244 | 244 | 'page_settings' => array( |
245 | 245 | 'id' => 'page_settings', |
246 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
246 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
247 | 247 | 'desc' => '', |
248 | 248 | 'type' => 'header', |
249 | 249 | ), |
250 | 250 | 'checkout_page' => array( |
251 | 251 | 'id' => 'checkout_page', |
252 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
253 | - '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' ), |
|
252 | + 'name' => __('Checkout Page', 'invoicing'), |
|
253 | + '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'), |
|
254 | 254 | 'type' => 'select', |
255 | 255 | 'options' => $pages, |
256 | 256 | 'class' => 'wpi_select2', |
257 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
257 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
258 | 258 | ), |
259 | 259 | 'tandc_page' => array( |
260 | 260 | 'id' => 'tandc_page', |
261 | - 'name' => __( 'Terms & Conditions', 'invoicing' ), |
|
262 | - 'desc' => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ), |
|
261 | + 'name' => __('Terms & Conditions', 'invoicing'), |
|
262 | + 'desc' => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'), |
|
263 | 263 | 'type' => 'select', |
264 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
264 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
265 | 265 | 'class' => 'wpi_select2', |
266 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
266 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
267 | 267 | ), |
268 | 268 | 'success_page' => array( |
269 | 269 | 'id' => 'success_page', |
270 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
271 | - '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' ), |
|
270 | + 'name' => __('Success Page', 'invoicing'), |
|
271 | + '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'), |
|
272 | 272 | 'type' => 'select', |
273 | 273 | 'options' => $pages, |
274 | 274 | 'class' => 'wpi_select2', |
275 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
275 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
276 | 276 | ), |
277 | 277 | 'failure_page' => array( |
278 | 278 | 'id' => 'failure_page', |
279 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
280 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
279 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
280 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
281 | 281 | 'type' => 'select', |
282 | 282 | 'options' => $pages, |
283 | 283 | 'class' => 'wpi_select2', |
284 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
284 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
285 | 285 | ), |
286 | 286 | 'invoice_history_page' => array( |
287 | 287 | 'id' => 'invoice_history_page', |
288 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
289 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
288 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
289 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
290 | 290 | 'type' => 'select', |
291 | 291 | 'options' => $pages, |
292 | 292 | 'class' => 'wpi_select2', |
293 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
293 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
294 | 294 | ), |
295 | 295 | 'invoice_subscription_page' => array( |
296 | 296 | 'id' => 'invoice_subscription_page', |
297 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
298 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
297 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
298 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
299 | 299 | 'type' => 'select', |
300 | 300 | 'options' => $pages, |
301 | 301 | 'class' => 'wpi_select2', |
302 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
302 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
303 | 303 | ), |
304 | 304 | ), |
305 | 305 | 'currency_section' => array( |
306 | 306 | 'currency_settings' => array( |
307 | 307 | 'id' => 'currency_settings', |
308 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
308 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
309 | 309 | 'desc' => '', |
310 | 310 | 'type' => 'header', |
311 | 311 | ), |
312 | 312 | 'currency' => array( |
313 | 313 | 'id' => 'currency', |
314 | - 'name' => __( 'Currency', 'invoicing' ), |
|
315 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
314 | + 'name' => __('Currency', 'invoicing'), |
|
315 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
316 | 316 | 'type' => 'select', |
317 | 317 | 'class' => 'wpi_select2', |
318 | 318 | 'options' => $currency_code_options, |
319 | 319 | ), |
320 | 320 | 'currency_position' => array( |
321 | 321 | 'id' => 'currency_position', |
322 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
323 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
322 | + 'name' => __('Currency Position', 'invoicing'), |
|
323 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
324 | 324 | 'type' => 'select', |
325 | 325 | 'class' => 'wpi_select2', |
326 | 326 | 'options' => array( |
327 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
328 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
329 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
330 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
327 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
328 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
329 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
330 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
331 | 331 | ) |
332 | 332 | ), |
333 | 333 | 'thousands_separator' => array( |
334 | 334 | 'id' => 'thousands_separator', |
335 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
336 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
335 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
336 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
337 | 337 | 'type' => 'text', |
338 | 338 | 'size' => 'small', |
339 | 339 | 'std' => ',', |
340 | 340 | ), |
341 | 341 | 'decimal_separator' => array( |
342 | 342 | 'id' => 'decimal_separator', |
343 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
344 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
343 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
344 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
345 | 345 | 'type' => 'text', |
346 | 346 | 'size' => 'small', |
347 | 347 | 'std' => '.', |
348 | 348 | ), |
349 | 349 | 'decimals' => array( |
350 | 350 | 'id' => 'decimals', |
351 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
352 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
351 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
352 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
353 | 353 | 'type' => 'number', |
354 | 354 | 'size' => 'small', |
355 | 355 | 'std' => '2', |
@@ -361,60 +361,60 @@ discard block |
||
361 | 361 | 'labels' => array( |
362 | 362 | 'labels' => array( |
363 | 363 | 'id' => 'labels_settings', |
364 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
364 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
365 | 365 | 'desc' => '', |
366 | 366 | 'type' => 'header', |
367 | 367 | ), |
368 | 368 | 'vat_name' => array( |
369 | 369 | 'id' => 'vat_name', |
370 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
371 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
370 | + 'name' => __('VAT Name', 'invoicing'), |
|
371 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
372 | 372 | 'type' => 'text', |
373 | 373 | 'size' => 'regular', |
374 | 374 | 'std' => 'VAT' |
375 | 375 | ), |
376 | 376 | 'vat_invoice_notice_label' => array( |
377 | 377 | 'id' => 'vat_invoice_notice_label', |
378 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
379 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
378 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
379 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
380 | 380 | 'type' => 'text', |
381 | 381 | 'size' => 'regular', |
382 | 382 | ), |
383 | 383 | 'vat_invoice_notice' => array( |
384 | 384 | 'id' => 'vat_invoice_notice', |
385 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
386 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
385 | + 'name' => __('Invoice notice', 'invoicing'), |
|
386 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
387 | 387 | 'type' => 'text', |
388 | 388 | 'size' => 'regular', |
389 | 389 | ), |
390 | 390 | 'name_your_price' => array( |
391 | 391 | 'id' => 'name_your_price_settings', |
392 | - 'name' => '<h3>' . __( 'Name Your Price', 'invoicing' ) . '</h3>', |
|
392 | + 'name' => '<h3>' . __('Name Your Price', 'invoicing') . '</h3>', |
|
393 | 393 | 'desc' => '', |
394 | 394 | 'type' => 'header', |
395 | 395 | ), |
396 | 396 | 'suggested_price_text' => array( |
397 | 397 | 'id' => 'suggested_price_text', |
398 | - 'name' => __( 'Suggested Price Text', 'invoicing' ), |
|
399 | - 'desc' => __( "The label used to indicate an item's suggested price", 'invoicing' ), |
|
398 | + 'name' => __('Suggested Price Text', 'invoicing'), |
|
399 | + 'desc' => __("The label used to indicate an item's suggested price", 'invoicing'), |
|
400 | 400 | 'type' => 'text', |
401 | 401 | 'size' => 'regular', |
402 | - 'std' => __( 'Suggested Price:', 'invoicing' ), |
|
402 | + 'std' => __('Suggested Price:', 'invoicing'), |
|
403 | 403 | ), |
404 | 404 | 'minimum_price_text' => array( |
405 | 405 | 'id' => 'minimum_price_text', |
406 | - 'name' => __( 'Minimum Price Text', 'invoicing' ), |
|
407 | - 'desc' => __( "The label used to indicate an item's minimum price", 'invoicing' ), |
|
406 | + 'name' => __('Minimum Price Text', 'invoicing'), |
|
407 | + 'desc' => __("The label used to indicate an item's minimum price", 'invoicing'), |
|
408 | 408 | 'type' => 'text', |
409 | 409 | 'size' => 'regular', |
410 | - 'std' => __( 'Minimum Price:', 'invoicing' ), |
|
410 | + 'std' => __('Minimum Price:', 'invoicing'), |
|
411 | 411 | ), |
412 | 412 | 'name_your_price_text' => array( |
413 | 413 | 'id' => 'name_your_price_text', |
414 | - 'name' => __( 'Name Your Price Text', 'invoicing' ), |
|
414 | + 'name' => __('Name Your Price Text', 'invoicing'), |
|
415 | 415 | 'type' => 'text', |
416 | 416 | 'size' => 'regular', |
417 | - 'std' => __( 'Name Your Price', 'invoicing' ), |
|
417 | + 'std' => __('Name Your Price', 'invoicing'), |
|
418 | 418 | ), |
419 | 419 | ) |
420 | 420 | ) |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | 'main' => array( |
425 | 425 | 'gateway_settings' => array( |
426 | 426 | 'id' => 'api_header', |
427 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
427 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
428 | 428 | 'desc' => '', |
429 | 429 | 'type' => 'header', |
430 | 430 | ), |
431 | 431 | 'gateways' => array( |
432 | 432 | 'id' => 'gateways', |
433 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
434 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
433 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
434 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
435 | 435 | 'type' => 'gateways', |
436 | 436 | 'std' => array('manual'=>1), |
437 | 437 | 'options' => wpinv_get_payment_gateways(), |
438 | 438 | ), |
439 | 439 | 'default_gateway' => array( |
440 | 440 | 'id' => 'default_gateway', |
441 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
442 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
441 | + 'name' => __('Default Gateway', 'invoicing'), |
|
442 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
443 | 443 | 'type' => 'gateway_select', |
444 | 444 | 'std' => 'manual', |
445 | 445 | 'class' => 'wpi_select2', |
@@ -454,19 +454,19 @@ discard block |
||
454 | 454 | 'main' => array( |
455 | 455 | 'tax_settings' => array( |
456 | 456 | 'id' => 'tax_settings', |
457 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
457 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
458 | 458 | 'type' => 'header', |
459 | 459 | ), |
460 | 460 | 'enable_taxes' => array( |
461 | 461 | 'id' => 'enable_taxes', |
462 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
463 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
462 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
463 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
464 | 464 | 'type' => 'checkbox', |
465 | 465 | ), |
466 | 466 | 'tax_rate' => array( |
467 | 467 | 'id' => 'tax_rate', |
468 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
469 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
468 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
469 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
470 | 470 | 'type' => 'number', |
471 | 471 | 'size' => 'small', |
472 | 472 | 'min' => '0', |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | 'rates' => array( |
479 | 479 | 'tax_rates' => array( |
480 | 480 | 'id' => 'tax_rates', |
481 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
482 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
481 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
482 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
483 | 483 | 'type' => 'tax_rates', |
484 | 484 | ), |
485 | 485 | ) |
@@ -491,61 +491,61 @@ discard block |
||
491 | 491 | 'main' => array( |
492 | 492 | 'email_settings_header' => array( |
493 | 493 | 'id' => 'email_settings_header', |
494 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
494 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
495 | 495 | 'type' => 'header', |
496 | 496 | ), |
497 | 497 | 'email_from_name' => array( |
498 | 498 | 'id' => 'email_from_name', |
499 | - 'name' => __( 'From Name', 'invoicing' ), |
|
500 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
501 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
499 | + 'name' => __('From Name', 'invoicing'), |
|
500 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
501 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
502 | 502 | 'type' => 'text', |
503 | 503 | ), |
504 | 504 | 'email_from' => array( |
505 | 505 | 'id' => 'email_from', |
506 | - 'name' => __( 'From Email', 'invoicing' ), |
|
507 | - '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), |
|
508 | - 'std' => get_option( 'admin_email' ), |
|
506 | + 'name' => __('From Email', 'invoicing'), |
|
507 | + '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), |
|
508 | + 'std' => get_option('admin_email'), |
|
509 | 509 | 'type' => 'text', |
510 | 510 | ), |
511 | 511 | 'overdue_settings_header' => array( |
512 | 512 | 'id' => 'overdue_settings_header', |
513 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
513 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
514 | 514 | 'type' => 'header', |
515 | 515 | ), |
516 | 516 | 'overdue_active' => array( |
517 | 517 | 'id' => 'overdue_active', |
518 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
519 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
518 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
519 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
520 | 520 | 'type' => 'checkbox', |
521 | 521 | 'std' => false, |
522 | 522 | ), |
523 | 523 | 'overdue_days' => array( |
524 | 524 | 'id' => 'overdue_days', |
525 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
526 | - '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' ), |
|
525 | + 'name' => __('Default Due Date', 'invoicing'), |
|
526 | + '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'), |
|
527 | 527 | 'type' => 'select', |
528 | 528 | 'options' => $due_payment_options, |
529 | 529 | 'std' => 0, |
530 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
530 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
531 | 531 | ), |
532 | 532 | 'email_template_header' => array( |
533 | 533 | 'id' => 'email_template_header', |
534 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
534 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
535 | 535 | 'type' => 'header', |
536 | 536 | ), |
537 | 537 | 'email_header_image' => array( |
538 | 538 | 'id' => 'email_header_image', |
539 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
540 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
539 | + 'name' => __('Header Image', 'invoicing'), |
|
540 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
541 | 541 | 'std' => '', |
542 | 542 | 'type' => 'text', |
543 | 543 | ), |
544 | 544 | 'email_footer_text' => array( |
545 | 545 | 'id' => 'email_footer_text', |
546 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
547 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
548 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
546 | + 'name' => __('Footer Text', 'invoicing'), |
|
547 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
548 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
549 | 549 | 'type' => 'textarea', |
550 | 550 | 'class' => 'regular-text', |
551 | 551 | 'rows' => 2, |
@@ -553,29 +553,29 @@ discard block |
||
553 | 553 | ), |
554 | 554 | 'email_base_color' => array( |
555 | 555 | 'id' => 'email_base_color', |
556 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
557 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
556 | + 'name' => __('Base Color', 'invoicing'), |
|
557 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
558 | 558 | 'std' => '#557da2', |
559 | 559 | 'type' => 'color', |
560 | 560 | ), |
561 | 561 | 'email_background_color' => array( |
562 | 562 | 'id' => 'email_background_color', |
563 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
564 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
563 | + 'name' => __('Background Color', 'invoicing'), |
|
564 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
565 | 565 | 'std' => '#f5f5f5', |
566 | 566 | 'type' => 'color', |
567 | 567 | ), |
568 | 568 | 'email_body_background_color' => array( |
569 | 569 | 'id' => 'email_body_background_color', |
570 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
571 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
570 | + 'name' => __('Body Background Color', 'invoicing'), |
|
571 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
572 | 572 | 'std' => '#fdfdfd', |
573 | 573 | 'type' => 'color', |
574 | 574 | ), |
575 | 575 | 'email_text_color' => array( |
576 | 576 | 'id' => 'email_text_color', |
577 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
578 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
577 | + 'name' => __('Body Text Color', 'invoicing'), |
|
578 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
579 | 579 | 'std' => '#505050', |
580 | 580 | 'type' => 'color', |
581 | 581 | ), |
@@ -594,26 +594,26 @@ discard block |
||
594 | 594 | 'main' => array( |
595 | 595 | 'invoicing_privacy_policy_settings' => array( |
596 | 596 | 'id' => 'invoicing_privacy_policy_settings', |
597 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
597 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
598 | 598 | 'type' => 'header', |
599 | 599 | ), |
600 | 600 | 'privacy_page' => array( |
601 | 601 | 'id' => 'privacy_page', |
602 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
603 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
602 | + 'name' => __('Privacy Page', 'invoicing'), |
|
603 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
604 | 604 | 'type' => 'select', |
605 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
605 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
606 | 606 | 'class' => 'wpi_select2', |
607 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
607 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
608 | 608 | ), |
609 | 609 | 'invoicing_privacy_checkout_message' => array( |
610 | 610 | 'id' => 'invoicing_privacy_checkout_message', |
611 | - 'name' => __( 'Checkout privacy policy', 'invoicing' ), |
|
612 | - 'desc' => __( 'Optionally add privacy policy message which will display on checkout page.', 'invoicing' ), |
|
611 | + 'name' => __('Checkout privacy policy', 'invoicing'), |
|
612 | + 'desc' => __('Optionally add privacy policy message which will display on checkout page.', 'invoicing'), |
|
613 | 613 | 'type' => 'textarea', |
614 | 614 | 'class'=> 'regular-text', |
615 | 615 | 'rows' => 4, |
616 | - 'std' => sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ), |
|
616 | + 'std' => sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'), |
|
617 | 617 | ), |
618 | 618 | ), |
619 | 619 | ) |
@@ -624,19 +624,19 @@ discard block |
||
624 | 624 | 'main' => array( |
625 | 625 | 'invoice_number_format_settings' => array( |
626 | 626 | 'id' => 'invoice_number_format_settings', |
627 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
627 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
628 | 628 | 'type' => 'header', |
629 | 629 | ), |
630 | 630 | 'sequential_invoice_number' => array( |
631 | 631 | 'id' => 'sequential_invoice_number', |
632 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
633 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
632 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
633 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
634 | 634 | 'type' => 'checkbox', |
635 | 635 | ), |
636 | 636 | 'invoice_sequence_start' => array( |
637 | 637 | 'id' => 'invoice_sequence_start', |
638 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
639 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
638 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
639 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
640 | 640 | 'type' => 'number', |
641 | 641 | 'size' => 'small', |
642 | 642 | 'std' => '1', |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | ), |
645 | 645 | 'invoice_number_padd' => array( |
646 | 646 | 'id' => 'invoice_number_padd', |
647 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
648 | - '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' ), |
|
647 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
648 | + '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'), |
|
649 | 649 | 'type' => 'select', |
650 | 650 | 'options' => $invoice_number_padd_options, |
651 | 651 | 'std' => 5, |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | ), |
654 | 654 | 'invoice_number_prefix' => array( |
655 | 655 | 'id' => 'invoice_number_prefix', |
656 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
657 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
656 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
657 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
658 | 658 | 'type' => 'text', |
659 | 659 | 'size' => 'regular', |
660 | 660 | 'std' => 'WPINV-', |
@@ -662,32 +662,32 @@ discard block |
||
662 | 662 | ), |
663 | 663 | 'invoice_number_postfix' => array( |
664 | 664 | 'id' => 'invoice_number_postfix', |
665 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
666 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
665 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
666 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
667 | 667 | 'type' => 'text', |
668 | 668 | 'size' => 'regular', |
669 | 669 | 'std' => '' |
670 | 670 | ), |
671 | 671 | 'checkout_settings' => array( |
672 | 672 | 'id' => 'checkout_settings', |
673 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
673 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
674 | 674 | 'type' => 'header', |
675 | 675 | ), |
676 | 676 | 'login_to_checkout' => array( |
677 | 677 | 'id' => 'login_to_checkout', |
678 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
679 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
678 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
679 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
680 | 680 | 'type' => 'checkbox', |
681 | 681 | ), |
682 | 682 | 'uninstall_settings' => array( |
683 | 683 | 'id' => 'uninstall_settings', |
684 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
684 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
685 | 685 | 'type' => 'header', |
686 | 686 | ), |
687 | 687 | 'remove_data_on_unistall' => array( |
688 | 688 | 'id' => 'remove_data_on_unistall', |
689 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
690 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
689 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
690 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
691 | 691 | 'type' => 'checkbox', |
692 | 692 | 'std' => '' |
693 | 693 | ), |
@@ -695,80 +695,80 @@ discard block |
||
695 | 695 | 'fields' => array( |
696 | 696 | 'fields_settings' => array( |
697 | 697 | 'id' => 'fields_settings', |
698 | - 'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>', |
|
699 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
698 | + 'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>', |
|
699 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
700 | 700 | 'type' => 'header', |
701 | 701 | ), |
702 | 702 | 'fname_mandatory' => array( |
703 | 703 | 'id' => 'fname_mandatory', |
704 | - 'name' => __( 'First Name', 'invoicing' ), |
|
704 | + 'name' => __('First Name', 'invoicing'), |
|
705 | 705 | 'type' => 'checkbox', |
706 | 706 | 'std' => true, |
707 | 707 | ), |
708 | 708 | 'lname_mandatory' => array( |
709 | 709 | 'id' => 'lname_mandatory', |
710 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
710 | + 'name' => __('Last Name', 'invoicing'), |
|
711 | 711 | 'type' => 'checkbox', |
712 | 712 | 'std' => true, |
713 | 713 | ), |
714 | 714 | 'address_mandatory' => array( |
715 | 715 | 'id' => 'address_mandatory', |
716 | - 'name' => __( 'Address', 'invoicing' ), |
|
716 | + 'name' => __('Address', 'invoicing'), |
|
717 | 717 | 'type' => 'checkbox', |
718 | 718 | 'std' => true, |
719 | 719 | ), |
720 | 720 | 'city_mandatory' => array( |
721 | 721 | 'id' => 'city_mandatory', |
722 | - 'name' => __( 'City', 'invoicing' ), |
|
722 | + 'name' => __('City', 'invoicing'), |
|
723 | 723 | 'type' => 'checkbox', |
724 | 724 | 'std' => true, |
725 | 725 | ), |
726 | 726 | 'country_mandatory' => array( |
727 | 727 | 'id' => 'country_mandatory', |
728 | - 'name' => __( 'Country', 'invoicing' ), |
|
728 | + 'name' => __('Country', 'invoicing'), |
|
729 | 729 | 'type' => 'checkbox', |
730 | 730 | 'std' => true, |
731 | 731 | ), |
732 | 732 | 'state_mandatory' => array( |
733 | 733 | 'id' => 'state_mandatory', |
734 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
734 | + 'name' => __('State / Province', 'invoicing'), |
|
735 | 735 | 'type' => 'checkbox', |
736 | 736 | 'std' => true, |
737 | 737 | ), |
738 | 738 | 'zip_mandatory' => array( |
739 | 739 | 'id' => 'zip_mandatory', |
740 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
740 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
741 | 741 | 'type' => 'checkbox', |
742 | 742 | 'std' => true, |
743 | 743 | ), |
744 | 744 | 'phone_mandatory' => array( |
745 | 745 | 'id' => 'phone_mandatory', |
746 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
746 | + 'name' => __('Phone Number', 'invoicing'), |
|
747 | 747 | 'type' => 'checkbox', |
748 | 748 | 'std' => true, |
749 | 749 | ), |
750 | 750 | 'force_show_company' => array( |
751 | 751 | 'id' => 'force_show_company', |
752 | - 'name' => __( 'Force show company name at checkout.', 'invoicing' ), |
|
752 | + 'name' => __('Force show company name at checkout.', 'invoicing'), |
|
753 | 753 | 'type' => 'checkbox', |
754 | 754 | 'std' => false, |
755 | 755 | ), |
756 | 756 | 'address_autofill_settings' => array( |
757 | 757 | 'id' => 'address_autofill_settings', |
758 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
758 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
759 | 759 | 'type' => 'header', |
760 | 760 | ), |
761 | 761 | 'address_autofill_active' => array( |
762 | 762 | 'id' => 'address_autofill_active', |
763 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
764 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
763 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
764 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
765 | 765 | 'type' => 'checkbox', |
766 | 766 | 'std' => 0 |
767 | 767 | ), |
768 | 768 | 'address_autofill_api' => array( |
769 | 769 | 'id' => 'address_autofill_api', |
770 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
771 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
770 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
771 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
772 | 772 | 'type' => 'text', |
773 | 773 | 'size' => 'regular', |
774 | 774 | 'std' => '' |
@@ -777,13 +777,13 @@ discard block |
||
777 | 777 | 'custom-css' => array( |
778 | 778 | 'css_settings' => array( |
779 | 779 | 'id' => 'css_settings', |
780 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
780 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
781 | 781 | 'type' => 'header', |
782 | 782 | ), |
783 | 783 | 'template_custom_css' => array( |
784 | 784 | 'id' => 'template_custom_css', |
785 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
786 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
785 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
786 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
787 | 787 | 'type' => 'textarea', |
788 | 788 | 'class'=> 'regular-text', |
789 | 789 | 'rows' => 10, |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | 'main' => array( |
798 | 798 | 'tool_settings' => array( |
799 | 799 | 'id' => 'tool_settings', |
800 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
801 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
800 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
801 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
802 | 802 | 'type' => 'tools', |
803 | 803 | ), |
804 | 804 | ), |
@@ -806,136 +806,136 @@ discard block |
||
806 | 806 | ) |
807 | 807 | ); |
808 | 808 | |
809 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
809 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
810 | 810 | } |
811 | 811 | |
812 | -function wpinv_settings_sanitize( $input = array() ) { |
|
812 | +function wpinv_settings_sanitize($input = array()) { |
|
813 | 813 | global $wpinv_options; |
814 | 814 | |
815 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
815 | + if (empty($_POST['_wp_http_referer'])) { |
|
816 | 816 | return $input; |
817 | 817 | } |
818 | 818 | |
819 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
819 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
820 | 820 | |
821 | 821 | $settings = wpinv_get_registered_settings(); |
822 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
823 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
822 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
823 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
824 | 824 | |
825 | 825 | $input = $input ? $input : array(); |
826 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
827 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
826 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
827 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
828 | 828 | |
829 | 829 | // Loop through each setting being saved and pass it through a sanitization filter |
830 | - foreach ( $input as $key => $value ) { |
|
830 | + foreach ($input as $key => $value) { |
|
831 | 831 | // Get the setting type (checkbox, select, etc) |
832 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
832 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
833 | 833 | |
834 | - if ( $type ) { |
|
834 | + if ($type) { |
|
835 | 835 | // Field type specific filter |
836 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
836 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | // General filter |
840 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
840 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | // Loop through the whitelist and unset any that are empty for the tab being saved |
844 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
845 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
844 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
845 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
846 | 846 | |
847 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
847 | + $found_settings = array_merge($main_settings, $section_settings); |
|
848 | 848 | |
849 | - if ( ! empty( $found_settings ) ) { |
|
850 | - foreach ( $found_settings as $key => $value ) { |
|
849 | + if (!empty($found_settings)) { |
|
850 | + foreach ($found_settings as $key => $value) { |
|
851 | 851 | |
852 | 852 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
853 | - if ( is_numeric( $key ) ) { |
|
853 | + if (is_numeric($key)) { |
|
854 | 854 | $key = $value['id']; |
855 | 855 | } |
856 | 856 | |
857 | - if ( empty( $input[ $key ] ) ) { |
|
858 | - unset( $wpinv_options[ $key ] ); |
|
857 | + if (empty($input[$key])) { |
|
858 | + unset($wpinv_options[$key]); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Merge our new settings with the existing |
864 | - $output = array_merge( $wpinv_options, $input ); |
|
864 | + $output = array_merge($wpinv_options, $input); |
|
865 | 865 | |
866 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
866 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
867 | 867 | |
868 | 868 | return $output; |
869 | 869 | } |
870 | 870 | |
871 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
871 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
872 | 872 | global $wpi_session; |
873 | 873 | |
874 | - if ( !current_user_can( 'manage_options' ) ) { |
|
874 | + if (!current_user_can('manage_options')) { |
|
875 | 875 | return $input; |
876 | 876 | } |
877 | 877 | |
878 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
878 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
879 | 879 | // Shows an admin notice about upgrading previous order numbers |
880 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
880 | + $wpi_session->set('upgrade_sequential', '1'); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | return $input; |
884 | 884 | } |
885 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
885 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
886 | 886 | |
887 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
888 | - if( !current_user_can( 'manage_options' ) ) { |
|
887 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
888 | + if (!current_user_can('manage_options')) { |
|
889 | 889 | return $input; |
890 | 890 | } |
891 | 891 | |
892 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
892 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
893 | 893 | |
894 | 894 | $tax_rates = array(); |
895 | 895 | |
896 | - if ( !empty( $new_rates ) ) { |
|
897 | - foreach ( $new_rates as $rate ) { |
|
898 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
896 | + if (!empty($new_rates)) { |
|
897 | + foreach ($new_rates as $rate) { |
|
898 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
899 | 899 | continue; |
900 | 900 | } |
901 | 901 | |
902 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
902 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
903 | 903 | |
904 | 904 | $tax_rates[] = $rate; |
905 | 905 | } |
906 | 906 | } |
907 | 907 | |
908 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
908 | + update_option('wpinv_tax_rates', $tax_rates); |
|
909 | 909 | |
910 | 910 | return $input; |
911 | 911 | } |
912 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
912 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
913 | 913 | |
914 | -function wpinv_sanitize_text_field( $input ) { |
|
915 | - return trim( $input ); |
|
914 | +function wpinv_sanitize_text_field($input) { |
|
915 | + return trim($input); |
|
916 | 916 | } |
917 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
917 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
918 | 918 | |
919 | 919 | function wpinv_get_settings_tabs() { |
920 | 920 | $tabs = array(); |
921 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
922 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
923 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
924 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
925 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
926 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
927 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
928 | - |
|
929 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
921 | + $tabs['general'] = __('General', 'invoicing'); |
|
922 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
923 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
924 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
925 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
926 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
927 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
928 | + |
|
929 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
930 | 930 | } |
931 | 931 | |
932 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
932 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
933 | 933 | $tabs = false; |
934 | 934 | $sections = wpinv_get_registered_settings_sections(); |
935 | 935 | |
936 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
937 | - $tabs = $sections[ $tab ]; |
|
938 | - } else if ( $tab ) { |
|
936 | + if ($tab && !empty($sections[$tab])) { |
|
937 | + $tabs = $sections[$tab]; |
|
938 | + } else if ($tab) { |
|
939 | 939 | $tabs = false; |
940 | 940 | } |
941 | 941 | |
@@ -945,143 +945,143 @@ discard block |
||
945 | 945 | function wpinv_get_registered_settings_sections() { |
946 | 946 | static $sections = false; |
947 | 947 | |
948 | - if ( false !== $sections ) { |
|
948 | + if (false !== $sections) { |
|
949 | 949 | return $sections; |
950 | 950 | } |
951 | 951 | |
952 | 952 | $sections = array( |
953 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
954 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
955 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
956 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
957 | - ) ), |
|
958 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
959 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
960 | - ) ), |
|
961 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
962 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
963 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
964 | - ) ), |
|
965 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
966 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
967 | - ) ), |
|
968 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
969 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
970 | - ) ), |
|
971 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
972 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
973 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
974 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
975 | - ) ), |
|
976 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
977 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
978 | - ) ), |
|
953 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
954 | + 'main' => __('General Settings', 'invoicing'), |
|
955 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
956 | + 'labels' => __('Label Texts', 'invoicing'), |
|
957 | + )), |
|
958 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
959 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
960 | + )), |
|
961 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
962 | + 'main' => __('Tax Settings', 'invoicing'), |
|
963 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
964 | + )), |
|
965 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
966 | + 'main' => __('Email Settings', 'invoicing'), |
|
967 | + )), |
|
968 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
969 | + 'main' => __('Privacy policy', 'invoicing'), |
|
970 | + )), |
|
971 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
972 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
973 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
974 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
975 | + )), |
|
976 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
977 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
978 | + )), |
|
979 | 979 | ); |
980 | 980 | |
981 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
981 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
982 | 982 | |
983 | 983 | return $sections; |
984 | 984 | } |
985 | 985 | |
986 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
986 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
987 | 987 | $pages_options = array(); |
988 | 988 | |
989 | - if( $default_label !== NULL && $default_label !== false ) { |
|
990 | - $pages_options = array( '' => $default_label ); // Blank option |
|
989 | + if ($default_label !== NULL && $default_label !== false) { |
|
990 | + $pages_options = array('' => $default_label); // Blank option |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | $pages = get_pages(); |
994 | - if ( $pages ) { |
|
995 | - foreach ( $pages as $page ) { |
|
994 | + if ($pages) { |
|
995 | + foreach ($pages as $page) { |
|
996 | 996 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
997 | - $pages_options[ $page->ID ] = $title; |
|
997 | + $pages_options[$page->ID] = $title; |
|
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | return $pages_options; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | -function wpinv_header_callback( $args ) { |
|
1005 | - if ( !empty( $args['desc'] ) ) { |
|
1004 | +function wpinv_header_callback($args) { |
|
1005 | + if (!empty($args['desc'])) { |
|
1006 | 1006 | echo $args['desc']; |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | |
1010 | -function wpinv_hidden_callback( $args ) { |
|
1010 | +function wpinv_hidden_callback($args) { |
|
1011 | 1011 | global $wpinv_options; |
1012 | 1012 | |
1013 | - if ( isset( $args['set_value'] ) ) { |
|
1013 | + if (isset($args['set_value'])) { |
|
1014 | 1014 | $value = $args['set_value']; |
1015 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1016 | - $value = $wpinv_options[ $args['id'] ]; |
|
1015 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
1016 | + $value = $wpinv_options[$args['id']]; |
|
1017 | 1017 | } else { |
1018 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1018 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1021 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1022 | 1022 | $args['readonly'] = true; |
1023 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1023 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1024 | 1024 | $name = ''; |
1025 | 1025 | } else { |
1026 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1026 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
1029 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
1030 | 1030 | |
1031 | 1031 | echo $html; |
1032 | 1032 | } |
1033 | 1033 | |
1034 | -function wpinv_checkbox_callback( $args ) { |
|
1034 | +function wpinv_checkbox_callback($args) { |
|
1035 | 1035 | global $wpinv_options; |
1036 | 1036 | |
1037 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1037 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1038 | 1038 | |
1039 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1039 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1040 | 1040 | $name = ''; |
1041 | 1041 | } else { |
1042 | 1042 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
1045 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
1046 | 1046 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
1047 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1047 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1048 | 1048 | |
1049 | 1049 | echo $html; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | -function wpinv_multicheck_callback( $args ) { |
|
1052 | +function wpinv_multicheck_callback($args) { |
|
1053 | 1053 | global $wpinv_options; |
1054 | 1054 | |
1055 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1056 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1055 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1056 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
1057 | 1057 | |
1058 | - if ( ! empty( $args['options'] ) ) { |
|
1058 | + if (!empty($args['options'])) { |
|
1059 | 1059 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
1060 | - foreach( $args['options'] as $key => $option ): |
|
1061 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1062 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
1060 | + foreach ($args['options'] as $key => $option): |
|
1061 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1062 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
1063 | 1063 | $enabled = $sanitize_key; |
1064 | 1064 | } else { |
1065 | 1065 | $enabled = NULL; |
1066 | 1066 | } |
1067 | - echo '<div class="wpi-mcheck-row"><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 ) . '/> '; |
|
1068 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
1067 | + echo '<div class="wpi-mcheck-row"><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) . '/> '; |
|
1068 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
1069 | 1069 | endforeach; |
1070 | 1070 | echo '</div>'; |
1071 | 1071 | echo '<p class="description">' . $args['desc'] . '</p>'; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | 1074 | |
1075 | -function wpinv_payment_icons_callback( $args ) { |
|
1075 | +function wpinv_payment_icons_callback($args) { |
|
1076 | 1076 | global $wpinv_options; |
1077 | 1077 | |
1078 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1078 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1079 | 1079 | |
1080 | - if ( ! empty( $args['options'] ) ) { |
|
1081 | - foreach( $args['options'] as $key => $option ) { |
|
1082 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1080 | + if (!empty($args['options'])) { |
|
1081 | + foreach ($args['options'] as $key => $option) { |
|
1082 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1083 | 1083 | |
1084 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
1084 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
1085 | 1085 | $enabled = $option; |
1086 | 1086 | } else { |
1087 | 1087 | $enabled = NULL; |
@@ -1089,197 +1089,197 @@ discard block |
||
1089 | 1089 | |
1090 | 1090 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
1091 | 1091 | |
1092 | - 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 ) . '/> '; |
|
1092 | + 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) . '/> '; |
|
1093 | 1093 | |
1094 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
1095 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1094 | + if (wpinv_string_is_image_url($key)) { |
|
1095 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1096 | 1096 | } else { |
1097 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
1097 | + $card = strtolower(str_replace(' ', '', $option)); |
|
1098 | 1098 | |
1099 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
1100 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
1099 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
1100 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
1101 | 1101 | } else { |
1102 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
1102 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
1103 | 1103 | $content_dir = WP_CONTENT_DIR; |
1104 | 1104 | |
1105 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
1105 | + if (function_exists('wp_normalize_path')) { |
|
1106 | 1106 | // Replaces backslashes with forward slashes for Windows systems |
1107 | - $image = wp_normalize_path( $image ); |
|
1108 | - $content_dir = wp_normalize_path( $content_dir ); |
|
1107 | + $image = wp_normalize_path($image); |
|
1108 | + $content_dir = wp_normalize_path($content_dir); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
1111 | + $image = str_replace($content_dir, content_url(), $image); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1114 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
1115 | 1115 | } |
1116 | 1116 | echo $option . '</label>'; |
1117 | 1117 | } |
1118 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1118 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | |
1122 | -function wpinv_radio_callback( $args ) { |
|
1122 | +function wpinv_radio_callback($args) { |
|
1123 | 1123 | global $wpinv_options; |
1124 | 1124 | |
1125 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1125 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1126 | 1126 | |
1127 | - foreach ( $args['options'] as $key => $option ) : |
|
1128 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1127 | + foreach ($args['options'] as $key => $option) : |
|
1128 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1129 | 1129 | |
1130 | 1130 | $checked = false; |
1131 | 1131 | |
1132 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1132 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
1133 | 1133 | $checked = true; |
1134 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1134 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
1135 | 1135 | $checked = true; |
1136 | 1136 | |
1137 | 1137 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
1138 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1138 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
1139 | 1139 | endforeach; |
1140 | 1140 | |
1141 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1141 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | -function wpinv_gateways_callback( $args ) { |
|
1144 | +function wpinv_gateways_callback($args) { |
|
1145 | 1145 | global $wpinv_options; |
1146 | 1146 | |
1147 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1147 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1148 | 1148 | |
1149 | - foreach ( $args['options'] as $key => $option ) : |
|
1150 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1149 | + foreach ($args['options'] as $key => $option) : |
|
1150 | + $sanitize_key = wpinv_sanitize_key($key); |
|
1151 | 1151 | |
1152 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
1152 | + if (isset($wpinv_options['gateways'][$key])) |
|
1153 | 1153 | $enabled = '1'; |
1154 | 1154 | else |
1155 | 1155 | $enabled = null; |
1156 | 1156 | |
1157 | - 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) . '/> '; |
|
1158 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1157 | + 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) . '/> '; |
|
1158 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
1159 | 1159 | endforeach; |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | function wpinv_gateway_select_callback($args) { |
1163 | 1163 | global $wpinv_options; |
1164 | 1164 | |
1165 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1166 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1165 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1166 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
1167 | 1167 | |
1168 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
1168 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
1169 | 1169 | |
1170 | - foreach ( $args['options'] as $key => $option ) : |
|
1171 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1172 | - $selected = selected( $key, $args['selected'], false ); |
|
1170 | + foreach ($args['options'] as $key => $option) : |
|
1171 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1172 | + $selected = selected($key, $args['selected'], false); |
|
1173 | 1173 | } else { |
1174 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
1174 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
1175 | 1175 | } |
1176 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1176 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
1177 | 1177 | endforeach; |
1178 | 1178 | |
1179 | 1179 | echo '</select>'; |
1180 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1180 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | -function wpinv_text_callback( $args ) { |
|
1183 | +function wpinv_text_callback($args) { |
|
1184 | 1184 | global $wpinv_options; |
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 | } else { |
1191 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1191 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1194 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1195 | 1195 | $args['readonly'] = true; |
1196 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1196 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1197 | 1197 | $name = ''; |
1198 | 1198 | } else { |
1199 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1199 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1200 | 1200 | } |
1201 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1201 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1202 | 1202 | |
1203 | 1203 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
1204 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1205 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1206 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1204 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1205 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
1206 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1207 | 1207 | |
1208 | 1208 | echo $html; |
1209 | 1209 | } |
1210 | 1210 | |
1211 | -function wpinv_number_callback( $args ) { |
|
1211 | +function wpinv_number_callback($args) { |
|
1212 | 1212 | global $wpinv_options; |
1213 | 1213 | |
1214 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1214 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1215 | 1215 | |
1216 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1217 | - $value = $wpinv_options[ $args['id'] ]; |
|
1216 | + if (isset($wpinv_options[$args['id']])) { |
|
1217 | + $value = $wpinv_options[$args['id']]; |
|
1218 | 1218 | } else { |
1219 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1219 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1222 | + if (isset($args['faux']) && true === $args['faux']) { |
|
1223 | 1223 | $args['readonly'] = true; |
1224 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1224 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1225 | 1225 | $name = ''; |
1226 | 1226 | } else { |
1227 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1227 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1231 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1232 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1233 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1230 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
1231 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
1232 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
1233 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
1234 | 1234 | |
1235 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1236 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1237 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1235 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1236 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
1237 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1238 | 1238 | |
1239 | 1239 | echo $html; |
1240 | 1240 | } |
1241 | 1241 | |
1242 | -function wpinv_textarea_callback( $args ) { |
|
1242 | +function wpinv_textarea_callback($args) { |
|
1243 | 1243 | global $wpinv_options; |
1244 | 1244 | |
1245 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1245 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1246 | 1246 | |
1247 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1248 | - $value = $wpinv_options[ $args['id'] ]; |
|
1247 | + if (isset($wpinv_options[$args['id']])) { |
|
1248 | + $value = $wpinv_options[$args['id']]; |
|
1249 | 1249 | } else { |
1250 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1250 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1254 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
1253 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1254 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
1255 | 1255 | |
1256 | - $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>'; |
|
1257 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1256 | + $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>'; |
|
1257 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1258 | 1258 | |
1259 | 1259 | echo $html; |
1260 | 1260 | } |
1261 | 1261 | |
1262 | -function wpinv_password_callback( $args ) { |
|
1262 | +function wpinv_password_callback($args) { |
|
1263 | 1263 | global $wpinv_options; |
1264 | 1264 | |
1265 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1265 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1266 | 1266 | |
1267 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1268 | - $value = $wpinv_options[ $args['id'] ]; |
|
1267 | + if (isset($wpinv_options[$args['id']])) { |
|
1268 | + $value = $wpinv_options[$args['id']]; |
|
1269 | 1269 | } else { |
1270 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1270 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1274 | - $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 ) . '"/>'; |
|
1275 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1273 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1274 | + $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) . '"/>'; |
|
1275 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1276 | 1276 | |
1277 | 1277 | echo $html; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | function wpinv_missing_callback($args) { |
1281 | 1281 | printf( |
1282 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1282 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
1283 | 1283 | '<strong>' . $args['id'] . '</strong>' |
1284 | 1284 | ); |
1285 | 1285 | } |
@@ -1287,133 +1287,133 @@ discard block |
||
1287 | 1287 | function wpinv_select_callback($args) { |
1288 | 1288 | global $wpinv_options; |
1289 | 1289 | |
1290 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1290 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1291 | 1291 | |
1292 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1293 | - $value = $wpinv_options[ $args['id'] ]; |
|
1292 | + if (isset($wpinv_options[$args['id']])) { |
|
1293 | + $value = $wpinv_options[$args['id']]; |
|
1294 | 1294 | } else { |
1295 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1295 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1298 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
1299 | 1299 | $value = $args['selected']; |
1300 | 1300 | } |
1301 | 1301 | |
1302 | - if ( isset( $args['placeholder'] ) ) { |
|
1302 | + if (isset($args['placeholder'])) { |
|
1303 | 1303 | $placeholder = $args['placeholder']; |
1304 | 1304 | } else { |
1305 | 1305 | $placeholder = ''; |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - if( !empty( $args['onchange'] ) ) { |
|
1309 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
1308 | + if (!empty($args['onchange'])) { |
|
1309 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
1310 | 1310 | } else { |
1311 | 1311 | $onchange = ''; |
1312 | 1312 | } |
1313 | 1313 | |
1314 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
1314 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
1315 | 1315 | |
1316 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1316 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
1317 | 1317 | |
1318 | - foreach ( $args['options'] as $option => $name ) { |
|
1319 | - $selected = selected( $option, $value, false ); |
|
1320 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1318 | + foreach ($args['options'] as $option => $name) { |
|
1319 | + $selected = selected($option, $value, false); |
|
1320 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | $html .= '</select>'; |
1324 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1324 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1325 | 1325 | |
1326 | 1326 | echo $html; |
1327 | 1327 | } |
1328 | 1328 | |
1329 | -function wpinv_color_select_callback( $args ) { |
|
1329 | +function wpinv_color_select_callback($args) { |
|
1330 | 1330 | global $wpinv_options; |
1331 | 1331 | |
1332 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1332 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1333 | 1333 | |
1334 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1335 | - $value = $wpinv_options[ $args['id'] ]; |
|
1334 | + if (isset($wpinv_options[$args['id']])) { |
|
1335 | + $value = $wpinv_options[$args['id']]; |
|
1336 | 1336 | } else { |
1337 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1337 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1340 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
1341 | 1341 | |
1342 | - foreach ( $args['options'] as $option => $color ) { |
|
1343 | - $selected = selected( $option, $value, false ); |
|
1344 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1342 | + foreach ($args['options'] as $option => $color) { |
|
1343 | + $selected = selected($option, $value, false); |
|
1344 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | $html .= '</select>'; |
1348 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1348 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1349 | 1349 | |
1350 | 1350 | echo $html; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | -function wpinv_rich_editor_callback( $args ) { |
|
1353 | +function wpinv_rich_editor_callback($args) { |
|
1354 | 1354 | global $wpinv_options, $wp_version; |
1355 | 1355 | |
1356 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1356 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1357 | 1357 | |
1358 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1359 | - $value = $wpinv_options[ $args['id'] ]; |
|
1358 | + if (isset($wpinv_options[$args['id']])) { |
|
1359 | + $value = $wpinv_options[$args['id']]; |
|
1360 | 1360 | |
1361 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1362 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1361 | + if (empty($args['allow_blank']) && empty($value)) { |
|
1362 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1363 | 1363 | } |
1364 | 1364 | } else { |
1365 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1365 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1368 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
1369 | 1369 | |
1370 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1370 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
1371 | 1371 | ob_start(); |
1372 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
1372 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
1373 | 1373 | $html = ob_get_clean(); |
1374 | 1374 | } else { |
1375 | - $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>'; |
|
1375 | + $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>'; |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1378 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1379 | 1379 | |
1380 | 1380 | echo $html; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | -function wpinv_upload_callback( $args ) { |
|
1383 | +function wpinv_upload_callback($args) { |
|
1384 | 1384 | global $wpinv_options; |
1385 | 1385 | |
1386 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1386 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1387 | 1387 | |
1388 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1388 | + if (isset($wpinv_options[$args['id']])) { |
|
1389 | 1389 | $value = $wpinv_options[$args['id']]; |
1390 | 1390 | } else { |
1391 | 1391 | $value = isset($args['std']) ? $args['std'] : ''; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1395 | - $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 ) ) . '"/>'; |
|
1396 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1397 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1394 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
1395 | + $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)) . '"/>'; |
|
1396 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
1397 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1398 | 1398 | |
1399 | 1399 | echo $html; |
1400 | 1400 | } |
1401 | 1401 | |
1402 | -function wpinv_color_callback( $args ) { |
|
1402 | +function wpinv_color_callback($args) { |
|
1403 | 1403 | global $wpinv_options; |
1404 | 1404 | |
1405 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1405 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1406 | 1406 | |
1407 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1408 | - $value = $wpinv_options[ $args['id'] ]; |
|
1407 | + if (isset($wpinv_options[$args['id']])) { |
|
1408 | + $value = $wpinv_options[$args['id']]; |
|
1409 | 1409 | } else { |
1410 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1410 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1413 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
1414 | 1414 | |
1415 | - $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 ) . '" />'; |
|
1416 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1415 | + $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) . '" />'; |
|
1416 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1417 | 1417 | |
1418 | 1418 | echo $html; |
1419 | 1419 | } |
@@ -1421,9 +1421,9 @@ discard block |
||
1421 | 1421 | function wpinv_country_states_callback($args) { |
1422 | 1422 | global $wpinv_options; |
1423 | 1423 | |
1424 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
1424 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
1425 | 1425 | |
1426 | - if ( isset( $args['placeholder'] ) ) { |
|
1426 | + if (isset($args['placeholder'])) { |
|
1427 | 1427 | $placeholder = $args['placeholder']; |
1428 | 1428 | } else { |
1429 | 1429 | $placeholder = ''; |
@@ -1431,16 +1431,16 @@ discard block |
||
1431 | 1431 | |
1432 | 1432 | $states = wpinv_get_country_states(); |
1433 | 1433 | |
1434 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1435 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1434 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
1435 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
1436 | 1436 | |
1437 | - foreach ( $states as $option => $name ) { |
|
1438 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1439 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1437 | + foreach ($states as $option => $name) { |
|
1438 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
1439 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | $html .= '</select>'; |
1443 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1443 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
1444 | 1444 | |
1445 | 1445 | echo $html; |
1446 | 1446 | } |
@@ -1455,96 +1455,96 @@ discard block |
||
1455 | 1455 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
1456 | 1456 | <thead> |
1457 | 1457 | <tr> |
1458 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
1459 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
1460 | - <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> |
|
1461 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
1462 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
1463 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
1458 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
1459 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
1460 | + <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> |
|
1461 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
1462 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
1463 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
1464 | 1464 | </tr> |
1465 | 1465 | </thead> |
1466 | 1466 | <tbody> |
1467 | - <?php if( !empty( $rates ) ) : ?> |
|
1468 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
1467 | + <?php if (!empty($rates)) : ?> |
|
1468 | + <?php foreach ($rates as $key => $rate) : ?> |
|
1469 | 1469 | <?php |
1470 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
1470 | + $sanitized_key = wpinv_sanitize_key($key); |
|
1471 | 1471 | ?> |
1472 | 1472 | <tr> |
1473 | 1473 | <td class="wpinv_tax_country"> |
1474 | 1474 | <?php |
1475 | - echo wpinv_html_select( array( |
|
1476 | - 'options' => wpinv_get_country_list( true ), |
|
1475 | + echo wpinv_html_select(array( |
|
1476 | + 'options' => wpinv_get_country_list(true), |
|
1477 | 1477 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
1478 | 1478 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1479 | 1479 | 'selected' => $rate['country'], |
1480 | 1480 | 'show_option_all' => false, |
1481 | 1481 | 'show_option_none' => false, |
1482 | 1482 | 'class' => 'wpinv-tax-country wpi_select2', |
1483 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1484 | - ) ); |
|
1483 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1484 | + )); |
|
1485 | 1485 | ?> |
1486 | 1486 | </td> |
1487 | 1487 | <td class="wpinv_tax_state"> |
1488 | 1488 | <?php |
1489 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1490 | - if( !empty( $states ) ) { |
|
1491 | - echo wpinv_html_select( array( |
|
1492 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1489 | + $states = wpinv_get_country_states($rate['country']); |
|
1490 | + if (!empty($states)) { |
|
1491 | + echo wpinv_html_select(array( |
|
1492 | + 'options' => array_merge(array('' => ''), $states), |
|
1493 | 1493 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
1494 | 1494 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1495 | 1495 | 'selected' => $rate['state'], |
1496 | 1496 | 'show_option_all' => false, |
1497 | 1497 | 'show_option_none' => false, |
1498 | 1498 | 'class' => 'wpi_select2', |
1499 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1500 | - ) ); |
|
1499 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
1500 | + )); |
|
1501 | 1501 | } else { |
1502 | - echo wpinv_html_text( array( |
|
1502 | + echo wpinv_html_text(array( |
|
1503 | 1503 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
1504 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1504 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
1505 | 1505 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1506 | - ) ); |
|
1506 | + )); |
|
1507 | 1507 | } |
1508 | 1508 | ?> |
1509 | 1509 | </td> |
1510 | 1510 | <td class="wpinv_tax_global"> |
1511 | - <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'] ) ); ?>/> |
|
1512 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1511 | + <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'])); ?>/> |
|
1512 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1513 | 1513 | </td> |
1514 | - <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> |
|
1515 | - <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> |
|
1516 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1514 | + <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> |
|
1515 | + <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> |
|
1516 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1517 | 1517 | </tr> |
1518 | 1518 | <?php endforeach; ?> |
1519 | 1519 | <?php else : ?> |
1520 | 1520 | <tr> |
1521 | 1521 | <td class="wpinv_tax_country"> |
1522 | 1522 | <?php |
1523 | - echo wpinv_html_select( array( |
|
1524 | - 'options' => wpinv_get_country_list( true ), |
|
1523 | + echo wpinv_html_select(array( |
|
1524 | + 'options' => wpinv_get_country_list(true), |
|
1525 | 1525 | 'name' => 'tax_rates[0][country]', |
1526 | 1526 | 'show_option_all' => false, |
1527 | 1527 | 'show_option_none' => false, |
1528 | 1528 | 'class' => 'wpinv-tax-country wpi_select2', |
1529 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1530 | - ) ); ?> |
|
1529 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
1530 | + )); ?> |
|
1531 | 1531 | </td> |
1532 | 1532 | <td class="wpinv_tax_state"> |
1533 | - <?php echo wpinv_html_text( array( |
|
1533 | + <?php echo wpinv_html_text(array( |
|
1534 | 1534 | 'name' => 'tax_rates[0][state]' |
1535 | - ) ); ?> |
|
1535 | + )); ?> |
|
1536 | 1536 | </td> |
1537 | 1537 | <td class="wpinv_tax_global"> |
1538 | 1538 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
1539 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
1539 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
1540 | 1540 | </td> |
1541 | - <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> |
|
1541 | + <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> |
|
1542 | 1542 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
1543 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
1543 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
1544 | 1544 | </tr> |
1545 | 1545 | <?php endif; ?> |
1546 | 1546 | </tbody> |
1547 | - <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> |
|
1547 | + <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> |
|
1548 | 1548 | </table> |
1549 | 1549 | <?php |
1550 | 1550 | echo ob_get_clean(); |
@@ -1555,76 +1555,76 @@ discard block |
||
1555 | 1555 | ob_start(); ?> |
1556 | 1556 | </td><tr> |
1557 | 1557 | <td colspan="2" class="wpinv_tools_tdbox"> |
1558 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1559 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1558 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1559 | + <?php do_action('wpinv_tools_before'); ?> |
|
1560 | 1560 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1561 | 1561 | <thead> |
1562 | 1562 | <tr> |
1563 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1564 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1565 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1563 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1564 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1565 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1566 | 1566 | </tr> |
1567 | 1567 | </thead> |
1568 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1568 | + <?php do_action('wpinv_tools_row'); ?> |
|
1569 | 1569 | <tbody> |
1570 | 1570 | </tbody> |
1571 | 1571 | </table> |
1572 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1572 | + <?php do_action('wpinv_tools_after'); ?> |
|
1573 | 1573 | <?php |
1574 | 1574 | echo ob_get_clean(); |
1575 | 1575 | } |
1576 | 1576 | |
1577 | -function wpinv_descriptive_text_callback( $args ) { |
|
1578 | - echo wp_kses_post( $args['desc'] ); |
|
1577 | +function wpinv_descriptive_text_callback($args) { |
|
1578 | + echo wp_kses_post($args['desc']); |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | -function wpinv_hook_callback( $args ) { |
|
1582 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1581 | +function wpinv_hook_callback($args) { |
|
1582 | + do_action('wpinv_' . $args['id'], $args); |
|
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | function wpinv_set_settings_cap() { |
1586 | 1586 | return 'manage_options'; |
1587 | 1587 | } |
1588 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1588 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1589 | 1589 | |
1590 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1591 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1592 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1590 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1591 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1592 | + $value = wpinv_sanitize_amount($value, 4); |
|
1593 | 1593 | $value = $value >= 100 ? 99 : $value; |
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | return $value; |
1597 | 1597 | } |
1598 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1598 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1599 | 1599 | |
1600 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1601 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1602 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1600 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1601 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1602 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1603 | 1603 | |
1604 | - if ( $old != $new ) { |
|
1605 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1604 | + if ($old != $new) { |
|
1605 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1606 | 1606 | } |
1607 | 1607 | } |
1608 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1609 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1610 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1611 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1612 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1613 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1614 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1615 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1616 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1617 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1618 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1619 | - |
|
1620 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1608 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1609 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1610 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1611 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1612 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1613 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1614 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1615 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1616 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1617 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1618 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1619 | + |
|
1620 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1621 | 1621 | ?> |
1622 | 1622 | <div class="wpinv-email-wc-row "> |
1623 | 1623 | <div class="wpinv-email-wc-td"> |
1624 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1624 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1625 | 1625 | <p class="wpinv-email-wc-description"> |
1626 | 1626 | <?php |
1627 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1627 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1628 | 1628 | <strong>{site_title} :</strong> Site Title<br> |
1629 | 1629 | <strong>{name} :</strong> Customer\'s full name<br> |
1630 | 1630 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1638,7 +1638,7 @@ discard block |
||
1638 | 1638 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1639 | 1639 | <strong>{date} :</strong> Today\'s date.<br> |
1640 | 1640 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1641 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1641 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1642 | 1642 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1643 | 1643 | ?> |
1644 | 1644 | </p> |
@@ -7,91 +7,91 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
26 | - if ( empty( $invoice ) ) { |
|
25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
26 | + if (empty($invoice)) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | ?> |
30 | 30 | <div class="row wpinv-top-bar no-print"> |
31 | 31 | <div class="container"> |
32 | 32 | <div class="col-xs-6"> |
33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
34 | 34 | </div> |
35 | 35 | <div class="col-xs-6 text-right"> |
36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | <?php |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
44 | - if ( empty( $invoice ) ) { |
|
43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
44 | + if (empty($invoice)) { |
|
45 | 45 | return; // Exit if invoice is not set. |
46 | 46 | } |
47 | 47 | |
48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
49 | - if ( $invoice->needs_payment() ) { |
|
50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
49 | + if ($invoice->needs_payment()) { |
|
50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
54 | 54 | } |
55 | 55 | |
56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
57 | - if ( empty( $invoice ) ) { |
|
56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
57 | + if (empty($invoice)) { |
|
58 | 58 | return; // Exit if invoice is not set. |
59 | 59 | } |
60 | 60 | |
61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
62 | - <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
63 | - <?php if ( is_user_logged_in() ) { ?> |
|
64 | - <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
62 | + <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
63 | + <?php if (is_user_logged_in()) { ?> |
|
64 | + <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
65 | 65 | <?php } |
66 | 66 | } |
67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_before_invoice_content( $content ) { |
|
70 | +function wpinv_before_invoice_content($content) { |
|
71 | 71 | global $post; |
72 | 72 | |
73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
74 | 74 | ob_start(); |
75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
76 | 76 | $content = ob_get_clean() . $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | return $content; |
80 | 80 | } |
81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
82 | 82 | |
83 | -function wpinv_after_invoice_content( $content ) { |
|
83 | +function wpinv_after_invoice_content($content) { |
|
84 | 84 | global $post; |
85 | 85 | |
86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
87 | 87 | ob_start(); |
88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
89 | 89 | $content .= ob_get_clean(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $content; |
93 | 93 | } |
94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
95 | 95 | |
96 | 96 | function wpinv_get_templates_dir() { |
97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
102 | 102 | } |
103 | 103 | |
104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
106 | - extract( $args ); |
|
104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
105 | + if (!empty($args) && is_array($args)) { |
|
106 | + extract($args); |
|
107 | 107 | } |
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
113 | + if (!file_exists($located)) { |
|
114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include($located); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
123 | 123 | } |
124 | 124 | |
125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
126 | 126 | ob_start(); |
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
128 | 128 | return ob_get_clean(); |
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
132 | - if ( ! $template_path ) { |
|
131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
132 | + if (!$template_path) { |
|
133 | 133 | $template_path = wpinv_template_path(); |
134 | 134 | } |
135 | 135 | |
136 | - if ( ! $default_path ) { |
|
136 | + if (!$default_path) { |
|
137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Look within passed path within the theme - this is priority. |
141 | 141 | $template = locate_template( |
142 | 142 | array( |
143 | - trailingslashit( $template_path ) . $template_name, |
|
143 | + trailingslashit($template_path) . $template_name, |
|
144 | 144 | $template_name |
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Get default templates/ |
149 | - if ( !$template && $default_path ) { |
|
150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
149 | + if (!$template && $default_path) { |
|
150 | + $template = trailingslashit($default_path) . $template_name; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Return what we found. |
154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
162 | + if (isset($name)) |
|
163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
164 | 164 | $templates[] = $slug . '.php'; |
165 | 165 | |
166 | 166 | // Allow template parts to be filtered |
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
168 | 168 | |
169 | 169 | // Return the part that is found |
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
171 | 171 | } |
172 | 172 | |
173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
174 | 174 | // No file found yet |
175 | 175 | $located = false; |
176 | 176 | |
177 | 177 | // Try to find a template file |
178 | - foreach ( (array)$template_names as $template_name ) { |
|
178 | + foreach ((array)$template_names as $template_name) { |
|
179 | 179 | |
180 | 180 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
181 | + if (empty($template_name)) |
|
182 | 182 | continue; |
183 | 183 | |
184 | 184 | // Trim off any slashes from the template name |
185 | - $template_name = ltrim( $template_name, '/' ); |
|
185 | + $template_name = ltrim($template_name, '/'); |
|
186 | 186 | |
187 | 187 | // try locating this template file by looping through the template paths |
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
190 | + if (file_exists($template_path . $template_name)) { |
|
191 | 191 | $located = $template_path . $template_name; |
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
196 | + if (!empty($located)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ((true == $load) && !empty($located)) |
|
202 | + load_template($located, $require_once); |
|
203 | 203 | |
204 | 204 | return $located; |
205 | 205 | } |
@@ -208,149 +208,149 @@ discard block |
||
208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
209 | 209 | |
210 | 210 | $file_paths = array( |
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
213 | 213 | 100 => wpinv_get_templates_dir() |
214 | 214 | ); |
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
217 | 217 | |
218 | 218 | // sort the file paths based on priority |
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
219 | + ksort($file_paths, SORT_NUMERIC); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map('trailingslashit', $file_paths); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | 230 | $pages = array(); |
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
231 | + $pages[] = wpinv_get_option('success_page'); |
|
232 | + $pages[] = wpinv_get_option('failure_page'); |
|
233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
241 | 241 | } |
242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
243 | 243 | |
244 | -function wpinv_add_body_classes( $class ) { |
|
244 | +function wpinv_add_body_classes($class) { |
|
245 | 245 | $classes = (array)$class; |
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
247 | + if (wpinv_is_checkout()) { |
|
248 | 248 | $classes[] = 'wpinv-checkout'; |
249 | 249 | $classes[] = 'wpinv-page'; |
250 | 250 | } |
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
252 | + if (wpinv_is_success_page()) { |
|
253 | 253 | $classes[] = 'wpinv-success'; |
254 | 254 | $classes[] = 'wpinv-page'; |
255 | 255 | } |
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
257 | + if (wpinv_is_failed_transaction_page()) { |
|
258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
259 | 259 | $classes[] = 'wpinv-page'; |
260 | 260 | } |
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
262 | + if (wpinv_is_invoice_history_page()) { |
|
263 | 263 | $classes[] = 'wpinv-history'; |
264 | 264 | $classes[] = 'wpinv-page'; |
265 | 265 | } |
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
267 | + if (wpinv_is_subscriptions_history_page()) { |
|
268 | 268 | $classes[] = 'wpinv-subscription'; |
269 | 269 | $classes[] = 'wpinv-page'; |
270 | 270 | } |
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
272 | + if (wpinv_is_test_mode()) { |
|
273 | 273 | $classes[] = 'wpinv-test-mode'; |
274 | 274 | $classes[] = 'wpinv-page'; |
275 | 275 | } |
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique($classes); |
|
278 | 278 | } |
279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
280 | 280 | |
281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
282 | - $args = array( 'nopaging' => true ); |
|
281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
282 | + $args = array('nopaging' => true); |
|
283 | 283 | |
284 | - if ( ! empty( $status ) ) |
|
284 | + if (!empty($status)) |
|
285 | 285 | $args['post_status'] = $status; |
286 | 286 | |
287 | - $discounts = wpinv_get_discounts( $args ); |
|
287 | + $discounts = wpinv_get_discounts($args); |
|
288 | 288 | $options = array(); |
289 | 289 | |
290 | - if ( $discounts ) { |
|
291 | - foreach ( $discounts as $discount ) { |
|
292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
290 | + if ($discounts) { |
|
291 | + foreach ($discounts as $discount) { |
|
292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
293 | 293 | } |
294 | 294 | } else { |
295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
296 | 296 | } |
297 | 297 | |
298 | - $output = wpinv_html_select( array( |
|
298 | + $output = wpinv_html_select(array( |
|
299 | 299 | 'name' => $name, |
300 | 300 | 'selected' => $selected, |
301 | 301 | 'options' => $options, |
302 | 302 | 'show_option_all' => false, |
303 | 303 | 'show_option_none' => false, |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | |
306 | 306 | return $output; |
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
310 | - $current = date( 'Y' ); |
|
311 | - $start_year = $current - absint( $years_before ); |
|
312 | - $end_year = $current + absint( $years_after ); |
|
313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
310 | + $current = date('Y'); |
|
311 | + $start_year = $current - absint($years_before); |
|
312 | + $end_year = $current + absint($years_after); |
|
313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
314 | 314 | $options = array(); |
315 | 315 | |
316 | - while ( $start_year <= $end_year ) { |
|
317 | - $options[ absint( $start_year ) ] = $start_year; |
|
316 | + while ($start_year <= $end_year) { |
|
317 | + $options[absint($start_year)] = $start_year; |
|
318 | 318 | $start_year++; |
319 | 319 | } |
320 | 320 | |
321 | - $output = wpinv_html_select( array( |
|
321 | + $output = wpinv_html_select(array( |
|
322 | 322 | 'name' => $name, |
323 | 323 | 'selected' => $selected, |
324 | 324 | 'options' => $options, |
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | 329 | return $output; |
330 | 330 | } |
331 | 331 | |
332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
333 | 333 | $month = 1; |
334 | 334 | $options = array(); |
335 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
335 | + $selected = empty($selected) ? date('n') : $selected; |
|
336 | 336 | |
337 | - while ( $month <= 12 ) { |
|
338 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
337 | + while ($month <= 12) { |
|
338 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
339 | 339 | $month++; |
340 | 340 | } |
341 | 341 | |
342 | - $output = wpinv_html_select( array( |
|
342 | + $output = wpinv_html_select(array( |
|
343 | 343 | 'name' => $name, |
344 | 344 | 'selected' => $selected, |
345 | 345 | 'options' => $options, |
346 | 346 | 'show_option_all' => false, |
347 | 347 | 'show_option_none' => false |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | |
350 | 350 | return $output; |
351 | 351 | } |
352 | 352 | |
353 | -function wpinv_html_select( $args = array() ) { |
|
353 | +function wpinv_html_select($args = array()) { |
|
354 | 354 | $defaults = array( |
355 | 355 | 'options' => array(), |
356 | 356 | 'name' => null, |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | 'selected' => 0, |
360 | 360 | 'placeholder' => null, |
361 | 361 | 'multiple' => false, |
362 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
363 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
362 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
363 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
364 | 364 | 'data' => array(), |
365 | 365 | 'onchange' => null, |
366 | 366 | 'required' => false, |
@@ -368,74 +368,74 @@ discard block |
||
368 | 368 | 'readonly' => false, |
369 | 369 | ); |
370 | 370 | |
371 | - $args = wp_parse_args( $args, $defaults ); |
|
371 | + $args = wp_parse_args($args, $defaults); |
|
372 | 372 | |
373 | 373 | $data_elements = ''; |
374 | - foreach ( $args['data'] as $key => $value ) { |
|
375 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
374 | + foreach ($args['data'] as $key => $value) { |
|
375 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
376 | 376 | } |
377 | 377 | |
378 | - if( $args['multiple'] ) { |
|
378 | + if ($args['multiple']) { |
|
379 | 379 | $multiple = ' MULTIPLE'; |
380 | 380 | } else { |
381 | 381 | $multiple = ''; |
382 | 382 | } |
383 | 383 | |
384 | - if( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | $options = ''; |
391 | - if( !empty( $args['onchange'] ) ) { |
|
392 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
391 | + if (!empty($args['onchange'])) { |
|
392 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
393 | 393 | } |
394 | 394 | |
395 | - if( !empty( $args['required'] ) ) { |
|
395 | + if (!empty($args['required'])) { |
|
396 | 396 | $options .= ' required="required"'; |
397 | 397 | } |
398 | 398 | |
399 | - if( !empty( $args['disabled'] ) ) { |
|
399 | + if (!empty($args['disabled'])) { |
|
400 | 400 | $options .= ' disabled'; |
401 | 401 | } |
402 | 402 | |
403 | - if( !empty( $args['readonly'] ) ) { |
|
403 | + if (!empty($args['readonly'])) { |
|
404 | 404 | $options .= ' readonly'; |
405 | 405 | } |
406 | 406 | |
407 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
408 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
407 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
408 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
409 | 409 | |
410 | - if ( $args['show_option_all'] ) { |
|
411 | - if( $args['multiple'] ) { |
|
412 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
410 | + if ($args['show_option_all']) { |
|
411 | + if ($args['multiple']) { |
|
412 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
413 | 413 | } else { |
414 | - $selected = selected( $args['selected'], 0, false ); |
|
414 | + $selected = selected($args['selected'], 0, false); |
|
415 | 415 | } |
416 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
416 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( !empty( $args['options'] ) ) { |
|
419 | + if (!empty($args['options'])) { |
|
420 | 420 | |
421 | - if ( $args['show_option_none'] ) { |
|
422 | - if( $args['multiple'] ) { |
|
423 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
421 | + if ($args['show_option_none']) { |
|
422 | + if ($args['multiple']) { |
|
423 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
424 | 424 | } else { |
425 | - $selected = selected( $args['selected'] === "", true, false ); |
|
425 | + $selected = selected($args['selected'] === "", true, false); |
|
426 | 426 | } |
427 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
427 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
428 | 428 | } |
429 | 429 | |
430 | - foreach( $args['options'] as $key => $option ) { |
|
430 | + foreach ($args['options'] as $key => $option) { |
|
431 | 431 | |
432 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
433 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
432 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
433 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
434 | 434 | } else { |
435 | - $selected = selected( $args['selected'], $key, false ); |
|
435 | + $selected = selected($args['selected'], $key, false); |
|
436 | 436 | } |
437 | 437 | |
438 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
438 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | return $output; |
445 | 445 | } |
446 | 446 | |
447 | -function wpinv_item_dropdown( $args = array() ) { |
|
447 | +function wpinv_item_dropdown($args = array()) { |
|
448 | 448 | $defaults = array( |
449 | 449 | 'name' => 'wpi_item', |
450 | 450 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | 'multiple' => false, |
453 | 453 | 'selected' => 0, |
454 | 454 | 'number' => 100, |
455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
456 | - 'data' => array( 'search-type' => 'item' ), |
|
455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
456 | + 'data' => array('search-type' => 'item'), |
|
457 | 457 | 'show_option_all' => false, |
458 | 458 | 'show_option_none' => false, |
459 | 459 | 'show_recurring' => false, |
460 | 460 | ); |
461 | 461 | |
462 | - $args = wp_parse_args( $args, $defaults ); |
|
462 | + $args = wp_parse_args($args, $defaults); |
|
463 | 463 | |
464 | 464 | $item_args = array( |
465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
468 | 468 | 'posts_per_page' => $args['number'] |
469 | 469 | ); |
470 | 470 | |
471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
472 | 472 | |
473 | - $items = get_posts( $item_args ); |
|
473 | + $items = get_posts($item_args); |
|
474 | 474 | $options = array(); |
475 | - if ( $items ) { |
|
476 | - foreach ( $items as $item ) { |
|
477 | - $title = esc_html( $item->post_title ); |
|
475 | + if ($items) { |
|
476 | + foreach ($items as $item) { |
|
477 | + $title = esc_html($item->post_title); |
|
478 | 478 | |
479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
479 | + if (!empty($args['show_recurring'])) { |
|
480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
481 | 481 | } |
482 | 482 | |
483 | - $options[ absint( $item->ID ) ] = $title; |
|
483 | + $options[absint($item->ID)] = $title; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | // This ensures that any selected items are included in the drop down |
488 | - if( is_array( $args['selected'] ) ) { |
|
489 | - foreach( $args['selected'] as $item ) { |
|
490 | - if( ! in_array( $item, $options ) ) { |
|
491 | - $title = get_the_title( $item ); |
|
492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
488 | + if (is_array($args['selected'])) { |
|
489 | + foreach ($args['selected'] as $item) { |
|
490 | + if (!in_array($item, $options)) { |
|
491 | + $title = get_the_title($item); |
|
492 | + if (!empty($args['show_recurring'])) { |
|
493 | + $title .= wpinv_get_item_suffix($item, false); |
|
494 | 494 | } |
495 | 495 | $options[$item] = $title; |
496 | 496 | } |
497 | 497 | } |
498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
500 | - $title = get_the_title( $args['selected'] ); |
|
501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
499 | + if (!in_array($args['selected'], $options)) { |
|
500 | + $title = get_the_title($args['selected']); |
|
501 | + if (!empty($args['show_recurring'])) { |
|
502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
503 | 503 | } |
504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $output = wpinv_html_select( array( |
|
508 | + $output = wpinv_html_select(array( |
|
509 | 509 | 'name' => $args['name'], |
510 | 510 | 'selected' => $args['selected'], |
511 | 511 | 'id' => $args['id'], |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | 'show_option_all' => $args['show_option_all'], |
517 | 517 | 'show_option_none' => $args['show_option_none'], |
518 | 518 | 'data' => $args['data'], |
519 | - ) ); |
|
519 | + )); |
|
520 | 520 | |
521 | 521 | return $output; |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_html_checkbox( $args = array() ) { |
|
524 | +function wpinv_html_checkbox($args = array()) { |
|
525 | 525 | $defaults = array( |
526 | 526 | 'name' => null, |
527 | 527 | 'current' => null, |
@@ -532,38 +532,38 @@ discard block |
||
532 | 532 | ) |
533 | 533 | ); |
534 | 534 | |
535 | - $args = wp_parse_args( $args, $defaults ); |
|
535 | + $args = wp_parse_args($args, $defaults); |
|
536 | 536 | |
537 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
537 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
538 | 538 | $options = ''; |
539 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
539 | + if (!empty($args['options']['disabled'])) { |
|
540 | 540 | $options .= ' disabled="disabled"'; |
541 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
541 | + } elseif (!empty($args['options']['readonly'])) { |
|
542 | 542 | $options .= ' readonly'; |
543 | 543 | } |
544 | 544 | |
545 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
545 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
549 | 549 | |
550 | -function wpinv_html_text( $args = array() ) { |
|
550 | +function wpinv_html_text($args = array()) { |
|
551 | 551 | // Backwards compatibility |
552 | - if ( func_num_args() > 1 ) { |
|
552 | + if (func_num_args() > 1) { |
|
553 | 553 | $args = func_get_args(); |
554 | 554 | |
555 | 555 | $name = $args[0]; |
556 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
557 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
558 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
556 | + $value = isset($args[1]) ? $args[1] : ''; |
|
557 | + $label = isset($args[2]) ? $args[2] : ''; |
|
558 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | $defaults = array( |
562 | 562 | 'id' => '', |
563 | - 'name' => isset( $name ) ? $name : 'text', |
|
564 | - 'value' => isset( $value ) ? $value : null, |
|
565 | - 'label' => isset( $label ) ? $label : null, |
|
566 | - 'desc' => isset( $desc ) ? $desc : null, |
|
563 | + 'name' => isset($name) ? $name : 'text', |
|
564 | + 'value' => isset($value) ? $value : null, |
|
565 | + 'label' => isset($label) ? $label : null, |
|
566 | + 'desc' => isset($desc) ? $desc : null, |
|
567 | 567 | 'placeholder' => '', |
568 | 568 | 'class' => 'regular-text', |
569 | 569 | 'disabled' => false, |
@@ -573,51 +573,51 @@ discard block |
||
573 | 573 | 'data' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
578 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
579 | 579 | $options = ''; |
580 | - if( $args['required'] ) { |
|
580 | + if ($args['required']) { |
|
581 | 581 | $options .= ' required="required"'; |
582 | 582 | } |
583 | - if( $args['readonly'] ) { |
|
583 | + if ($args['readonly']) { |
|
584 | 584 | $options .= ' readonly'; |
585 | 585 | } |
586 | - if( $args['readonly'] ) { |
|
586 | + if ($args['readonly']) { |
|
587 | 587 | $options .= ' readonly'; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $data = ''; |
591 | - if ( !empty( $args['data'] ) ) { |
|
592 | - foreach ( $args['data'] as $key => $value ) { |
|
593 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
591 | + if (!empty($args['data'])) { |
|
592 | + foreach ($args['data'] as $key => $value) { |
|
593 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
598 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
599 | - if ( ! empty( $args['desc'] ) ) { |
|
600 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
597 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
598 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
599 | + if (!empty($args['desc'])) { |
|
600 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
601 | 601 | } |
602 | 602 | |
603 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
603 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
604 | 604 | |
605 | 605 | $output .= '</span>'; |
606 | 606 | |
607 | 607 | return $output; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_date_field( $args = array() ) { |
|
611 | - if( empty( $args['class'] ) ) { |
|
610 | +function wpinv_html_date_field($args = array()) { |
|
611 | + if (empty($args['class'])) { |
|
612 | 612 | $args['class'] = 'wpiDatepicker'; |
613 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
613 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
614 | 614 | $args['class'] .= ' wpiDatepicker'; |
615 | 615 | } |
616 | 616 | |
617 | - return wpinv_html_text( $args ); |
|
617 | + return wpinv_html_text($args); |
|
618 | 618 | } |
619 | 619 | |
620 | -function wpinv_html_textarea( $args = array() ) { |
|
620 | +function wpinv_html_textarea($args = array()) { |
|
621 | 621 | $defaults = array( |
622 | 622 | 'name' => 'textarea', |
623 | 623 | 'value' => null, |
@@ -627,31 +627,31 @@ discard block |
||
627 | 627 | 'disabled' => false |
628 | 628 | ); |
629 | 629 | |
630 | - $args = wp_parse_args( $args, $defaults ); |
|
630 | + $args = wp_parse_args($args, $defaults); |
|
631 | 631 | |
632 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
632 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
633 | 633 | $disabled = ''; |
634 | - if( $args['disabled'] ) { |
|
634 | + if ($args['disabled']) { |
|
635 | 635 | $disabled = ' disabled="disabled"'; |
636 | 636 | } |
637 | 637 | |
638 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
639 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
640 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
638 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
639 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
640 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
641 | 641 | |
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | $output .= '</span>'; |
646 | 646 | |
647 | 647 | return $output; |
648 | 648 | } |
649 | 649 | |
650 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
650 | +function wpinv_html_ajax_user_search($args = array()) { |
|
651 | 651 | $defaults = array( |
652 | 652 | 'name' => 'user_id', |
653 | 653 | 'value' => null, |
654 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
654 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
655 | 655 | 'label' => null, |
656 | 656 | 'desc' => null, |
657 | 657 | 'class' => '', |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | 'data' => false |
661 | 661 | ); |
662 | 662 | |
663 | - $args = wp_parse_args( $args, $defaults ); |
|
663 | + $args = wp_parse_args($args, $defaults); |
|
664 | 664 | |
665 | 665 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
666 | 666 | |
667 | 667 | $output = '<span class="wpinv_user_search_wrap">'; |
668 | - $output .= wpinv_html_text( $args ); |
|
669 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
668 | + $output .= wpinv_html_text($args); |
|
669 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
670 | 670 | $output .= '</span>'; |
671 | 671 | |
672 | 672 | return $output; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function wpinv_ip_geolocation() { |
676 | 676 | global $wpinv_euvat; |
677 | 677 | |
678 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
678 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
679 | 679 | $content = ''; |
680 | 680 | $iso = ''; |
681 | 681 | $country = ''; |
@@ -686,69 +686,69 @@ discard block |
||
686 | 686 | $credit = ''; |
687 | 687 | $address = ''; |
688 | 688 | |
689 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
689 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
690 | 690 | try { |
691 | 691 | $iso = $geoip2_city->country->isoCode; |
692 | 692 | $country = $geoip2_city->country->name; |
693 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
693 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
694 | 694 | $city = $geoip2_city->city->name; |
695 | 695 | $longitude = $geoip2_city->location->longitude; |
696 | 696 | $latitude = $geoip2_city->location->latitude; |
697 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
698 | - } catch( Exception $e ) { } |
|
697 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
698 | + } catch (Exception $e) { } |
|
699 | 699 | } |
700 | 700 | |
701 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
701 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
702 | 702 | try { |
703 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
703 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
704 | 704 | |
705 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
705 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
706 | 706 | $iso = $load_xml->geoplugin_countryCode; |
707 | 707 | $country = $load_xml->geoplugin_countryName; |
708 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
709 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
708 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
709 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
710 | 710 | $longitude = $load_xml->geoplugin_longitude; |
711 | 711 | $latitude = $load_xml->geoplugin_latitude; |
712 | 712 | $credit = $load_xml->geoplugin_credit; |
713 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
713 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
714 | 714 | } |
715 | - } catch( Exception $e ) { } |
|
715 | + } catch (Exception $e) { } |
|
716 | 716 | } |
717 | 717 | |
718 | - if ( $iso && $longitude && $latitude ) { |
|
719 | - if ( $city ) { |
|
718 | + if ($iso && $longitude && $latitude) { |
|
719 | + if ($city) { |
|
720 | 720 | $address .= $city . ', '; |
721 | 721 | } |
722 | 722 | |
723 | - if ( $region ) { |
|
723 | + if ($region) { |
|
724 | 724 | $address .= $region . ', '; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $address .= $country . ' (' . $iso . ')'; |
728 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
729 | - $content .= '<p>'. $credit . '</p>'; |
|
728 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
729 | + $content .= '<p>' . $credit . '</p>'; |
|
730 | 730 | } else { |
731 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
731 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
732 | 732 | } |
733 | 733 | ?> |
734 | 734 | <!DOCTYPE html> |
735 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
735 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
736 | 736 | <body> |
737 | - <?php if ( $latitude && $latitude ) { ?> |
|
737 | + <?php if ($latitude && $latitude) { ?> |
|
738 | 738 | <div id="map"></div> |
739 | 739 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
740 | 740 | <script type="text/javascript"> |
741 | 741 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
742 | 742 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
743 | 743 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
744 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
744 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
745 | 745 | |
746 | 746 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
747 | 747 | |
748 | 748 | var marker = new L.Marker(latlng); |
749 | 749 | map.addLayer(marker); |
750 | 750 | |
751 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
751 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
752 | 752 | </script> |
753 | 753 | <?php } ?> |
754 | 754 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | <?php |
757 | 757 | exit; |
758 | 758 | } |
759 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
760 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
759 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
760 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
761 | 761 | |
762 | 762 | // Set up the template for the invoice. |
763 | -function wpinv_template( $template ) { |
|
763 | +function wpinv_template($template) { |
|
764 | 764 | global $post, $wp_query; |
765 | 765 | |
766 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
767 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
768 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
766 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
767 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
768 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
769 | 769 | } else { |
770 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
770 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | function wpinv_get_business_address() { |
778 | 778 | $business_address = wpinv_store_address(); |
779 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
779 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
780 | 780 | |
781 | 781 | /* |
782 | 782 | $default_country = wpinv_get_default_country(); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | |
801 | 801 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
802 | 802 | |
803 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
803 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | function wpinv_display_from_address() { |
@@ -810,192 +810,192 @@ discard block |
||
810 | 810 | if (empty($from_name)) { |
811 | 811 | $from_name = wpinv_get_business_name(); |
812 | 812 | } |
813 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
813 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
814 | 814 | <div class="wrapper col-xs-10"> |
815 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
816 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
817 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
815 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
816 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
817 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
818 | 818 | <?php } ?> |
819 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
820 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
819 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
820 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
821 | 821 | <?php } ?> |
822 | 822 | </div> |
823 | 823 | <?php |
824 | 824 | } |
825 | 825 | |
826 | -function wpinv_watermark( $id = 0 ) { |
|
827 | - $output = wpinv_get_watermark( $id ); |
|
826 | +function wpinv_watermark($id = 0) { |
|
827 | + $output = wpinv_get_watermark($id); |
|
828 | 828 | |
829 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
829 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_get_watermark( $id ) { |
|
833 | - if ( !$id > 0 ) { |
|
832 | +function wpinv_get_watermark($id) { |
|
833 | + if (!$id > 0) { |
|
834 | 834 | return NULL; |
835 | 835 | } |
836 | - $invoice = wpinv_get_invoice( $id ); |
|
836 | + $invoice = wpinv_get_invoice($id); |
|
837 | 837 | |
838 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
839 | - if ( $invoice->is_paid() ) { |
|
840 | - return __( 'Paid', 'invoicing' ); |
|
838 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
839 | + if ($invoice->is_paid()) { |
|
840 | + return __('Paid', 'invoicing'); |
|
841 | 841 | } |
842 | - if ( $invoice->is_refunded() ) { |
|
843 | - return __( 'Refunded', 'invoicing' ); |
|
842 | + if ($invoice->is_refunded()) { |
|
843 | + return __('Refunded', 'invoicing'); |
|
844 | 844 | } |
845 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
846 | - return __( 'Cancelled', 'invoicing' ); |
|
845 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
846 | + return __('Cancelled', 'invoicing'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | 850 | return NULL; |
851 | 851 | } |
852 | 852 | |
853 | -function wpinv_display_invoice_details( $invoice ) { |
|
853 | +function wpinv_display_invoice_details($invoice) { |
|
854 | 854 | global $wpinv_euvat; |
855 | 855 | |
856 | 856 | $invoice_id = $invoice->ID; |
857 | 857 | $vat_name = $wpinv_euvat->get_vat_name(); |
858 | 858 | $use_taxes = wpinv_use_taxes(); |
859 | 859 | |
860 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
860 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
861 | 861 | ?> |
862 | 862 | <table class="table table-bordered table-sm"> |
863 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
863 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
864 | 864 | <tr class="wpi-row-number"> |
865 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
866 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
865 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
866 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
867 | 867 | </tr> |
868 | 868 | <?php } ?> |
869 | 869 | <tr class="wpi-row-status"> |
870 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
871 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
870 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
871 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
872 | 872 | </tr> |
873 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
873 | + <?php if ($invoice->is_renewal()) { ?> |
|
874 | 874 | <tr class="wpi-row-parent"> |
875 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
876 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
875 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
876 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
877 | 877 | </tr> |
878 | 878 | <?php } ?> |
879 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
879 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
880 | 880 | <tr class="wpi-row-gateway"> |
881 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
881 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
882 | 882 | <td><?php echo $gateway_name; ?></td> |
883 | 883 | </tr> |
884 | 884 | <?php } ?> |
885 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
885 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
886 | 886 | <tr class="wpi-row-date"> |
887 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
887 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
888 | 888 | <td><?php echo $invoice_date; ?></td> |
889 | 889 | </tr> |
890 | 890 | <?php } ?> |
891 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
891 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
892 | 892 | <tr class="wpi-row-date"> |
893 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
893 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
894 | 894 | <td><?php echo $due_date; ?></td> |
895 | 895 | </tr> |
896 | 896 | <?php } ?> |
897 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
898 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
897 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
898 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
899 | 899 | <tr class="wpi-row-ovatno"> |
900 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
900 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
901 | 901 | <td><?php echo $owner_vat_number; ?></td> |
902 | 902 | </tr> |
903 | 903 | <?php } ?> |
904 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
904 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
906 | 906 | <tr class="wpi-row-uvatno"> |
907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
908 | 908 | <td><?php echo $user_vat_number; ?></td> |
909 | 909 | </tr> |
910 | 910 | <?php } ?> |
911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
914 | 914 | </tr> |
915 | 915 | </table> |
916 | 916 | <?php |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
921 | 921 | |
922 | - if ( empty( $invoice ) ) { |
|
922 | + if (empty($invoice)) { |
|
923 | 923 | return NULL; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $billing_details = $invoice->get_user_info(); |
927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
929 | 929 | |
930 | 930 | ob_start(); |
931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
932 | 932 | $output .= ob_get_clean(); |
933 | 933 | |
934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
935 | - if ( $company = $billing_details['company'] ) { |
|
936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
935 | + if ($company = $billing_details['company']) { |
|
936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
937 | 937 | } |
938 | 938 | $address_row = ''; |
939 | - if ( $address = $billing_details['address'] ) { |
|
940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
939 | + if ($address = $billing_details['address']) { |
|
940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | $address_fields = array(); |
944 | - if ( !empty( $billing_details['city'] ) ) { |
|
944 | + if (!empty($billing_details['city'])) { |
|
945 | 945 | $address_fields[] = $billing_details['city']; |
946 | 946 | } |
947 | 947 | |
948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
949 | - if ( !empty( $billing_details['state'] ) ) { |
|
950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
949 | + if (!empty($billing_details['state'])) { |
|
950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
951 | 951 | } |
952 | 952 | |
953 | - if ( !empty( $billing_country ) ) { |
|
954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
953 | + if (!empty($billing_country)) { |
|
954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( !empty( $address_fields ) ) { |
|
958 | - $address_fields = implode( ", ", $address_fields ); |
|
957 | + if (!empty($address_fields)) { |
|
958 | + $address_fields = implode(", ", $address_fields); |
|
959 | 959 | |
960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
960 | + if (!empty($billing_details['zip'])) { |
|
961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
962 | 962 | } |
963 | 963 | |
964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
965 | 965 | } |
966 | 966 | |
967 | - if ( $address_row ) { |
|
967 | + if ($address_row) { |
|
968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
969 | 969 | } |
970 | 970 | |
971 | - if ( $phone = $invoice->get_phone() ) { |
|
972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
971 | + if ($phone = $invoice->get_phone()) { |
|
972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
973 | 973 | } |
974 | - if ( $email = $invoice->get_email() ) { |
|
975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
974 | + if ($email = $invoice->get_email()) { |
|
975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | ob_start(); |
979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
980 | 980 | $output .= ob_get_clean(); |
981 | 981 | |
982 | 982 | $output .= '</div>'; |
983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
984 | 984 | |
985 | 985 | echo $output; |
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
992 | 992 | $use_taxes = wpinv_use_taxes(); |
993 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
993 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
994 | 994 | $use_taxes = true; |
995 | 995 | } |
996 | 996 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
997 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
998 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
997 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
998 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
999 | 999 | |
1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
1001 | 1001 | $ajax_cart_details = $cart_details; |
@@ -1004,67 +1004,67 @@ discard block |
||
1004 | 1004 | <table class="table table-sm table-bordered table-responsive"> |
1005 | 1005 | <thead> |
1006 | 1006 | <tr> |
1007 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1008 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1007 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1008 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1009 | 1009 | <?php if ($quantities_enabled) { ?> |
1010 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1010 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1011 | 1011 | <?php } ?> |
1012 | 1012 | <?php if ($use_taxes && !$zero_tax) { ?> |
1013 | 1013 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1014 | 1014 | <?php } ?> |
1015 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1015 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1016 | 1016 | </tr> |
1017 | 1017 | </thead> |
1018 | 1018 | <tbody> |
1019 | 1019 | <?php |
1020 | - if ( !empty( $cart_details ) ) { |
|
1021 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1020 | + if (!empty($cart_details)) { |
|
1021 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1022 | 1022 | |
1023 | 1023 | $count = 0; |
1024 | 1024 | $cols = 3; |
1025 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1026 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1027 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1028 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1029 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1025 | + foreach ($cart_details as $key => $cart_item) { |
|
1026 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1027 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1028 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1029 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1030 | 1030 | |
1031 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1031 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1032 | 1032 | $summary = ''; |
1033 | - $item_name = ''; |
|
1033 | + $item_name = ''; |
|
1034 | 1034 | $cols = 3; |
1035 | - if ( !empty($item) ) { |
|
1035 | + if (!empty($item)) { |
|
1036 | 1036 | $item_name = $item->get_name(); |
1037 | 1037 | $summary = $item->get_summary(); |
1038 | 1038 | } |
1039 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1039 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1040 | 1040 | |
1041 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1041 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1042 | 1042 | |
1043 | 1043 | $item_tax = ''; |
1044 | 1044 | $tax_rate = ''; |
1045 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1046 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1047 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1048 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1045 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1046 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1047 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1048 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1049 | 1049 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | $line_item_tax = $item_tax . $tax_rate; |
1053 | 1053 | |
1054 | - if ( $line_item_tax === '' ) { |
|
1054 | + if ($line_item_tax === '') { |
|
1055 | 1055 | $line_item_tax = 0; // Zero tax |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
1058 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
1059 | 1059 | |
1060 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1061 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1062 | - if ( $summary !== '' ) { |
|
1063 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1060 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1061 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1062 | + if ($summary !== '') { |
|
1063 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1064 | 1064 | } |
1065 | 1065 | $line_item .= '</td>'; |
1066 | 1066 | |
1067 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1067 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1068 | 1068 | if ($quantities_enabled) { |
1069 | 1069 | $cols++; |
1070 | 1070 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1073,55 +1073,55 @@ discard block |
||
1073 | 1073 | $cols++; |
1074 | 1074 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1075 | 1075 | } |
1076 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1076 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1077 | 1077 | $line_item .= '</tr>'; |
1078 | 1078 | |
1079 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1079 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1080 | 1080 | |
1081 | 1081 | $count++; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1084 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1085 | 1085 | ?> |
1086 | 1086 | <tr class="row-sub-total row_odd"> |
1087 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1088 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1087 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1088 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1089 | 1089 | </tr> |
1090 | 1090 | <?php |
1091 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1091 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1092 | 1092 | |
1093 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1094 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1093 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1094 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1095 | 1095 | ?> |
1096 | 1096 | <tr class="row-discount"> |
1097 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1098 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1097 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1098 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1099 | 1099 | </tr> |
1100 | 1100 | <?php |
1101 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1101 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( $use_taxes ) { |
|
1105 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1104 | + if ($use_taxes) { |
|
1105 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1106 | 1106 | ?> |
1107 | 1107 | <tr class="row-tax"> |
1108 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1109 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1108 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1109 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1110 | 1110 | </tr> |
1111 | 1111 | <?php |
1112 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1112 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1115 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1116 | 1116 | ?> |
1117 | 1117 | <tr class="table-active row-total"> |
1118 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1119 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1118 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1119 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1120 | 1120 | </tr> |
1121 | 1121 | <?php |
1122 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1122 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1123 | 1123 | |
1124 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1124 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1125 | 1125 | } |
1126 | 1126 | ?> |
1127 | 1127 | </tbody> |
@@ -1130,35 +1130,35 @@ discard block |
||
1130 | 1130 | echo ob_get_clean(); |
1131 | 1131 | } |
1132 | 1132 | |
1133 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1133 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1134 | 1134 | $use_taxes = wpinv_use_taxes(); |
1135 | 1135 | |
1136 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1136 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1137 | 1137 | ?> |
1138 | 1138 | <table class="table table-sm table-bordered table-responsive"> |
1139 | 1139 | <tbody> |
1140 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1140 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1141 | 1141 | <tr class="row-sub-total"> |
1142 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1143 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1142 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1143 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1144 | 1144 | </tr> |
1145 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1146 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1145 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1146 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1147 | 1147 | <tr class="row-discount"> |
1148 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1149 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1148 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1149 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1150 | 1150 | </tr> |
1151 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1151 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1152 | 1152 | <?php } ?> |
1153 | - <?php if ( $use_taxes ) { ?> |
|
1153 | + <?php if ($use_taxes) { ?> |
|
1154 | 1154 | <tr class="row-tax"> |
1155 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1156 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1155 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1156 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1157 | 1157 | </tr> |
1158 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1158 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1159 | 1159 | <?php } ?> |
1160 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1161 | - <?php foreach ( $fees as $fee ) { ?> |
|
1160 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1161 | + <?php foreach ($fees as $fee) { ?> |
|
1162 | 1162 | <tr class="row-fee"> |
1163 | 1163 | <td class="rate"><?php echo $fee['label']; ?></td> |
1164 | 1164 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1166,82 +1166,82 @@ discard block |
||
1166 | 1166 | <?php } ?> |
1167 | 1167 | <?php } ?> |
1168 | 1168 | <tr class="table-active row-total"> |
1169 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1170 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1169 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1170 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1171 | 1171 | </tr> |
1172 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1172 | + <?php do_action('wpinv_after_totals'); ?> |
|
1173 | 1173 | </tbody> |
1174 | 1174 | |
1175 | 1175 | </table> |
1176 | 1176 | |
1177 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1177 | + <?php do_action('wpinv_after_totals_table'); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1181 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1180 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1181 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1182 | 1182 | |
1183 | 1183 | ob_start(); |
1184 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1185 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1184 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1185 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1186 | 1186 | ?> |
1187 | 1187 | <div class="wpi-payment-info"> |
1188 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1189 | - <?php if ( $gateway_title ) { ?> |
|
1190 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1188 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1189 | + <?php if ($gateway_title) { ?> |
|
1190 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1191 | 1191 | <?php } ?> |
1192 | 1192 | </div> |
1193 | 1193 | <?php |
1194 | 1194 | } |
1195 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1195 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1196 | 1196 | $outout = ob_get_clean(); |
1197 | 1197 | |
1198 | - if ( $echo ) { |
|
1198 | + if ($echo) { |
|
1199 | 1199 | echo $outout; |
1200 | 1200 | } else { |
1201 | 1201 | return $outout; |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | 1204 | |
1205 | -function wpinv_display_style( $invoice ) { |
|
1206 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1205 | +function wpinv_display_style($invoice) { |
|
1206 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1207 | 1207 | |
1208 | - wp_print_styles( 'open-sans' ); |
|
1209 | - wp_print_styles( 'wpinv-single-style' ); |
|
1208 | + wp_print_styles('open-sans'); |
|
1209 | + wp_print_styles('wpinv-single-style'); |
|
1210 | 1210 | |
1211 | 1211 | $custom_css = wpinv_get_option('template_custom_css'); |
1212 | - if(isset($custom_css) && !empty($custom_css)){ |
|
1213 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1214 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1212 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1213 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1214 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1215 | 1215 | echo '<style type="text/css">'; |
1216 | 1216 | echo $custom_css; |
1217 | 1217 | echo '</style>'; |
1218 | 1218 | } |
1219 | 1219 | } |
1220 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1221 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1220 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1221 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1222 | 1222 | |
1223 | 1223 | function wpinv_checkout_billing_details() { |
1224 | 1224 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1225 | 1225 | if (empty($invoice_id)) { |
1226 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1226 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1227 | 1227 | return null; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1230 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1231 | 1231 | if (empty($invoice)) { |
1232 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1232 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1233 | 1233 | return null; |
1234 | 1234 | } |
1235 | 1235 | $user_id = $invoice->get_user_id(); |
1236 | 1236 | $user_info = $invoice->get_user_info(); |
1237 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1237 | + $address_info = wpinv_get_user_address($user_id); |
|
1238 | 1238 | |
1239 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1239 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1240 | 1240 | $user_info['first_name'] = $user_info['first_name']; |
1241 | 1241 | $user_info['last_name'] = $user_info['last_name']; |
1242 | 1242 | } |
1243 | 1243 | |
1244 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1244 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1245 | 1245 | $user_info['country'] = $address_info['country']; |
1246 | 1246 | $user_info['state'] = $address_info['state']; |
1247 | 1247 | $user_info['city'] = $address_info['city']; |
@@ -1257,98 +1257,98 @@ discard block |
||
1257 | 1257 | 'address' |
1258 | 1258 | ); |
1259 | 1259 | |
1260 | - foreach ( $address_fields as $field ) { |
|
1261 | - if ( empty( $user_info[$field] ) ) { |
|
1260 | + foreach ($address_fields as $field) { |
|
1261 | + if (empty($user_info[$field])) { |
|
1262 | 1262 | $user_info[$field] = $address_info[$field]; |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1266 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | function wpinv_admin_get_line_items($invoice = array()) { |
1270 | 1270 | $item_quantities = wpinv_item_quantities_enabled(); |
1271 | 1271 | $use_taxes = wpinv_use_taxes(); |
1272 | 1272 | |
1273 | - if ( empty( $invoice ) ) { |
|
1273 | + if (empty($invoice)) { |
|
1274 | 1274 | return NULL; |
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | $cart_items = $invoice->get_cart_details(); |
1278 | - if ( empty( $cart_items ) ) { |
|
1278 | + if (empty($cart_items)) { |
|
1279 | 1279 | return NULL; |
1280 | 1280 | } |
1281 | 1281 | ob_start(); |
1282 | 1282 | |
1283 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1283 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1284 | 1284 | |
1285 | 1285 | $count = 0; |
1286 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1286 | + foreach ($cart_items as $key => $cart_item) { |
|
1287 | 1287 | $item_id = $cart_item['id']; |
1288 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1288 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1289 | 1289 | |
1290 | 1290 | if (empty($wpi_item)) { |
1291 | 1291 | continue; |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1295 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1296 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1294 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1295 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1296 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1297 | 1297 | $can_remove = true; |
1298 | 1298 | |
1299 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1299 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1300 | 1300 | |
1301 | 1301 | $item_tax = ''; |
1302 | 1302 | $tax_rate = ''; |
1303 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1304 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1305 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1306 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1303 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1304 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1305 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1306 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1307 | 1307 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1308 | 1308 | } |
1309 | 1309 | $line_item_tax = $item_tax . $tax_rate; |
1310 | 1310 | |
1311 | - if ( $line_item_tax === '' ) { |
|
1311 | + if ($line_item_tax === '') { |
|
1312 | 1312 | $line_item_tax = 0; // Zero tax |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1315 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1316 | 1316 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1317 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1318 | - if ( $summary !== '' ) { |
|
1319 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1317 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1318 | + if ($summary !== '') { |
|
1319 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1320 | 1320 | } |
1321 | 1321 | $line_item .= '</td>'; |
1322 | 1322 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1323 | 1323 | |
1324 | - if ( $item_quantities ) { |
|
1325 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1324 | + if ($item_quantities) { |
|
1325 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1326 | 1326 | $can_remove = false; |
1327 | 1327 | } |
1328 | 1328 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1329 | 1329 | } else { |
1330 | - if ( count( $cart_items ) == 1 ) { |
|
1330 | + if (count($cart_items) == 1) { |
|
1331 | 1331 | $can_remove = false; |
1332 | 1332 | } |
1333 | 1333 | } |
1334 | 1334 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1335 | 1335 | |
1336 | - if ( $use_taxes ) { |
|
1336 | + if ($use_taxes) { |
|
1337 | 1337 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1338 | 1338 | } |
1339 | 1339 | $line_item .= '<td class="action">'; |
1340 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1340 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1341 | 1341 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1342 | 1342 | } |
1343 | 1343 | $line_item .= '</td>'; |
1344 | 1344 | $line_item .= '</tr>'; |
1345 | 1345 | |
1346 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1346 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1347 | 1347 | |
1348 | 1348 | $count++; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1351 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1352 | 1352 | |
1353 | 1353 | return ob_get_clean(); |
1354 | 1354 | } |
@@ -1360,32 +1360,32 @@ discard block |
||
1360 | 1360 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1361 | 1361 | |
1362 | 1362 | //Maybe update the prices |
1363 | - if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) { |
|
1363 | + if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) { |
|
1364 | 1364 | |
1365 | 1365 | //If the invoice exists, update it with new pricing details |
1366 | - if (! empty( $wpi_checkout_id ) ) { |
|
1366 | + if (!empty($wpi_checkout_id)) { |
|
1367 | 1367 | |
1368 | 1368 | $_invoice = wpinv_get_invoice_cart(); |
1369 | 1369 | $_cart_details = $_invoice->get_cart_details(); |
1370 | - $_dynamic_item = sanitize_text_field( $_GET['wpi_dynamic_item'] ); |
|
1370 | + $_dynamic_item = sanitize_text_field($_GET['wpi_dynamic_item']); |
|
1371 | 1371 | |
1372 | 1372 | //First, fetch the item |
1373 | - $item = new WPInv_Item( $_dynamic_item ); |
|
1373 | + $item = new WPInv_Item($_dynamic_item); |
|
1374 | 1374 | |
1375 | 1375 | //Next, ensure it supports dynamic pricing... |
1376 | - if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) { |
|
1376 | + if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) { |
|
1377 | 1377 | |
1378 | 1378 | //... and that the new price is not lower than the minimum price |
1379 | - $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) ); |
|
1380 | - if( $_dynamic_price < $item->get_minimum_price() ) { |
|
1379 | + $_dynamic_price = (float)wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price'])); |
|
1380 | + if ($_dynamic_price < $item->get_minimum_price()) { |
|
1381 | 1381 | $_dynamic_price = $item->get_minimum_price(); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | //Finally, update our invoice with the new price |
1385 | - if ( !empty( $_cart_details ) ) { |
|
1385 | + if (!empty($_cart_details)) { |
|
1386 | 1386 | |
1387 | - foreach ( $_cart_details as $key => $item ) { |
|
1388 | - if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) { |
|
1387 | + foreach ($_cart_details as $key => $item) { |
|
1388 | + if (!empty($item['id']) && $_dynamic_item == $item['id']) { |
|
1389 | 1389 | $_cart_details[$key]['custom_price'] = $_dynamic_price; |
1390 | 1390 | $_cart_details[$key]['item_price'] = $_dynamic_price; |
1391 | 1391 | } |
@@ -1393,8 +1393,8 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | $_meta = $_invoice->get_meta(); |
1395 | 1395 | $_meta['cart_details'] = $_cart_details; |
1396 | - $_invoice->set( 'payment_meta', $_meta ); |
|
1397 | - $_invoice->set( 'cart_details', $_cart_details ); |
|
1396 | + $_invoice->set('payment_meta', $_meta); |
|
1397 | + $_invoice->set('cart_details', $_cart_details); |
|
1398 | 1398 | $_invoice->recalculate_totals(); |
1399 | 1399 | |
1400 | 1400 | } |
@@ -1405,58 +1405,58 @@ discard block |
||
1405 | 1405 | |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1408 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1409 | 1409 | |
1410 | 1410 | ob_start(); |
1411 | 1411 | echo '<div id="wpinv_checkout_wrap">'; |
1412 | 1412 | |
1413 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1413 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1414 | 1414 | ?> |
1415 | 1415 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1416 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1416 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1417 | 1417 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1418 | 1418 | <?php |
1419 | - do_action( 'wpinv_checkout_form_top' ); |
|
1420 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1421 | - do_action( 'wpinv_checkout_cart' ); |
|
1422 | - do_action( 'wpinv_payment_mode_select' ); |
|
1423 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1419 | + do_action('wpinv_checkout_form_top'); |
|
1420 | + do_action('wpinv_checkout_billing_info'); |
|
1421 | + do_action('wpinv_checkout_cart'); |
|
1422 | + do_action('wpinv_payment_mode_select'); |
|
1423 | + do_action('wpinv_checkout_form_bottom') |
|
1424 | 1424 | ?> |
1425 | 1425 | </form> |
1426 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1426 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1427 | 1427 | </div><!--end #wpinv_checkout_form_wrap--> |
1428 | 1428 | <?php |
1429 | 1429 | } else { |
1430 | - do_action( 'wpinv_cart_empty' ); |
|
1430 | + do_action('wpinv_cart_empty'); |
|
1431 | 1431 | } |
1432 | 1432 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1433 | 1433 | return ob_get_clean(); |
1434 | 1434 | } |
1435 | 1435 | |
1436 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1436 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1437 | 1437 | global $ajax_cart_details; |
1438 | 1438 | $ajax_cart_details = $cart_details; |
1439 | 1439 | |
1440 | 1440 | ob_start(); |
1441 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1441 | + do_action('wpinv_before_checkout_cart'); |
|
1442 | 1442 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1443 | 1443 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1444 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1444 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1445 | 1445 | echo '</div>'; |
1446 | 1446 | echo '</div>'; |
1447 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1447 | + do_action('wpinv_after_checkout_cart'); |
|
1448 | 1448 | $content = ob_get_clean(); |
1449 | 1449 | |
1450 | - if ( $echo ) { |
|
1450 | + if ($echo) { |
|
1451 | 1451 | echo $content; |
1452 | 1452 | } else { |
1453 | 1453 | return $content; |
1454 | 1454 | } |
1455 | 1455 | } |
1456 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1456 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1457 | 1457 | |
1458 | 1458 | function wpinv_empty_cart_message() { |
1459 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1459 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | /** |
@@ -1468,83 +1468,83 @@ discard block |
||
1468 | 1468 | function wpinv_empty_checkout_cart() { |
1469 | 1469 | echo wpinv_empty_cart_message(); |
1470 | 1470 | } |
1471 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1471 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1472 | 1472 | |
1473 | 1473 | function wpinv_update_cart_button() { |
1474 | - if ( !wpinv_item_quantities_enabled() ) |
|
1474 | + if (!wpinv_item_quantities_enabled()) |
|
1475 | 1475 | return; |
1476 | 1476 | ?> |
1477 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1477 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1478 | 1478 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1479 | 1479 | <?php |
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | function wpinv_checkout_cart_columns() { |
1483 | 1483 | $default = 3; |
1484 | - if ( wpinv_item_quantities_enabled() ) { |
|
1484 | + if (wpinv_item_quantities_enabled()) { |
|
1485 | 1485 | $default++; |
1486 | 1486 | } |
1487 | 1487 | |
1488 | - if ( wpinv_use_taxes() ) { |
|
1488 | + if (wpinv_use_taxes()) { |
|
1489 | 1489 | $default++; |
1490 | 1490 | } |
1491 | 1491 | |
1492 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1492 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | function wpinv_display_cart_messages() { |
1496 | 1496 | global $wpi_session; |
1497 | 1497 | |
1498 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1498 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1499 | 1499 | |
1500 | - if ( $messages ) { |
|
1501 | - foreach ( $messages as $message_id => $message ) { |
|
1500 | + if ($messages) { |
|
1501 | + foreach ($messages as $message_id => $message) { |
|
1502 | 1502 | // Try and detect what type of message this is |
1503 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1503 | + if (strpos(strtolower($message), 'error')) { |
|
1504 | 1504 | $type = 'error'; |
1505 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1505 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1506 | 1506 | $type = 'success'; |
1507 | 1507 | } else { |
1508 | 1508 | $type = 'info'; |
1509 | 1509 | } |
1510 | 1510 | |
1511 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1511 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1512 | 1512 | |
1513 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1513 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1514 | 1514 | // Loop message codes and display messages |
1515 | 1515 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1516 | 1516 | echo '</div>'; |
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | // Remove all of the cart saving messages |
1520 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1520 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1521 | 1521 | } |
1522 | 1522 | } |
1523 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1523 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1524 | 1524 | |
1525 | 1525 | function wpinv_discount_field() { |
1526 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1526 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1527 | 1527 | return; // Only show before a payment method has been selected if ajax is disabled |
1528 | 1528 | } |
1529 | 1529 | |
1530 | - if ( !wpinv_is_checkout() ) { |
|
1530 | + if (!wpinv_is_checkout()) { |
|
1531 | 1531 | return; |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1534 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1535 | 1535 | ?> |
1536 | 1536 | <div id="wpinv-discount-field" class="panel panel-default"> |
1537 | 1537 | <div class="panel-body"> |
1538 | 1538 | <p> |
1539 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1540 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1539 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1540 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1541 | 1541 | </p> |
1542 | 1542 | <div class="form-group row"> |
1543 | 1543 | <div class="col-sm-4"> |
1544 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1544 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1545 | 1545 | </div> |
1546 | 1546 | <div class="col-sm-3"> |
1547 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1547 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1548 | 1548 | </div> |
1549 | 1549 | <div style="clear:both"></div> |
1550 | 1550 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1557,10 +1557,10 @@ discard block |
||
1557 | 1557 | <?php |
1558 | 1558 | } |
1559 | 1559 | } |
1560 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1560 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1561 | 1561 | |
1562 | 1562 | function wpinv_agree_to_terms_js() { |
1563 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1563 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1564 | 1564 | ?> |
1565 | 1565 | <script type="text/javascript"> |
1566 | 1566 | jQuery(document).ready(function($){ |
@@ -1575,127 +1575,127 @@ discard block |
||
1575 | 1575 | <?php |
1576 | 1576 | } |
1577 | 1577 | } |
1578 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1578 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1579 | 1579 | |
1580 | 1580 | function wpinv_payment_mode_select() { |
1581 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1582 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1581 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1582 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1583 | 1583 | $page_URL = wpinv_get_current_page_url(); |
1584 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1584 | + $invoice = wpinv_get_invoice(0, true); |
|
1585 | 1585 | |
1586 | 1586 | do_action('wpinv_payment_mode_top'); |
1587 | 1587 | $invoice_id = (int)$invoice->ID; |
1588 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1588 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1589 | 1589 | ?> |
1590 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1591 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1590 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1591 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1592 | 1592 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1593 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1593 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1594 | 1594 | <div class="panel-body list-group wpi-payment_methods"> |
1595 | 1595 | <?php |
1596 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1597 | - |
|
1598 | - if ( !empty( $gateways ) ) { |
|
1599 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1600 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1601 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1602 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
1603 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1596 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1597 | + |
|
1598 | + if (!empty($gateways)) { |
|
1599 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1600 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1601 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1602 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
1603 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1604 | 1604 | ?> |
1605 | 1605 | <div class="list-group-item"> |
1606 | 1606 | <div class="radio"> |
1607 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label> |
|
1607 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label> |
|
1608 | 1608 | </div> |
1609 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1610 | - <?php if ( !empty( $description ) ) { ?> |
|
1611 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
1609 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1610 | + <?php if (!empty($description)) { ?> |
|
1611 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
1612 | 1612 | <?php } ?> |
1613 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1613 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1614 | 1614 | </div> |
1615 | 1615 | </div> |
1616 | 1616 | <?php |
1617 | 1617 | } |
1618 | 1618 | } else { |
1619 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1619 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1622 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1623 | 1623 | ?> |
1624 | 1624 | </div> |
1625 | 1625 | </div> |
1626 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1626 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1627 | 1627 | </div> |
1628 | 1628 | <?php |
1629 | 1629 | do_action('wpinv_payment_mode_bottom'); |
1630 | 1630 | } |
1631 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1631 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1632 | 1632 | |
1633 | 1633 | function wpinv_checkout_billing_info() { |
1634 | - if ( wpinv_is_checkout() ) { |
|
1634 | + if (wpinv_is_checkout()) { |
|
1635 | 1635 | $logged_in = is_user_logged_in(); |
1636 | 1636 | $billing_details = wpinv_checkout_billing_details(); |
1637 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1637 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1638 | 1638 | ?> |
1639 | 1639 | <div id="wpinv-fields" class="clearfix"> |
1640 | 1640 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1641 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1641 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1642 | 1642 | <div id="wpinv-fields-box" class="panel-body"> |
1643 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1643 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1644 | 1644 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1645 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1645 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1646 | 1646 | <?php |
1647 | - echo wpinv_html_text( array( |
|
1647 | + echo wpinv_html_text(array( |
|
1648 | 1648 | 'id' => 'wpinv_first_name', |
1649 | 1649 | 'name' => 'wpinv_first_name', |
1650 | 1650 | 'value' => $billing_details['first_name'], |
1651 | 1651 | 'class' => 'wpi-input form-control', |
1652 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1653 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1654 | - ) ); |
|
1652 | + 'placeholder' => __('First name', 'invoicing'), |
|
1653 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1654 | + )); |
|
1655 | 1655 | ?> |
1656 | 1656 | </p> |
1657 | 1657 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1658 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1658 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1659 | 1659 | <?php |
1660 | - echo wpinv_html_text( array( |
|
1660 | + echo wpinv_html_text(array( |
|
1661 | 1661 | 'id' => 'wpinv_last_name', |
1662 | 1662 | 'name' => 'wpinv_last_name', |
1663 | 1663 | 'value' => $billing_details['last_name'], |
1664 | 1664 | 'class' => 'wpi-input form-control', |
1665 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1666 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1667 | - ) ); |
|
1665 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1666 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1667 | + )); |
|
1668 | 1668 | ?> |
1669 | 1669 | </p> |
1670 | 1670 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1671 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1671 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1672 | 1672 | <?php |
1673 | - echo wpinv_html_text( array( |
|
1673 | + echo wpinv_html_text(array( |
|
1674 | 1674 | 'id' => 'wpinv_address', |
1675 | 1675 | 'name' => 'wpinv_address', |
1676 | 1676 | 'value' => $billing_details['address'], |
1677 | 1677 | 'class' => 'wpi-input form-control', |
1678 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1679 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1680 | - ) ); |
|
1678 | + 'placeholder' => __('Address', 'invoicing'), |
|
1679 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1680 | + )); |
|
1681 | 1681 | ?> |
1682 | 1682 | </p> |
1683 | 1683 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1684 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1684 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1685 | 1685 | <?php |
1686 | - echo wpinv_html_text( array( |
|
1686 | + echo wpinv_html_text(array( |
|
1687 | 1687 | 'id' => 'wpinv_city', |
1688 | 1688 | 'name' => 'wpinv_city', |
1689 | 1689 | 'value' => $billing_details['city'], |
1690 | 1690 | 'class' => 'wpi-input form-control', |
1691 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1692 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1693 | - ) ); |
|
1691 | + 'placeholder' => __('City', 'invoicing'), |
|
1692 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1693 | + )); |
|
1694 | 1694 | ?> |
1695 | 1695 | </p> |
1696 | 1696 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1697 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1698 | - <?php echo wpinv_html_select( array( |
|
1697 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1698 | + <?php echo wpinv_html_select(array( |
|
1699 | 1699 | 'options' => wpinv_get_country_list(), |
1700 | 1700 | 'name' => 'wpinv_country', |
1701 | 1701 | 'id' => 'wpinv_country', |
@@ -1703,16 +1703,16 @@ discard block |
||
1703 | 1703 | 'show_option_all' => false, |
1704 | 1704 | 'show_option_none' => false, |
1705 | 1705 | 'class' => 'wpi-input form-control wpi_select2', |
1706 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1707 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1708 | - ) ); ?> |
|
1706 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1707 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1708 | + )); ?> |
|
1709 | 1709 | </p> |
1710 | 1710 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1711 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1711 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1712 | 1712 | <?php |
1713 | - $states = wpinv_get_country_states( $selected_country ); |
|
1714 | - if( !empty( $states ) ) { |
|
1715 | - echo wpinv_html_select( array( |
|
1713 | + $states = wpinv_get_country_states($selected_country); |
|
1714 | + if (!empty($states)) { |
|
1715 | + echo wpinv_html_select(array( |
|
1716 | 1716 | 'options' => $states, |
1717 | 1717 | 'name' => 'wpinv_state', |
1718 | 1718 | 'id' => 'wpinv_state', |
@@ -1720,61 +1720,61 @@ discard block |
||
1720 | 1720 | 'show_option_all' => false, |
1721 | 1721 | 'show_option_none' => false, |
1722 | 1722 | 'class' => 'wpi-input form-control wpi_select2', |
1723 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1724 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1725 | - ) ); |
|
1723 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1724 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1725 | + )); |
|
1726 | 1726 | } else { |
1727 | - echo wpinv_html_text( array( |
|
1727 | + echo wpinv_html_text(array( |
|
1728 | 1728 | 'name' => 'wpinv_state', |
1729 | 1729 | 'value' => $billing_details['state'], |
1730 | 1730 | 'id' => 'wpinv_state', |
1731 | 1731 | 'class' => 'wpi-input form-control', |
1732 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1733 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1734 | - ) ); |
|
1732 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1733 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1734 | + )); |
|
1735 | 1735 | } |
1736 | 1736 | ?> |
1737 | 1737 | </p> |
1738 | 1738 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1739 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1739 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1740 | 1740 | <?php |
1741 | - echo wpinv_html_text( array( |
|
1741 | + echo wpinv_html_text(array( |
|
1742 | 1742 | 'name' => 'wpinv_zip', |
1743 | 1743 | 'value' => $billing_details['zip'], |
1744 | 1744 | 'id' => 'wpinv_zip', |
1745 | 1745 | 'class' => 'wpi-input form-control', |
1746 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1747 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1748 | - ) ); |
|
1746 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1747 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1748 | + )); |
|
1749 | 1749 | ?> |
1750 | 1750 | </p> |
1751 | 1751 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1752 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1752 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1753 | 1753 | <?php |
1754 | - echo wpinv_html_text( array( |
|
1754 | + echo wpinv_html_text(array( |
|
1755 | 1755 | 'id' => 'wpinv_phone', |
1756 | 1756 | 'name' => 'wpinv_phone', |
1757 | 1757 | 'value' => $billing_details['phone'], |
1758 | 1758 | 'class' => 'wpi-input form-control', |
1759 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1760 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1761 | - ) ); |
|
1759 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1760 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1761 | + )); |
|
1762 | 1762 | ?> |
1763 | 1763 | </p> |
1764 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1764 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1765 | 1765 | <div class="clearfix"></div> |
1766 | 1766 | </div> |
1767 | 1767 | </div> |
1768 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1768 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1769 | 1769 | </div> |
1770 | 1770 | <?php |
1771 | 1771 | } |
1772 | 1772 | } |
1773 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1773 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1774 | 1774 | |
1775 | 1775 | function wpinv_checkout_hidden_fields() { |
1776 | 1776 | ?> |
1777 | - <?php if ( is_user_logged_in() ) { ?> |
|
1777 | + <?php if (is_user_logged_in()) { ?> |
|
1778 | 1778 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1779 | 1779 | <?php } ?> |
1780 | 1780 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1784,9 +1784,9 @@ discard block |
||
1784 | 1784 | function wpinv_checkout_button_purchase() { |
1785 | 1785 | ob_start(); |
1786 | 1786 | ?> |
1787 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1787 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1788 | 1788 | <?php |
1789 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1789 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | function wpinv_checkout_total() { |
@@ -1795,116 +1795,116 @@ discard block |
||
1795 | 1795 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1796 | 1796 | <div class="panel-body"> |
1797 | 1797 | <?php |
1798 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1798 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1799 | 1799 | ?> |
1800 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1800 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1801 | 1801 | <?php |
1802 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1802 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1803 | 1803 | ?> |
1804 | 1804 | </div> |
1805 | 1805 | </div> |
1806 | 1806 | <?php |
1807 | 1807 | } |
1808 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1808 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1809 | 1809 | |
1810 | 1810 | function wpinv_checkout_accept_tandc() { |
1811 | - $page = wpinv_get_option( 'tandc_page' ); |
|
1811 | + $page = wpinv_get_option('tandc_page'); |
|
1812 | 1812 | ?> |
1813 | 1813 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
1814 | 1814 | <div class="panel-body"> |
1815 | 1815 | <?php echo wpinv_get_policy_text(); ?> |
1816 | 1816 | <?php |
1817 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
1818 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
1817 | + if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
1818 | + $terms_link = esc_url(get_permalink($page)); |
|
1819 | 1819 | ?> |
1820 | 1820 | <label class=""> |
1821 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
1821 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
1822 | 1822 | </label> |
1823 | 1823 | <?php } ?> |
1824 | 1824 | </div> |
1825 | 1825 | </div> |
1826 | 1826 | <?php |
1827 | 1827 | } |
1828 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
1828 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
1829 | 1829 | |
1830 | 1830 | function wpinv_checkout_submit() { |
1831 | 1831 | ?> |
1832 | 1832 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1833 | 1833 | <div class="panel-body text-center"> |
1834 | 1834 | <?php |
1835 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1835 | + do_action('wpinv_purchase_form_before_submit'); |
|
1836 | 1836 | wpinv_checkout_hidden_fields(); |
1837 | 1837 | echo wpinv_checkout_button_purchase(); |
1838 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1838 | + do_action('wpinv_purchase_form_after_submit'); |
|
1839 | 1839 | ?> |
1840 | 1840 | </div> |
1841 | 1841 | </div> |
1842 | 1842 | <?php |
1843 | 1843 | } |
1844 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1844 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1845 | 1845 | |
1846 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1847 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1846 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1847 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1848 | 1848 | |
1849 | - if ( empty( $invoice ) ) { |
|
1849 | + if (empty($invoice)) { |
|
1850 | 1850 | return NULL; |
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | $billing_details = $invoice->get_user_info(); |
1854 | 1854 | $address_row = ''; |
1855 | - if ( $address = $billing_details['address'] ) { |
|
1856 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1855 | + if ($address = $billing_details['address']) { |
|
1856 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1857 | 1857 | } |
1858 | 1858 | |
1859 | 1859 | $address_fields = array(); |
1860 | - if ( !empty( $billing_details['city'] ) ) { |
|
1860 | + if (!empty($billing_details['city'])) { |
|
1861 | 1861 | $address_fields[] = $billing_details['city']; |
1862 | 1862 | } |
1863 | 1863 | |
1864 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1865 | - if ( !empty( $billing_details['state'] ) ) { |
|
1866 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1864 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1865 | + if (!empty($billing_details['state'])) { |
|
1866 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1867 | 1867 | } |
1868 | 1868 | |
1869 | - if ( !empty( $billing_country ) ) { |
|
1870 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1869 | + if (!empty($billing_country)) { |
|
1870 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1871 | 1871 | } |
1872 | 1872 | |
1873 | - if ( !empty( $address_fields ) ) { |
|
1874 | - $address_fields = implode( ", ", $address_fields ); |
|
1873 | + if (!empty($address_fields)) { |
|
1874 | + $address_fields = implode(", ", $address_fields); |
|
1875 | 1875 | |
1876 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1876 | + if (!empty($billing_details['zip'])) { |
|
1877 | 1877 | $address_fields .= ' ' . $billing_details['zip']; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1880 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1881 | 1881 | } |
1882 | 1882 | ob_start(); |
1883 | 1883 | ?> |
1884 | 1884 | <table class="table table-bordered table-sm wpi-billing-details"> |
1885 | 1885 | <tbody> |
1886 | 1886 | <tr class="wpi-receipt-name"> |
1887 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1888 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1887 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1888 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1889 | 1889 | </tr> |
1890 | 1890 | <tr class="wpi-receipt-email"> |
1891 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1892 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1891 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1892 | + <td><?php echo $billing_details['email']; ?></td> |
|
1893 | 1893 | </tr> |
1894 | - <?php if ( $billing_details['company'] ) { ?> |
|
1894 | + <?php if ($billing_details['company']) { ?> |
|
1895 | 1895 | <tr class="wpi-receipt-company"> |
1896 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1897 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1896 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1897 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1898 | 1898 | </tr> |
1899 | 1899 | <?php } ?> |
1900 | 1900 | <tr class="wpi-receipt-address"> |
1901 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1902 | - <td><?php echo $address_row ;?></td> |
|
1901 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1902 | + <td><?php echo $address_row; ?></td> |
|
1903 | 1903 | </tr> |
1904 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1904 | + <?php if ($billing_details['phone']) { ?> |
|
1905 | 1905 | <tr class="wpi-receipt-phone"> |
1906 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1907 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1906 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1907 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1908 | 1908 | </tr> |
1909 | 1909 | <?php } ?> |
1910 | 1910 | </tbody> |
@@ -1912,74 +1912,74 @@ discard block |
||
1912 | 1912 | <?php |
1913 | 1913 | $output = ob_get_clean(); |
1914 | 1914 | |
1915 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1915 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1916 | 1916 | |
1917 | 1917 | echo $output; |
1918 | 1918 | } |
1919 | 1919 | |
1920 | -function wpinv_filter_success_page_content( $content ) { |
|
1921 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1922 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1923 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1920 | +function wpinv_filter_success_page_content($content) { |
|
1921 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1922 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1923 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1924 | 1924 | } |
1925 | 1925 | } |
1926 | 1926 | |
1927 | 1927 | return $content; |
1928 | 1928 | } |
1929 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1929 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1930 | 1930 | |
1931 | -function wpinv_receipt_actions( $invoice ) { |
|
1932 | - if ( !empty( $invoice ) ) { |
|
1931 | +function wpinv_receipt_actions($invoice) { |
|
1932 | + if (!empty($invoice)) { |
|
1933 | 1933 | $actions = array(); |
1934 | 1934 | |
1935 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1936 | - $actions['print'] = array( |
|
1937 | - 'url' => $invoice->get_view_url( true ), |
|
1938 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1935 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1936 | + $actions['print'] = array( |
|
1937 | + 'url' => $invoice->get_view_url(true), |
|
1938 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1939 | 1939 | 'class' => 'btn-primary', |
1940 | 1940 | ); |
1941 | 1941 | } |
1942 | 1942 | |
1943 | - if ( is_user_logged_in() ) { |
|
1943 | + if (is_user_logged_in()) { |
|
1944 | 1944 | $actions['history'] = array( |
1945 | 1945 | 'url' => wpinv_get_history_page_uri(), |
1946 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1946 | + 'name' => __('Invoice History', 'invoicing'), |
|
1947 | 1947 | 'class' => 'btn-warning', |
1948 | 1948 | ); |
1949 | 1949 | } |
1950 | 1950 | |
1951 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1951 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1952 | 1952 | |
1953 | - if ( !empty( $actions ) ) { |
|
1953 | + if (!empty($actions)) { |
|
1954 | 1954 | ?> |
1955 | 1955 | <div class="wpinv-receipt-actions text-right"> |
1956 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1957 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1956 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1957 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1958 | 1958 | <?php } ?> |
1959 | 1959 | </div> |
1960 | 1960 | <?php |
1961 | 1961 | } |
1962 | 1962 | } |
1963 | 1963 | } |
1964 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1964 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1965 | 1965 | |
1966 | -function wpinv_invoice_link( $invoice_id ) { |
|
1967 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1966 | +function wpinv_invoice_link($invoice_id) { |
|
1967 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1968 | 1968 | |
1969 | - if ( empty( $invoice ) ) { |
|
1969 | + if (empty($invoice)) { |
|
1970 | 1970 | return NULL; |
1971 | 1971 | } |
1972 | 1972 | |
1973 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1973 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1974 | 1974 | |
1975 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1975 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1976 | 1976 | } |
1977 | 1977 | |
1978 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1979 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
1980 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
1978 | +function wpinv_invoice_subscription_details($invoice) { |
|
1979 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1980 | + $subscription = wpinv_get_subscription($invoice, true); |
|
1981 | 1981 | |
1982 | - if ( empty( $subscription ) ) { |
|
1982 | + if (empty($subscription)) { |
|
1983 | 1983 | return; |
1984 | 1984 | } |
1985 | 1985 | |
@@ -1990,15 +1990,15 @@ discard block |
||
1990 | 1990 | $payments = $subscription->get_child_payments(); |
1991 | 1991 | ?> |
1992 | 1992 | <div class="wpinv-subscriptions-details"> |
1993 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1993 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1994 | 1994 | <table class="table"> |
1995 | 1995 | <thead> |
1996 | 1996 | <tr> |
1997 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
1998 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
1999 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
2000 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
2001 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1997 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
1998 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
1999 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
2000 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
2001 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
2002 | 2002 | </tr> |
2003 | 2003 | </thead> |
2004 | 2004 | <tbody> |
@@ -2012,29 +2012,29 @@ discard block |
||
2012 | 2012 | </tbody> |
2013 | 2013 | </table> |
2014 | 2014 | </div> |
2015 | - <?php if ( !empty( $payments ) ) { ?> |
|
2015 | + <?php if (!empty($payments)) { ?> |
|
2016 | 2016 | <div class="wpinv-renewal-payments"> |
2017 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
2017 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
2018 | 2018 | <table class="table"> |
2019 | 2019 | <thead> |
2020 | 2020 | <tr> |
2021 | 2021 | <th>#</th> |
2022 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
2023 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2024 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
2022 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
2023 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2024 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2025 | 2025 | </tr> |
2026 | 2026 | </thead> |
2027 | 2027 | <tbody> |
2028 | 2028 | <?php |
2029 | 2029 | $i = 1; |
2030 | - foreach ( $payments as $payment ) { |
|
2030 | + foreach ($payments as $payment) { |
|
2031 | 2031 | $invoice_id = $payment->ID; |
2032 | 2032 | ?> |
2033 | 2033 | <tr> |
2034 | - <th scope="row"><?php echo $i;?></th> |
|
2035 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2036 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2037 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2034 | + <th scope="row"><?php echo $i; ?></th> |
|
2035 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2036 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2037 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2038 | 2038 | </tr> |
2039 | 2039 | <?php $i++; } ?> |
2040 | 2040 | </tbody> |
@@ -2045,52 +2045,52 @@ discard block |
||
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | |
2048 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2049 | - if ( empty( $invoice ) ) { |
|
2048 | +function wpinv_cart_total_label($label, $invoice) { |
|
2049 | + if (empty($invoice)) { |
|
2050 | 2050 | return $label; |
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | $prefix_label = ''; |
2054 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2055 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2056 | - } else if ( $invoice->is_renewal() ) { |
|
2057 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2054 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2055 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2056 | + } else if ($invoice->is_renewal()) { |
|
2057 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2058 | 2058 | } |
2059 | 2059 | |
2060 | - if ( $prefix_label != '' ) { |
|
2061 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2060 | + if ($prefix_label != '') { |
|
2061 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2062 | 2062 | } |
2063 | 2063 | |
2064 | 2064 | return $label; |
2065 | 2065 | } |
2066 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2067 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2068 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2066 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2067 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2068 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2069 | 2069 | |
2070 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2070 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2071 | 2071 | |
2072 | -function wpinv_invoice_print_description( $invoice ) { |
|
2073 | - if ( empty( $invoice ) ) { |
|
2072 | +function wpinv_invoice_print_description($invoice) { |
|
2073 | + if (empty($invoice)) { |
|
2074 | 2074 | return NULL; |
2075 | 2075 | } |
2076 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2076 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2077 | 2077 | ?> |
2078 | 2078 | <div class="row wpinv-lower"> |
2079 | 2079 | <div class="col-sm-12 wpinv-description"> |
2080 | - <?php echo wpautop( $description ); ?> |
|
2080 | + <?php echo wpautop($description); ?> |
|
2081 | 2081 | </div> |
2082 | 2082 | </div> |
2083 | 2083 | <?php |
2084 | 2084 | } |
2085 | 2085 | } |
2086 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2086 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2087 | 2087 | |
2088 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2089 | - if ( empty( $invoice ) ) { |
|
2088 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2089 | + if (empty($invoice)) { |
|
2090 | 2090 | return NULL; |
2091 | 2091 | } |
2092 | 2092 | |
2093 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2093 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2094 | 2094 | ?> |
2095 | 2095 | <div class="row wpinv-payments"> |
2096 | 2096 | <div class="col-sm-12"> |
@@ -2102,43 +2102,43 @@ discard block |
||
2102 | 2102 | } |
2103 | 2103 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2104 | 2104 | |
2105 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2106 | - if ( empty( $note ) ) { |
|
2105 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2106 | + if (empty($note)) { |
|
2107 | 2107 | return NULL; |
2108 | 2108 | } |
2109 | 2109 | |
2110 | - if ( is_int( $note ) ) { |
|
2111 | - $note = get_comment( $note ); |
|
2110 | + if (is_int($note)) { |
|
2111 | + $note = get_comment($note); |
|
2112 | 2112 | } |
2113 | 2113 | |
2114 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2114 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2115 | 2115 | return NULL; |
2116 | 2116 | } |
2117 | 2117 | |
2118 | - $note_classes = array( 'note' ); |
|
2119 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2118 | + $note_classes = array('note'); |
|
2119 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2120 | 2120 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2121 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2122 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2121 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2122 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2123 | 2123 | |
2124 | 2124 | ob_start(); |
2125 | 2125 | ?> |
2126 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2126 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2127 | 2127 | <div class="note_content"> |
2128 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2128 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2129 | 2129 | </div> |
2130 | 2130 | <p class="meta"> |
2131 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2132 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
2133 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2131 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2132 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
2133 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2134 | 2134 | <?php } ?> |
2135 | 2135 | </p> |
2136 | 2136 | </li> |
2137 | 2137 | <?php |
2138 | 2138 | $note_content = ob_get_clean(); |
2139 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2139 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2140 | 2140 | |
2141 | - if ( $echo ) { |
|
2141 | + if ($echo) { |
|
2142 | 2142 | echo $note_content; |
2143 | 2143 | } else { |
2144 | 2144 | return $note_content; |
@@ -2148,43 +2148,43 @@ discard block |
||
2148 | 2148 | function wpinv_invalid_invoice_content() { |
2149 | 2149 | global $post; |
2150 | 2150 | |
2151 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2151 | + $invoice = wpinv_get_invoice($post->ID); |
|
2152 | 2152 | |
2153 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2154 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2155 | - if ( is_user_logged_in() ) { |
|
2156 | - if ( wpinv_require_login_to_checkout() ) { |
|
2157 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2158 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2153 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2154 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2155 | + if (is_user_logged_in()) { |
|
2156 | + if (wpinv_require_login_to_checkout()) { |
|
2157 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2158 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2159 | 2159 | } |
2160 | 2160 | } |
2161 | 2161 | } else { |
2162 | - if ( wpinv_require_login_to_checkout() ) { |
|
2163 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2164 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2162 | + if (wpinv_require_login_to_checkout()) { |
|
2163 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2164 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2165 | 2165 | } |
2166 | 2166 | } |
2167 | 2167 | } |
2168 | 2168 | } else { |
2169 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2169 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2170 | 2170 | } |
2171 | 2171 | ?> |
2172 | 2172 | <div class="row wpinv-row-invalid"> |
2173 | 2173 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2174 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2174 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2175 | 2175 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2176 | 2176 | </div> |
2177 | 2177 | </div> |
2178 | 2178 | <?php |
2179 | 2179 | } |
2180 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2180 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2181 | 2181 | |
2182 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2183 | -function wpinv_force_company_name_field(){ |
|
2182 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2183 | +function wpinv_force_company_name_field() { |
|
2184 | 2184 | $invoice = wpinv_get_invoice_cart(); |
2185 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
2186 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
2187 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
2185 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
2186 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
2187 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
2188 | 2188 | ?> |
2189 | 2189 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
2190 | 2190 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2209,21 +2209,21 @@ discard block |
||
2209 | 2209 | * @return string |
2210 | 2210 | */ |
2211 | 2211 | function wpinv_get_policy_text() { |
2212 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
2212 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
2213 | 2213 | |
2214 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
2214 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
2215 | 2215 | |
2216 | - if(!$privacy_page_id){ |
|
2217 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
2216 | + if (!$privacy_page_id) { |
|
2217 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
2218 | 2218 | } |
2219 | 2219 | |
2220 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
2220 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
2221 | 2221 | |
2222 | 2222 | $find_replace = array( |
2223 | 2223 | '[wpinv_privacy_policy]' => $privacy_link, |
2224 | 2224 | ); |
2225 | 2225 | |
2226 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
2226 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
2227 | 2227 | |
2228 | 2228 | return wp_kses_post(wpautop($privacy_text)); |
2229 | 2229 | } |
@@ -2232,25 +2232,25 @@ discard block |
||
2232 | 2232 | /** |
2233 | 2233 | * Allows the user to set their own price for an invoice item |
2234 | 2234 | */ |
2235 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
2235 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
2236 | 2236 | |
2237 | 2237 | //Ensure we have an item id |
2238 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
2238 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
2239 | 2239 | return; |
2240 | 2240 | } |
2241 | 2241 | |
2242 | 2242 | //Fetch the item |
2243 | 2243 | $item_id = $cart_item['id']; |
2244 | - $item = new WPInv_Item( $item_id ); |
|
2244 | + $item = new WPInv_Item($item_id); |
|
2245 | 2245 | |
2246 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
2246 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
2247 | 2247 | return; |
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | //Fetch the dynamic pricing "strings" |
2251 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
2252 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
2253 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
2251 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
2252 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
2253 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
2254 | 2254 | |
2255 | 2255 | //Display a "name_your_price" button |
2256 | 2256 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | echo '<div class="name-your-price-miniform">'; |
2260 | 2260 | |
2261 | 2261 | //Maybe display the recommended price |
2262 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
2262 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
2263 | 2263 | $suggested_price = $item->get_the_price(); |
2264 | 2264 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
2265 | 2265 | } |
@@ -2267,30 +2267,30 @@ discard block |
||
2267 | 2267 | //Display the update price form |
2268 | 2268 | $symbol = wpinv_currency_symbol(); |
2269 | 2269 | $position = wpinv_currency_position(); |
2270 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
2271 | - $price = esc_attr( $cart_item['item_price'] ); |
|
2272 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
2270 | + $minimum = esc_attr($item->get_minimum_price()); |
|
2271 | + $price = esc_attr($cart_item['item_price']); |
|
2272 | + $update = esc_attr__("Update", 'invoicing'); |
|
2273 | 2273 | |
2274 | 2274 | //Ensure it supports dynamic prici |
2275 | - if( $price < $minimum ) { |
|
2275 | + if ($price < $minimum) { |
|
2276 | 2276 | $price = $minimum; |
2277 | 2277 | } |
2278 | 2278 | |
2279 | 2279 | echo '<label>'; |
2280 | 2280 | echo $position != 'right' ? $symbol . ' ' : ''; |
2281 | 2281 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
2282 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
2282 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
2283 | 2283 | echo "</label>"; |
2284 | 2284 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
2285 | 2285 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
2286 | 2286 | |
2287 | 2287 | //Maybe display the minimum price |
2288 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
2289 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
2288 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
2289 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
2290 | 2290 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
2291 | 2291 | } |
2292 | 2292 | |
2293 | 2293 | echo "</div>"; |
2294 | 2294 | |
2295 | 2295 | } |
2296 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
2297 | 2296 | \ No newline at end of file |
2297 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
2298 | 2298 | \ No newline at end of file |