@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param string $context View or edit context. |
95 | 95 | * @return string |
96 | 96 | */ |
97 | - public function get_name( $context = 'view' ) { |
|
98 | - $name = parent::get_name( $context ); |
|
99 | - return $name . wpinv_get_item_suffix( $this ); |
|
97 | + public function get_name($context = 'view') { |
|
98 | + $name = parent::get_name($context); |
|
99 | + return $name . wpinv_get_item_suffix($this); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * @param string $context View or edit context. |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - public function get_raw_name( $context = 'view' ) { |
|
110 | - return parent::get_name( $context ); |
|
109 | + public function get_raw_name($context = 'view') { |
|
110 | + return parent::get_name($context); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | * @param string $context View or edit context. |
118 | 118 | * @return string |
119 | 119 | */ |
120 | - public function get_description( $context = 'view' ) { |
|
120 | + public function get_description($context = 'view') { |
|
121 | 121 | |
122 | - if ( isset( $this->custom_description ) ) { |
|
122 | + if (isset($this->custom_description)) { |
|
123 | 123 | return $this->custom_description; |
124 | 124 | } |
125 | 125 | |
126 | - return parent::get_description( $context ); |
|
126 | + return parent::get_description($context); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param string $context View or edit context. |
134 | 134 | * @return float |
135 | 135 | */ |
136 | - public function get_sub_total( $context = 'view' ) { |
|
137 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
136 | + public function get_sub_total($context = 'view') { |
|
137 | + return $this->get_quantity($context) * $this->get_initial_price($context); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @param string $context View or edit context. |
145 | 145 | * @return float |
146 | 146 | */ |
147 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
147 | + public function get_recurring_sub_total($context = 'view') { |
|
148 | 148 | |
149 | - if ( $this->is_recurring() ) { |
|
150 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
149 | + if ($this->is_recurring()) { |
|
150 | + return $this->get_quantity($context) * $this->get_price($context); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return 0; |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * @deprecated |
158 | 158 | */ |
159 | - public function get_qantity( $context = 'view' ) { |
|
160 | - return $this->get_quantity( $context ); |
|
159 | + public function get_qantity($context = 'view') { |
|
160 | + return $this->get_quantity($context); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | * @param string $context View or edit context. |
168 | 168 | * @return float |
169 | 169 | */ |
170 | - public function get_quantity( $context = 'view' ) { |
|
170 | + public function get_quantity($context = 'view') { |
|
171 | 171 | $quantity = (float) $this->quantity; |
172 | 172 | |
173 | - if ( 'view' === $context ) { |
|
174 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
173 | + if ('view' === $context) { |
|
174 | + return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $quantity; |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return meta |
187 | 187 | */ |
188 | - public function get_item_meta( $context = 'view' ) { |
|
188 | + public function get_item_meta($context = 'view') { |
|
189 | 189 | $meta = $this->meta; |
190 | 190 | |
191 | - if ( 'view' === $context ) { |
|
192 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
191 | + if ('view' === $context) { |
|
192 | + return apply_filters('getpaid_payment_form_item_meta', $meta, $this); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | return $meta; |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @param string $context View or edit context. |
204 | 204 | * @return bool |
205 | 205 | */ |
206 | - public function get_allow_quantities( $context = 'view' ) { |
|
206 | + public function get_allow_quantities($context = 'view') { |
|
207 | 207 | $allow_quantities = (bool) $this->allow_quantities; |
208 | 208 | |
209 | - if ( 'view' === $context ) { |
|
210 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
209 | + if ('view' === $context) { |
|
210 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | return $allow_quantities; |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @param string $context View or edit context. |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | - public function get_is_required( $context = 'view' ) { |
|
224 | + public function get_is_required($context = 'view') { |
|
225 | 225 | $is_required = (bool) $this->is_required; |
226 | 226 | |
227 | - if ( 'view' === $context ) { |
|
228 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
227 | + if ('view' === $context) { |
|
228 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | return $is_required; |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | * @since 1.0.19 |
239 | 239 | * @return array |
240 | 240 | */ |
241 | - public function prepare_data_for_use( $required = null ) { |
|
241 | + public function prepare_data_for_use($required = null) { |
|
242 | 242 | |
243 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
243 | + $required = is_null($required) ? $this->is_required() : $required; |
|
244 | 244 | return array( |
245 | - 'title' => wp_strip_all_tags( $this->get_name() ), |
|
245 | + 'title' => wp_strip_all_tags($this->get_name()), |
|
246 | 246 | 'id' => $this->get_id(), |
247 | 247 | 'price' => $this->get_price(), |
248 | 248 | 'recurring' => $this->is_recurring(), |
@@ -259,30 +259,30 @@ discard block |
||
259 | 259 | * @since 1.0.19 |
260 | 260 | * @return array |
261 | 261 | */ |
262 | - public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) { |
|
262 | + public function prepare_data_for_invoice_edit_ajax($currency = '', $is_renewal = false) { |
|
263 | 263 | |
264 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
264 | + $description = getpaid_item_recurring_price_help_text($this, $currency); |
|
265 | 265 | |
266 | - if ( $description ) { |
|
266 | + if ($description) { |
|
267 | 267 | $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
268 | 268 | } |
269 | 269 | |
270 | - $price = ! $is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | - $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
270 | + $price = !$is_renewal ? $this->get_price() : $this->get_recurring_price(); |
|
271 | + $subtotal = !$is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total(); |
|
272 | 272 | return array( |
273 | 273 | 'id' => $this->get_id(), |
274 | 274 | 'texts' => array( |
275 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
276 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
277 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
278 | - 'item-price' => wpinv_price( $price, $currency ), |
|
279 | - 'item-total' => wpinv_price( $subtotal, $currency ), |
|
275 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
276 | + 'item-description' => wp_kses_post($this->get_description()) . $description, |
|
277 | + 'item-quantity' => floatval($this->get_quantity()), |
|
278 | + 'item-price' => wpinv_price($price, $currency), |
|
279 | + 'item-total' => wpinv_price($subtotal, $currency), |
|
280 | 280 | ), |
281 | 281 | 'inputs' => array( |
282 | 282 | 'item-id' => $this->get_id(), |
283 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
284 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
285 | - 'item-quantity' => floatval( $this->get_quantity() ), |
|
283 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
284 | + 'item-description' => wp_kses_post($this->get_description()), |
|
285 | + 'item-quantity' => floatval($this->get_quantity()), |
|
286 | 286 | 'item-price' => $price, |
287 | 287 | ), |
288 | 288 | ); |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | return array( |
301 | 301 | 'post_id' => $this->invoice_id, |
302 | 302 | 'item_id' => $this->get_id(), |
303 | - 'item_name' => sanitize_text_field( $this->get_raw_name( 'edit' ) ), |
|
304 | - 'item_description' => $this->get_description( 'edit' ), |
|
303 | + 'item_name' => sanitize_text_field($this->get_raw_name('edit')), |
|
304 | + 'item_description' => $this->get_description('edit'), |
|
305 | 305 | 'tax' => $this->item_tax, |
306 | - 'item_price' => $this->get_price( 'edit' ), |
|
307 | - 'quantity' => (float) $this->get_quantity( 'edit' ), |
|
306 | + 'item_price' => $this->get_price('edit'), |
|
307 | + 'quantity' => (float) $this->get_quantity('edit'), |
|
308 | 308 | 'discount' => $this->item_discount, |
309 | - 'subtotal' => $this->get_sub_total( 'edit' ), |
|
310 | - 'price' => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount, |
|
311 | - 'meta' => $this->get_item_meta( 'edit' ), |
|
309 | + 'subtotal' => $this->get_sub_total('edit'), |
|
310 | + 'price' => $this->get_sub_total('edit') + $this->item_tax - $this->item_discount, |
|
311 | + 'meta' => $this->get_item_meta('edit'), |
|
312 | 312 | ); |
313 | 313 | |
314 | 314 | } |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | * @since 1.0.19 |
330 | 330 | * @param float $quantity The item quantity. |
331 | 331 | */ |
332 | - public function set_quantity( $quantity ) { |
|
332 | + public function set_quantity($quantity) { |
|
333 | 333 | |
334 | - if ( ! is_numeric( $quantity ) ) { |
|
334 | + if (!is_numeric($quantity)) { |
|
335 | 335 | $quantity = 1; |
336 | 336 | } |
337 | 337 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @since 1.0.19 |
346 | 346 | * @param array $meta The item meta data. |
347 | 347 | */ |
348 | - public function set_item_meta( $meta ) { |
|
349 | - $this->meta = maybe_unserialize( $meta ); |
|
348 | + public function set_item_meta($meta) { |
|
349 | + $this->meta = maybe_unserialize($meta); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @since 1.0.19 |
356 | 356 | * @param bool $allow_quantities |
357 | 357 | */ |
358 | - public function set_allow_quantities( $allow_quantities ) { |
|
358 | + public function set_allow_quantities($allow_quantities) { |
|
359 | 359 | $this->allow_quantities = (bool) $allow_quantities; |
360 | 360 | } |
361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @since 1.0.19 |
366 | 366 | * @param bool $is_required |
367 | 367 | */ |
368 | - public function set_is_required( $is_required ) { |
|
368 | + public function set_is_required($is_required) { |
|
369 | 369 | $this->is_required = (bool) $is_required; |
370 | 370 | } |
371 | 371 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @since 1.0.19 |
376 | 376 | * @param string $description |
377 | 377 | */ |
378 | - public function set_custom_description( $description ) { |
|
378 | + public function set_custom_description($description) { |
|
379 | 379 | $this->custom_description = $description; |
380 | 380 | } |
381 | 381 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return int item id |
386 | 386 | */ |
387 | - public function save( $data = array() ) { |
|
387 | + public function save($data = array()) { |
|
388 | 388 | return $this->get_id(); |
389 | 389 | } |
390 | 390 |
@@ -8,40 +8,40 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | $getpaid_pages = GetPaid_Installer::get_pages(); |
14 | -$pages = wpinv_get_pages( true ); |
|
14 | +$pages = wpinv_get_pages(true); |
|
15 | 15 | |
16 | 16 | $currencies = wpinv_get_currencies(); |
17 | 17 | |
18 | 18 | $currency_code_options = array(); |
19 | -foreach ( $currencies as $code => $name ) { |
|
20 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
19 | +foreach ($currencies as $code => $name) { |
|
20 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $invoice_number_padd_options = array(); |
24 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
25 | - $invoice_number_padd_options[ $i ] = $i; |
|
24 | +for ($i = 0; $i <= 20; $i++) { |
|
25 | + $invoice_number_padd_options[$i] = $i; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $currency_symbol = wpinv_currency_symbol(); |
29 | 29 | |
30 | 30 | $last_number = $reset_number = ''; |
31 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
32 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
31 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
32 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
33 | 33 | |
34 | - if ( ! empty( $last_invoice_number ) ) { |
|
35 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
34 | + if (!empty($last_invoice_number)) { |
|
35 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
36 | 36 | } |
37 | 37 | |
38 | - $nonce = wp_create_nonce( 'reset_invoice_count' ); |
|
38 | + $nonce = wp_create_nonce('reset_invoice_count'); |
|
39 | 39 | $reset_number = '<a href="' . add_query_arg( |
40 | 40 | array( |
41 | 41 | 'reset_invoice_count' => 1, |
42 | 42 | '_nonce' => $nonce, |
43 | 43 | ) |
44 | - ) . '" class="btn button">' . __( 'Force Reset Sequence', 'invoicing' ) . '</a>'; |
|
44 | + ) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $alert_wrapper_start = '<p style="color: #F00">'; |
@@ -54,59 +54,59 @@ discard block |
||
54 | 54 | 'main' => array( |
55 | 55 | 'location_settings' => array( |
56 | 56 | 'id' => 'location_settings', |
57 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
57 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
58 | 58 | 'desc' => '', |
59 | 59 | 'type' => 'header', |
60 | 60 | ), |
61 | 61 | 'default_country' => array( |
62 | 62 | 'id' => 'default_country', |
63 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
64 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
63 | + 'name' => __('Default Country', 'invoicing'), |
|
64 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
65 | 65 | 'type' => 'select', |
66 | 66 | 'options' => wpinv_get_country_list(), |
67 | 67 | 'std' => 'GB', |
68 | 68 | 'class' => 'wpi_select2', |
69 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
69 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
70 | 70 | ), |
71 | 71 | 'default_state' => array( |
72 | 72 | 'id' => 'default_state', |
73 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
74 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
73 | + 'name' => __('Default State / Province', 'invoicing'), |
|
74 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
75 | 75 | 'type' => 'country_states', |
76 | 76 | 'class' => 'wpi_select2', |
77 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
77 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
78 | 78 | ), |
79 | 79 | 'store_name' => array( |
80 | 80 | 'id' => 'store_name', |
81 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
82 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
83 | - 'std' => get_option( 'blogname' ), |
|
81 | + 'name' => __('Store Name', 'invoicing'), |
|
82 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
83 | + 'std' => get_option('blogname'), |
|
84 | 84 | 'type' => 'text', |
85 | 85 | ), |
86 | 86 | 'logo' => array( |
87 | 87 | 'id' => 'logo', |
88 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
89 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
88 | + 'name' => __('Logo URL', 'invoicing'), |
|
89 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
90 | 90 | 'type' => 'text', |
91 | 91 | ), |
92 | 92 | 'logo_width' => array( |
93 | 93 | 'id' => 'logo_width', |
94 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
95 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
94 | + 'name' => __('Logo width', 'invoicing'), |
|
95 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
96 | 96 | 'type' => 'number', |
97 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
97 | + 'placeholder' => __('Auto', 'invoicing'), |
|
98 | 98 | ), |
99 | 99 | 'logo_height' => array( |
100 | 100 | 'id' => 'logo_height', |
101 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
102 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
101 | + 'name' => __('Logo height', 'invoicing'), |
|
102 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
103 | 103 | 'type' => 'number', |
104 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
104 | + 'placeholder' => __('Auto', 'invoicing'), |
|
105 | 105 | ), |
106 | 106 | 'store_address' => array( |
107 | 107 | 'id' => 'store_address', |
108 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
109 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
108 | + 'name' => __('Store Address', 'invoicing'), |
|
109 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
110 | 110 | 'type' => 'textarea', |
111 | 111 | ), |
112 | 112 | |
@@ -114,114 +114,114 @@ discard block |
||
114 | 114 | 'page_section' => array( |
115 | 115 | 'page_settings' => array( |
116 | 116 | 'id' => 'page_settings', |
117 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
117 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
118 | 118 | 'desc' => '', |
119 | 119 | 'type' => 'header', |
120 | 120 | ), |
121 | 121 | 'checkout_page' => array( |
122 | 122 | 'id' => 'checkout_page', |
123 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
124 | - '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' ), |
|
123 | + 'name' => __('Checkout Page', 'invoicing'), |
|
124 | + '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'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
129 | - 'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'], |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | + 'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'], |
|
130 | 130 | 'help-tip' => true, |
131 | 131 | ), |
132 | 132 | 'success_page' => array( |
133 | 133 | 'id' => 'success_page', |
134 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
135 | - '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' ), |
|
134 | + 'name' => __('Success Page', 'invoicing'), |
|
135 | + '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'), |
|
136 | 136 | 'type' => 'select', |
137 | 137 | 'options' => $pages, |
138 | 138 | 'class' => 'wpi_select2', |
139 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
140 | - 'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'], |
|
139 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
140 | + 'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'], |
|
141 | 141 | 'help-tip' => true, |
142 | 142 | ), |
143 | 143 | 'failure_page' => array( |
144 | 144 | 'id' => 'failure_page', |
145 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
146 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
145 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
146 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
147 | 147 | 'type' => 'select', |
148 | 148 | 'options' => $pages, |
149 | 149 | 'class' => 'wpi_select2', |
150 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
151 | - 'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'], |
|
150 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
151 | + 'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'], |
|
152 | 152 | 'help-tip' => true, |
153 | 153 | ), |
154 | 154 | 'invoice_history_page' => array( |
155 | 155 | 'id' => 'invoice_history_page', |
156 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
157 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
156 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
157 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
158 | 158 | 'type' => 'select', |
159 | 159 | 'options' => $pages, |
160 | 160 | 'class' => 'wpi_select2', |
161 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
162 | - 'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
161 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
162 | + 'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
163 | 163 | 'help-tip' => true, |
164 | 164 | ), |
165 | 165 | 'invoice_subscription_page' => array( |
166 | 166 | 'id' => 'invoice_subscription_page', |
167 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
168 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
167 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
168 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
169 | 169 | 'type' => 'select', |
170 | 170 | 'options' => $pages, |
171 | 171 | 'class' => 'wpi_select2', |
172 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
173 | - 'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
172 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
173 | + 'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
174 | 174 | 'help-tip' => true, |
175 | 175 | ), |
176 | 176 | ), |
177 | 177 | 'currency_section' => array( |
178 | 178 | 'currency_settings' => array( |
179 | 179 | 'id' => 'currency_settings', |
180 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
180 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
181 | 181 | 'desc' => '', |
182 | 182 | 'type' => 'header', |
183 | 183 | ), |
184 | 184 | 'currency' => array( |
185 | 185 | 'id' => 'currency', |
186 | - 'name' => __( 'Currency', 'invoicing' ), |
|
187 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
186 | + 'name' => __('Currency', 'invoicing'), |
|
187 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
188 | 188 | 'type' => 'select', |
189 | 189 | 'class' => 'wpi_select2', |
190 | 190 | 'options' => $currency_code_options, |
191 | 191 | ), |
192 | 192 | 'currency_position' => array( |
193 | 193 | 'id' => 'currency_position', |
194 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
195 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
194 | + 'name' => __('Currency Position', 'invoicing'), |
|
195 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
196 | 196 | 'type' => 'select', |
197 | 197 | 'class' => 'wpi_select2', |
198 | 198 | 'options' => array( |
199 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
200 | - 'right' => __( 'Right', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
201 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
202 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')', |
|
199 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
200 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
201 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
202 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')', |
|
203 | 203 | ), |
204 | 204 | ), |
205 | 205 | 'thousands_separator' => array( |
206 | 206 | 'id' => 'thousands_separator', |
207 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
208 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
207 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
208 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
209 | 209 | 'type' => 'text', |
210 | 210 | 'size' => 'small', |
211 | 211 | 'std' => ',', |
212 | 212 | ), |
213 | 213 | 'decimal_separator' => array( |
214 | 214 | 'id' => 'decimal_separator', |
215 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
216 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
215 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
216 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
217 | 217 | 'type' => 'text', |
218 | 218 | 'size' => 'small', |
219 | 219 | 'std' => '.', |
220 | 220 | ), |
221 | 221 | 'decimals' => array( |
222 | 222 | 'id' => 'decimals', |
223 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
224 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
223 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
224 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
225 | 225 | 'type' => 'number', |
226 | 226 | 'size' => 'small', |
227 | 227 | 'std' => '2', |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | 'labels' => array( |
234 | 234 | 'labels' => array( |
235 | 235 | 'id' => 'labels_settings', |
236 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
236 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
237 | 237 | 'desc' => '', |
238 | 238 | 'type' => 'header', |
239 | 239 | ), |
240 | 240 | 'vat_invoice_notice_label' => array( |
241 | 241 | 'id' => 'vat_invoice_notice_label', |
242 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
243 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
242 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
243 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
244 | 244 | 'type' => 'text', |
245 | 245 | 'size' => 'regular', |
246 | 246 | ), |
247 | 247 | 'vat_invoice_notice' => array( |
248 | 248 | 'id' => 'vat_invoice_notice', |
249 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
250 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
249 | + 'name' => __('Invoice notice', 'invoicing'), |
|
250 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
251 | 251 | 'type' => 'text', |
252 | 252 | 'size' => 'regular', |
253 | 253 | ), |
@@ -260,22 +260,22 @@ discard block |
||
260 | 260 | 'main' => array( |
261 | 261 | 'gateway_settings' => array( |
262 | 262 | 'id' => 'api_header', |
263 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
263 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
264 | 264 | 'desc' => '', |
265 | 265 | 'type' => 'header', |
266 | 266 | ), |
267 | 267 | 'gateways' => array( |
268 | 268 | 'id' => 'gateways', |
269 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
270 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
269 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
270 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
271 | 271 | 'type' => 'gateways', |
272 | - 'std' => array( 'manual' => 1 ), |
|
272 | + 'std' => array('manual' => 1), |
|
273 | 273 | 'options' => wpinv_get_payment_gateways(), |
274 | 274 | ), |
275 | 275 | 'default_gateway' => array( |
276 | 276 | 'id' => 'default_gateway', |
277 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
278 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
277 | + 'name' => __('Default Gateway', 'invoicing'), |
|
278 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
279 | 279 | 'type' => 'gateway_select', |
280 | 280 | 'std' => 'manual', |
281 | 281 | 'class' => 'wpi_select2', |
@@ -291,32 +291,32 @@ discard block |
||
291 | 291 | 'main' => array( |
292 | 292 | 'tax_settings' => array( |
293 | 293 | 'id' => 'tax_settings', |
294 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
294 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
295 | 295 | 'type' => 'header', |
296 | 296 | ), |
297 | 297 | |
298 | 298 | 'enable_taxes' => array( |
299 | 299 | 'id' => 'enable_taxes', |
300 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
301 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
300 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
301 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
302 | 302 | 'type' => 'checkbox', |
303 | 303 | 'std' => 0, |
304 | 304 | ), |
305 | 305 | |
306 | 306 | 'tax_subtotal_rounding' => array( |
307 | 307 | 'id' => 'tax_subtotal_rounding', |
308 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
309 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
308 | + 'name' => __('Rounding', 'invoicing'), |
|
309 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
310 | 310 | 'type' => 'checkbox', |
311 | 311 | 'std' => 1, |
312 | 312 | ), |
313 | 313 | |
314 | 314 | 'prices_include_tax' => array( |
315 | 315 | 'id' => 'prices_include_tax', |
316 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
316 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
317 | 317 | 'options' => array( |
318 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
319 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
318 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
319 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
320 | 320 | ), |
321 | 321 | 'type' => 'select', |
322 | 322 | 'std' => 'no', |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | |
325 | 325 | 'tax_base' => array( |
326 | 326 | 'id' => 'tax_base', |
327 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
327 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
328 | 328 | 'options' => array( |
329 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
330 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
329 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
330 | + 'base' => __('Shop base address', 'invoicing'), |
|
331 | 331 | ), |
332 | 332 | 'type' => 'select', |
333 | 333 | 'std' => 'billing', |
@@ -335,24 +335,24 @@ discard block |
||
335 | 335 | |
336 | 336 | 'vat_same_country_rule' => array( |
337 | 337 | 'id' => 'vat_same_country_rule', |
338 | - 'name' => __( 'Same country rule', 'invoicing' ), |
|
339 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
338 | + 'name' => __('Same country rule', 'invoicing'), |
|
339 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
340 | 340 | 'type' => 'select', |
341 | 341 | 'options' => array( |
342 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
343 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
344 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ), |
|
342 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
343 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
344 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing'), |
|
345 | 345 | ), |
346 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
346 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
347 | 347 | 'std' => 'vat_too', |
348 | 348 | ), |
349 | 349 | |
350 | 350 | 'tax_display_totals' => array( |
351 | 351 | 'id' => 'tax_display_totals', |
352 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
352 | + 'name' => __('Display tax totals', 'invoicing'), |
|
353 | 353 | 'options' => array( |
354 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
355 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
354 | + 'single' => __('As a single total', 'invoicing'), |
|
355 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
356 | 356 | ), |
357 | 357 | 'type' => 'select', |
358 | 358 | 'std' => 'individual', |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | |
361 | 361 | 'tax_rate' => array( |
362 | 362 | 'id' => 'tax_rate', |
363 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
364 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
363 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
364 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
365 | 365 | 'type' => 'number', |
366 | 366 | 'size' => 'small', |
367 | 367 | 'min' => '0', |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | 'rules' => array( |
374 | 374 | 'tax_rules' => array( |
375 | 375 | 'id' => 'tax_rules', |
376 | - 'name' => '<h3>' . __( 'Tax Rules', 'invoicing' ) . '</h3>', |
|
377 | - 'desc' => __( 'Create/Update tax rules', 'invoicing' ), |
|
376 | + 'name' => '<h3>' . __('Tax Rules', 'invoicing') . '</h3>', |
|
377 | + 'desc' => __('Create/Update tax rules', 'invoicing'), |
|
378 | 378 | 'type' => 'tax_rules', |
379 | 379 | ), |
380 | 380 | ), |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | 'rates' => array( |
383 | 383 | 'tax_rates' => array( |
384 | 384 | 'id' => 'tax_rates', |
385 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
386 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
385 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
386 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
387 | 387 | 'type' => 'tax_rates', |
388 | 388 | ), |
389 | 389 | ), |
@@ -392,31 +392,31 @@ discard block |
||
392 | 392 | |
393 | 393 | 'vat_company_name' => array( |
394 | 394 | 'id' => 'vat_company_name', |
395 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
396 | - 'desc' => wp_sprintf( __( 'Verify your company name and VAT number on the %1$sEU VIES System.%2$s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
395 | + 'name' => __('Company Name', 'invoicing'), |
|
396 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %1$sEU VIES System.%2$s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
397 | 397 | 'type' => 'text', |
398 | 398 | 'size' => 'regular', |
399 | 399 | ), |
400 | 400 | |
401 | 401 | 'vat_number' => array( |
402 | 402 | 'id' => 'vat_number', |
403 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
404 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
403 | + 'name' => __('VAT Number', 'invoicing'), |
|
404 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
405 | 405 | 'type' => 'text', |
406 | 406 | 'size' => 'regular', |
407 | 407 | ), |
408 | 408 | |
409 | 409 | 'vat_prevent_b2c_purchase' => array( |
410 | 410 | 'id' => 'vat_prevent_b2c_purchase', |
411 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
412 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
411 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
412 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
413 | 413 | 'type' => 'checkbox', |
414 | 414 | ), |
415 | 415 | |
416 | 416 | 'validate_vat_number' => array( |
417 | 417 | 'id' => 'validate_vat_number', |
418 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
419 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
418 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
419 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
420 | 420 | 'type' => 'checkbox', |
421 | 421 | ), |
422 | 422 | |
@@ -431,66 +431,66 @@ discard block |
||
431 | 431 | 'main' => array( |
432 | 432 | 'email_settings_header' => array( |
433 | 433 | 'id' => 'email_settings_header', |
434 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
434 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
435 | 435 | 'type' => 'header', |
436 | 436 | ), |
437 | 437 | 'email_from_name' => array( |
438 | 438 | 'id' => 'email_from_name', |
439 | - 'name' => __( 'From Name', 'invoicing' ), |
|
440 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
441 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
439 | + 'name' => __('From Name', 'invoicing'), |
|
440 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
441 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
442 | 442 | 'type' => 'text', |
443 | 443 | ), |
444 | 444 | 'email_from' => array( |
445 | 445 | 'id' => 'email_from', |
446 | - 'name' => __( 'From Email', 'invoicing' ), |
|
447 | - 'desc' => sprintf( __( 'Email address to send invoice emails from. This will act as the "from" address. %1$s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%2$s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close ), |
|
448 | - 'std' => get_option( 'admin_email' ), |
|
446 | + 'name' => __('From Email', 'invoicing'), |
|
447 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %1$s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%2$s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
448 | + 'std' => get_option('admin_email'), |
|
449 | 449 | 'type' => 'text', |
450 | 450 | ), |
451 | 451 | 'admin_email' => array( |
452 | 452 | 'id' => 'admin_email', |
453 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
454 | - 'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ), |
|
455 | - 'std' => get_option( 'admin_email' ), |
|
453 | + 'name' => __('Admin Email', 'invoicing'), |
|
454 | + 'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'), |
|
455 | + 'std' => get_option('admin_email'), |
|
456 | 456 | 'type' => 'text', |
457 | 457 | ), |
458 | 458 | 'skip_email_free_invoice' => array( |
459 | 459 | 'id' => 'skip_email_free_invoice', |
460 | - 'name' => __( 'Skip Free Invoices', 'invoicing' ), |
|
461 | - 'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ), |
|
460 | + 'name' => __('Skip Free Invoices', 'invoicing'), |
|
461 | + 'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'), |
|
462 | 462 | 'type' => 'checkbox', |
463 | 463 | 'std' => false, |
464 | 464 | ), |
465 | 465 | 'overdue_settings_header' => array( |
466 | 466 | 'id' => 'overdue_settings_header', |
467 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
467 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
468 | 468 | 'type' => 'header', |
469 | 469 | ), |
470 | 470 | 'overdue_active' => array( |
471 | 471 | 'id' => 'overdue_active', |
472 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
473 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
472 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
473 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
474 | 474 | 'type' => 'checkbox', |
475 | 475 | 'std' => false, |
476 | 476 | ), |
477 | 477 | 'email_template_header' => array( |
478 | 478 | 'id' => 'email_template_header', |
479 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
479 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
480 | 480 | 'type' => 'header', |
481 | 481 | ), |
482 | 482 | 'email_header_image' => array( |
483 | 483 | 'id' => 'email_header_image', |
484 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
485 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
484 | + 'name' => __('Header Image', 'invoicing'), |
|
485 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
486 | 486 | 'std' => '', |
487 | 487 | 'type' => 'text', |
488 | 488 | ), |
489 | 489 | 'email_footer_text' => array( |
490 | 490 | 'id' => 'email_footer_text', |
491 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
492 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
493 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
491 | + 'name' => __('Footer Text', 'invoicing'), |
|
492 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
493 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
494 | 494 | 'type' => 'textarea', |
495 | 495 | 'class' => 'regular-text', |
496 | 496 | 'rows' => 2, |
@@ -498,29 +498,29 @@ discard block |
||
498 | 498 | ), |
499 | 499 | 'email_base_color' => array( |
500 | 500 | 'id' => 'email_base_color', |
501 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
502 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
501 | + 'name' => __('Base Color', 'invoicing'), |
|
502 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
503 | 503 | 'std' => '#557da2', |
504 | 504 | 'type' => 'color', |
505 | 505 | ), |
506 | 506 | 'email_background_color' => array( |
507 | 507 | 'id' => 'email_background_color', |
508 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
509 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
508 | + 'name' => __('Background Color', 'invoicing'), |
|
509 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
510 | 510 | 'std' => '#f5f5f5', |
511 | 511 | 'type' => 'color', |
512 | 512 | ), |
513 | 513 | 'email_body_background_color' => array( |
514 | 514 | 'id' => 'email_body_background_color', |
515 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
516 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
515 | + 'name' => __('Body Background Color', 'invoicing'), |
|
516 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
517 | 517 | 'std' => '#fdfdfd', |
518 | 518 | 'type' => 'color', |
519 | 519 | ), |
520 | 520 | 'email_text_color' => array( |
521 | 521 | 'id' => 'email_text_color', |
522 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
523 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
522 | + 'name' => __('Body Text Color', 'invoicing'), |
|
523 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
524 | 524 | 'std' => '#505050', |
525 | 525 | 'type' => 'color', |
526 | 526 | ), |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ), |
536 | 536 | |
537 | 537 | // Integrations. |
538 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
538 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
539 | 539 | |
540 | 540 | /** Privacy Settings */ |
541 | 541 | 'privacy' => apply_filters( |
@@ -544,17 +544,17 @@ discard block |
||
544 | 544 | 'main' => array( |
545 | 545 | 'invoicing_privacy_policy_settings' => array( |
546 | 546 | 'id' => 'invoicing_privacy_policy_settings', |
547 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
547 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
548 | 548 | 'type' => 'header', |
549 | 549 | ), |
550 | 550 | 'privacy_page' => array( |
551 | 551 | 'id' => 'privacy_page', |
552 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
553 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
552 | + 'name' => __('Privacy Page', 'invoicing'), |
|
553 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
554 | 554 | 'type' => 'select', |
555 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' ) ), |
|
555 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
556 | 556 | 'class' => 'wpi_select2', |
557 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
557 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
558 | 558 | ), |
559 | 559 | ), |
560 | 560 | ) |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | 'main' => array( |
567 | 567 | 'invoice_number_format_settings' => array( |
568 | 568 | 'id' => 'invoice_number_format_settings', |
569 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
569 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
570 | 570 | 'type' => 'header', |
571 | 571 | ), |
572 | 572 | 'sequential_invoice_number' => array( |
573 | 573 | 'id' => 'sequential_invoice_number', |
574 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
575 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
574 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
575 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
576 | 576 | 'type' => 'checkbox', |
577 | 577 | ), |
578 | 578 | 'invoice_sequence_start' => array( |
579 | 579 | 'id' => 'invoice_sequence_start', |
580 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
581 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
580 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
581 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
582 | 582 | 'type' => 'number', |
583 | 583 | 'size' => 'small', |
584 | 584 | 'std' => '1', |
@@ -586,8 +586,8 @@ discard block |
||
586 | 586 | ), |
587 | 587 | 'invoice_number_padd' => array( |
588 | 588 | 'id' => 'invoice_number_padd', |
589 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
590 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
589 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
590 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
591 | 591 | 'type' => 'select', |
592 | 592 | 'options' => $invoice_number_padd_options, |
593 | 593 | 'std' => 5, |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | ), |
596 | 596 | 'invoice_number_prefix' => array( |
597 | 597 | 'id' => 'invoice_number_prefix', |
598 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
599 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
598 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
599 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
600 | 600 | 'type' => 'text', |
601 | 601 | 'size' => 'regular', |
602 | 602 | 'std' => 'INV-', |
@@ -604,77 +604,77 @@ discard block |
||
604 | 604 | ), |
605 | 605 | 'invoice_number_postfix' => array( |
606 | 606 | 'id' => 'invoice_number_postfix', |
607 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
608 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
607 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
608 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
609 | 609 | 'type' => 'text', |
610 | 610 | 'size' => 'regular', |
611 | 611 | 'std' => '', |
612 | 612 | ), |
613 | 613 | 'checkout_settings' => array( |
614 | 614 | 'id' => 'checkout_settings', |
615 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
615 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
616 | 616 | 'type' => 'header', |
617 | 617 | ), |
618 | 618 | 'disable_new_user_emails' => array( |
619 | 619 | 'id' => 'disable_new_user_emails', |
620 | - 'name' => __( 'Disable new user emails', 'invoicing' ), |
|
621 | - 'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ), |
|
620 | + 'name' => __('Disable new user emails', 'invoicing'), |
|
621 | + 'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'), |
|
622 | 622 | 'type' => 'checkbox', |
623 | 623 | ), |
624 | 624 | 'login_to_checkout' => array( |
625 | 625 | 'id' => 'login_to_checkout', |
626 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
627 | - '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' ), |
|
626 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
627 | + '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'), |
|
628 | 628 | 'type' => 'checkbox', |
629 | 629 | ), |
630 | 630 | 'enable_recaptcha' => array( |
631 | 631 | 'id' => 'enable_recaptcha', |
632 | - 'name' => __( 'Enable reCAPTCHA', 'invoicing' ), |
|
633 | - 'desc' => __( 'If ticked then reCAPTCHA will be enabled on the checkout page.', 'invoicing' ), |
|
632 | + 'name' => __('Enable reCAPTCHA', 'invoicing'), |
|
633 | + 'desc' => __('If ticked then reCAPTCHA will be enabled on the checkout page.', 'invoicing'), |
|
634 | 634 | 'type' => 'checkbox', |
635 | 635 | ), |
636 | 636 | 'recaptcha_version' => array( |
637 | 637 | 'id' => 'recaptcha_version', |
638 | - 'name' => __( 'reCAPTCHA Version', 'invoicing' ), |
|
639 | - 'desc' => __( 'Select the version of reCAPTCHA you would like to use.', 'invoicing' ), |
|
638 | + 'name' => __('reCAPTCHA Version', 'invoicing'), |
|
639 | + 'desc' => __('Select the version of reCAPTCHA you would like to use.', 'invoicing'), |
|
640 | 640 | 'type' => 'select', |
641 | 641 | 'options' => array( |
642 | - 'v2' => __( 'reCAPTCHA v2', 'invoicing' ), |
|
643 | - 'v3' => __( 'reCAPTCHA v3', 'invoicing' ), |
|
642 | + 'v2' => __('reCAPTCHA v2', 'invoicing'), |
|
643 | + 'v3' => __('reCAPTCHA v3', 'invoicing'), |
|
644 | 644 | ), |
645 | 645 | 'std' => 'v2', |
646 | 646 | ), |
647 | 647 | 'recaptcha_site_key' => array( |
648 | 648 | 'id' => 'recaptcha_site_key', |
649 | - 'name' => __( 'reCAPTCHA Site Key', 'invoicing' ), |
|
650 | - 'desc' => __( 'Enter your reCAPTCHA site key.', 'invoicing' ) . ' <a href="https://www.google.com/recaptcha/admin/create" target="_blank">' . __( 'Generate a site key.', 'invoicing' ) . '</a>', |
|
649 | + 'name' => __('reCAPTCHA Site Key', 'invoicing'), |
|
650 | + 'desc' => __('Enter your reCAPTCHA site key.', 'invoicing') . ' <a href="https://www.google.com/recaptcha/admin/create" target="_blank">' . __('Generate a site key.', 'invoicing') . '</a>', |
|
651 | 651 | 'type' => 'text', |
652 | 652 | 'size' => 'regular', |
653 | 653 | ), |
654 | 654 | 'recaptcha_secret_key' => array( |
655 | 655 | 'id' => 'recaptcha_secret_key', |
656 | - 'name' => __( 'reCAPTCHA Secret Key', 'invoicing' ), |
|
657 | - 'desc' => __( 'Enter your reCAPTCHA secret key.', 'invoicing' ), |
|
656 | + 'name' => __('reCAPTCHA Secret Key', 'invoicing'), |
|
657 | + 'desc' => __('Enter your reCAPTCHA secret key.', 'invoicing'), |
|
658 | 658 | 'type' => 'text', |
659 | 659 | 'size' => 'regular', |
660 | 660 | ), |
661 | 661 | 'maxmind_license_key' => array( |
662 | 662 | 'id' => 'maxmind_license_key', |
663 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
663 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
664 | 664 | 'type' => 'text', |
665 | 665 | 'size' => 'regular', |
666 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/hc/en-us/articles/4407111582235-Generate-a-License-Key">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
666 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/hc/en-us/articles/4407111582235-Generate-a-License-Key">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
667 | 667 | ), |
668 | 668 | |
669 | 669 | 'uninstall_settings' => array( |
670 | 670 | 'id' => 'uninstall_settings', |
671 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
671 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
672 | 672 | 'type' => 'header', |
673 | 673 | ), |
674 | 674 | 'remove_data_on_unistall' => array( |
675 | 675 | 'id' => 'remove_data_on_unistall', |
676 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
677 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
676 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
677 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
678 | 678 | 'type' => 'checkbox', |
679 | 679 | 'std' => '', |
680 | 680 | ), |
@@ -683,13 +683,13 @@ discard block |
||
683 | 683 | 'custom-css' => array( |
684 | 684 | 'css_settings' => array( |
685 | 685 | 'id' => 'css_settings', |
686 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
686 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
687 | 687 | 'type' => 'header', |
688 | 688 | ), |
689 | 689 | 'template_custom_css' => array( |
690 | 690 | 'id' => 'template_custom_css', |
691 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
692 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
691 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
692 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
693 | 693 | 'type' => 'textarea', |
694 | 694 | 'class' => 'regular-text', |
695 | 695 | 'rows' => 10, |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | 'main' => array( |
705 | 705 | 'tool_settings' => array( |
706 | 706 | 'id' => 'tool_settings', |
707 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
708 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
707 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
708 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
709 | 709 | 'type' => 'tools', |
710 | 710 | ), |
711 | 711 | ), |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Standardize IDs. |
13 | 13 | global $rendered_getpaid_forms; |
14 | 14 | |
15 | 15 | // Make sure that the form is active. |
16 | -if ( ! $form->is_active() ) { |
|
16 | +if (!$form->is_active()) { |
|
17 | 17 | aui()->alert( |
18 | 18 | array( |
19 | 19 | 'type' => 'warning', |
20 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
20 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
21 | 21 | ), |
22 | 22 | true |
23 | 23 | ); |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | // Require login to checkout. |
28 | -if ( wpinv_require_login_to_checkout() && ! get_current_user_id() ) { |
|
28 | +if (wpinv_require_login_to_checkout() && !get_current_user_id()) { |
|
29 | 29 | |
30 | 30 | aui()->alert( |
31 | 31 | array( |
32 | 32 | 'type' => 'danger', |
33 | - 'content' => __( 'You must be logged in to checkout.', 'invoicing' ), |
|
33 | + 'content' => __('You must be logged in to checkout.', 'invoicing'), |
|
34 | 34 | ), |
35 | 35 | true |
36 | 36 | ); |
@@ -38,36 +38,36 @@ discard block |
||
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | -if ( ! is_array( $rendered_getpaid_forms ) ) { |
|
41 | +if (!is_array($rendered_getpaid_forms)) { |
|
42 | 42 | $rendered_getpaid_forms = array(); |
43 | 43 | } |
44 | 44 | |
45 | -$rendered_getpaid_forms[ $form->get_id() ] = isset( $rendered_getpaid_forms[ $form->get_id() ] ) ? $rendered_getpaid_forms[ $form->get_id() ] + 1 : 0; |
|
45 | +$rendered_getpaid_forms[$form->get_id()] = isset($rendered_getpaid_forms[$form->get_id()]) ? $rendered_getpaid_forms[$form->get_id()] + 1 : 0; |
|
46 | 46 | |
47 | 47 | // Fires before displaying a payment form. |
48 | -do_action( 'getpaid_before_payment_form', $form ); |
|
48 | +do_action('getpaid_before_payment_form', $form); |
|
49 | 49 | ?> |
50 | 50 | |
51 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr( uniqid( 'gpf' ) ); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>' novalidate> |
|
51 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo esc_attr(uniqid('gpf')); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>' novalidate> |
|
52 | 52 | |
53 | 53 | <?php |
54 | 54 | |
55 | 55 | // Fires when printing the top of a payment form. |
56 | - do_action( 'getpaid_payment_form_top', $form ); |
|
56 | + do_action('getpaid_payment_form_top', $form); |
|
57 | 57 | |
58 | 58 | // And the optional invoice id. |
59 | - if ( ! empty( $form->invoice ) ) { |
|
60 | - getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
59 | + if (!empty($form->invoice)) { |
|
60 | + getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // We also want to include the form id. |
64 | - getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
64 | + getpaid_hidden_field('form_id', $form->get_id()); |
|
65 | 65 | |
66 | 66 | // And an indication that this is a payment form submission. |
67 | - getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
67 | + getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
68 | 68 | |
69 | 69 | // Fires before displaying payment form elements. |
70 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
70 | + do_action('getpaid_payment_form_before_elements', $form); |
|
71 | 71 | |
72 | 72 | // Display the elements. |
73 | 73 | ?> |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | <div class="row"> |
76 | 76 | <?php |
77 | 77 | |
78 | - foreach ( $form->get_elements() as $element ) { |
|
79 | - if ( isset( $element['type'] ) ) { |
|
80 | - $grid_class = getpaid_get_form_element_grid_class( $element ); |
|
81 | - do_action( 'getpaid_payment_form_element_before', $element, $form ); |
|
82 | - do_action( "getpaid_payment_form_element_before_{$element['type']}_template", $element, $form ); |
|
83 | - echo "<div class='" . esc_attr( $grid_class ) . "'>"; |
|
84 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
85 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
78 | + foreach ($form->get_elements() as $element) { |
|
79 | + if (isset($element['type'])) { |
|
80 | + $grid_class = getpaid_get_form_element_grid_class($element); |
|
81 | + do_action('getpaid_payment_form_element_before', $element, $form); |
|
82 | + do_action("getpaid_payment_form_element_before_{$element['type']}_template", $element, $form); |
|
83 | + echo "<div class='" . esc_attr($grid_class) . "'>"; |
|
84 | + do_action('getpaid_payment_form_element', $element, $form); |
|
85 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
86 | 86 | echo '</div>'; |
87 | - do_action( 'getpaid_payment_form_element_after', $element, $form ); |
|
88 | - do_action( "getpaid_payment_form_element_after_{$element['type']}_template", $element, $form ); |
|
87 | + do_action('getpaid_payment_form_element_after', $element, $form); |
|
88 | + do_action("getpaid_payment_form_element_after_{$element['type']}_template", $element, $form); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -95,28 +95,28 @@ discard block |
||
95 | 95 | |
96 | 96 | <?php |
97 | 97 | // Fires after displaying payment form elements. |
98 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
98 | + do_action('getpaid_payment_form_after_elements', $form); |
|
99 | 99 | |
100 | 100 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
101 | 101 | |
102 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
102 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
103 | 103 | |
104 | 104 | edit_post_link( |
105 | - __( 'Edit this form.', 'invoicing' ), |
|
105 | + __('Edit this form.', 'invoicing'), |
|
106 | 106 | '<small class="form-text text-muted">', |
107 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
107 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
108 | 108 | $form->get_id(), |
109 | 109 | 'text-danger' |
110 | 110 | ); |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | - echo wp_kses( $extra_markup, getpaid_allowed_html() ); |
|
114 | + echo wp_kses($extra_markup, getpaid_allowed_html()); |
|
115 | 115 | ?> |
116 | 116 | |
117 | 117 | <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;"> |
118 | 118 | <div class="spinner-border mx-auto align-self-center text-white" role="status"> |
119 | - <span class="sr-only"><?php esc_html_e( 'Loading...', 'invoicing' ); ?></span> |
|
119 | + <span class="sr-only"><?php esc_html_e('Loading...', 'invoicing'); ?></span> |
|
120 | 120 | </div> |
121 | 121 | </div> |
122 | 122 | |
@@ -125,4 +125,4 @@ discard block |
||
125 | 125 | <?php |
126 | 126 | |
127 | 127 | // Fires after displaying a payment form. |
128 | -do_action( 'getpaid_after_payment_form', $form ); |
|
128 | +do_action('getpaid_after_payment_form', $form); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states(), true ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states(), true) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states(), true ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states(), true) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = ! $is_eu && wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = !$is_eu && wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' !== $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return bool |
95 | 95 | */ |
96 | -function wpinv_use_store_address_as_tax_base( $tax_rule = false ) { |
|
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) === 'base'; |
|
96 | +function wpinv_use_store_address_as_tax_base($tax_rule = false) { |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') === 'base'; |
|
98 | 98 | |
99 | - if ( $tax_rule ) { |
|
100 | - $rules = getpaid_get_tax_rules( 'tax_base' ); |
|
101 | - $use_base = isset( $rules[ $tax_rule ] ) ? 'base' === $rules[ $tax_rule ] : $use_base; |
|
99 | + if ($tax_rule) { |
|
100 | + $rules = getpaid_get_tax_rules('tax_base'); |
|
101 | + $use_base = isset($rules[$tax_rule]) ? 'base' === $rules[$tax_rule] : $use_base; |
|
102 | 102 | } |
103 | 103 | |
104 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base, $tax_rule ); |
|
104 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base, $tax_rule); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return bool |
111 | 111 | */ |
112 | -function wpinv_get_vat_same_country_rule( $tax_rule = false ) { |
|
113 | - $rule = wpinv_get_option( 'vat_same_country_rule', 'vat_too' ); |
|
112 | +function wpinv_get_vat_same_country_rule($tax_rule = false) { |
|
113 | + $rule = wpinv_get_option('vat_same_country_rule', 'vat_too'); |
|
114 | 114 | |
115 | - if ( $tax_rule ) { |
|
116 | - $rules = getpaid_get_tax_rules( 'same_country_rule' ); |
|
117 | - $rule = isset( $rules[ $tax_rule ] ) ? $rules[ $tax_rule ] : $rule; |
|
115 | + if ($tax_rule) { |
|
116 | + $rules = getpaid_get_tax_rules('same_country_rule'); |
|
117 | + $rule = isset($rules[$tax_rule]) ? $rules[$tax_rule] : $rule; |
|
118 | 118 | } |
119 | 119 | |
120 | - return (bool) apply_filters( 'wpinv_get_vat_same_country_rule', $rule, $tax_rule ); |
|
120 | + return (bool) apply_filters('wpinv_get_vat_same_country_rule', $rule, $tax_rule); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return bool |
127 | 127 | */ |
128 | 128 | function wpinv_prices_include_tax() { |
129 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) === 'yes'; |
|
130 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
129 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') === 'yes'; |
|
130 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @return bool |
137 | 137 | */ |
138 | 138 | function wpinv_round_tax_per_tax_rate() { |
139 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
140 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
139 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
140 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return bool |
147 | 147 | */ |
148 | 148 | function wpinv_display_individual_tax_rates() { |
149 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) === 'individual'; |
|
150 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
149 | + $individual = wpinv_get_option('tax_display_totals', 'single') === 'individual'; |
|
150 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return float |
157 | 157 | */ |
158 | 158 | function wpinv_get_default_tax_rate() { |
159 | - $rate = wpinv_get_option( 'tax_rate', 0 ); |
|
160 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
159 | + $rate = wpinv_get_option('tax_rate', 0); |
|
160 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return bool |
167 | 167 | */ |
168 | 168 | function wpinv_same_country_exempt_vat() { |
169 | - return 'no' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ); |
|
169 | + return 'no' === wpinv_get_option('vat_same_country_rule', 'vat_too'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -186,28 +186,28 @@ discard block |
||
186 | 186 | * @param string $state |
187 | 187 | * @return array |
188 | 188 | */ |
189 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
189 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
190 | 190 | |
191 | 191 | // Abort if the item is not taxable. |
192 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
192 | + if (!wpinv_is_item_taxable($item)) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Maybe use the store address. |
197 | - if ( wpinv_use_store_address_as_tax_base( $item->get_vat_rule() ) ) { |
|
197 | + if (wpinv_use_store_address_as_tax_base($item->get_vat_rule())) { |
|
198 | 198 | $country = wpinv_get_default_country(); |
199 | 199 | $state = wpinv_get_default_state(); |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Retrieve tax rates. |
203 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
203 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
204 | 204 | |
205 | 205 | // Fallback to the default tax rates if non were found. |
206 | - if ( empty( $tax_rates ) ) { |
|
206 | + if (empty($tax_rates)) { |
|
207 | 207 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
208 | 208 | } |
209 | 209 | |
210 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
210 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | * @param array $rates |
218 | 218 | * @return array |
219 | 219 | */ |
220 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
220 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
221 | 221 | |
222 | 222 | $tax_class = $item->get_vat_class(); |
223 | 223 | |
224 | - foreach ( $rates as $i => $rate ) { |
|
224 | + foreach ($rates as $i => $rate) { |
|
225 | 225 | |
226 | - if ( '_reduced' === $tax_class ) { |
|
227 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
226 | + if ('_reduced' === $tax_class) { |
|
227 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( '_exempt' === $tax_class ) { |
|
231 | - $rates[ $i ]['rate'] = 0; |
|
230 | + if ('_exempt' === $tax_class) { |
|
231 | + $rates[$i]['rate'] = 0; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
235 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * @param array $rates |
243 | 243 | * @return array |
244 | 244 | */ |
245 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
245 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
246 | 246 | |
247 | 247 | $is_inclusive = wpinv_prices_include_tax(); |
248 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
248 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
249 | 249 | |
250 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
250 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * @param float $recurring_tax_amount |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
262 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
263 | 263 | |
264 | - $initial_tax = $tax_amount; |
|
264 | + $initial_tax = $tax_amount; |
|
265 | 265 | $recurring_tax = 0; |
266 | 266 | |
267 | - if ( $item->is_recurring() ) { |
|
267 | + if ($item->is_recurring()) { |
|
268 | 268 | $recurring_tax = $recurring_tax_amount; |
269 | 269 | } |
270 | 270 | |
271 | 271 | return array( |
272 | - 'name' => sanitize_text_field( $tax_name ), |
|
272 | + 'name' => sanitize_text_field($tax_name), |
|
273 | 273 | 'initial_tax' => $initial_tax, |
274 | 274 | 'recurring_tax' => $recurring_tax, |
275 | 275 | ); |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @param string $vat_number |
283 | 283 | * @return string |
284 | 284 | */ |
285 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
286 | - return str_replace( array( ' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
285 | +function wpinv_sanitize_vat_number($vat_number) { |
|
286 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -292,22 +292,22 @@ discard block |
||
292 | 292 | * @param string $vat_number |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
295 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
296 | 296 | |
297 | - $country = substr( $vat_number, 0, 2 ); |
|
298 | - $vatin = substr( $vat_number, 2 ); |
|
299 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
297 | + $country = substr($vat_number, 0, 2); |
|
298 | + $vatin = substr($vat_number, 2); |
|
299 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
300 | 300 | |
301 | - if ( isset( $regexes[ $country ] ) ) { |
|
301 | + if (isset($regexes[$country])) { |
|
302 | 302 | |
303 | - $regex = $regexes[ $country ]; |
|
303 | + $regex = $regexes[$country]; |
|
304 | 304 | $regex = '/^(?:' . $regex . ')$/'; |
305 | - return 1 === preg_match( $regex, $vatin ); |
|
305 | + return 1 === preg_match($regex, $vatin); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | 309 | // Not an EU state, use filters to validate the number. |
310 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
310 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -316,29 +316,29 @@ discard block |
||
316 | 316 | * @param string $vat_number |
317 | 317 | * @return bool |
318 | 318 | */ |
319 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
319 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
320 | 320 | |
321 | - $country = substr( $vat_number, 0, 2 ); |
|
322 | - $vatin = substr( $vat_number, 2 ); |
|
321 | + $country = substr($vat_number, 0, 2); |
|
322 | + $vatin = substr($vat_number, 2); |
|
323 | 323 | |
324 | 324 | $url = add_query_arg( |
325 | 325 | array( |
326 | - 'ms' => rawurlencode( $country ), |
|
327 | - 'iso' => rawurlencode( $country ), |
|
328 | - 'vat' => rawurlencode( $vatin ), |
|
326 | + 'ms' => rawurlencode($country), |
|
327 | + 'iso' => rawurlencode($country), |
|
328 | + 'vat' => rawurlencode($vatin), |
|
329 | 329 | ), |
330 | 330 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
331 | 331 | ); |
332 | 332 | |
333 | - $response = wp_remote_get( $url ); |
|
334 | - $response = wp_remote_retrieve_body( $response ); |
|
333 | + $response = wp_remote_get($url); |
|
334 | + $response = wp_remote_retrieve_body($response); |
|
335 | 335 | |
336 | 336 | // Fallback gracefully if the VIES website is down. |
337 | - if ( empty( $response ) ) { |
|
337 | + if (empty($response)) { |
|
338 | 338 | return true; |
339 | 339 | } |
340 | 340 | |
341 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
341 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
@@ -349,17 +349,17 @@ discard block |
||
349 | 349 | * @param string $country |
350 | 350 | * @return bool |
351 | 351 | */ |
352 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
352 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
353 | 353 | |
354 | 354 | // In case the vat number does not have a country code... |
355 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
356 | - $_country = substr( $vat_number, 0, 2 ); |
|
355 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
356 | + $_country = substr($vat_number, 0, 2); |
|
357 | 357 | |
358 | - if ( wpinv_country_name( $_country ) === $_country ) { |
|
359 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
358 | + if (wpinv_country_name($_country) === $_country) { |
|
359 | + $vat_number = strtoupper($country) . $vat_number; |
|
360 | 360 | } |
361 | 361 | |
362 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
362 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -368,39 +368,39 @@ discard block |
||
368 | 368 | * @return bool |
369 | 369 | */ |
370 | 370 | function wpinv_should_validate_vat_number() { |
371 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
372 | - return ! empty( $validate ); |
|
371 | + $validate = wpinv_get_option('validate_vat_number'); |
|
372 | + return !empty($validate); |
|
373 | 373 | } |
374 | 374 | |
375 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
376 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
375 | +function wpinv_sales_tax_for_year($year = null) { |
|
376 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
379 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
380 | 380 | global $wpdb; |
381 | 381 | |
382 | 382 | // Start at zero |
383 | 383 | $tax = 0; |
384 | 384 | |
385 | - if ( ! empty( $year ) ) { |
|
385 | + if (!empty($year)) { |
|
386 | 386 | $args = array( |
387 | 387 | 'post_type' => 'wpi_invoice', |
388 | - 'post_status' => array( 'publish' ), |
|
388 | + 'post_status' => array('publish'), |
|
389 | 389 | 'posts_per_page' => -1, |
390 | 390 | 'year' => $year, |
391 | 391 | 'fields' => 'ids', |
392 | 392 | ); |
393 | 393 | |
394 | - $payments = get_posts( $args ); |
|
395 | - $payment_ids = implode( ',', $payments ); |
|
394 | + $payments = get_posts($args); |
|
395 | + $payment_ids = implode(',', $payments); |
|
396 | 396 | |
397 | - if ( count( $payments ) > 0 ) { |
|
397 | + if (count($payments) > 0) { |
|
398 | 398 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
399 | - $tax = $wpdb->get_var( $sql ); |
|
399 | + $tax = $wpdb->get_var($sql); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
403 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
403 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | function wpinv_is_cart_taxed() { |
@@ -409,34 +409,34 @@ discard block |
||
409 | 409 | |
410 | 410 | function wpinv_prices_show_tax_on_checkout() { |
411 | 411 | return false; // TODO |
412 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) === 'yes' && wpinv_use_taxes() ); |
|
412 | + $ret = (wpinv_get_option('checkout_include_tax', false) === 'yes' && wpinv_use_taxes()); |
|
413 | 413 | |
414 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
414 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | function wpinv_display_tax_rate() { |
418 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
418 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
419 | 419 | |
420 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
420 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | function wpinv_cart_needs_tax_address_fields() { |
424 | - if ( ! wpinv_is_cart_taxed() ) { |
|
424 | + if (!wpinv_is_cart_taxed()) { |
|
425 | 425 | return false; |
426 | 426 | } |
427 | 427 | |
428 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
428 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
429 | 429 | } |
430 | 430 | |
431 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
432 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
433 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
431 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
432 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
433 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
434 | 434 | } |
435 | 435 | |
436 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
436 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
437 | 437 | $currency = wpinv_get_currency(); |
438 | 438 | |
439 | - switch ( $currency ) { |
|
439 | + switch ($currency) { |
|
440 | 440 | case 'RIAL': |
441 | 441 | case 'JPY': |
442 | 442 | case 'TWD': |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | break; |
446 | 446 | } |
447 | 447 | |
448 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
448 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | function wpinv_tax_amount() { |
452 | 452 | $output = 0.00; |
453 | 453 | |
454 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
454 | + return apply_filters('wpinv_tax_amount', $output); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -459,25 +459,25 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @param string|bool|null $vat_rule |
461 | 461 | */ |
462 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
462 | +function getpaid_filter_vat_rule($vat_rule) { |
|
463 | 463 | |
464 | - if ( empty( $vat_rule ) ) { |
|
464 | + if (empty($vat_rule)) { |
|
465 | 465 | return 'digital'; |
466 | 466 | } |
467 | 467 | |
468 | 468 | return $vat_rule; |
469 | 469 | } |
470 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
470 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
471 | 471 | |
472 | 472 | /** |
473 | 473 | * Filters the VAT class to ensure that each item has a VAT class. |
474 | 474 | * |
475 | 475 | * @param string|bool|null $vat_rule |
476 | 476 | */ |
477 | -function getpaid_filter_vat_class( $vat_class ) { |
|
478 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
477 | +function getpaid_filter_vat_class($vat_class) { |
|
478 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
479 | 479 | } |
480 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
480 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Returns a list of all tax classes. |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | return apply_filters( |
490 | 490 | 'getpaid_tax_classes', |
491 | 491 | array( |
492 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
493 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
494 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
492 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
493 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
494 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
495 | 495 | ) |
496 | 496 | ); |
497 | 497 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array |
504 | 504 | */ |
505 | -function getpaid_get_tax_rules( $return = 'label' ) { |
|
506 | - return wp_list_pluck( GetPaid_Tax::get_all_tax_rules(), $return, 'key' ); |
|
505 | +function getpaid_get_tax_rules($return = 'label') { |
|
506 | + return wp_list_pluck(GetPaid_Tax::get_all_tax_rules(), $return, 'key'); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -512,15 +512,15 @@ discard block |
||
512 | 512 | * @param string $tax_class |
513 | 513 | * @return string |
514 | 514 | */ |
515 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
515 | +function getpaid_get_tax_class_label($tax_class) { |
|
516 | 516 | |
517 | 517 | $classes = getpaid_get_tax_classes(); |
518 | 518 | |
519 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
520 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
519 | + if (isset($classes[$tax_class])) { |
|
520 | + return sanitize_text_field($classes[$tax_class]); |
|
521 | 521 | } |
522 | 522 | |
523 | - return sanitize_text_field( $tax_class ); |
|
523 | + return sanitize_text_field($tax_class); |
|
524 | 524 | |
525 | 525 | } |
526 | 526 | |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | * @param string $tax_rule |
531 | 531 | * @return string |
532 | 532 | */ |
533 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
533 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
534 | 534 | |
535 | 535 | $rules = getpaid_get_tax_rules(); |
536 | 536 | |
537 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
538 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
537 | + if (isset($rules[$tax_rule])) { |
|
538 | + return sanitize_text_field($rules[$tax_rule]); |
|
539 | 539 | } |
540 | 540 | |
541 | - return sanitize_text_field( $tax_rule ); |
|
541 | + return sanitize_text_field($tax_rule); |
|
542 | 542 | |
543 | 543 | } |
544 | 544 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | * @param string $recurring |
550 | 550 | * @return string |
551 | 551 | */ |
552 | -function getpaid_get_taxable_amount( $item, $recurring = false ) { |
|
552 | +function getpaid_get_taxable_amount($item, $recurring = false) { |
|
553 | 553 | |
554 | 554 | $taxable_amount = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
555 | 555 | $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount; |
556 | - $taxable_amount = max( 0, $taxable_amount ); |
|
557 | - return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring ); |
|
556 | + $taxable_amount = max(0, $taxable_amount); |
|
557 | + return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring); |
|
558 | 558 | |
559 | 559 | } |
@@ -12,75 +12,75 @@ discard block |
||
12 | 12 | * @var GetPaid_Payment_Form $form |
13 | 13 | */ |
14 | 14 | |
15 | -defined( 'ABSPATH' ) || exit; |
|
15 | +defined('ABSPATH') || exit; |
|
16 | 16 | |
17 | -$field_type = sanitize_key( $field_type ); |
|
17 | +$field_type = sanitize_key($field_type); |
|
18 | 18 | |
19 | -echo "<div class='row " . esc_attr( $field_type ) . "'>"; |
|
19 | +echo "<div class='row " . esc_attr($field_type) . "'>"; |
|
20 | 20 | |
21 | 21 | // Prepare current user. |
22 | -if ( ! empty( $form->invoice ) ) { |
|
22 | +if (!empty($form->invoice)) { |
|
23 | 23 | $user_id = $form->invoice->get_user_id(); |
24 | 24 | } |
25 | 25 | |
26 | -if ( empty( $user_id ) && is_user_logged_in() ) { |
|
26 | +if (empty($user_id) && is_user_logged_in()) { |
|
27 | 27 | $user_id = get_current_user_id(); |
28 | 28 | } |
29 | 29 | |
30 | -if ( ! empty( $user_id ) ) { |
|
31 | - $user = wp_get_current_user(); |
|
30 | +if (!empty($user_id)) { |
|
31 | + $user = wp_get_current_user(); |
|
32 | 32 | } |
33 | 33 | |
34 | -foreach ( $fields as $address_field ) { |
|
34 | +foreach ($fields as $address_field) { |
|
35 | 35 | |
36 | 36 | // Skip if it is hidden. |
37 | - if ( empty( $address_field['visible'] ) ) { |
|
37 | + if (empty($address_field['visible'])) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
41 | + do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field); |
|
42 | 42 | |
43 | 43 | // Prepare variables. |
44 | 44 | $field_name = $address_field['name']; |
45 | 45 | $field_name = "{$field_type}[$field_name]"; |
46 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
47 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
48 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
49 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
50 | - $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; |
|
51 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
52 | - |
|
53 | - $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] ); |
|
54 | - if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) { |
|
55 | - $value = call_user_func( array( $form->invoice, $method_name ) ); |
|
46 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
47 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
48 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
49 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
50 | + $value = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : ''; |
|
51 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
52 | + |
|
53 | + $method_name = 'get_' . str_replace('wpinv_', '', $address_field['name']); |
|
54 | + if (!empty($form->invoice) && is_callable(array($form->invoice, $method_name))) { |
|
55 | + $value = call_user_func(array($form->invoice, $method_name)); |
|
56 | 56 | } |
57 | 57 | |
58 | - if ( empty( $value ) && 'wpinv_first_name' === $address_field['name'] && ! empty( $user ) ) { |
|
58 | + if (empty($value) && 'wpinv_first_name' === $address_field['name'] && !empty($user)) { |
|
59 | 59 | $value = $user->first_name; |
60 | 60 | } |
61 | 61 | |
62 | - if ( empty( $value ) && 'wpinv_last_name' === $address_field['name'] && ! empty( $user ) ) { |
|
62 | + if (empty($value) && 'wpinv_last_name' === $address_field['name'] && !empty($user)) { |
|
63 | 63 | $value = $user->last_name; |
64 | 64 | } |
65 | 65 | |
66 | - if ( ! empty( $address_field['required'] ) ) { |
|
66 | + if (!empty($address_field['required'])) { |
|
67 | 67 | $label .= "<span class='text-danger'> *</span>"; |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Display the country. |
71 | - if ( 'wpinv_country' === $address_field['name'] ) { |
|
71 | + if ('wpinv_country' === $address_field['name']) { |
|
72 | 72 | |
73 | - echo "<div class='form-group mb-3 " . esc_attr( $wrap_class ) . " getpaid-address-field-wrapper__country'"; |
|
73 | + echo "<div class='form-group mb-3 " . esc_attr($wrap_class) . " getpaid-address-field-wrapper__country'"; |
|
74 | 74 | |
75 | 75 | aui()->select( |
76 | 76 | array( |
77 | 77 | 'options' => wpinv_get_country_list(), |
78 | - 'name' => esc_attr( $field_name ), |
|
79 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
80 | - 'value' => esc_attr( $country ), |
|
78 | + 'name' => esc_attr($field_name), |
|
79 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
80 | + 'value' => esc_attr($country), |
|
81 | 81 | 'placeholder' => $placeholder, |
82 | - 'required' => ! empty( $address_field['required'] ), |
|
83 | - 'label' => wp_kses_post( $label ), |
|
82 | + 'required' => !empty($address_field['required']), |
|
83 | + 'label' => wp_kses_post($label), |
|
84 | 84 | 'label_type' => 'vertical', |
85 | 85 | 'help_text' => $description, |
86 | 86 | 'class' => 'getpaid-address-field wpinv_country', |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | true |
95 | 95 | ); |
96 | 96 | |
97 | - if ( wpinv_should_validate_vat_number() ) { |
|
97 | + if (wpinv_should_validate_vat_number()) { |
|
98 | 98 | |
99 | 99 | aui()->input( |
100 | 100 | array( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'id' => "shipping-toggle$uniqid", |
104 | 104 | 'wrap_class' => 'getpaid-address-field-wrapper__address-confirm mt-1 d-none', |
105 | 105 | 'required' => false, |
106 | - 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", |
|
106 | + 'label' => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>", |
|
107 | 107 | 'value' => 1, |
108 | 108 | 'checked' => true, |
109 | 109 | 'class' => 'w-auto', |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // Display the state. |
121 | - elseif ( 'wpinv_state' == $address_field['name'] ) { |
|
121 | + elseif ('wpinv_state' == $address_field['name']) { |
|
122 | 122 | |
123 | - if ( empty( $value ) ) { |
|
123 | + if (empty($value)) { |
|
124 | 124 | $value = wpinv_get_default_state(); |
125 | 125 | } |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $placeholder, |
131 | 131 | $label, |
132 | 132 | $description, |
133 | - ! empty( $address_field['required'] ), |
|
133 | + !empty($address_field['required']), |
|
134 | 134 | $wrap_class, |
135 | 135 | $field_name, |
136 | 136 | true |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | |
139 | 139 | } else { |
140 | 140 | |
141 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
142 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
141 | + $key = str_replace('wpinv_', '', $address_field['name']); |
|
142 | + $key = esc_attr(str_replace('_', '-', $key)); |
|
143 | 143 | $autocomplete = ''; |
144 | 144 | $replacements = array( |
145 | 145 | 'zip' => 'postal-code', |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | ); |
153 | 153 | |
154 | 154 | |
155 | - if ( isset( $replacements[ $key ] ) ) { |
|
155 | + if (isset($replacements[$key])) { |
|
156 | 156 | $autocomplete = array( |
157 | - 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
157 | + 'autocomplete' => "$field_type {$replacements[$key]}", |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | |
161 | 161 | $append = ''; |
162 | 162 | |
163 | - if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { |
|
164 | - $valid = esc_attr__( 'Valid', 'invoicing' ); |
|
165 | - $invalid = esc_attr__( 'Invalid', 'invoicing' ); |
|
166 | - $validate = esc_attr__( 'Validate', 'invoicing' ); |
|
163 | + if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) { |
|
164 | + $valid = esc_attr__('Valid', 'invoicing'); |
|
165 | + $invalid = esc_attr__('Invalid', 'invoicing'); |
|
166 | + $validate = esc_attr__('Validate', 'invoicing'); |
|
167 | 167 | $append = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; |
168 | 168 | } |
169 | 169 | |
170 | - if ( 'billing' === $field_type ) { |
|
171 | - $description .= '<div class="getpaid-error-' . esc_attr( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
170 | + if ('billing' === $field_type) { |
|
171 | + $description .= '<div class="getpaid-error-' . esc_attr($field_name) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>'; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | aui()->input( |
175 | 175 | array( |
176 | - 'name' => esc_attr( $field_name ), |
|
177 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
178 | - 'required' => ! empty( $address_field['required'] ), |
|
176 | + 'name' => esc_attr($field_name), |
|
177 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
178 | + 'required' => !empty($address_field['required']), |
|
179 | 179 | 'placeholder' => $placeholder, |
180 | - 'label' => wp_kses_post( $label ), |
|
180 | + 'label' => wp_kses_post($label), |
|
181 | 181 | 'label_type' => 'vertical', |
182 | 182 | 'help_text' => $description, |
183 | 183 | 'type' => 'text', |
184 | - 'value' => apply_filters( 'getpaid_payment_form_value_' . $address_field['name'], esc_attr( $value ) ), |
|
185 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
184 | + 'value' => apply_filters('getpaid_payment_form_value_' . $address_field['name'], esc_attr($value)), |
|
185 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), |
|
186 | 186 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
187 | 187 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
188 | 188 | 'extra_attributes' => $autocomplete, |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
196 | + do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | echo '</div>'; |
@@ -7,37 +7,37 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | $value = $query_value; |
13 | 13 | $class = ''; |
14 | 14 | |
15 | -if ( ! empty( $form->invoice ) ) { |
|
16 | - $value = sanitize_email( $form->invoice->get_email() ); |
|
17 | -} elseif ( is_user_logged_in() ) { |
|
15 | +if (!empty($form->invoice)) { |
|
16 | + $value = sanitize_email($form->invoice->get_email()); |
|
17 | +} elseif (is_user_logged_in()) { |
|
18 | 18 | $user = wp_get_current_user(); |
19 | - $value = sanitize_email( $user->user_email ); |
|
19 | + $value = sanitize_email($user->user_email); |
|
20 | 20 | } |
21 | 21 | |
22 | -if ( ! empty( $value ) && ! empty( $hide_billing_email ) ) { |
|
22 | +if (!empty($value) && !empty($hide_billing_email)) { |
|
23 | 23 | $class = 'd-none'; |
24 | 24 | } |
25 | 25 | |
26 | -do_action( 'getpaid_before_payment_form_billing_email', $form ); |
|
26 | +do_action('getpaid_before_payment_form_billing_email', $form); |
|
27 | 27 | |
28 | -echo "<span class='" . esc_attr( $class ) . "'>"; |
|
28 | +echo "<span class='" . esc_attr($class) . "'>"; |
|
29 | 29 | |
30 | 30 | aui()->input( |
31 | 31 | array( |
32 | 32 | 'name' => 'billing_email', |
33 | - 'id' => esc_attr( $element_id ), |
|
34 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
35 | - 'required' => ! empty( $required ), |
|
36 | - 'label' => empty( $label ) ? '' : wp_kses_post( $label ) . '<span class="text-danger"> *</span>', |
|
33 | + 'id' => esc_attr($element_id), |
|
34 | + 'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder), |
|
35 | + 'required' => !empty($required), |
|
36 | + 'label' => empty($label) ? '' : wp_kses_post($label) . '<span class="text-danger"> *</span>', |
|
37 | 37 | 'label_type' => 'vertical', |
38 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
38 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
39 | 39 | 'type' => 'email', |
40 | - 'value' => apply_filters ( 'getpaid_payment_form_billing_email_value', $value ), |
|
40 | + 'value' => apply_filters('getpaid_payment_form_billing_email_value', $value), |
|
41 | 41 | 'class' => 'wpinv_billing_email getpaid-refresh-on-change', |
42 | 42 | 'extra_attributes' => array( |
43 | 43 | 'autocomplete' => 'billing email', |
@@ -48,4 +48,4 @@ discard block |
||
48 | 48 | |
49 | 49 | echo '</span>'; |
50 | 50 | |
51 | -do_action( 'getpaid_after_payment_form_billing_email', $form ); |
|
51 | +do_action('getpaid_after_payment_form_billing_email', $form); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns an array of discount type. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | return apply_filters( |
18 | 18 | 'wpinv_discount_types', |
19 | 19 | array( |
20 | - 'percent' => __( 'Percentage', 'invoicing' ), |
|
21 | - 'flat' => __( 'Flat Amount', 'invoicing' ), |
|
20 | + 'percent' => __('Percentage', 'invoicing'), |
|
21 | + 'flat' => __('Flat Amount', 'invoicing'), |
|
22 | 22 | ) |
23 | 23 | ); |
24 | 24 | } |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | -function wpinv_get_discount_type_name( $type = '' ) { |
|
31 | +function wpinv_get_discount_type_name($type = '') { |
|
32 | 32 | $types = wpinv_get_discount_types(); |
33 | - return isset( $types[ $type ] ) ? $types[ $type ] : $type; |
|
33 | + return isset($types[$type]) ? $types[$type] : $type; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Deletes a discount via the admin page. |
38 | 38 | * |
39 | 39 | */ |
40 | -function wpinv_delete_discount( $data ) { |
|
40 | +function wpinv_delete_discount($data) { |
|
41 | 41 | |
42 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
43 | - $discount->delete( true ); |
|
42 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
43 | + $discount->delete(true); |
|
44 | 44 | |
45 | 45 | } |
46 | -add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' ); |
|
46 | +add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount'); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deactivates a discount via the admin page. |
50 | 50 | */ |
51 | -function wpinv_activate_discount( $data ) { |
|
51 | +function wpinv_activate_discount($data) { |
|
52 | 52 | |
53 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
54 | - $discount->set_status( 'publish' ); |
|
53 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
54 | + $discount->set_status('publish'); |
|
55 | 55 | $discount->save(); |
56 | 56 | |
57 | 57 | } |
58 | -add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' ); |
|
58 | +add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Activates a discount via the admin page. |
62 | 62 | */ |
63 | -function wpinv_deactivate_discount( $data ) { |
|
63 | +function wpinv_deactivate_discount($data) { |
|
64 | 64 | |
65 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
66 | - $discount->set_status( 'pending' ); |
|
65 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
66 | + $discount->set_status('pending'); |
|
67 | 67 | $discount->save(); |
68 | 68 | |
69 | 69 | } |
70 | -add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' ); |
|
70 | +add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Fetches a discount object. |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @since 1.0.15 |
77 | 77 | * @return WPInv_Discount |
78 | 78 | */ |
79 | -function wpinv_get_discount( $discount ) { |
|
80 | - return new WPInv_Discount( $discount ); |
|
79 | +function wpinv_get_discount($discount) { |
|
80 | + return new WPInv_Discount($discount); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @since 1.0.15 |
88 | 88 | * @return WPInv_Discount |
89 | 89 | */ |
90 | -function wpinv_get_discount_obj( $discount = 0 ) { |
|
91 | - return new WPInv_Discount( $discount ); |
|
90 | +function wpinv_get_discount_obj($discount = 0) { |
|
91 | + return new WPInv_Discount($discount); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @param string|int $value The field value |
99 | 99 | * @return bool|WPInv_Discount |
100 | 100 | */ |
101 | -function wpinv_get_discount_by( $deprecated = null, $value = '' ) { |
|
102 | - $discount = new WPInv_Discount( $value ); |
|
101 | +function wpinv_get_discount_by($deprecated = null, $value = '') { |
|
102 | + $discount = new WPInv_Discount($value); |
|
103 | 103 | |
104 | - if ( $discount->get_id() != 0 ) { |
|
104 | + if ($discount->get_id() != 0) { |
|
105 | 105 | return $discount; |
106 | 106 | } |
107 | 107 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | function wpinv_get_discount_statuses() { |
117 | 117 | |
118 | 118 | return array( |
119 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
120 | - 'publish' => __( 'Active', 'invoicing' ), |
|
121 | - 'inactive' => __( 'Inactive', 'invoicing' ), |
|
119 | + 'expired' => __('Expired', 'invoicing'), |
|
120 | + 'publish' => __('Active', 'invoicing'), |
|
121 | + 'inactive' => __('Inactive', 'invoicing'), |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * Retrieves an invoice status label. |
128 | 128 | */ |
129 | -function wpinv_discount_status( $status ) { |
|
129 | +function wpinv_discount_status($status) { |
|
130 | 130 | $statuses = wpinv_get_discount_statuses(); |
131 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' ); |
|
131 | + return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @param int|array|string|WPInv_Discount $code discount data, object, ID or code. |
139 | 139 | * @return bool |
140 | 140 | */ |
141 | -function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) { |
|
141 | +function wpinv_discount_is_recurring($discount = 0, $code = 0) { |
|
142 | 142 | |
143 | - if ( ! empty( $discount ) ) { |
|
144 | - $discount = wpinv_get_discount_obj( $discount ); |
|
143 | + if (!empty($discount)) { |
|
144 | + $discount = wpinv_get_discount_obj($discount); |
|
145 | 145 | } else { |
146 | - $discount = wpinv_get_discount_obj( $code ); |
|
146 | + $discount = wpinv_get_discount_obj($code); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $discount->get_is_recurring(); |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param WPInv_Discount $discount |
159 | 159 | * @return array |
160 | 160 | */ |
161 | -function getpaid_calculate_invoice_discount( $invoice, $discount ) { |
|
161 | +function getpaid_calculate_invoice_discount($invoice, $discount) { |
|
162 | 162 | |
163 | 163 | $initial_discount = 0; |
164 | 164 | $recurring_discount = 0; |
165 | 165 | |
166 | - foreach ( $invoice->get_items() as $item ) { |
|
166 | + foreach ($invoice->get_items() as $item) { |
|
167 | 167 | |
168 | 168 | // Abort if it is not valid for this item. |
169 | - if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
169 | + if (!$discount->is_valid_for_items(array($item->get_id()))) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Calculate the initial amount... |
174 | - $item_discount = $discount->get_discounted_amount( $item->get_sub_total() ); |
|
174 | + $item_discount = $discount->get_discounted_amount($item->get_sub_total()); |
|
175 | 175 | $recurring_item_discount = 0; |
176 | 176 | |
177 | 177 | // ... and maybe the recurring amount. |
178 | - if ( $item->is_recurring() && $discount->is_recurring() ) { |
|
179 | - $recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() ); |
|
178 | + if ($item->is_recurring() && $discount->is_recurring()) { |
|
179 | + $recurring_item_discount = $discount->get_discounted_amount($item->get_recurring_sub_total()); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Discount should not exceed discounted amount. |
183 | - if ( ! $discount->is_type( 'percent' ) ) { |
|
183 | + if (!$discount->is_type('percent')) { |
|
184 | 184 | |
185 | - if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) { |
|
185 | + if (($initial_discount + $item_discount) > $discount->get_amount()) { |
|
186 | 186 | $item_discount = $discount->get_amount() - $initial_discount; |
187 | 187 | } |
188 | 188 | |
189 | - if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) { |
|
189 | + if (($recurring_discount + $recurring_item_discount) > $discount->get_amount()) { |
|
190 | 190 | $recurring_item_discount = $discount->get_amount() - $recurring_discount; |
191 | 191 | } |
192 | 192 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | array( |
219 | 219 | 'post_type' => 'wpi_discount', |
220 | 220 | 'numberposts' => 1, |
221 | - 'fields' => array( 'ids' ), |
|
221 | + 'fields' => array('ids'), |
|
222 | 222 | ) |
223 | 223 | ); |
224 | 224 | |
225 | - return ! empty( $discounts ); |
|
225 | + return !empty($discounts); |
|
226 | 226 | |
227 | 227 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | // Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity (buy buttons) |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
287 | + if ($item->can_purchase()) { |
|
288 | 288 | |
289 | 289 | $value = (float) $value; |
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
290 | + $item->set_quantity($value); |
|
291 | + if (0 == $value) { |
|
292 | + $item->set_quantity(1); |
|
293 | + $item->set_allow_quantities(true); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Items saved via payment forms editor. |
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
303 | + if (is_array($value) && isset($value['id'])) { |
|
304 | 304 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
305 | + $item = new GetPaid_Form_Item($value['id']); |
|
306 | 306 | |
307 | - if ( ! $item->can_purchase() ) { |
|
307 | + if (!$item->can_purchase()) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Sub-total (Cart items). |
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
312 | + if (isset($value['subtotal'])) { |
|
313 | + $item->set_price($value['subtotal']); |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
316 | + if (isset($value['quantity'])) { |
|
317 | + $item->set_quantity($value['quantity']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
320 | + if (isset($value['allow_quantities'])) { |
|
321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
324 | + if (isset($value['required'])) { |
|
325 | + $item->set_is_required($value['required']); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
328 | + if (isset($value['description'])) { |
|
329 | + $item->set_custom_description($value['description']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
338 | + if (is_numeric($key) && is_array($value)) { |
|
339 | + $item = new GetPaid_Form_Item($key); |
|
340 | 340 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
342 | + $item->set_price($value['price']); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $item->can_purchase() ) { |
|
345 | + if ($item->can_purchase()) { |
|
346 | 346 | $prepared[] = $item; |
347 | 347 | } |
348 | 348 | |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | - if ( 'objects' == $return && 'view' == $context ) { |
|
353 | + if ('objects' == $return && 'view' == $context) { |
|
354 | 354 | return $prepared; |
355 | 355 | } |
356 | 356 | |
357 | 357 | $items = array(); |
358 | - foreach ( $prepared as $item ) { |
|
358 | + foreach ($prepared as $item) { |
|
359 | 359 | $items[] = $item->prepare_data_for_use(); |
360 | 360 | } |
361 | 361 | |
@@ -369,14 +369,14 @@ discard block |
||
369 | 369 | * @param int $item_id The item id to return. |
370 | 370 | * @return GetPaid_Form_Item|bool |
371 | 371 | */ |
372 | - public function get_item( $item_id ) { |
|
372 | + public function get_item($item_id) { |
|
373 | 373 | |
374 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
374 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
375 | 375 | return false; |
376 | 376 | } |
377 | 377 | |
378 | - foreach ( $this->get_items() as $item ) { |
|
379 | - if ( $item->get_id() == (int) $item_id ) { |
|
378 | + foreach ($this->get_items() as $item) { |
|
379 | + if ($item->get_id() == (int) $item_id) { |
|
380 | 380 | return $item; |
381 | 381 | } |
382 | 382 | } |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | * @param string $element_type The element type to return. |
393 | 393 | * @return array|bool |
394 | 394 | */ |
395 | - public function get_element_type( $element_type ) { |
|
395 | + public function get_element_type($element_type) { |
|
396 | 396 | |
397 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
397 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
398 | 398 | return false; |
399 | 399 | } |
400 | 400 | |
401 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
401 | + foreach ($this->get_prop('elements') as $element) { |
|
402 | 402 | |
403 | - if ( $element['type'] === $element_type ) { |
|
403 | + if ($element['type'] === $element_type) { |
|
404 | 404 | return $element; |
405 | 405 | } |
406 | 406 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return float |
418 | 418 | */ |
419 | - public function get_earned( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'earned', $context ); |
|
419 | + public function get_earned($context = 'view') { |
|
420 | + return $this->get_prop('earned', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return float |
429 | 429 | */ |
430 | - public function get_refunded( $context = 'view' ) { |
|
431 | - return $this->get_prop( 'refunded', $context ); |
|
430 | + public function get_refunded($context = 'view') { |
|
431 | + return $this->get_prop('refunded', $context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $context View or edit context. |
439 | 439 | * @return float |
440 | 440 | */ |
441 | - public function get_cancelled( $context = 'view' ) { |
|
442 | - return $this->get_prop( 'cancelled', $context ); |
|
441 | + public function get_cancelled($context = 'view') { |
|
442 | + return $this->get_prop('cancelled', $context); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * @param string $context View or edit context. |
450 | 450 | * @return float |
451 | 451 | */ |
452 | - public function get_failed( $context = 'view' ) { |
|
453 | - return $this->get_prop( 'failed', $context ); |
|
452 | + public function get_failed($context = 'view') { |
|
453 | + return $this->get_prop('failed', $context); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @return string |
462 | 462 | */ |
463 | 463 | public function get_currency() { |
464 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
465 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
464 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
465 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /* |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @since 1.0.19 |
482 | 482 | */ |
483 | - public function set_version( $value ) { |
|
484 | - $this->set_prop( 'version', $value ); |
|
483 | + public function set_version($value) { |
|
484 | + $this->set_prop('version', $value); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | * @param string $value Value to set. |
492 | 492 | * @return bool Whether or not the date was set. |
493 | 493 | */ |
494 | - public function set_date_created( $value ) { |
|
495 | - $date = strtotime( $value ); |
|
494 | + public function set_date_created($value) { |
|
495 | + $date = strtotime($value); |
|
496 | 496 | |
497 | - if ( $date ) { |
|
498 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
497 | + if ($date) { |
|
498 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
499 | 499 | return true; |
500 | 500 | } |
501 | 501 | |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @param string $value Value to set. |
511 | 511 | * @return bool Whether or not the date was set. |
512 | 512 | */ |
513 | - public function set_date_modified( $value ) { |
|
514 | - $date = strtotime( $value ); |
|
513 | + public function set_date_modified($value) { |
|
514 | + $date = strtotime($value); |
|
515 | 515 | |
516 | - if ( $date ) { |
|
517 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
516 | + if ($date) { |
|
517 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
518 | 518 | return true; |
519 | 519 | } |
520 | 520 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @since 1.0.19 |
529 | 529 | * @param string $value New name. |
530 | 530 | */ |
531 | - public function set_name( $value ) { |
|
532 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
531 | + public function set_name($value) { |
|
532 | + $this->set_prop('name', sanitize_text_field($value)); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | * @since 1.0.19 |
539 | 539 | * @param string $value New name. |
540 | 540 | */ |
541 | - public function set_title( $value ) { |
|
542 | - $this->set_name( $value ); |
|
541 | + public function set_title($value) { |
|
542 | + $this->set_name($value); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * @since 1.0.19 |
549 | 549 | * @param int $value New author. |
550 | 550 | */ |
551 | - public function set_author( $value ) { |
|
552 | - $this->set_prop( 'author', (int) $value ); |
|
551 | + public function set_author($value) { |
|
552 | + $this->set_prop('author', (int) $value); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | * @sinve 2.3.4 Array values sanitized. |
560 | 560 | * @param array $value Form elements. |
561 | 561 | */ |
562 | - public function set_elements( $value ) { |
|
563 | - if ( is_array( $value ) ) { |
|
564 | - $this->set_prop( 'elements', wp_kses_post_deep( $value ) ); |
|
562 | + public function set_elements($value) { |
|
563 | + if (is_array($value)) { |
|
564 | + $this->set_prop('elements', wp_kses_post_deep($value)); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
@@ -572,36 +572,36 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return mixed |
574 | 574 | */ |
575 | - public function sanitize_array_values( $value ) { |
|
575 | + public function sanitize_array_values($value) { |
|
576 | 576 | |
577 | 577 | // sanitize |
578 | - if ( ! empty( $value ) ) { |
|
578 | + if (!empty($value)) { |
|
579 | 579 | |
580 | - foreach ( $value as $key => $val_arr ) { |
|
580 | + foreach ($value as $key => $val_arr) { |
|
581 | 581 | |
582 | - if ( is_array( $val_arr ) ) { |
|
582 | + if (is_array($val_arr)) { |
|
583 | 583 | // check if we have sub array items. |
584 | 584 | $sub_arr = array(); |
585 | - foreach ( $val_arr as $key2 => $val2 ) { |
|
586 | - if ( is_array( $val2 ) ) { |
|
587 | - $sub_arr[ $key2 ] = $this->sanitize_array_values( $val2 ); |
|
588 | - unset( $val_arr[ $key ][ $key2 ] ); |
|
585 | + foreach ($val_arr as $key2 => $val2) { |
|
586 | + if (is_array($val2)) { |
|
587 | + $sub_arr[$key2] = $this->sanitize_array_values($val2); |
|
588 | + unset($val_arr[$key][$key2]); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | 592 | // we allow some html in description so we sanitize it separately. |
593 | - $help_text = ! empty( $val_arr['description'] ) ? wp_kses_post( $val_arr['description'] ) : ''; |
|
593 | + $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
|
594 | 594 | |
595 | 595 | // sanitize array elements |
596 | - $value[ $key ] = array_map( 'sanitize_text_field', $val_arr ); |
|
596 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
597 | 597 | |
598 | 598 | // add back the description if set |
599 | - if ( isset( $val_arr['description'] ) ) { |
|
600 | -$value[ $key ]['description'] = $help_text;} |
|
599 | + if (isset($val_arr['description'])) { |
|
600 | +$value[$key]['description'] = $help_text; } |
|
601 | 601 | |
602 | 602 | // add back sub array items after its been sanitized. |
603 | - if ( ! empty( $sub_arr ) ) { |
|
604 | - $value[ $key ] = array_merge( $value[ $key ], $sub_arr ); |
|
603 | + if (!empty($sub_arr)) { |
|
604 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | } |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | * @since 1.0.19 |
617 | 617 | * @param array $value Form elements. |
618 | 618 | */ |
619 | - public function set_items( $value ) { |
|
620 | - if ( is_array( $value ) ) { |
|
621 | - $this->set_prop( 'items', $value ); |
|
619 | + public function set_items($value) { |
|
620 | + if (is_array($value)) { |
|
621 | + $this->set_prop('items', $value); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | * @since 1.0.19 |
629 | 629 | * @param float $value Amount earned. |
630 | 630 | */ |
631 | - public function set_earned( $value ) { |
|
632 | - $value = max( (float) $value, 0 ); |
|
633 | - $this->set_prop( 'earned', $value ); |
|
631 | + public function set_earned($value) { |
|
632 | + $value = max((float) $value, 0); |
|
633 | + $this->set_prop('earned', $value); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -639,9 +639,9 @@ discard block |
||
639 | 639 | * @since 1.0.19 |
640 | 640 | * @param float $value Amount refunded. |
641 | 641 | */ |
642 | - public function set_refunded( $value ) { |
|
643 | - $value = max( (float) $value, 0 ); |
|
644 | - $this->set_prop( 'refunded', $value ); |
|
642 | + public function set_refunded($value) { |
|
643 | + $value = max((float) $value, 0); |
|
644 | + $this->set_prop('refunded', $value); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | * @since 1.0.19 |
651 | 651 | * @param float $value Amount cancelled. |
652 | 652 | */ |
653 | - public function set_cancelled( $value ) { |
|
654 | - $value = max( (float) $value, 0 ); |
|
655 | - $this->set_prop( 'cancelled', $value ); |
|
653 | + public function set_cancelled($value) { |
|
654 | + $value = max((float) $value, 0); |
|
655 | + $this->set_prop('cancelled', $value); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | * @since 1.0.19 |
662 | 662 | * @param float $value Amount cancelled. |
663 | 663 | */ |
664 | - public function set_failed( $value ) { |
|
665 | - $value = max( (float) $value, 0 ); |
|
666 | - $this->set_prop( 'failed', $value ); |
|
664 | + public function set_failed($value) { |
|
665 | + $value = max((float) $value, 0); |
|
666 | + $this->set_prop('failed', $value); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -672,11 +672,11 @@ discard block |
||
672 | 672 | * @deprecated |
673 | 673 | * @return int item id |
674 | 674 | */ |
675 | - public function create( $data = array() ) { |
|
675 | + public function create($data = array()) { |
|
676 | 676 | |
677 | 677 | // Set the properties. |
678 | - if ( is_array( $data ) ) { |
|
679 | - $this->set_props( $data ); |
|
678 | + if (is_array($data)) { |
|
679 | + $this->set_props($data); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | // Save the item. |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @deprecated |
691 | 691 | * @return int item id |
692 | 692 | */ |
693 | - public function update( $data = array() ) { |
|
694 | - return $this->create( $data ); |
|
693 | + public function update($data = array()) { |
|
694 | + return $this->create($data); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /* |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function is_default() { |
713 | 713 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
714 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
714 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -723,11 +723,11 @@ discard block |
||
723 | 723 | public function is_active() { |
724 | 724 | $is_active = 0 !== (int) $this->get_id(); |
725 | 725 | |
726 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
726 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
727 | 727 | $is_active = false; |
728 | 728 | } |
729 | 729 | |
730 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
730 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | * @since 1.0.19 |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function has_item( $item_id ) { |
|
740 | - return false !== $this->get_item( $item_id ); |
|
739 | + public function has_item($item_id) { |
|
740 | + return false !== $this->get_item($item_id); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | * @since 1.0.19 |
747 | 747 | * @return bool |
748 | 748 | */ |
749 | - public function has_element_type( $element_type ) { |
|
750 | - return false !== $this->get_element_type( $element_type ); |
|
749 | + public function has_element_type($element_type) { |
|
750 | + return false !== $this->get_element_type($element_type); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | /** |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function is_recurring() { |
760 | 760 | |
761 | - if ( ! empty( $this->invoice ) ) { |
|
761 | + if (!empty($this->invoice)) { |
|
762 | 762 | return $this->invoice->is_recurring(); |
763 | 763 | } |
764 | 764 | |
765 | - foreach ( $this->get_items() as $item ) { |
|
765 | + foreach ($this->get_items() as $item) { |
|
766 | 766 | |
767 | - if ( $item->is_recurring() ) { |
|
767 | + if ($item->is_recurring()) { |
|
768 | 768 | return true; |
769 | 769 | } |
770 | 770 | } |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | * |
778 | 778 | * @since 1.0.19 |
779 | 779 | */ |
780 | - public function get_html( $extra_markup = '' ) { |
|
780 | + public function get_html($extra_markup = '') { |
|
781 | 781 | |
782 | 782 | // Return the HTML. |
783 | 783 | return wpinv_get_template_html( |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @since 1.0.19 |
797 | 797 | */ |
798 | - public function display( $extra_markup = '' ) { |
|
798 | + public function display($extra_markup = '') { |
|
799 | 799 | wpinv_get_template( |
800 | 800 | 'payment-forms/form.php', |
801 | 801 | array( |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * GetPaid_Item_Data_Store class file. |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -80,39 +80,39 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param WPInv_Item $item Item object. |
82 | 82 | */ |
83 | - public function create( &$item ) { |
|
84 | - $item->set_version( WPINV_VERSION ); |
|
85 | - $item->set_date_created( current_time( 'mysql' ) ); |
|
83 | + public function create(&$item) { |
|
84 | + $item->set_version(WPINV_VERSION); |
|
85 | + $item->set_date_created(current_time('mysql')); |
|
86 | 86 | |
87 | 87 | // Create a new post. |
88 | 88 | $id = wp_insert_post( |
89 | 89 | apply_filters( |
90 | 90 | 'getpaid_new_item_data', |
91 | 91 | array( |
92 | - 'post_date' => $item->get_date_created( 'edit' ), |
|
92 | + 'post_date' => $item->get_date_created('edit'), |
|
93 | 93 | 'post_type' => 'wpi_item', |
94 | - 'post_status' => $this->get_post_status( $item ), |
|
94 | + 'post_status' => $this->get_post_status($item), |
|
95 | 95 | 'ping_status' => 'closed', |
96 | - 'post_author' => $item->get_author( 'edit' ), |
|
97 | - 'post_title' => $item->get_name( 'edit' ), |
|
96 | + 'post_author' => $item->get_author('edit'), |
|
97 | + 'post_title' => $item->get_name('edit'), |
|
98 | 98 | 'post_parent' => $item->get_parent_id(), |
99 | - 'post_excerpt' => $item->get_description( 'edit' ), |
|
99 | + 'post_excerpt' => $item->get_description('edit'), |
|
100 | 100 | ) |
101 | 101 | ), |
102 | 102 | true |
103 | 103 | ); |
104 | 104 | |
105 | - if ( $id && ! is_wp_error( $id ) ) { |
|
106 | - $item->set_id( $id ); |
|
107 | - $this->update_post_meta( $item ); |
|
105 | + if ($id && !is_wp_error($id)) { |
|
106 | + $item->set_id($id); |
|
107 | + $this->update_post_meta($item); |
|
108 | 108 | $item->save_meta_data(); |
109 | 109 | $item->apply_changes(); |
110 | - $this->clear_caches( $item ); |
|
111 | - do_action( 'getpaid_new_item', $item ); |
|
110 | + $this->clear_caches($item); |
|
111 | + do_action('getpaid_new_item', $item); |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | - if ( is_wp_error( $id ) ) { |
|
115 | + if (is_wp_error($id)) { |
|
116 | 116 | $item->last_error = $id->get_error_message(); |
117 | 117 | } |
118 | 118 | |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | * @param WPInv_Item $item Item object. |
126 | 126 | * |
127 | 127 | */ |
128 | - public function read( &$item ) { |
|
128 | + public function read(&$item) { |
|
129 | 129 | |
130 | 130 | $item->set_defaults(); |
131 | - $item_object = get_post( $item->get_id() ); |
|
131 | + $item_object = get_post($item->get_id()); |
|
132 | 132 | |
133 | - if ( ! $item->get_id() || ! $item_object || $item_object->post_type != 'wpi_item' ) { |
|
134 | - $item->last_error = __( 'Invalid item.', 'invoicing' ); |
|
135 | - $item->set_id( 0 ); |
|
133 | + if (!$item->get_id() || !$item_object || $item_object->post_type != 'wpi_item') { |
|
134 | + $item->last_error = __('Invalid item.', 'invoicing'); |
|
135 | + $item->set_id(0); |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | ) |
149 | 149 | ); |
150 | 150 | |
151 | - $this->read_object_data( $item, $item_object ); |
|
151 | + $this->read_object_data($item, $item_object); |
|
152 | 152 | $item->read_meta_data(); |
153 | - $item->set_object_read( true ); |
|
154 | - do_action( 'getpaid_read_item', $item ); |
|
153 | + $item->set_object_read(true); |
|
154 | + do_action('getpaid_read_item', $item); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
@@ -160,29 +160,29 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param WPInv_Item $item Item object. |
162 | 162 | */ |
163 | - public function update( &$item ) { |
|
163 | + public function update(&$item) { |
|
164 | 164 | $item->save_meta_data(); |
165 | - $item->set_version( WPINV_VERSION ); |
|
165 | + $item->set_version(WPINV_VERSION); |
|
166 | 166 | |
167 | - if ( null === $item->get_date_created( 'edit' ) ) { |
|
168 | - $item->set_date_created( current_time( 'mysql' ) ); |
|
167 | + if (null === $item->get_date_created('edit')) { |
|
168 | + $item->set_date_created(current_time('mysql')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Grab the current status so we can compare. |
172 | - $previous_status = get_post_status( $item->get_id() ); |
|
172 | + $previous_status = get_post_status($item->get_id()); |
|
173 | 173 | |
174 | 174 | $changes = $item->get_changes(); |
175 | 175 | |
176 | 176 | // Only update the post when the post data changes. |
177 | - if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'parent_id', 'description', 'name', 'author' ), array_keys( $changes ) ) ) { |
|
177 | + if (array_intersect(array('date_created', 'date_modified', 'status', 'parent_id', 'description', 'name', 'author'), array_keys($changes))) { |
|
178 | 178 | $post_data = array( |
179 | - 'post_date' => $item->get_date_created( 'edit' ), |
|
180 | - 'post_status' => $item->get_status( 'edit' ), |
|
181 | - 'post_parent' => $item->get_parent_id( 'edit' ), |
|
182 | - 'post_excerpt' => $item->get_description( 'edit' ), |
|
183 | - 'post_modified' => $item->get_date_modified( 'edit' ), |
|
184 | - 'post_title' => $item->get_name( 'edit' ), |
|
185 | - 'post_author' => $item->get_author( 'edit' ), |
|
179 | + 'post_date' => $item->get_date_created('edit'), |
|
180 | + 'post_status' => $item->get_status('edit'), |
|
181 | + 'post_parent' => $item->get_parent_id('edit'), |
|
182 | + 'post_excerpt' => $item->get_description('edit'), |
|
183 | + 'post_modified' => $item->get_date_modified('edit'), |
|
184 | + 'post_title' => $item->get_name('edit'), |
|
185 | + 'post_author' => $item->get_author('edit'), |
|
186 | 186 | ); |
187 | 187 | |
188 | 188 | /** |
@@ -193,25 +193,25 @@ discard block |
||
193 | 193 | * This ensures hooks are fired by either WP itself (admin screen save), |
194 | 194 | * or an update purely from CRUD. |
195 | 195 | */ |
196 | - if ( doing_action( 'save_post' ) ) { |
|
197 | - $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $item->get_id() ) ); |
|
198 | - clean_post_cache( $item->get_id() ); |
|
196 | + if (doing_action('save_post')) { |
|
197 | + $GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $item->get_id())); |
|
198 | + clean_post_cache($item->get_id()); |
|
199 | 199 | } else { |
200 | - wp_update_post( array_merge( array( 'ID' => $item->get_id() ), $post_data ) ); |
|
200 | + wp_update_post(array_merge(array('ID' => $item->get_id()), $post_data)); |
|
201 | 201 | } |
202 | - $item->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
202 | + $item->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. |
|
203 | 203 | } |
204 | - $this->update_post_meta( $item ); |
|
204 | + $this->update_post_meta($item); |
|
205 | 205 | $item->apply_changes(); |
206 | - $this->clear_caches( $item ); |
|
206 | + $this->clear_caches($item); |
|
207 | 207 | |
208 | 208 | // Fire a hook depending on the status - this should be considered a creation if it was previously draft status. |
209 | - $new_status = $item->get_status( 'edit' ); |
|
209 | + $new_status = $item->get_status('edit'); |
|
210 | 210 | |
211 | - if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) { |
|
212 | - do_action( 'getpaid_new_item', $item ); |
|
211 | + if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) { |
|
212 | + do_action('getpaid_new_item', $item); |
|
213 | 213 | } else { |
214 | - do_action( 'getpaid_update_item', $item ); |
|
214 | + do_action('getpaid_update_item', $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * @param WPInv_Item $item WPInv_Item object. |
229 | 229 | * @since 1.0.19 |
230 | 230 | */ |
231 | - protected function update_post_meta( &$item ) { |
|
231 | + protected function update_post_meta(&$item) { |
|
232 | 232 | |
233 | 233 | // Ensure that we have a custom id. |
234 | - if ( ! $item->get_custom_id() ) { |
|
235 | - $item->set_custom_id( $item->get_id() ); |
|
234 | + if (!$item->get_custom_id()) { |
|
235 | + $item->set_custom_id($item->get_id()); |
|
236 | 236 | } |
237 | 237 | |
238 | - parent::update_post_meta( $item ); |
|
238 | + parent::update_post_meta($item); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |