@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '1.1.0' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '1.1.0'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'> |
|
19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'> |
|
20 | 20 | |
21 | 21 | <div class="form-row"> |
22 | 22 | |
23 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
23 | + <?php foreach (array_keys($columns) as $column): ?> |
|
24 | 24 | |
25 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
25 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | 29 | // Fires before printing a line item column. |
30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
31 | 31 | |
32 | 32 | // Item name. |
33 | - if ( 'name' == $column ) { |
|
33 | + if ('name' == $column) { |
|
34 | 34 | |
35 | 35 | // Display the name. |
36 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
36 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
37 | 37 | |
38 | 38 | // And an optional description. |
39 | 39 | $description = $item->get_description(); |
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - $description = wp_kses_post( $description ); |
|
41 | + if (!empty($description)) { |
|
42 | + $description = wp_kses_post($description); |
|
43 | 43 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Price help text. |
47 | - $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() ); |
|
48 | - if ( $description ) { |
|
47 | + $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency()); |
|
48 | + if ($description) { |
|
49 | 49 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Fires before printing the line item actions. |
53 | - do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice ); |
|
53 | + do_action("getpaid_before_invoice_line_item_actions", $item, $invoice); |
|
54 | 54 | |
55 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
55 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
56 | 56 | |
57 | - if ( ! empty( $actions ) ) { |
|
57 | + if (!empty($actions)) { |
|
58 | 58 | |
59 | - $sanitized = array(); |
|
60 | - foreach ( $actions as $key => $action ) { |
|
61 | - $key = sanitize_html_class( $key ); |
|
62 | - $action = wp_kses_post( $action ); |
|
59 | + $sanitized = array(); |
|
60 | + foreach ($actions as $key => $action) { |
|
61 | + $key = sanitize_html_class($key); |
|
62 | + $action = wp_kses_post($action); |
|
63 | 63 | $sanitized[] = "<span class='$key'>$action</span>"; |
64 | 64 | } |
65 | 65 | |
66 | 66 | echo "<small class='form-text getpaid-line-item-actions'>"; |
67 | - echo implode( ' | ', $sanitized ); |
|
67 | + echo implode(' | ', $sanitized); |
|
68 | 68 | echo '</small>'; |
69 | 69 | |
70 | 70 | } |
@@ -72,30 +72,30 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // Item price. |
75 | - if ( 'price' == $column ) { |
|
75 | + if ('price' == $column) { |
|
76 | 76 | |
77 | 77 | // Display the item price (or recurring price if this is a renewal invoice) |
78 | 78 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
79 | - echo wpinv_price( $price ); |
|
79 | + echo wpinv_price($price); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | 83 | // Item quantity. |
84 | - if ( 'quantity' == $column ) { |
|
84 | + if ('quantity' == $column) { |
|
85 | 85 | echo (int) $item->get_quantity(); |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Item sub total. |
89 | - if ( 'subtotal' == $column ) { |
|
89 | + if ('subtotal' == $column) { |
|
90 | 90 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
91 | - echo wpinv_price( $subtotal ); |
|
91 | + echo wpinv_price($subtotal); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Fires when printing a line item column. |
95 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
95 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
96 | 96 | |
97 | 97 | // Fires after printing a line item column. |
98 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
98 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
99 | 99 | |
100 | 100 | ?> |
101 | 101 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -78,30 +78,30 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param int|object|WPInv_Item|WP_Post $item Item to read. |
80 | 80 | */ |
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | - $this->set_id( $item ); |
|
86 | - } elseif ( $item instanceof self ) { |
|
87 | - $this->set_id( $item->get_id() ); |
|
88 | - } elseif ( ! empty( $item->ID ) ) { |
|
89 | - $this->set_id( $item->ID ); |
|
90 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | - $this->set_id( $item_id ); |
|
92 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | - $this->set_id( $item_id ); |
|
81 | + public function __construct($item = 0) { |
|
82 | + parent::__construct($item); |
|
83 | + |
|
84 | + if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) { |
|
85 | + $this->set_id($item); |
|
86 | + } elseif ($item instanceof self) { |
|
87 | + $this->set_id($item->get_id()); |
|
88 | + } elseif (!empty($item->ID)) { |
|
89 | + $this->set_id($item->ID); |
|
90 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) { |
|
91 | + $this->set_id($item_id); |
|
92 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) { |
|
93 | + $this->set_id($item_id); |
|
94 | 94 | } else { |
95 | - $this->set_object_read( true ); |
|
95 | + $this->set_object_read(true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Load the datastore. |
99 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
99 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
100 | 100 | |
101 | - if ( $this->get_id() > 0 ) { |
|
102 | - $this->post = get_post( $this->get_id() ); |
|
101 | + if ($this->get_id() > 0) { |
|
102 | + $this->post = get_post($this->get_id()); |
|
103 | 103 | $this->ID = $this->get_id(); |
104 | - $this->data_store->read( $this ); |
|
104 | + $this->data_store->read($this); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param string $context View or edit context. |
129 | 129 | * @return int |
130 | 130 | */ |
131 | - public function get_parent_id( $context = 'view' ) { |
|
132 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
131 | + public function get_parent_id($context = 'view') { |
|
132 | + return (int) $this->get_prop('parent_id', $context); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $context View or edit context. |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public function get_status( $context = 'view' ) { |
|
143 | - return $this->get_prop( 'status', $context ); |
|
142 | + public function get_status($context = 'view') { |
|
143 | + return $this->get_prop('status', $context); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string $context View or edit context. |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_version( $context = 'view' ) { |
|
154 | - return $this->get_prop( 'version', $context ); |
|
153 | + public function get_version($context = 'view') { |
|
154 | + return $this->get_prop('version', $context); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param string $context View or edit context. |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function get_date_created( $context = 'view' ) { |
|
165 | - return $this->get_prop( 'date_created', $context ); |
|
164 | + public function get_date_created($context = 'view') { |
|
165 | + return $this->get_prop('date_created', $context); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | * @param string $context View or edit context. |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_date_created_gmt( $context = 'view' ) { |
|
176 | - $date = $this->get_date_created( $context ); |
|
175 | + public function get_date_created_gmt($context = 'view') { |
|
176 | + $date = $this->get_date_created($context); |
|
177 | 177 | |
178 | - if ( $date ) { |
|
179 | - $date = get_gmt_from_date( $date ); |
|
178 | + if ($date) { |
|
179 | + $date = get_gmt_from_date($date); |
|
180 | 180 | } |
181 | 181 | return $date; |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param string $context View or edit context. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function get_date_modified( $context = 'view' ) { |
|
192 | - return $this->get_prop( 'date_modified', $context ); |
|
191 | + public function get_date_modified($context = 'view') { |
|
192 | + return $this->get_prop('date_modified', $context); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
203 | - $date = $this->get_date_modified( $context ); |
|
202 | + public function get_date_modified_gmt($context = 'view') { |
|
203 | + $date = $this->get_date_modified($context); |
|
204 | 204 | |
205 | - if ( $date ) { |
|
206 | - $date = get_gmt_from_date( $date ); |
|
205 | + if ($date) { |
|
206 | + $date = get_gmt_from_date($date); |
|
207 | 207 | } |
208 | 208 | return $date; |
209 | 209 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $context View or edit context. |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function get_name( $context = 'view' ) { |
|
219 | - return $this->get_prop( 'name', $context ); |
|
218 | + public function get_name($context = 'view') { |
|
219 | + return $this->get_prop('name', $context); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $context View or edit context. |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public function get_title( $context = 'view' ) { |
|
230 | - return $this->get_name( $context ); |
|
229 | + public function get_title($context = 'view') { |
|
230 | + return $this->get_name($context); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @param string $context View or edit context. |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public function get_description( $context = 'view' ) { |
|
241 | - return $this->get_prop( 'description', $context ); |
|
240 | + public function get_description($context = 'view') { |
|
241 | + return $this->get_prop('description', $context); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function get_excerpt( $context = 'view' ) { |
|
252 | - return $this->get_description( $context ); |
|
251 | + public function get_excerpt($context = 'view') { |
|
252 | + return $this->get_description($context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @param string $context View or edit context. |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - public function get_summary( $context = 'view' ) { |
|
263 | - return $this->get_description( $context ); |
|
262 | + public function get_summary($context = 'view') { |
|
263 | + return $this->get_description($context); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @param string $context View or edit context. |
271 | 271 | * @return int |
272 | 272 | */ |
273 | - public function get_author( $context = 'view' ) { |
|
274 | - return (int) $this->get_prop( 'author', $context ); |
|
273 | + public function get_author($context = 'view') { |
|
274 | + return (int) $this->get_prop('author', $context); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @param string $context View or edit context. |
282 | 282 | * @return int |
283 | 283 | */ |
284 | - public function get_owner( $context = 'view' ) { |
|
285 | - return $this->get_author( $context ); |
|
284 | + public function get_owner($context = 'view') { |
|
285 | + return $this->get_author($context); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $context View or edit context. |
293 | 293 | * @return float |
294 | 294 | */ |
295 | - public function get_price( $context = 'view' ) { |
|
296 | - return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
|
295 | + public function get_price($context = 'view') { |
|
296 | + return wpinv_sanitize_amount($this->get_prop('price', $context)); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | * @param string $context View or edit context. |
304 | 304 | * @return float |
305 | 305 | */ |
306 | - public function get_initial_price( $context = 'view' ) { |
|
306 | + public function get_initial_price($context = 'view') { |
|
307 | 307 | |
308 | - $price = (float) $this->get_price( $context ); |
|
308 | + $price = (float) $this->get_price($context); |
|
309 | 309 | |
310 | - if ( $this->has_free_trial() ) { |
|
310 | + if ($this->has_free_trial()) { |
|
311 | 311 | $price = 0; |
312 | 312 | } |
313 | 313 | |
314 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
|
314 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return string |
323 | 323 | */ |
324 | 324 | public function get_the_price() { |
325 | - return wpinv_price( wpinv_format_amount( $this->get_price() ) ); |
|
325 | + return wpinv_price(wpinv_format_amount($this->get_price())); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return string |
334 | 334 | */ |
335 | 335 | public function get_the_initial_price() { |
336 | - return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) ); |
|
336 | + return wpinv_price(wpinv_format_amount($this->get_initial_price())); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * @param string $context View or edit context. |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public function get_vat_rule( $context = 'view' ) { |
|
347 | - return $this->get_prop( 'vat_rule', $context ); |
|
346 | + public function get_vat_rule($context = 'view') { |
|
347 | + return $this->get_prop('vat_rule', $context); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $context View or edit context. |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public function get_vat_class( $context = 'view' ) { |
|
358 | - return $this->get_prop( 'vat_class', $context ); |
|
357 | + public function get_vat_class($context = 'view') { |
|
358 | + return $this->get_prop('vat_class', $context); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $context View or edit context. |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function get_type( $context = 'view' ) { |
|
369 | - return $this->get_prop( 'type', $context ); |
|
368 | + public function get_type($context = 'view') { |
|
369 | + return $this->get_prop('type', $context); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_custom_id( $context = 'view' ) { |
|
380 | - return $this->get_prop( 'custom_id', $context ); |
|
379 | + public function get_custom_id($context = 'view') { |
|
380 | + return $this->get_prop('custom_id', $context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_custom_name( $context = 'view' ) { |
|
391 | - return $this->get_prop( 'custom_name', $context ); |
|
390 | + public function get_custom_name($context = 'view') { |
|
391 | + return $this->get_prop('custom_name', $context); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * @param string $context View or edit context. |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function get_custom_singular_name( $context = 'view' ) { |
|
402 | - return $this->get_prop( 'custom_singular_name', $context ); |
|
401 | + public function get_custom_singular_name($context = 'view') { |
|
402 | + return $this->get_prop('custom_singular_name', $context); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * @param string $context View or edit context. |
410 | 410 | * @return int |
411 | 411 | */ |
412 | - public function get_is_editable( $context = 'view' ) { |
|
413 | - return (int) $this->get_prop( 'is_editable', $context ); |
|
412 | + public function get_is_editable($context = 'view') { |
|
413 | + return (int) $this->get_prop('is_editable', $context); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * @param string $context View or edit context. |
421 | 421 | * @return int |
422 | 422 | */ |
423 | - public function get_editable( $context = 'view' ) { |
|
424 | - return $this->get_is_editable( $context ); |
|
423 | + public function get_editable($context = 'view') { |
|
424 | + return $this->get_is_editable($context); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return int |
433 | 433 | */ |
434 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
435 | - return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
|
434 | + public function get_is_dynamic_pricing($context = 'view') { |
|
435 | + return (int) $this->get_prop('is_dynamic_pricing', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return float |
444 | 444 | */ |
445 | - public function get_minimum_price( $context = 'view' ) { |
|
446 | - return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
|
445 | + public function get_minimum_price($context = 'view') { |
|
446 | + return wpinv_sanitize_amount($this->get_prop('minimum_price', $context)); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return int |
455 | 455 | */ |
456 | - public function get_is_recurring( $context = 'view' ) { |
|
457 | - return (int) $this->get_prop( 'is_recurring', $context ); |
|
456 | + public function get_is_recurring($context = 'view') { |
|
457 | + return (int) $this->get_prop('is_recurring', $context); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | * @param string $context View or edit context. |
465 | 465 | * @return float |
466 | 466 | */ |
467 | - public function get_recurring_price( $context = 'view' ) { |
|
468 | - $price = $this->get_price( $context ); |
|
469 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
|
467 | + public function get_recurring_price($context = 'view') { |
|
468 | + $price = $this->get_price($context); |
|
469 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID)); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return string |
478 | 478 | */ |
479 | 479 | public function get_the_recurring_price() { |
480 | - return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) ); |
|
480 | + return wpinv_price(wpinv_format_amount($this->get_recurring_price())); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | $period = $this->get_recurring_period(); |
499 | 499 | $interval = $this->get_recurring_interval(); |
500 | 500 | |
501 | - if ( $this->has_free_trial() ) { |
|
501 | + if ($this->has_free_trial()) { |
|
502 | 502 | $period = $this->get_trial_period(); |
503 | 503 | $interval = $this->get_trial_interval(); |
504 | 504 | } |
505 | 505 | |
506 | - $period = $periods[ $period ]; |
|
507 | - $interval = empty( $interval ) ? 1 : $interval; |
|
508 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
509 | - return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
|
506 | + $period = $periods[$period]; |
|
507 | + $interval = empty($interval) ? 1 : $interval; |
|
508 | + $next_renewal = strtotime("+$interval $period", current_time('timestamp')); |
|
509 | + return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -516,14 +516,14 @@ discard block |
||
516 | 516 | * @param bool $full Return abbreviation or in full. |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - public function get_recurring_period( $full = false ) { |
|
520 | - $period = $this->get_prop( 'recurring_period', 'view' ); |
|
519 | + public function get_recurring_period($full = false) { |
|
520 | + $period = $this->get_prop('recurring_period', 'view'); |
|
521 | 521 | |
522 | - if ( $full && ! is_bool( $full ) ) { |
|
522 | + if ($full && !is_bool($full)) { |
|
523 | 523 | $full = false; |
524 | 524 | } |
525 | 525 | |
526 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
526 | + return getpaid_sanitize_recurring_period($period, $full); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * @param string $context View or edit context. |
534 | 534 | * @return int |
535 | 535 | */ |
536 | - public function get_recurring_interval( $context = 'view' ) { |
|
537 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
536 | + public function get_recurring_interval($context = 'view') { |
|
537 | + $interval = absint($this->get_prop('recurring_interval', $context)); |
|
538 | 538 | |
539 | - if ( $interval < 1 ) { |
|
539 | + if ($interval < 1) { |
|
540 | 540 | $interval = 1; |
541 | 541 | } |
542 | 542 | |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @param string $context View or edit context. |
551 | 551 | * @return int |
552 | 552 | */ |
553 | - public function get_recurring_limit( $context = 'view' ) { |
|
554 | - return (int) $this->get_prop( 'recurring_limit', $context ); |
|
553 | + public function get_recurring_limit($context = 'view') { |
|
554 | + return (int) $this->get_prop('recurring_limit', $context); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * @param string $context View or edit context. |
562 | 562 | * @return int |
563 | 563 | */ |
564 | - public function get_is_free_trial( $context = 'view' ) { |
|
565 | - return (int) $this->get_prop( 'is_free_trial', $context ); |
|
564 | + public function get_is_free_trial($context = 'view') { |
|
565 | + return (int) $this->get_prop('is_free_trial', $context); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -572,8 +572,8 @@ discard block |
||
572 | 572 | * @param string $context View or edit context. |
573 | 573 | * @return int |
574 | 574 | */ |
575 | - public function get_free_trial( $context = 'view' ) { |
|
576 | - return $this->get_is_free_trial( $context ); |
|
575 | + public function get_free_trial($context = 'view') { |
|
576 | + return $this->get_is_free_trial($context); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | * @param bool $full Return abbreviation or in full. |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - public function get_trial_period( $full = false ) { |
|
587 | - $period = $this->get_prop( 'trial_period', 'view' ); |
|
586 | + public function get_trial_period($full = false) { |
|
587 | + $period = $this->get_prop('trial_period', 'view'); |
|
588 | 588 | |
589 | - if ( $full && ! is_bool( $full ) ) { |
|
589 | + if ($full && !is_bool($full)) { |
|
590 | 590 | $full = false; |
591 | 591 | } |
592 | 592 | |
593 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
593 | + return getpaid_sanitize_recurring_period($period, $full); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @param string $context View or edit context. |
601 | 601 | * @return int |
602 | 602 | */ |
603 | - public function get_trial_interval( $context = 'view' ) { |
|
604 | - return (int) $this->get_prop( 'trial_interval', $context ); |
|
603 | + public function get_trial_interval($context = 'view') { |
|
604 | + return (int) $this->get_prop('trial_interval', $context); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @return string |
612 | 612 | */ |
613 | 613 | public function get_edit_url() { |
614 | - return get_edit_post_link( $this->get_id() ); |
|
614 | + return get_edit_post_link($this->get_id()); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -625,35 +625,35 @@ discard block |
||
625 | 625 | * @since 1.0.15 |
626 | 626 | * @return int |
627 | 627 | */ |
628 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
628 | + public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') { |
|
629 | 629 | |
630 | 630 | // Trim the value. |
631 | - $value = sanitize_text_field( $value ); |
|
632 | - if ( empty( $value ) ) { |
|
631 | + $value = sanitize_text_field($value); |
|
632 | + if (empty($value)) { |
|
633 | 633 | return 0; |
634 | 634 | } |
635 | 635 | |
636 | 636 | // Valid fields. |
637 | - $fields = array( 'custom_id', 'name', 'slug' ); |
|
637 | + $fields = array('custom_id', 'name', 'slug'); |
|
638 | 638 | |
639 | 639 | // Ensure a field has been passed. |
640 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
640 | + if (empty($field) || !in_array($field, $fields)) { |
|
641 | 641 | return 0; |
642 | 642 | } |
643 | 643 | |
644 | - if ( $field == 'name' ) { |
|
644 | + if ($field == 'name') { |
|
645 | 645 | $field = 'slug'; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // Maybe retrieve from the cache. |
649 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
650 | - if ( ! empty( $item_id ) ) { |
|
649 | + $item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
650 | + if (!empty($item_id)) { |
|
651 | 651 | return $item_id; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Fetch from the db. |
655 | 655 | $items = array(); |
656 | - if ( $field == 'slug' ) { |
|
656 | + if ($field == 'slug') { |
|
657 | 657 | $items = get_posts( |
658 | 658 | array( |
659 | 659 | 'post_type' => 'wpi_item', |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | ); |
665 | 665 | } |
666 | 666 | |
667 | - if ( $field =='custom_id' ) { |
|
667 | + if ($field == 'custom_id') { |
|
668 | 668 | $items = get_posts( |
669 | 669 | array( |
670 | 670 | 'post_type' => 'wpi_item', |
@@ -684,12 +684,12 @@ discard block |
||
684 | 684 | ); |
685 | 685 | } |
686 | 686 | |
687 | - if ( empty( $items ) ) { |
|
687 | + if (empty($items)) { |
|
688 | 688 | return 0; |
689 | 689 | } |
690 | 690 | |
691 | 691 | // Update the cache with our data |
692 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
692 | + wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
693 | 693 | |
694 | 694 | return $items[0]->ID; |
695 | 695 | } |
@@ -697,19 +697,19 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * Margic method for retrieving a property. |
699 | 699 | */ |
700 | - public function __get( $key ) { |
|
700 | + public function __get($key) { |
|
701 | 701 | |
702 | 702 | // Check if we have a helper method for that. |
703 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
704 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
703 | + if (method_exists($this, 'get_' . $key)) { |
|
704 | + return call_user_func(array($this, 'get_' . $key)); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | // Check if the key is in the associated $post object. |
708 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
708 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
709 | 709 | return $this->post->$key; |
710 | 710 | } |
711 | 711 | |
712 | - return $this->get_prop( $key ); |
|
712 | + return $this->get_prop($key); |
|
713 | 713 | |
714 | 714 | } |
715 | 715 | |
@@ -728,11 +728,11 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @since 1.0.19 |
730 | 730 | */ |
731 | - public function set_parent_id( $value ) { |
|
732 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
731 | + public function set_parent_id($value) { |
|
732 | + if ($value && ($value === $this->get_id() || !get_post($value))) { |
|
733 | 733 | return; |
734 | 734 | } |
735 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
735 | + $this->set_prop('parent_id', absint($value)); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | * @param string $status New status. |
743 | 743 | * @return array details of change. |
744 | 744 | */ |
745 | - public function set_status( $status ) { |
|
745 | + public function set_status($status) { |
|
746 | 746 | $old_status = $this->get_status(); |
747 | 747 | |
748 | - $this->set_prop( 'status', $status ); |
|
748 | + $this->set_prop('status', $status); |
|
749 | 749 | |
750 | 750 | return array( |
751 | 751 | 'from' => $old_status, |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @since 1.0.19 |
760 | 760 | */ |
761 | - public function set_version( $value ) { |
|
762 | - $this->set_prop( 'version', $value ); |
|
761 | + public function set_version($value) { |
|
762 | + $this->set_prop('version', $value); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,11 +769,11 @@ discard block |
||
769 | 769 | * @param string $value Value to set. |
770 | 770 | * @return bool Whether or not the date was set. |
771 | 771 | */ |
772 | - public function set_date_created( $value ) { |
|
773 | - $date = strtotime( $value ); |
|
772 | + public function set_date_created($value) { |
|
773 | + $date = strtotime($value); |
|
774 | 774 | |
775 | - if ( $date ) { |
|
776 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
775 | + if ($date) { |
|
776 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
777 | 777 | return true; |
778 | 778 | } |
779 | 779 | |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | * @param string $value Value to set. |
789 | 789 | * @return bool Whether or not the date was set. |
790 | 790 | */ |
791 | - public function set_date_modified( $value ) { |
|
792 | - $date = strtotime( $value ); |
|
791 | + public function set_date_modified($value) { |
|
792 | + $date = strtotime($value); |
|
793 | 793 | |
794 | - if ( $date ) { |
|
795 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
794 | + if ($date) { |
|
795 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
796 | 796 | return true; |
797 | 797 | } |
798 | 798 | |
@@ -806,9 +806,9 @@ discard block |
||
806 | 806 | * @since 1.0.19 |
807 | 807 | * @param string $value New name. |
808 | 808 | */ |
809 | - public function set_name( $value ) { |
|
810 | - $name = sanitize_text_field( $value ); |
|
811 | - $this->set_prop( 'name', $name ); |
|
809 | + public function set_name($value) { |
|
810 | + $name = sanitize_text_field($value); |
|
811 | + $this->set_prop('name', $name); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | * @since 1.0.19 |
818 | 818 | * @param string $value New name. |
819 | 819 | */ |
820 | - public function set_title( $value ) { |
|
821 | - $this->set_name( $value ); |
|
820 | + public function set_title($value) { |
|
821 | + $this->set_name($value); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | /** |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * @since 1.0.19 |
828 | 828 | * @param string $value New description. |
829 | 829 | */ |
830 | - public function set_description( $value ) { |
|
831 | - $description = wp_kses_post( $value ); |
|
832 | - return $this->set_prop( 'description', $description ); |
|
830 | + public function set_description($value) { |
|
831 | + $description = wp_kses_post($value); |
|
832 | + return $this->set_prop('description', $description); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -838,8 +838,8 @@ discard block |
||
838 | 838 | * @since 1.0.19 |
839 | 839 | * @param string $value New description. |
840 | 840 | */ |
841 | - public function set_excerpt( $value ) { |
|
842 | - $this->set_description( $value ); |
|
841 | + public function set_excerpt($value) { |
|
842 | + $this->set_description($value); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @since 1.0.19 |
849 | 849 | * @param string $value New description. |
850 | 850 | */ |
851 | - public function set_summary( $value ) { |
|
852 | - $this->set_description( $value ); |
|
851 | + public function set_summary($value) { |
|
852 | + $this->set_description($value); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | * @since 1.0.19 |
859 | 859 | * @param int $value New author. |
860 | 860 | */ |
861 | - public function set_author( $value ) { |
|
862 | - $this->set_prop( 'author', (int) $value ); |
|
861 | + public function set_author($value) { |
|
862 | + $this->set_prop('author', (int) $value); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | * @since 1.0.19 |
869 | 869 | * @param int $value New author. |
870 | 870 | */ |
871 | - public function set_owner( $value ) { |
|
872 | - $this->set_author( $value ); |
|
871 | + public function set_owner($value) { |
|
872 | + $this->set_author($value); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | /** |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | * @since 1.0.19 |
879 | 879 | * @param float $value New price. |
880 | 880 | */ |
881 | - public function set_price( $value ) { |
|
882 | - $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
|
881 | + public function set_price($value) { |
|
882 | + $this->set_prop('price', (float) wpinv_sanitize_amount($value)); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | * @since 1.0.19 |
889 | 889 | * @param string $value new rule. |
890 | 890 | */ |
891 | - public function set_vat_rule( $value ) { |
|
892 | - $this->set_prop( 'vat_rule', $value ); |
|
891 | + public function set_vat_rule($value) { |
|
892 | + $this->set_prop('vat_rule', $value); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | * @since 1.0.19 |
899 | 899 | * @param string $value new class. |
900 | 900 | */ |
901 | - public function set_vat_class( $value ) { |
|
902 | - $this->set_prop( 'vat_class', $value ); |
|
901 | + public function set_vat_class($value) { |
|
902 | + $this->set_prop('vat_class', $value); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -909,13 +909,13 @@ discard block |
||
909 | 909 | * @param string $value new item type. |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public function set_type( $value ) { |
|
912 | + public function set_type($value) { |
|
913 | 913 | |
914 | - if ( empty( $value ) ) { |
|
914 | + if (empty($value)) { |
|
915 | 915 | $value = 'custom'; |
916 | 916 | } |
917 | 917 | |
918 | - $this->set_prop( 'type', $value ); |
|
918 | + $this->set_prop('type', $value); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | * @since 1.0.19 |
925 | 925 | * @param string $value new custom id. |
926 | 926 | */ |
927 | - public function set_custom_id( $value ) { |
|
928 | - $this->set_prop( 'custom_id', $value ); |
|
927 | + public function set_custom_id($value) { |
|
928 | + $this->set_prop('custom_id', $value); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * @since 1.0.19 |
935 | 935 | * @param string $value new custom name. |
936 | 936 | */ |
937 | - public function set_custom_name( $value ) { |
|
938 | - $this->set_prop( 'custom_name', $value ); |
|
937 | + public function set_custom_name($value) { |
|
938 | + $this->set_prop('custom_name', $value); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | * @since 1.0.19 |
945 | 945 | * @param string $value new custom singular name. |
946 | 946 | */ |
947 | - public function set_custom_singular_name( $value ) { |
|
948 | - $this->set_prop( 'custom_singular_name', $value ); |
|
947 | + public function set_custom_singular_name($value) { |
|
948 | + $this->set_prop('custom_singular_name', $value); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | * @since 1.0.19 |
955 | 955 | * @param int|bool $value whether or not the item is editable. |
956 | 956 | */ |
957 | - public function set_is_editable( $value ) { |
|
958 | - $this->set_prop( 'is_editable', (int) $value ); |
|
957 | + public function set_is_editable($value) { |
|
958 | + $this->set_prop('is_editable', (int) $value); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | * @since 1.0.19 |
965 | 965 | * @param int|bool $value whether or not dynamic pricing is allowed. |
966 | 966 | */ |
967 | - public function set_is_dynamic_pricing( $value ) { |
|
968 | - $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
|
967 | + public function set_is_dynamic_pricing($value) { |
|
968 | + $this->set_prop('is_dynamic_pricing', (int) $value); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | /** |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | * @since 1.0.19 |
975 | 975 | * @param float $value minimum price. |
976 | 976 | */ |
977 | - public function set_minimum_price( $value ) { |
|
978 | - $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
|
977 | + public function set_minimum_price($value) { |
|
978 | + $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value)); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | * @since 1.0.19 |
985 | 985 | * @param int|bool $value whether or not dynamic pricing is allowed. |
986 | 986 | */ |
987 | - public function set_is_recurring( $value ) { |
|
988 | - $this->set_prop( 'is_recurring', (int) $value ); |
|
987 | + public function set_is_recurring($value) { |
|
988 | + $this->set_prop('is_recurring', (int) $value); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -994,8 +994,8 @@ discard block |
||
994 | 994 | * @since 1.0.19 |
995 | 995 | * @param string $value new period. |
996 | 996 | */ |
997 | - public function set_recurring_period( $value ) { |
|
998 | - $this->set_prop( 'recurring_period', $value ); |
|
997 | + public function set_recurring_period($value) { |
|
998 | + $this->set_prop('recurring_period', $value); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
@@ -1004,8 +1004,8 @@ discard block |
||
1004 | 1004 | * @since 1.0.19 |
1005 | 1005 | * @param int $value recurring interval. |
1006 | 1006 | */ |
1007 | - public function set_recurring_interval( $value ) { |
|
1008 | - return $this->set_prop( 'recurring_interval', (int) $value ); |
|
1007 | + public function set_recurring_interval($value) { |
|
1008 | + return $this->set_prop('recurring_interval', (int) $value); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * @param int $value The recurring limit. |
1015 | 1015 | * @return int |
1016 | 1016 | */ |
1017 | - public function set_recurring_limit( $value ) { |
|
1018 | - $this->set_prop( 'recurring_limit', (int) $value ); |
|
1017 | + public function set_recurring_limit($value) { |
|
1018 | + $this->set_prop('recurring_limit', (int) $value); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | * @since 1.0.19 |
1025 | 1025 | * @param int|bool $value whether or not it has a free trial. |
1026 | 1026 | */ |
1027 | - public function set_is_free_trial( $value ) { |
|
1028 | - $this->set_prop( 'is_free_trial', (int) $value ); |
|
1027 | + public function set_is_free_trial($value) { |
|
1028 | + $this->set_prop('is_free_trial', (int) $value); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | /** |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | * @since 1.0.19 |
1035 | 1035 | * @param string $value trial period. |
1036 | 1036 | */ |
1037 | - public function set_trial_period( $value ) { |
|
1038 | - $this->set_prop( 'trial_period', $value ); |
|
1037 | + public function set_trial_period($value) { |
|
1038 | + $this->set_prop('trial_period', $value); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | * @since 1.0.19 |
1045 | 1045 | * @param int $value trial interval. |
1046 | 1046 | */ |
1047 | - public function set_trial_interval( $value ) { |
|
1048 | - $this->set_prop( 'trial_interval', $value ); |
|
1047 | + public function set_trial_interval($value) { |
|
1048 | + $this->set_prop('trial_interval', $value); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1054,11 +1054,11 @@ discard block |
||
1054 | 1054 | * @deprecated |
1055 | 1055 | * @return int item id |
1056 | 1056 | */ |
1057 | - public function create( $data = array() ) { |
|
1057 | + public function create($data = array()) { |
|
1058 | 1058 | |
1059 | 1059 | // Set the properties. |
1060 | - if ( is_array( $data ) ) { |
|
1061 | - $this->set_props( $data ); |
|
1060 | + if (is_array($data)) { |
|
1061 | + $this->set_props($data); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | // Save the item. |
@@ -1072,8 +1072,8 @@ discard block |
||
1072 | 1072 | * @deprecated |
1073 | 1073 | * @return int item id |
1074 | 1074 | */ |
1075 | - public function update( $data = array() ) { |
|
1076 | - return $this->create( $data ); |
|
1075 | + public function update($data = array()) { |
|
1076 | + return $this->create($data); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /* |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | */ |
1114 | 1114 | public function has_free_trial() { |
1115 | 1115 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1116 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
1116 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @return bool |
1124 | 1124 | */ |
1125 | 1125 | public function is_free() { |
1126 | - $is_free = $this->get_price() == 0; |
|
1127 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
1126 | + $is_free = $this->get_price() == 0; |
|
1127 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1133,9 +1133,9 @@ discard block |
||
1133 | 1133 | * @param array|string $status Status to check. |
1134 | 1134 | * @return bool |
1135 | 1135 | */ |
1136 | - public function has_status( $status ) { |
|
1137 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1138 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1136 | + public function has_status($status) { |
|
1137 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
1138 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1144,9 +1144,9 @@ discard block |
||
1144 | 1144 | * @param array|string $type Type to check. |
1145 | 1145 | * @return bool |
1146 | 1146 | */ |
1147 | - public function is_type( $type ) { |
|
1148 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1149 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1147 | + public function is_type($type) { |
|
1148 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
1149 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1157,52 +1157,52 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function is_editable() { |
1159 | 1159 | $is_editable = $this->get_is_editable(); |
1160 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
1160 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
1164 | 1164 | * Returns an array of cart fees. |
1165 | 1165 | */ |
1166 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
1166 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
1167 | 1167 | |
1168 | - $fees = getpaid_session()->get( 'wpi_cart_fees' ); |
|
1168 | + $fees = getpaid_session()->get('wpi_cart_fees'); |
|
1169 | 1169 | |
1170 | - if ( ! wpinv_get_cart_contents() ) { |
|
1170 | + if (!wpinv_get_cart_contents()) { |
|
1171 | 1171 | // We can only get item type fees when the cart is empty |
1172 | 1172 | $type = 'custom'; |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
1176 | - foreach( $fees as $key => $fee ) { |
|
1177 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1178 | - unset( $fees[ $key ] ); |
|
1175 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
1176 | + foreach ($fees as $key => $fee) { |
|
1177 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
1178 | + unset($fees[$key]); |
|
1179 | 1179 | } |
1180 | 1180 | } |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
1183 | + if (!empty($fees) && !empty($item_id)) { |
|
1184 | 1184 | // Remove fees that don't belong to the specified Item |
1185 | - foreach ( $fees as $key => $fee ) { |
|
1186 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
1187 | - unset( $fees[ $key ] ); |
|
1185 | + foreach ($fees as $key => $fee) { |
|
1186 | + if ((int) $item_id !== (int) $fee['custom_id']) { |
|
1187 | + unset($fees[$key]); |
|
1188 | 1188 | } |
1189 | 1189 | } |
1190 | 1190 | } |
1191 | 1191 | |
1192 | - if ( ! empty( $fees ) ) { |
|
1192 | + if (!empty($fees)) { |
|
1193 | 1193 | // Remove fees that belong to a specific item but are not in the cart |
1194 | - foreach( $fees as $key => $fee ) { |
|
1195 | - if( empty( $fee['custom_id'] ) ) { |
|
1194 | + foreach ($fees as $key => $fee) { |
|
1195 | + if (empty($fee['custom_id'])) { |
|
1196 | 1196 | continue; |
1197 | 1197 | } |
1198 | 1198 | |
1199 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
1200 | - unset( $fees[ $key ] ); |
|
1199 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
1200 | + unset($fees[$key]); |
|
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | 1204 | |
1205 | - return ! empty( $fees ) ? $fees : array(); |
|
1205 | + return !empty($fees) ? $fees : array(); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | /** |
@@ -1214,11 +1214,11 @@ discard block |
||
1214 | 1214 | public function can_purchase() { |
1215 | 1215 | $can_purchase = $this->exists(); |
1216 | 1216 | |
1217 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1217 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1218 | 1218 | $can_purchase = false; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1221 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | /** |
@@ -1228,6 +1228,6 @@ discard block |
||
1228 | 1228 | * @return bool |
1229 | 1229 | */ |
1230 | 1230 | public function supports_dynamic_pricing() { |
1231 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1231 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1232 | 1232 | } |
1233 | 1233 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * Please use GetPaid_Notification_Email_Sender |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /* |
12 | 12 | |-------------------------------------------------------------------------- |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Generates the email header. |
19 | 19 | */ |
20 | -function wpinv_email_header( $email_heading ) { |
|
21 | - wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) ); |
|
20 | +function wpinv_email_header($email_heading) { |
|
21 | + wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading')); |
|
22 | 22 | } |
23 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
23 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Generates the email footer. |
28 | 28 | */ |
29 | 29 | function wpinv_email_footer() { |
30 | - wpinv_get_template( 'emails/wpinv-email-footer.php' ); |
|
30 | + wpinv_get_template('emails/wpinv-email-footer.php'); |
|
31 | 31 | } |
32 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
32 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param string $email_type |
40 | 40 | * @param bool $sent_to_admin |
41 | 41 | */ |
42 | -function wpinv_email_invoice_details( $invoice, $email_type, $sent_to_admin ) { |
|
42 | +function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) { |
|
43 | 43 | |
44 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
45 | - wpinv_get_template( 'emails/invoice-details.php', $args ); |
|
44 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
45 | + wpinv_get_template('emails/invoice-details.php', $args); |
|
46 | 46 | |
47 | 47 | } |
48 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
48 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Display line items in emails. |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | * @param string $email_type |
55 | 55 | * @param bool $sent_to_admin |
56 | 56 | */ |
57 | -function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) { |
|
57 | +function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) { |
|
58 | 58 | |
59 | 59 | // Prepare line items. |
60 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
61 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
60 | + $columns = getpaid_invoice_item_columns($invoice); |
|
61 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
62 | 62 | |
63 | 63 | // Load the template. |
64 | - wpinv_get_template( 'emails/invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) ); |
|
64 | + wpinv_get_template('emails/invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin')); |
|
65 | 65 | |
66 | 66 | } |
67 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
67 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | /** |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * @param string $email_type |
75 | 75 | * @param bool $sent_to_admin |
76 | 76 | */ |
77 | -function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) { |
|
77 | +function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) { |
|
78 | 78 | |
79 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
80 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args ); |
|
79 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
80 | + wpinv_get_template('emails/wpinv-email-billing-details.php', $args); |
|
81 | 81 | |
82 | 82 | } |
83 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
83 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Returns email css. |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function getpaid_get_email_css() { |
90 | 90 | |
91 | - $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' ); |
|
92 | - return apply_filters( 'wpinv_email_styles', $css ); |
|
91 | + $css = wpinv_get_template_html('emails/wpinv-email-styles.php'); |
|
92 | + return apply_filters('wpinv_email_styles', $css); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -100,26 +100,26 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | * |
102 | 102 | */ |
103 | -function wpinv_email_style_body( $content ) { |
|
103 | +function wpinv_email_style_body($content) { |
|
104 | 104 | |
105 | - if ( ! class_exists( 'DOMDocument' ) ) { |
|
105 | + if (!class_exists('DOMDocument')) { |
|
106 | 106 | return $content; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $css = getpaid_get_email_css(); |
110 | 110 | |
111 | 111 | // include css inliner |
112 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
113 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
112 | + if (!class_exists('Emogrifier')) { |
|
113 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | // Inline the css. |
117 | 117 | try { |
118 | - $emogrifier = new Emogrifier( $content, $css ); |
|
118 | + $emogrifier = new Emogrifier($content, $css); |
|
119 | 119 | $_content = $emogrifier->emogrify(); |
120 | 120 | $content = $_content; |
121 | - } catch ( Exception $e ) { |
|
122 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
121 | + } catch (Exception $e) { |
|
122 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $content; |
@@ -128,37 +128,37 @@ discard block |
||
128 | 128 | |
129 | 129 | // Backwards compatibility. |
130 | 130 | function wpinv_init_transactional_emails() { |
131 | - foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) { |
|
132 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
131 | + foreach (apply_filters('wpinv_email_actions', array()) as $action) { |
|
132 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
133 | 133 | } |
134 | 134 | } |
135 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
135 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
136 | 136 | |
137 | 137 | function wpinv_send_transactional_email() { |
138 | 138 | $args = func_get_args(); |
139 | 139 | $function = current_filter() . '_notification'; |
140 | - do_action_ref_array( $function, $args ); |
|
140 | + do_action_ref_array($function, $args); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_mail_get_from_address() { |
144 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
145 | - return sanitize_email( $from_address ); |
|
144 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
145 | + return sanitize_email($from_address); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | function wpinv_mail_get_from_name() { |
149 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
150 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
149 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
150 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
151 | 151 | } |
152 | 152 | |
153 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
154 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
155 | - return ( $active ? true : false ); |
|
153 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
154 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
155 | + return ($active ? true : false); |
|
156 | 156 | } |
157 | 157 | |
158 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
159 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
158 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
159 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
160 | 160 | |
161 | - switch ( $email_type ) { |
|
161 | + switch ($email_type) { |
|
162 | 162 | case 'html' : |
163 | 163 | $content_type = 'text/html'; |
164 | 164 | break; |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $attachments Any files to attach to the email. |
184 | 184 | * @param string|array $cc An email or array of extra emails to send a copy of the email to. |
185 | 185 | */ |
186 | -function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) { |
|
186 | +function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) { |
|
187 | 187 | |
188 | 188 | $mailer = new GetPaid_Notification_Email_Sender(); |
189 | - $message = wpinv_email_style_body( $message ); |
|
190 | - $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
|
189 | + $message = wpinv_email_style_body($message); |
|
190 | + $to = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc)); |
|
191 | 191 | |
192 | 192 | return $mailer->send( |
193 | 193 | $to, |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return array |
205 | 205 | */ |
206 | 206 | function wpinv_get_emails() { |
207 | - return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) ); |
|
207 | + return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,172 +213,172 @@ discard block |
||
213 | 213 | * @param array $settings |
214 | 214 | * @return array |
215 | 215 | */ |
216 | -function wpinv_settings_emails( $settings = array() ) { |
|
217 | - $settings = array_merge( $settings, wpinv_get_emails() ); |
|
218 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
216 | +function wpinv_settings_emails($settings = array()) { |
|
217 | + $settings = array_merge($settings, wpinv_get_emails()); |
|
218 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
219 | 219 | } |
220 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
220 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Filter email section names. |
224 | 224 | * |
225 | 225 | */ |
226 | -function wpinv_settings_sections_emails( $settings ) { |
|
227 | - foreach ( wpinv_get_emails() as $key => $email) { |
|
228 | - $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key ); |
|
226 | +function wpinv_settings_sections_emails($settings) { |
|
227 | + foreach (wpinv_get_emails() as $key => $email) { |
|
228 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | return $settings; |
232 | 232 | } |
233 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
233 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
234 | 234 | |
235 | -function wpinv_email_is_enabled( $email_type ) { |
|
235 | +function wpinv_email_is_enabled($email_type) { |
|
236 | 236 | $emails = wpinv_get_emails(); |
237 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
237 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
239 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
243 | - switch ( $email_type ) { |
|
242 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
243 | + switch ($email_type) { |
|
244 | 244 | case 'new_invoice': |
245 | 245 | case 'cancelled_invoice': |
246 | 246 | case 'failed_invoice': |
247 | 247 | $recipient = wpinv_get_admin_email(); |
248 | 248 | break; |
249 | 249 | default: |
250 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
251 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
250 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
251 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
255 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
255 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Returns invoice CC recipients |
260 | 260 | */ |
261 | -function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
262 | - switch ( $email_type ) { |
|
261 | +function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
262 | + switch ($email_type) { |
|
263 | 263 | case 'new_invoice': |
264 | 264 | case 'cancelled_invoice': |
265 | 265 | case 'failed_invoice': |
266 | 266 | return array(); |
267 | 267 | break; |
268 | 268 | default: |
269 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
270 | - $recipient = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true ); |
|
271 | - if ( empty( $recipient ) ) { |
|
269 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
270 | + $recipient = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true); |
|
271 | + if (empty($recipient)) { |
|
272 | 272 | return array(); |
273 | 273 | } |
274 | - return array_filter( array_map( 'trim', explode( ',', $recipient ) ) ); |
|
274 | + return array_filter(array_map('trim', explode(',', $recipient))); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
281 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
282 | - $subject = __( $subject, 'invoicing' ); |
|
280 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
281 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
282 | + $subject = __($subject, 'invoicing'); |
|
283 | 283 | |
284 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
284 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
285 | 285 | |
286 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
286 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
287 | 287 | } |
288 | 288 | |
289 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
290 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
291 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
289 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
290 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
291 | + $email_heading = __($email_heading, 'invoicing'); |
|
292 | 292 | |
293 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
293 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
294 | 294 | |
295 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
295 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
296 | 296 | } |
297 | 297 | |
298 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
299 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
300 | - $content = __( $content, 'invoicing' ); |
|
298 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
299 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
300 | + $content = __($content, 'invoicing'); |
|
301 | 301 | |
302 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
302 | + $content = wpinv_email_format_text($content, $invoice); |
|
303 | 303 | |
304 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
304 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
305 | 305 | } |
306 | 306 | |
307 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
307 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
308 | 308 | $from_name = wpinv_mail_get_from_address(); |
309 | 309 | $from_email = wpinv_mail_get_from_address(); |
310 | 310 | |
311 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
311 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
312 | 312 | |
313 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
314 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
313 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
314 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
315 | 315 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
316 | 316 | |
317 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
317 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
320 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
321 | 321 | $attachments = array(); |
322 | 322 | |
323 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
323 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Searches for and replaces certain placeholders in an email. |
328 | 328 | */ |
329 | -function wpinv_email_format_text( $content, $invoice ) { |
|
329 | +function wpinv_email_format_text($content, $invoice) { |
|
330 | 330 | |
331 | 331 | $replace_array = array( |
332 | 332 | '{site_title}' => wpinv_get_blogname(), |
333 | - '{date}' => getpaid_format_date( current_time( 'mysql' ) ), |
|
333 | + '{date}' => getpaid_format_date(current_time('mysql')), |
|
334 | 334 | ); |
335 | 335 | |
336 | - $invoice = new WPInv_Invoice( $invoice ); |
|
336 | + $invoice = new WPInv_Invoice($invoice); |
|
337 | 337 | |
338 | - if ( $invoice->get_id() ) { |
|
338 | + if ($invoice->get_id()) { |
|
339 | 339 | |
340 | 340 | $replace_array = array_merge( |
341 | 341 | $replace_array, |
342 | 342 | array( |
343 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
344 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
345 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
346 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
347 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
348 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
349 | - '{invoice_total}' => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ), |
|
350 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
351 | - '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ), |
|
352 | - '{invoice_date}' => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ), |
|
353 | - '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ), |
|
354 | - '{invoice_quote}' => sanitize_text_field( $invoice->get_type() ), |
|
355 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
356 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
343 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
344 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
345 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
346 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
347 | + '{email}' => sanitize_email($invoice->get_email()), |
|
348 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
349 | + '{invoice_total}' => wpinv_price(wpinv_format_amount($invoice->get_total(true))), |
|
350 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
351 | + '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()), |
|
352 | + '{invoice_date}' => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))), |
|
353 | + '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))), |
|
354 | + '{invoice_quote}' => sanitize_text_field($invoice->get_type()), |
|
355 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_type())), |
|
356 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
357 | 357 | ) |
358 | 358 | ); |
359 | 359 | |
360 | 360 | } |
361 | 361 | |
362 | 362 | // Let third party plugins filter the arra. |
363 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
363 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
364 | 364 | |
365 | - foreach ( $replace_array as $key => $value ) { |
|
366 | - $content = str_replace( $key, $value, $content ); |
|
365 | + foreach ($replace_array as $key => $value) { |
|
366 | + $content = str_replace($key, $value, $content); |
|
367 | 367 | } |
368 | 368 | |
369 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
369 | + return apply_filters('wpinv_email_content_replace', $content); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | -function wpinv_email_wrap_message( $message ) { |
|
373 | +function wpinv_email_wrap_message($message) { |
|
374 | 374 | // Buffer |
375 | 375 | ob_start(); |
376 | 376 | |
377 | - do_action( 'wpinv_email_header' ); |
|
377 | + do_action('wpinv_email_header'); |
|
378 | 378 | |
379 | - echo wpautop( wptexturize( $message ) ); |
|
379 | + echo wpautop(wptexturize($message)); |
|
380 | 380 | |
381 | - do_action( 'wpinv_email_footer' ); |
|
381 | + do_action('wpinv_email_footer'); |
|
382 | 382 | |
383 | 383 | // Get contents |
384 | 384 | $message = ob_get_clean(); |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | return $message; |
387 | 387 | } |
388 | 388 | |
389 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) { |
|
390 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->get_id(), true ) ) { |
|
391 | - $date_format = get_option( 'date_format' ); |
|
392 | - $time_format = get_option( 'time_format' ); |
|
389 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type) { |
|
390 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->get_id(), true)) { |
|
391 | + $date_format = get_option('date_format'); |
|
392 | + $time_format = get_option('time_format'); |
|
393 | 393 | ?> |
394 | 394 | <div id="wpinv-email-notes"> |
395 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
395 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
396 | 396 | <ol class="wpinv-notes-lists"> |
397 | 397 | <?php |
398 | - foreach ( $invoice_notes as $note ) { |
|
399 | - $note_time = strtotime( $note->comment_date ); |
|
398 | + foreach ($invoice_notes as $note) { |
|
399 | + $note_time = strtotime($note->comment_date); |
|
400 | 400 | ?> |
401 | 401 | <li class="comment wpinv-note"> |
402 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
403 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
402 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
403 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
404 | 404 | </li> |
405 | 405 | <?php |
406 | 406 | } |
@@ -409,4 +409,4 @@ discard block |
||
409 | 409 | <?php |
410 | 410 | } |
411 | 411 | } |
412 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
412 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
@@ -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 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' == strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $field ); |
|
29 | + if ('id' == strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($field); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | - $args = wp_parse_args( $args, array( |
|
58 | - 'status' => array( 'publish' ), |
|
59 | - 'limit' => get_option( 'posts_per_page' ), |
|
57 | + $args = wp_parse_args($args, array( |
|
58 | + 'status' => array('publish'), |
|
59 | + 'limit' => get_option('posts_per_page'), |
|
60 | 60 | 'page' => 1, |
61 | 61 | 'exclude' => array(), |
62 | 62 | 'orderby' => 'date', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'meta_query' => array(), |
66 | 66 | 'return' => 'objects', |
67 | 67 | 'paginate' => false, |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_item', |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | 'fields' => 'ids', |
76 | 76 | 'orderby' => $args['orderby'], |
77 | 77 | 'order' => $args['order'], |
78 | - 'paged' => absint( $args['page'] ), |
|
78 | + 'paged' => absint($args['page']), |
|
79 | 79 | ); |
80 | 80 | |
81 | - if ( ! empty( $args['exclude'] ) ) { |
|
82 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
81 | + if (!empty($args['exclude'])) { |
|
82 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( ! $args['paginate' ] ) { |
|
85 | + if (!$args['paginate']) { |
|
86 | 86 | $wp_query_args['no_found_rows'] = true; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $args['search'] ) ) { |
|
89 | + if (!empty($args['search'])) { |
|
90 | 90 | $wp_query_args['s'] = $args['search']; |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
94 | - $types = wpinv_parse_list( $args['type'] ); |
|
93 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
94 | + $types = wpinv_parse_list($args['type']); |
|
95 | 95 | $wp_query_args['meta_query'][] = array( |
96 | 96 | 'key' => '_wpinv_type', |
97 | - 'value' => implode( ',', $types ), |
|
97 | + 'value' => implode(',', $types), |
|
98 | 98 | 'compare' => 'IN', |
99 | 99 | ); |
100 | 100 | } |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
103 | 103 | |
104 | 104 | // Get results. |
105 | - $items = new WP_Query( $wp_query_args ); |
|
105 | + $items = new WP_Query($wp_query_args); |
|
106 | 106 | |
107 | - if ( 'objects' === $args['return'] ) { |
|
108 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
109 | - } elseif ( 'self' === $args['return'] ) { |
|
107 | + if ('objects' === $args['return']) { |
|
108 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
109 | + } elseif ('self' === $args['return']) { |
|
110 | 110 | return $items; |
111 | 111 | } else { |
112 | 112 | $return = $items->posts; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $args['paginate' ] ) { |
|
115 | + if ($args['paginate']) { |
|
116 | 116 | return (object) array( |
117 | 117 | 'items' => $return, |
118 | 118 | 'total' => $items->found_posts, |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
128 | - if( empty( $item_id ) ) { |
|
127 | +function wpinv_is_free_item($item_id = 0) { |
|
128 | + if (empty($item_id)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $item = new WPInv_Item( $item_id ); |
|
132 | + $item = new WPInv_Item($item_id); |
|
133 | 133 | |
134 | 134 | return $item->is_free(); |
135 | 135 | } |
@@ -139,21 +139,21 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
141 | 141 | */ |
142 | -function wpinv_item_is_editable( $item = 0 ) { |
|
142 | +function wpinv_item_is_editable($item = 0) { |
|
143 | 143 | |
144 | 144 | // Fetch the item. |
145 | - $item = new WPInv_Item( $item ); |
|
145 | + $item = new WPInv_Item($item); |
|
146 | 146 | |
147 | 147 | // Check if it is editable. |
148 | 148 | return $item->is_editable(); |
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
152 | - if( empty( $item_id ) ) { |
|
151 | +function wpinv_get_item_price($item_id = 0) { |
|
152 | + if (empty($item_id)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - $item = new WPInv_Item( $item_id ); |
|
156 | + $item = new WPInv_Item($item_id); |
|
157 | 157 | |
158 | 158 | return $item->get_price(); |
159 | 159 | } |
@@ -163,266 +163,266 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param WPInv_Item|int $item |
165 | 165 | */ |
166 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
167 | - $item = new WPInv_Item( $item ); |
|
166 | +function wpinv_is_recurring_item($item = 0) { |
|
167 | + $item = new WPInv_Item($item); |
|
168 | 168 | return $item->is_recurring(); |
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_item_price( $item_id = 0 ) { |
|
172 | - if( empty( $item_id ) ) { |
|
171 | +function wpinv_item_price($item_id = 0) { |
|
172 | + if (empty($item_id)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - $price = wpinv_get_item_price( $item_id ); |
|
177 | - $price = wpinv_price( wpinv_format_amount( $price ) ); |
|
176 | + $price = wpinv_get_item_price($item_id); |
|
177 | + $price = wpinv_price(wpinv_format_amount($price)); |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
179 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
180 | 180 | } |
181 | 181 | |
182 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
183 | - if ( is_null( $amount_override ) ) { |
|
184 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
182 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
183 | + if (is_null($amount_override)) { |
|
184 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
185 | 185 | } else { |
186 | 186 | $original_price = $amount_override; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $price = $original_price; |
190 | 190 | |
191 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
191 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
195 | - if( empty( $item_id ) ) { |
|
194 | +function wpinv_item_custom_singular_name($item_id) { |
|
195 | + if (empty($item_id)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | - $item = new WPInv_Item( $item_id ); |
|
199 | + $item = new WPInv_Item($item_id); |
|
200 | 200 | |
201 | 201 | return $item->get_custom_singular_name(); |
202 | 202 | } |
203 | 203 | |
204 | 204 | function wpinv_get_item_types() { |
205 | 205 | $item_types = array( |
206 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
207 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
206 | + 'custom' => __('Standard', 'invoicing'), |
|
207 | + 'fee' => __('Fee', 'invoicing'), |
|
208 | 208 | ); |
209 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
209 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_item_types() { |
213 | 213 | $item_types = wpinv_get_item_types(); |
214 | 214 | |
215 | - return ( !empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
215 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
216 | 216 | } |
217 | 217 | |
218 | -function wpinv_get_item_type( $item_id ) { |
|
219 | - if( empty( $item_id ) ) { |
|
218 | +function wpinv_get_item_type($item_id) { |
|
219 | + if (empty($item_id)) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - $item = new WPInv_Item( $item_id ); |
|
223 | + $item = new WPInv_Item($item_id); |
|
224 | 224 | |
225 | 225 | return $item->get_type(); |
226 | 226 | } |
227 | 227 | |
228 | -function wpinv_item_type( $item_id ) { |
|
228 | +function wpinv_item_type($item_id) { |
|
229 | 229 | $item_types = wpinv_get_item_types(); |
230 | 230 | |
231 | - $item_type = wpinv_get_item_type( $item_id ); |
|
231 | + $item_type = wpinv_get_item_type($item_id); |
|
232 | 232 | |
233 | - if ( empty( $item_type ) ) { |
|
233 | + if (empty($item_type)) { |
|
234 | 234 | $item_type = '-'; |
235 | 235 | } |
236 | 236 | |
237 | - $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' ); |
|
237 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
239 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_random_item( $post_ids = true ) { |
|
243 | - wpinv_get_random_items( 1, $post_ids ); |
|
242 | +function wpinv_get_random_item($post_ids = true) { |
|
243 | + wpinv_get_random_items(1, $post_ids); |
|
244 | 244 | } |
245 | 245 | |
246 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
247 | - if ( $post_ids ) { |
|
248 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' ); |
|
246 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
247 | + if ($post_ids) { |
|
248 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids'); |
|
249 | 249 | } else { |
250 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num ); |
|
250 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num); |
|
251 | 251 | } |
252 | 252 | |
253 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
253 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
254 | 254 | |
255 | - return get_posts( $args ); |
|
255 | + return get_posts($args); |
|
256 | 256 | } |
257 | 257 | |
258 | -function wpinv_get_item_token( $url = '' ) { |
|
258 | +function wpinv_get_item_token($url = '') { |
|
259 | 259 | $args = array(); |
260 | - $hash = apply_filters( 'wpinv_get_url_token_algorithm', 'sha256' ); |
|
261 | - $secret = apply_filters( 'wpinv_get_url_token_secret', hash( $hash, wp_salt() ) ); |
|
260 | + $hash = apply_filters('wpinv_get_url_token_algorithm', 'sha256'); |
|
261 | + $secret = apply_filters('wpinv_get_url_token_secret', hash($hash, wp_salt())); |
|
262 | 262 | |
263 | - $parts = parse_url( $url ); |
|
263 | + $parts = parse_url($url); |
|
264 | 264 | $options = array(); |
265 | 265 | |
266 | - if ( isset( $parts['query'] ) ) { |
|
267 | - wp_parse_str( $parts['query'], $query_args ); |
|
266 | + if (isset($parts['query'])) { |
|
267 | + wp_parse_str($parts['query'], $query_args); |
|
268 | 268 | |
269 | - if ( ! empty( $query_args['o'] ) ) { |
|
270 | - $options = explode( ':', rawurldecode( $query_args['o'] ) ); |
|
269 | + if (!empty($query_args['o'])) { |
|
270 | + $options = explode(':', rawurldecode($query_args['o'])); |
|
271 | 271 | |
272 | - if ( in_array( 'ip', $options ) ) { |
|
272 | + if (in_array('ip', $options)) { |
|
273 | 273 | $args['ip'] = wpinv_get_ip(); |
274 | 274 | } |
275 | 275 | |
276 | - if ( in_array( 'ua', $options ) ) { |
|
276 | + if (in_array('ua', $options)) { |
|
277 | 277 | $ua = wpinv_get_user_agent(); |
278 | - $args['user_agent'] = rawurlencode( $ua ); |
|
278 | + $args['user_agent'] = rawurlencode($ua); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - $args = apply_filters( 'wpinv_get_url_token_args', $args, $url, $options ); |
|
283 | + $args = apply_filters('wpinv_get_url_token_args', $args, $url, $options); |
|
284 | 284 | |
285 | 285 | $args['secret'] = $secret; |
286 | 286 | $args['token'] = false; |
287 | 287 | |
288 | - $url = add_query_arg( $args, $url ); |
|
289 | - $parts = parse_url( $url ); |
|
288 | + $url = add_query_arg($args, $url); |
|
289 | + $parts = parse_url($url); |
|
290 | 290 | |
291 | - if ( ! isset( $parts['path'] ) ) { |
|
291 | + if (!isset($parts['path'])) { |
|
292 | 292 | $parts['path'] = ''; |
293 | 293 | } |
294 | 294 | |
295 | - $token = md5( $parts['path'] . '?' . $parts['query'] ); |
|
295 | + $token = md5($parts['path'] . '?' . $parts['query']); |
|
296 | 296 | |
297 | 297 | return $token; |
298 | 298 | } |
299 | 299 | |
300 | -function wpinv_validate_url_token( $url = '' ) { |
|
300 | +function wpinv_validate_url_token($url = '') { |
|
301 | 301 | $ret = false; |
302 | - $parts = parse_url( $url ); |
|
302 | + $parts = parse_url($url); |
|
303 | 303 | |
304 | - if ( isset( $parts['query'] ) ) { |
|
305 | - wp_parse_str( $parts['query'], $query_args ); |
|
304 | + if (isset($parts['query'])) { |
|
305 | + wp_parse_str($parts['query'], $query_args); |
|
306 | 306 | |
307 | - $allowed = apply_filters( 'wpinv_url_token_allowed_params', array( |
|
307 | + $allowed = apply_filters('wpinv_url_token_allowed_params', array( |
|
308 | 308 | 'item', |
309 | 309 | 'ttl', |
310 | 310 | 'token' |
311 | - ) ); |
|
311 | + )); |
|
312 | 312 | |
313 | 313 | $remove = array(); |
314 | 314 | |
315 | - foreach( $query_args as $key => $value ) { |
|
316 | - if( false === in_array( $key, $allowed ) ) { |
|
315 | + foreach ($query_args as $key => $value) { |
|
316 | + if (false === in_array($key, $allowed)) { |
|
317 | 317 | $remove[] = $key; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - if( ! empty( $remove ) ) { |
|
322 | - $url = remove_query_arg( $remove, $url ); |
|
321 | + if (!empty($remove)) { |
|
322 | + $url = remove_query_arg($remove, $url); |
|
323 | 323 | } |
324 | 324 | |
325 | - if ( isset( $query_args['ttl'] ) && current_time( 'timestamp' ) > $query_args['ttl'] ) { |
|
326 | - wp_die( apply_filters( 'wpinv_item_link_expired_text', __( 'Sorry but your item link has expired.', 'invoicing' ) ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
325 | + if (isset($query_args['ttl']) && current_time('timestamp') > $query_args['ttl']) { |
|
326 | + wp_die(apply_filters('wpinv_item_link_expired_text', __('Sorry but your item link has expired.', 'invoicing')), __('Error', 'invoicing'), array('response' => 403)); |
|
327 | 327 | } |
328 | 328 | |
329 | - if ( isset( $query_args['token'] ) && $query_args['token'] == wpinv_get_item_token( $url ) ) { |
|
329 | + if (isset($query_args['token']) && $query_args['token'] == wpinv_get_item_token($url)) { |
|
330 | 330 | $ret = true; |
331 | 331 | } |
332 | 332 | |
333 | 333 | } |
334 | 334 | |
335 | - return apply_filters( 'wpinv_validate_url_token', $ret, $url, $query_args ); |
|
335 | + return apply_filters('wpinv_validate_url_token', $ret, $url, $query_args); |
|
336 | 336 | } |
337 | 337 | |
338 | -function wpinv_item_in_cart( $item_id = 0, $options = array() ) { |
|
338 | +function wpinv_item_in_cart($item_id = 0, $options = array()) { |
|
339 | 339 | $cart_items = wpinv_get_cart_contents(); |
340 | 340 | |
341 | 341 | $ret = false; |
342 | 342 | |
343 | - if ( is_array( $cart_items ) ) { |
|
344 | - foreach ( $cart_items as $item ) { |
|
345 | - if ( $item['id'] == $item_id ) { |
|
343 | + if (is_array($cart_items)) { |
|
344 | + foreach ($cart_items as $item) { |
|
345 | + if ($item['id'] == $item_id) { |
|
346 | 346 | $ret = true; |
347 | 347 | break; |
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
352 | - return (bool) apply_filters( 'wpinv_item_in_cart', $ret, $item_id, $options ); |
|
352 | + return (bool) apply_filters('wpinv_item_in_cart', $ret, $item_id, $options); |
|
353 | 353 | } |
354 | 354 | |
355 | -function wpinv_get_cart_item_tax( $item_id = 0, $subtotal = '', $options = array() ) { |
|
355 | +function wpinv_get_cart_item_tax($item_id = 0, $subtotal = '', $options = array()) { |
|
356 | 356 | $tax = 0; |
357 | - if ( ! wpinv_item_is_tax_exclusive( $item_id ) ) { |
|
358 | - $country = !empty( $_POST['country'] ) ? $_POST['country'] : false; |
|
359 | - $state = isset( $_POST['state'] ) ? $_POST['state'] : ''; |
|
357 | + if (!wpinv_item_is_tax_exclusive($item_id)) { |
|
358 | + $country = !empty($_POST['country']) ? $_POST['country'] : false; |
|
359 | + $state = isset($_POST['state']) ? $_POST['state'] : ''; |
|
360 | 360 | |
361 | - $tax = wpinv_calculate_tax( $subtotal, $country, $state, $item_id ); |
|
361 | + $tax = wpinv_calculate_tax($subtotal, $country, $state, $item_id); |
|
362 | 362 | } |
363 | 363 | |
364 | - return apply_filters( 'wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options ); |
|
364 | + return apply_filters('wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options); |
|
365 | 365 | } |
366 | 366 | |
367 | -function wpinv_cart_item_price( $item, $currency = '' ) { |
|
367 | +function wpinv_cart_item_price($item, $currency = '') { |
|
368 | 368 | |
369 | - if( empty( $currency ) ) { |
|
369 | + if (empty($currency)) { |
|
370 | 370 | $currency = wpinv_get_currency(); |
371 | 371 | } |
372 | 372 | |
373 | - $item_id = isset( $item['id'] ) ? $item['id'] : 0; |
|
374 | - $price = isset( $item['item_price'] ) ? wpinv_round_amount( $item['item_price'] ) : 0; |
|
375 | - $tax = wpinv_price( wpinv_format_amount( $item['tax'] ) ); |
|
373 | + $item_id = isset($item['id']) ? $item['id'] : 0; |
|
374 | + $price = isset($item['item_price']) ? wpinv_round_amount($item['item_price']) : 0; |
|
375 | + $tax = wpinv_price(wpinv_format_amount($item['tax'])); |
|
376 | 376 | |
377 | - if ( !wpinv_is_free_item( $item_id ) && !wpinv_item_is_tax_exclusive( $item_id ) ) { |
|
378 | - if ( wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax() ) { |
|
377 | + if (!wpinv_is_free_item($item_id) && !wpinv_item_is_tax_exclusive($item_id)) { |
|
378 | + if (wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax()) { |
|
379 | 379 | $price += $tax; |
380 | 380 | } |
381 | 381 | |
382 | - if( !wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax() ) { |
|
382 | + if (!wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax()) { |
|
383 | 383 | $price -= $tax; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - $price = wpinv_price( wpinv_format_amount( $price ), $currency ); |
|
387 | + $price = wpinv_price(wpinv_format_amount($price), $currency); |
|
388 | 388 | |
389 | - return apply_filters( 'wpinv_cart_item_price_label', $price, $item ); |
|
389 | + return apply_filters('wpinv_cart_item_price_label', $price, $item); |
|
390 | 390 | } |
391 | 391 | |
392 | -function wpinv_cart_item_subtotal( $item, $currency = '' ) { |
|
392 | +function wpinv_cart_item_subtotal($item, $currency = '') { |
|
393 | 393 | |
394 | - if( empty( $currency ) ) { |
|
394 | + if (empty($currency)) { |
|
395 | 395 | $currency = wpinv_get_currency(); |
396 | 396 | } |
397 | 397 | |
398 | - $subtotal = isset( $item['subtotal'] ) ? $item['subtotal'] : 0; |
|
399 | - $subtotal = wpinv_price( wpinv_format_amount( $subtotal ), $currency ); |
|
398 | + $subtotal = isset($item['subtotal']) ? $item['subtotal'] : 0; |
|
399 | + $subtotal = wpinv_price(wpinv_format_amount($subtotal), $currency); |
|
400 | 400 | |
401 | - return apply_filters( 'wpinv_cart_item_subtotal_label', $subtotal, $item ); |
|
401 | + return apply_filters('wpinv_cart_item_subtotal_label', $subtotal, $item); |
|
402 | 402 | } |
403 | 403 | |
404 | -function wpinv_cart_item_tax( $item, $currency = '' ) { |
|
404 | +function wpinv_cart_item_tax($item, $currency = '') { |
|
405 | 405 | $tax = ''; |
406 | 406 | $tax_rate = ''; |
407 | 407 | |
408 | - if( empty( $currency ) ) { |
|
408 | + if (empty($currency)) { |
|
409 | 409 | $currency = wpinv_get_currency(); |
410 | 410 | } |
411 | 411 | |
412 | - if ( isset( $item['tax'] ) && $item['tax'] > 0 && $item['subtotal'] > 0 ) { |
|
413 | - $tax = wpinv_price( wpinv_format_amount( $item['tax'] ), $currency ); |
|
414 | - $tax_rate = !empty( $item['vat_rate'] ) ? $item['vat_rate'] : ( $item['tax'] / $item['subtotal'] ) * 100; |
|
415 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
412 | + if (isset($item['tax']) && $item['tax'] > 0 && $item['subtotal'] > 0) { |
|
413 | + $tax = wpinv_price(wpinv_format_amount($item['tax']), $currency); |
|
414 | + $tax_rate = !empty($item['vat_rate']) ? $item['vat_rate'] : ($item['tax'] / $item['subtotal']) * 100; |
|
415 | + $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : ''; |
|
416 | 416 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate normal small">(' . $tax_rate . '%)</small>' : ''; |
417 | 417 | } |
418 | 418 | |
419 | - $tax = $tax . $tax_rate; |
|
419 | + $tax = $tax . $tax_rate; |
|
420 | 420 | |
421 | - if ( $tax === '' ) { |
|
421 | + if ($tax === '') { |
|
422 | 422 | $tax = 0; // Zero tax |
423 | 423 | } |
424 | 424 | |
425 | - return apply_filters( 'wpinv_cart_item_tax_label', $tax, $item ); |
|
425 | + return apply_filters('wpinv_cart_item_tax_label', $tax, $item); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | * @param WPInv_Item|int $item |
432 | 432 | * @param bool $html |
433 | 433 | */ |
434 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
434 | +function wpinv_get_item_suffix($item, $html = true) { |
|
435 | 435 | |
436 | - $item = new WPInv_Item( $item ); |
|
437 | - $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : ''; |
|
438 | - $suffix = $html ? $suffix : strip_tags( $suffix ); |
|
436 | + $item = new WPInv_Item($item); |
|
437 | + $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''; |
|
438 | + $suffix = $html ? $suffix : strip_tags($suffix); |
|
439 | 439 | |
440 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
440 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | * @param WPInv_Item|int $item |
447 | 447 | * @param bool $force_delete |
448 | 448 | */ |
449 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
450 | - $item = new WPInv_Item( $item ); |
|
451 | - $item->delete( $force_delete ); |
|
449 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
450 | + $item = new WPInv_Item($item); |
|
451 | + $item->delete($force_delete); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -487,45 +487,45 @@ discard block |
||
487 | 487 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
488 | 488 | * @return bool|WP_Error|WPInv_Item |
489 | 489 | */ |
490 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
490 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
491 | 491 | |
492 | 492 | // Prepare the item. |
493 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
494 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
495 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
493 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
494 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
495 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
496 | 496 | |
497 | - if ( ! empty( $item ) ) { |
|
497 | + if (!empty($item)) { |
|
498 | 498 | $args['ID'] = $item->get_id(); |
499 | 499 | } |
500 | 500 | |
501 | 501 | } |
502 | 502 | |
503 | 503 | // Do we have an item? |
504 | - if ( ! empty( $args['ID'] ) ) { |
|
505 | - $item = new WPInv_Item( $args['ID'] ); |
|
504 | + if (!empty($args['ID'])) { |
|
505 | + $item = new WPInv_Item($args['ID']); |
|
506 | 506 | } else { |
507 | 507 | $item = new WPInv_Item(); |
508 | 508 | } |
509 | 509 | |
510 | 510 | // Do we have an error? |
511 | - if ( ! empty( $item->last_error ) ) { |
|
512 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
511 | + if (!empty($item->last_error)) { |
|
512 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | // Update item props. |
516 | - $item->set_props( $args ); |
|
516 | + $item->set_props($args); |
|
517 | 517 | |
518 | 518 | // Save the item. |
519 | 519 | $item->save(); |
520 | 520 | |
521 | 521 | // Do we have an error? |
522 | - if ( ! empty( $item->last_error ) ) { |
|
523 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
522 | + if (!empty($item->last_error)) { |
|
523 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | // Was the item saved? |
527 | - if ( ! $item->get_id() ) { |
|
528 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
527 | + if (!$item->get_id()) { |
|
528 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | return $item; |
@@ -537,14 +537,14 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @see wpinv_create_item() |
539 | 539 | */ |
540 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
541 | - return wpinv_create_item( $args, $wp_error ); |
|
540 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
541 | + return wpinv_create_item($args, $wp_error); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
545 | 545 | * Sanitizes a recurring period |
546 | 546 | */ |
547 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
547 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
548 | 548 | |
549 | 549 | $periods = array( |
550 | 550 | 'D' => 'day', |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | 'Y' => 'year', |
554 | 554 | ); |
555 | 555 | |
556 | - if ( ! isset( $periods[ $period ] ) ) { |
|
556 | + if (!isset($periods[$period])) { |
|
557 | 557 | $period = 'D'; |
558 | 558 | } |
559 | 559 | |
560 | - return $full ? $periods[ $period ] : $period; |
|
560 | + return $full ? $periods[$period] : $period; |
|
561 | 561 | |
562 | 562 | } |
563 | 563 | |
@@ -566,34 +566,34 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @param WPInv_Item|GetPaid_Form_Item $item |
568 | 568 | */ |
569 | -function getpaid_item_recurring_price_help_text( $item, $currency = '' ) { |
|
569 | +function getpaid_item_recurring_price_help_text($item, $currency = '') { |
|
570 | 570 | |
571 | 571 | // Abort if it is not recurring. |
572 | - if ( ! $item->is_recurring() ) { |
|
572 | + if (!$item->is_recurring()) { |
|
573 | 573 | return ''; |
574 | 574 | } |
575 | 575 | |
576 | - $initial_price = wpinv_price( $item->get_initial_price(), $currency ); |
|
577 | - $recurring_price = wpinv_price( $item->get_recurring_price(), $currency ); |
|
578 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
576 | + $initial_price = wpinv_price($item->get_initial_price(), $currency); |
|
577 | + $recurring_price = wpinv_price($item->get_recurring_price(), $currency); |
|
578 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
579 | 579 | $initial_class = 'getpaid-item-initial-price'; |
580 | 580 | $recurring_class = 'getpaid-item-recurring-price'; |
581 | 581 | |
582 | - if ( $item instanceof GetPaid_Form_Item ) { |
|
583 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
584 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
582 | + if ($item instanceof GetPaid_Form_Item) { |
|
583 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
584 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | // For free trial items. |
588 | - if ( $item->has_free_trial() ) { |
|
589 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
588 | + if ($item->has_free_trial()) { |
|
589 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
590 | 590 | |
591 | - if ( 0 == $item->get_initial_price() ) { |
|
591 | + if (0 == $item->get_initial_price()) { |
|
592 | 592 | |
593 | 593 | return sprintf( |
594 | 594 | |
595 | 595 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
596 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
596 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
597 | 597 | $trial_period, |
598 | 598 | "<span class='$recurring_class'>$recurring_price</span>", |
599 | 599 | $period |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | return sprintf( |
606 | 606 | |
607 | 607 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
608 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
608 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
609 | 609 | "<span class='$initial_class'>$initial_price</span>", |
610 | 610 | $trial_period, |
611 | 611 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | |
616 | 616 | } |
617 | 617 | |
618 | - if ( $initial_price == $recurring_price ) { |
|
618 | + if ($initial_price == $recurring_price) { |
|
619 | 619 | |
620 | 620 | return sprintf( |
621 | 621 | |
622 | 622 | // translators: $1: is the recurring price, $2: is the susbcription period |
623 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
623 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
624 | 624 | "<span class='$recurring_class'>$recurring_price</span>", |
625 | 625 | $period |
626 | 626 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | return sprintf( |
632 | 632 | |
633 | 633 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
634 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
634 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
635 | 635 | "<span class='$initial_class'>$initial_price</span>", |
636 | 636 | "<span class='$recurring_class'>$recurring_price</span>", |
637 | 637 | $period |
@@ -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 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
137 | 137 | */ |
138 | - public function __construct( $invoice = false ) { |
|
138 | + public function __construct($invoice = false) { |
|
139 | 139 | |
140 | - parent::__construct( $invoice ); |
|
140 | + parent::__construct($invoice); |
|
141 | 141 | |
142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
143 | - $this->set_id( $invoice ); |
|
144 | - } elseif ( $invoice instanceof self ) { |
|
145 | - $this->set_id( $invoice->get_id() ); |
|
146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
147 | - $this->set_id( $invoice->ID ); |
|
148 | - } elseif ( is_array( $invoice ) ) { |
|
149 | - $this->set_props( $invoice ); |
|
142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
143 | + $this->set_id($invoice); |
|
144 | + } elseif ($invoice instanceof self) { |
|
145 | + $this->set_id($invoice->get_id()); |
|
146 | + } elseif (!empty($invoice->ID)) { |
|
147 | + $this->set_id($invoice->ID); |
|
148 | + } elseif (is_array($invoice)) { |
|
149 | + $this->set_props($invoice); |
|
150 | 150 | |
151 | - if ( isset( $invoice['ID'] ) ) { |
|
152 | - $this->set_id( $invoice['ID'] ); |
|
151 | + if (isset($invoice['ID'])) { |
|
152 | + $this->set_id($invoice['ID']); |
|
153 | 153 | } |
154 | 154 | |
155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
156 | - $this->set_id( $invoice_id ); |
|
157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
158 | - $this->set_id( $invoice_id ); |
|
159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
160 | - $this->set_id( $invoice_id ); |
|
161 | - }else { |
|
162 | - $this->set_object_read( true ); |
|
155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
156 | + $this->set_id($invoice_id); |
|
157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
158 | + $this->set_id($invoice_id); |
|
159 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
160 | + $this->set_id($invoice_id); |
|
161 | + } else { |
|
162 | + $this->set_object_read(true); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Load the datastore. |
166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
167 | 167 | |
168 | - if ( $this->get_id() > 0 ) { |
|
169 | - $this->post = get_post( $this->get_id() ); |
|
168 | + if ($this->get_id() > 0) { |
|
169 | + $this->post = get_post($this->get_id()); |
|
170 | 170 | $this->ID = $this->get_id(); |
171 | - $this->data_store->read( $this ); |
|
171 | + $this->data_store->read($this); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
183 | 183 | * @since 1.0.15 |
184 | 184 | * @return int |
185 | 185 | */ |
186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
187 | 187 | global $wpdb; |
188 | 188 | |
189 | 189 | // Trim the value. |
190 | - $value = trim( $value ); |
|
190 | + $value = trim($value); |
|
191 | 191 | |
192 | - if ( empty( $value ) ) { |
|
192 | + if (empty($value)) { |
|
193 | 193 | return 0; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Valid fields. |
197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
197 | + $fields = array('key', 'number', 'transaction_id'); |
|
198 | 198 | |
199 | 199 | // Ensure a field has been passed. |
200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
200 | + if (empty($field) || !in_array($field, $fields)) { |
|
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Maybe retrieve from the cache. |
205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
206 | - if ( false !== $invoice_id ) { |
|
205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
206 | + if (false !== $invoice_id) { |
|
207 | 207 | return $invoice_id; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Fetch from the db. |
211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
212 | 212 | $invoice_id = (int) $wpdb->get_var( |
213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | // Update the cache with our data |
217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
218 | 218 | |
219 | 219 | return $invoice_id; |
220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Checks if an invoice key is set. |
224 | 224 | */ |
225 | - public function _isset( $key ) { |
|
226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
225 | + public function _isset($key) { |
|
226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return int |
250 | 250 | */ |
251 | - public function get_parent_id( $context = 'view' ) { |
|
252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
251 | + public function get_parent_id($context = 'view') { |
|
252 | + return (int) $this->get_prop('parent_id', $context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @return WPInv_Invoice |
260 | 260 | */ |
261 | 261 | public function get_parent_payment() { |
262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param string $context View or edit context. |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function get_status( $context = 'view' ) { |
|
283 | - return $this->get_prop( 'status', $context ); |
|
282 | + public function get_status($context = 'view') { |
|
283 | + return $this->get_prop('status', $context); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -291,10 +291,10 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function get_all_statuses() { |
293 | 293 | |
294 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
294 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
295 | 295 | |
296 | 296 | // For backwards compatibility. |
297 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
297 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
298 | 298 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
299 | 299 | } |
300 | 300 | |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | public function get_status_nicename() { |
311 | 311 | $statuses = $this->get_all_statuses(); |
312 | 312 | |
313 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
313 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
314 | 314 | |
315 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
315 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public function get_status_label_html() { |
325 | 325 | |
326 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
327 | - $status = sanitize_html_class( $this->get_status() ); |
|
326 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
327 | + $status = sanitize_html_class($this->get_status()); |
|
328 | 328 | |
329 | 329 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
330 | 330 | } |
@@ -336,23 +336,23 @@ discard block |
||
336 | 336 | * @param string $context View or edit context. |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public function get_version( $context = 'view' ) { |
|
340 | - return $this->get_prop( 'version', $context ); |
|
339 | + public function get_version($context = 'view') { |
|
340 | + return $this->get_prop('version', $context); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
344 | 344 | * @deprecated |
345 | 345 | */ |
346 | - public function get_invoice_date( $format = true ) { |
|
347 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
348 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
349 | - $formatted = getpaid_format_date( $date ); |
|
346 | + public function get_invoice_date($format = true) { |
|
347 | + $date = getpaid_format_date($this->get_date_completed()); |
|
348 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
349 | + $formatted = getpaid_format_date($date); |
|
350 | 350 | |
351 | - if ( $format ) { |
|
351 | + if ($format) { |
|
352 | 352 | return $formatted; |
353 | 353 | } |
354 | 354 | |
355 | - return empty( $formatted ) ? '' : $date; |
|
355 | + return empty($formatted) ? '' : $date; |
|
356 | 356 | |
357 | 357 | } |
358 | 358 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | * @param string $context View or edit context. |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - public function get_date_created( $context = 'view' ) { |
|
367 | - return $this->get_prop( 'date_created', $context ); |
|
366 | + public function get_date_created($context = 'view') { |
|
367 | + return $this->get_prop('date_created', $context); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | * @param string $context View or edit context. |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public function get_created_date( $context = 'view' ) { |
|
378 | - return $this->get_date_created( $context ); |
|
377 | + public function get_created_date($context = 'view') { |
|
378 | + return $this->get_date_created($context); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -385,11 +385,11 @@ discard block |
||
385 | 385 | * @param string $context View or edit context. |
386 | 386 | * @return string |
387 | 387 | */ |
388 | - public function get_date_created_gmt( $context = 'view' ) { |
|
389 | - $date = $this->get_date_created( $context ); |
|
388 | + public function get_date_created_gmt($context = 'view') { |
|
389 | + $date = $this->get_date_created($context); |
|
390 | 390 | |
391 | - if ( $date ) { |
|
392 | - $date = get_gmt_from_date( $date ); |
|
391 | + if ($date) { |
|
392 | + $date = get_gmt_from_date($date); |
|
393 | 393 | } |
394 | 394 | return $date; |
395 | 395 | } |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @param string $context View or edit context. |
402 | 402 | * @return string |
403 | 403 | */ |
404 | - public function get_date_modified( $context = 'view' ) { |
|
405 | - return $this->get_prop( 'date_modified', $context ); |
|
404 | + public function get_date_modified($context = 'view') { |
|
405 | + return $this->get_prop('date_modified', $context); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * @param string $context View or edit context. |
413 | 413 | * @return string |
414 | 414 | */ |
415 | - public function get_modified_date( $context = 'view' ) { |
|
416 | - return $this->get_date_modified( $context ); |
|
415 | + public function get_modified_date($context = 'view') { |
|
416 | + return $this->get_date_modified($context); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | * @param string $context View or edit context. |
424 | 424 | * @return string |
425 | 425 | */ |
426 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
427 | - $date = $this->get_date_modified( $context ); |
|
426 | + public function get_date_modified_gmt($context = 'view') { |
|
427 | + $date = $this->get_date_modified($context); |
|
428 | 428 | |
429 | - if ( $date ) { |
|
430 | - $date = get_gmt_from_date( $date ); |
|
429 | + if ($date) { |
|
430 | + $date = get_gmt_from_date($date); |
|
431 | 431 | } |
432 | 432 | return $date; |
433 | 433 | } |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * @param string $context View or edit context. |
440 | 440 | * @return string |
441 | 441 | */ |
442 | - public function get_due_date( $context = 'view' ) { |
|
443 | - return $this->get_prop( 'due_date', $context ); |
|
442 | + public function get_due_date($context = 'view') { |
|
443 | + return $this->get_prop('due_date', $context); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | * @param string $context View or edit context. |
451 | 451 | * @return string |
452 | 452 | */ |
453 | - public function get_date_due( $context = 'view' ) { |
|
454 | - return $this->get_due_date( $context ); |
|
453 | + public function get_date_due($context = 'view') { |
|
454 | + return $this->get_due_date($context); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | * @param string $context View or edit context. |
462 | 462 | * @return string |
463 | 463 | */ |
464 | - public function get_due_date_gmt( $context = 'view' ) { |
|
465 | - $date = $this->get_due_date( $context ); |
|
464 | + public function get_due_date_gmt($context = 'view') { |
|
465 | + $date = $this->get_due_date($context); |
|
466 | 466 | |
467 | - if ( $date ) { |
|
468 | - $date = get_gmt_from_date( $date ); |
|
467 | + if ($date) { |
|
468 | + $date = get_gmt_from_date($date); |
|
469 | 469 | } |
470 | 470 | return $date; |
471 | 471 | } |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | * @param string $context View or edit context. |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function get_gmt_date_due( $context = 'view' ) { |
|
481 | - return $this->get_due_date_gmt( $context ); |
|
480 | + public function get_gmt_date_due($context = 'view') { |
|
481 | + return $this->get_due_date_gmt($context); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | * @param string $context View or edit context. |
489 | 489 | * @return string |
490 | 490 | */ |
491 | - public function get_completed_date( $context = 'view' ) { |
|
492 | - return $this->get_prop( 'completed_date', $context ); |
|
491 | + public function get_completed_date($context = 'view') { |
|
492 | + return $this->get_prop('completed_date', $context); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param string $context View or edit context. |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public function get_date_completed( $context = 'view' ) { |
|
503 | - return $this->get_completed_date( $context ); |
|
502 | + public function get_date_completed($context = 'view') { |
|
503 | + return $this->get_completed_date($context); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @param string $context View or edit context. |
511 | 511 | * @return string |
512 | 512 | */ |
513 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
514 | - $date = $this->get_completed_date( $context ); |
|
513 | + public function get_completed_date_gmt($context = 'view') { |
|
514 | + $date = $this->get_completed_date($context); |
|
515 | 515 | |
516 | - if ( $date ) { |
|
517 | - $date = get_gmt_from_date( $date ); |
|
516 | + if ($date) { |
|
517 | + $date = get_gmt_from_date($date); |
|
518 | 518 | } |
519 | 519 | return $date; |
520 | 520 | } |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | * @param string $context View or edit context. |
527 | 527 | * @return string |
528 | 528 | */ |
529 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
530 | - return $this->get_completed_date_gmt( $context ); |
|
529 | + public function get_gmt_completed_date($context = 'view') { |
|
530 | + return $this->get_completed_date_gmt($context); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -537,12 +537,12 @@ discard block |
||
537 | 537 | * @param string $context View or edit context. |
538 | 538 | * @return string |
539 | 539 | */ |
540 | - public function get_number( $context = 'view' ) { |
|
541 | - $number = $this->get_prop( 'number', $context ); |
|
540 | + public function get_number($context = 'view') { |
|
541 | + $number = $this->get_prop('number', $context); |
|
542 | 542 | |
543 | - if ( empty( $number ) ) { |
|
543 | + if (empty($number)) { |
|
544 | 544 | $number = $this->generate_number(); |
545 | - $this->set_number( $this->generate_number() ); |
|
545 | + $this->set_number($this->generate_number()); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | return $number; |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | public function maybe_set_number() { |
557 | 557 | $number = $this->get_number(); |
558 | 558 | |
559 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
560 | - $this->set_number( $this->generate_number() ); |
|
559 | + if (empty($number) || $this->get_id() == $number) { |
|
560 | + $this->set_number($this->generate_number()); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | } |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | * @param string $context View or edit context. |
570 | 570 | * @return string |
571 | 571 | */ |
572 | - public function get_key( $context = 'view' ) { |
|
573 | - return $this->get_prop( 'key', $context ); |
|
572 | + public function get_key($context = 'view') { |
|
573 | + return $this->get_prop('key', $context); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -581,9 +581,9 @@ discard block |
||
581 | 581 | public function maybe_set_key() { |
582 | 582 | $key = $this->get_key(); |
583 | 583 | |
584 | - if ( empty( $key ) ) { |
|
585 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
586 | - $this->set_key( $key ); |
|
584 | + if (empty($key)) { |
|
585 | + $key = $this->generate_key($this->get_type() . '_'); |
|
586 | + $this->set_key($key); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | } |
@@ -595,15 +595,15 @@ discard block |
||
595 | 595 | * @param string $context View or edit context. |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - public function get_type( $context = 'view' ) { |
|
599 | - return $this->get_prop( 'type', $context ); |
|
598 | + public function get_type($context = 'view') { |
|
599 | + return $this->get_prop('type', $context); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
603 | 603 | * @deprecated |
604 | 604 | */ |
605 | 605 | public function get_invoice_quote_type() { |
606 | - ucfirst( $this->get_type() ); |
|
606 | + ucfirst($this->get_type()); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -613,8 +613,8 @@ discard block |
||
613 | 613 | * @param string $context View or edit context. |
614 | 614 | * @return string |
615 | 615 | */ |
616 | - public function get_post_type( $context = 'view' ) { |
|
617 | - return $this->get_prop( 'post_type', $context ); |
|
616 | + public function get_post_type($context = 'view') { |
|
617 | + return $this->get_prop('post_type', $context); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | * @param string $context View or edit context. |
625 | 625 | * @return string |
626 | 626 | */ |
627 | - public function get_mode( $context = 'view' ) { |
|
628 | - return $this->get_prop( 'mode', $context ); |
|
627 | + public function get_mode($context = 'view') { |
|
628 | + return $this->get_prop('mode', $context); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | * @param string $context View or edit context. |
636 | 636 | * @return string |
637 | 637 | */ |
638 | - public function get_path( $context = 'view' ) { |
|
639 | - $path = $this->get_prop( 'path', $context ); |
|
640 | - $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
638 | + public function get_path($context = 'view') { |
|
639 | + $path = $this->get_prop('path', $context); |
|
640 | + $prefix = wpinv_post_name_prefix($this->get_post_type()); |
|
641 | 641 | |
642 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
643 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
644 | - $this->set_path( $path ); |
|
642 | + if (0 !== strpos($path, $prefix)) { |
|
643 | + $path = sanitize_title($prefix . $this->get_id()); |
|
644 | + $this->set_path($path); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | return $path; |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * @param string $context View or edit context. |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public function get_name( $context = 'view' ) { |
|
658 | - return $this->get_prop( 'title', $context ); |
|
657 | + public function get_name($context = 'view') { |
|
658 | + return $this->get_prop('title', $context); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | * @param string $context View or edit context. |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - public function get_title( $context = 'view' ) { |
|
669 | - return $this->get_name( $context ); |
|
668 | + public function get_title($context = 'view') { |
|
669 | + return $this->get_name($context); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @param string $context View or edit context. |
677 | 677 | * @return string |
678 | 678 | */ |
679 | - public function get_description( $context = 'view' ) { |
|
680 | - return $this->get_prop( 'description', $context ); |
|
679 | + public function get_description($context = 'view') { |
|
680 | + return $this->get_prop('description', $context); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | * @param string $context View or edit context. |
688 | 688 | * @return string |
689 | 689 | */ |
690 | - public function get_excerpt( $context = 'view' ) { |
|
691 | - return $this->get_description( $context ); |
|
690 | + public function get_excerpt($context = 'view') { |
|
691 | + return $this->get_description($context); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -698,8 +698,8 @@ discard block |
||
698 | 698 | * @param string $context View or edit context. |
699 | 699 | * @return string |
700 | 700 | */ |
701 | - public function get_summary( $context = 'view' ) { |
|
702 | - return $this->get_description( $context ); |
|
701 | + public function get_summary($context = 'view') { |
|
702 | + return $this->get_description($context); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -709,25 +709,25 @@ discard block |
||
709 | 709 | * @param string $context View or edit context. |
710 | 710 | * @return array |
711 | 711 | */ |
712 | - public function get_user_info( $context = 'view' ) { |
|
712 | + public function get_user_info($context = 'view') { |
|
713 | 713 | |
714 | 714 | $user_info = array( |
715 | - 'user_id' => $this->get_user_id( $context ), |
|
716 | - 'email' => $this->get_email( $context ), |
|
717 | - 'first_name' => $this->get_first_name( $context ), |
|
718 | - 'last_name' => $this->get_last_name( $context ), |
|
719 | - 'address' => $this->get_address( $context ), |
|
720 | - 'phone' => $this->get_phone( $context ), |
|
721 | - 'city' => $this->get_city( $context ), |
|
722 | - 'country' => $this->get_country( $context ), |
|
723 | - 'state' => $this->get_state( $context ), |
|
724 | - 'zip' => $this->get_zip( $context ), |
|
725 | - 'company' => $this->get_company( $context ), |
|
726 | - 'vat_number' => $this->get_vat_number( $context ), |
|
727 | - 'discount' => $this->get_discount_code( $context ), |
|
715 | + 'user_id' => $this->get_user_id($context), |
|
716 | + 'email' => $this->get_email($context), |
|
717 | + 'first_name' => $this->get_first_name($context), |
|
718 | + 'last_name' => $this->get_last_name($context), |
|
719 | + 'address' => $this->get_address($context), |
|
720 | + 'phone' => $this->get_phone($context), |
|
721 | + 'city' => $this->get_city($context), |
|
722 | + 'country' => $this->get_country($context), |
|
723 | + 'state' => $this->get_state($context), |
|
724 | + 'zip' => $this->get_zip($context), |
|
725 | + 'company' => $this->get_company($context), |
|
726 | + 'vat_number' => $this->get_vat_number($context), |
|
727 | + 'discount' => $this->get_discount_code($context), |
|
728 | 728 | ); |
729 | 729 | |
730 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
730 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
731 | 731 | |
732 | 732 | } |
733 | 733 | |
@@ -738,8 +738,8 @@ discard block |
||
738 | 738 | * @param string $context View or edit context. |
739 | 739 | * @return int |
740 | 740 | */ |
741 | - public function get_author( $context = 'view' ) { |
|
742 | - return (int) $this->get_prop( 'author', $context ); |
|
741 | + public function get_author($context = 'view') { |
|
742 | + return (int) $this->get_prop('author', $context); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | * @param string $context View or edit context. |
750 | 750 | * @return int |
751 | 751 | */ |
752 | - public function get_user_id( $context = 'view' ) { |
|
753 | - return $this->get_author( $context ); |
|
752 | + public function get_user_id($context = 'view') { |
|
753 | + return $this->get_author($context); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -760,8 +760,8 @@ discard block |
||
760 | 760 | * @param string $context View or edit context. |
761 | 761 | * @return int |
762 | 762 | */ |
763 | - public function get_customer_id( $context = 'view' ) { |
|
764 | - return $this->get_author( $context ); |
|
763 | + public function get_customer_id($context = 'view') { |
|
764 | + return $this->get_author($context); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /** |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * @param string $context View or edit context. |
772 | 772 | * @return string |
773 | 773 | */ |
774 | - public function get_ip( $context = 'view' ) { |
|
775 | - return $this->get_prop( 'user_ip', $context ); |
|
774 | + public function get_ip($context = 'view') { |
|
775 | + return $this->get_prop('user_ip', $context); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | * @param string $context View or edit context. |
783 | 783 | * @return string |
784 | 784 | */ |
785 | - public function get_user_ip( $context = 'view' ) { |
|
786 | - return $this->get_ip( $context ); |
|
785 | + public function get_user_ip($context = 'view') { |
|
786 | + return $this->get_ip($context); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -793,8 +793,8 @@ discard block |
||
793 | 793 | * @param string $context View or edit context. |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - public function get_customer_ip( $context = 'view' ) { |
|
797 | - return $this->get_ip( $context ); |
|
796 | + public function get_customer_ip($context = 'view') { |
|
797 | + return $this->get_ip($context); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | /** |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | * @param string $context View or edit context. |
805 | 805 | * @return string |
806 | 806 | */ |
807 | - public function get_first_name( $context = 'view' ) { |
|
808 | - return $this->get_prop( 'first_name', $context ); |
|
807 | + public function get_first_name($context = 'view') { |
|
808 | + return $this->get_prop('first_name', $context); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | * @param string $context View or edit context. |
816 | 816 | * @return int |
817 | 817 | */ |
818 | - public function get_user_first_name( $context = 'view' ) { |
|
819 | - return $this->get_first_name( $context ); |
|
818 | + public function get_user_first_name($context = 'view') { |
|
819 | + return $this->get_first_name($context); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | /** |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | * @param string $context View or edit context. |
827 | 827 | * @return int |
828 | 828 | */ |
829 | - public function get_customer_first_name( $context = 'view' ) { |
|
830 | - return $this->get_first_name( $context ); |
|
829 | + public function get_customer_first_name($context = 'view') { |
|
830 | + return $this->get_first_name($context); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | /** |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * @param string $context View or edit context. |
838 | 838 | * @return string |
839 | 839 | */ |
840 | - public function get_last_name( $context = 'view' ) { |
|
841 | - return $this->get_prop( 'last_name', $context ); |
|
840 | + public function get_last_name($context = 'view') { |
|
841 | + return $this->get_prop('last_name', $context); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @param string $context View or edit context. |
849 | 849 | * @return int |
850 | 850 | */ |
851 | - public function get_user_last_name( $context = 'view' ) { |
|
852 | - return $this->get_last_name( $context ); |
|
851 | + public function get_user_last_name($context = 'view') { |
|
852 | + return $this->get_last_name($context); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | * @param string $context View or edit context. |
860 | 860 | * @return int |
861 | 861 | */ |
862 | - public function get_customer_last_name( $context = 'view' ) { |
|
863 | - return $this->get_last_name( $context ); |
|
862 | + public function get_customer_last_name($context = 'view') { |
|
863 | + return $this->get_last_name($context); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | /** |
@@ -870,8 +870,8 @@ discard block |
||
870 | 870 | * @param string $context View or edit context. |
871 | 871 | * @return string |
872 | 872 | */ |
873 | - public function get_full_name( $context = 'view' ) { |
|
874 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
873 | + public function get_full_name($context = 'view') { |
|
874 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /** |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | * @param string $context View or edit context. |
882 | 882 | * @return int |
883 | 883 | */ |
884 | - public function get_user_full_name( $context = 'view' ) { |
|
885 | - return $this->get_full_name( $context ); |
|
884 | + public function get_user_full_name($context = 'view') { |
|
885 | + return $this->get_full_name($context); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -892,8 +892,8 @@ discard block |
||
892 | 892 | * @param string $context View or edit context. |
893 | 893 | * @return int |
894 | 894 | */ |
895 | - public function get_customer_full_name( $context = 'view' ) { |
|
896 | - return $this->get_full_name( $context ); |
|
895 | + public function get_customer_full_name($context = 'view') { |
|
896 | + return $this->get_full_name($context); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | /** |
@@ -903,8 +903,8 @@ discard block |
||
903 | 903 | * @param string $context View or edit context. |
904 | 904 | * @return string |
905 | 905 | */ |
906 | - public function get_phone( $context = 'view' ) { |
|
907 | - return $this->get_prop( 'phone', $context ); |
|
906 | + public function get_phone($context = 'view') { |
|
907 | + return $this->get_prop('phone', $context); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | /** |
@@ -914,8 +914,8 @@ discard block |
||
914 | 914 | * @param string $context View or edit context. |
915 | 915 | * @return int |
916 | 916 | */ |
917 | - public function get_phone_number( $context = 'view' ) { |
|
918 | - return $this->get_phone( $context ); |
|
917 | + public function get_phone_number($context = 'view') { |
|
918 | + return $this->get_phone($context); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | * @param string $context View or edit context. |
926 | 926 | * @return int |
927 | 927 | */ |
928 | - public function get_user_phone( $context = 'view' ) { |
|
929 | - return $this->get_phone( $context ); |
|
928 | + public function get_user_phone($context = 'view') { |
|
929 | + return $this->get_phone($context); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | /** |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | * @param string $context View or edit context. |
937 | 937 | * @return int |
938 | 938 | */ |
939 | - public function get_customer_phone( $context = 'view' ) { |
|
940 | - return $this->get_phone( $context ); |
|
939 | + public function get_customer_phone($context = 'view') { |
|
940 | + return $this->get_phone($context); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -947,8 +947,8 @@ discard block |
||
947 | 947 | * @param string $context View or edit context. |
948 | 948 | * @return string |
949 | 949 | */ |
950 | - public function get_email( $context = 'view' ) { |
|
951 | - return $this->get_prop( 'email', $context ); |
|
950 | + public function get_email($context = 'view') { |
|
951 | + return $this->get_prop('email', $context); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | /** |
@@ -958,8 +958,8 @@ discard block |
||
958 | 958 | * @param string $context View or edit context. |
959 | 959 | * @return string |
960 | 960 | */ |
961 | - public function get_email_address( $context = 'view' ) { |
|
962 | - return $this->get_email( $context ); |
|
961 | + public function get_email_address($context = 'view') { |
|
962 | + return $this->get_email($context); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | /** |
@@ -969,8 +969,8 @@ discard block |
||
969 | 969 | * @param string $context View or edit context. |
970 | 970 | * @return int |
971 | 971 | */ |
972 | - public function get_user_email( $context = 'view' ) { |
|
973 | - return $this->get_email( $context ); |
|
972 | + public function get_user_email($context = 'view') { |
|
973 | + return $this->get_email($context); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -980,8 +980,8 @@ discard block |
||
980 | 980 | * @param string $context View or edit context. |
981 | 981 | * @return int |
982 | 982 | */ |
983 | - public function get_customer_email( $context = 'view' ) { |
|
984 | - return $this->get_email( $context ); |
|
983 | + public function get_customer_email($context = 'view') { |
|
984 | + return $this->get_email($context); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | /** |
@@ -991,9 +991,9 @@ discard block |
||
991 | 991 | * @param string $context View or edit context. |
992 | 992 | * @return string |
993 | 993 | */ |
994 | - public function get_country( $context = 'view' ) { |
|
995 | - $country = $this->get_prop( 'country', $context ); |
|
996 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
994 | + public function get_country($context = 'view') { |
|
995 | + $country = $this->get_prop('country', $context); |
|
996 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
997 | 997 | } |
998 | 998 | |
999 | 999 | /** |
@@ -1003,8 +1003,8 @@ discard block |
||
1003 | 1003 | * @param string $context View or edit context. |
1004 | 1004 | * @return int |
1005 | 1005 | */ |
1006 | - public function get_user_country( $context = 'view' ) { |
|
1007 | - return $this->get_country( $context ); |
|
1006 | + public function get_user_country($context = 'view') { |
|
1007 | + return $this->get_country($context); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | /** |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * @param string $context View or edit context. |
1015 | 1015 | * @return int |
1016 | 1016 | */ |
1017 | - public function get_customer_country( $context = 'view' ) { |
|
1018 | - return $this->get_country( $context ); |
|
1017 | + public function get_customer_country($context = 'view') { |
|
1018 | + return $this->get_country($context); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1025,9 +1025,9 @@ discard block |
||
1025 | 1025 | * @param string $context View or edit context. |
1026 | 1026 | * @return string |
1027 | 1027 | */ |
1028 | - public function get_state( $context = 'view' ) { |
|
1029 | - $state = $this->get_prop( 'state', $context ); |
|
1030 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1028 | + public function get_state($context = 'view') { |
|
1029 | + $state = $this->get_prop('state', $context); |
|
1030 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | * @param string $context View or edit context. |
1038 | 1038 | * @return int |
1039 | 1039 | */ |
1040 | - public function get_user_state( $context = 'view' ) { |
|
1041 | - return $this->get_state( $context ); |
|
1040 | + public function get_user_state($context = 'view') { |
|
1041 | + return $this->get_state($context); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * @param string $context View or edit context. |
1049 | 1049 | * @return int |
1050 | 1050 | */ |
1051 | - public function get_customer_state( $context = 'view' ) { |
|
1052 | - return $this->get_state( $context ); |
|
1051 | + public function get_customer_state($context = 'view') { |
|
1052 | + return $this->get_state($context); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | * @param string $context View or edit context. |
1060 | 1060 | * @return string |
1061 | 1061 | */ |
1062 | - public function get_city( $context = 'view' ) { |
|
1063 | - return $this->get_prop( 'city', $context ); |
|
1062 | + public function get_city($context = 'view') { |
|
1063 | + return $this->get_prop('city', $context); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | /** |
@@ -1070,8 +1070,8 @@ discard block |
||
1070 | 1070 | * @param string $context View or edit context. |
1071 | 1071 | * @return string |
1072 | 1072 | */ |
1073 | - public function get_user_city( $context = 'view' ) { |
|
1074 | - return $this->get_city( $context ); |
|
1073 | + public function get_user_city($context = 'view') { |
|
1074 | + return $this->get_city($context); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | /** |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | * @param string $context View or edit context. |
1082 | 1082 | * @return string |
1083 | 1083 | */ |
1084 | - public function get_customer_city( $context = 'view' ) { |
|
1085 | - return $this->get_city( $context ); |
|
1084 | + public function get_customer_city($context = 'view') { |
|
1085 | + return $this->get_city($context); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -1092,8 +1092,8 @@ discard block |
||
1092 | 1092 | * @param string $context View or edit context. |
1093 | 1093 | * @return string |
1094 | 1094 | */ |
1095 | - public function get_zip( $context = 'view' ) { |
|
1096 | - return $this->get_prop( 'zip', $context ); |
|
1095 | + public function get_zip($context = 'view') { |
|
1096 | + return $this->get_prop('zip', $context); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
@@ -1103,8 +1103,8 @@ discard block |
||
1103 | 1103 | * @param string $context View or edit context. |
1104 | 1104 | * @return string |
1105 | 1105 | */ |
1106 | - public function get_user_zip( $context = 'view' ) { |
|
1107 | - return $this->get_zip( $context ); |
|
1106 | + public function get_user_zip($context = 'view') { |
|
1107 | + return $this->get_zip($context); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
@@ -1114,8 +1114,8 @@ discard block |
||
1114 | 1114 | * @param string $context View or edit context. |
1115 | 1115 | * @return string |
1116 | 1116 | */ |
1117 | - public function get_customer_zip( $context = 'view' ) { |
|
1118 | - return $this->get_zip( $context ); |
|
1117 | + public function get_customer_zip($context = 'view') { |
|
1118 | + return $this->get_zip($context); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | /** |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | * @param string $context View or edit context. |
1126 | 1126 | * @return string |
1127 | 1127 | */ |
1128 | - public function get_company( $context = 'view' ) { |
|
1129 | - return $this->get_prop( 'company', $context ); |
|
1128 | + public function get_company($context = 'view') { |
|
1129 | + return $this->get_prop('company', $context); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | /** |
@@ -1136,8 +1136,8 @@ discard block |
||
1136 | 1136 | * @param string $context View or edit context. |
1137 | 1137 | * @return string |
1138 | 1138 | */ |
1139 | - public function get_user_company( $context = 'view' ) { |
|
1140 | - return $this->get_company( $context ); |
|
1139 | + public function get_user_company($context = 'view') { |
|
1140 | + return $this->get_company($context); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1147,8 +1147,8 @@ discard block |
||
1147 | 1147 | * @param string $context View or edit context. |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | - public function get_customer_company( $context = 'view' ) { |
|
1151 | - return $this->get_company( $context ); |
|
1150 | + public function get_customer_company($context = 'view') { |
|
1151 | + return $this->get_company($context); |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | /** |
@@ -1158,8 +1158,8 @@ discard block |
||
1158 | 1158 | * @param string $context View or edit context. |
1159 | 1159 | * @return string |
1160 | 1160 | */ |
1161 | - public function get_vat_number( $context = 'view' ) { |
|
1162 | - return $this->get_prop( 'vat_number', $context ); |
|
1161 | + public function get_vat_number($context = 'view') { |
|
1162 | + return $this->get_prop('vat_number', $context); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | /** |
@@ -1169,8 +1169,8 @@ discard block |
||
1169 | 1169 | * @param string $context View or edit context. |
1170 | 1170 | * @return string |
1171 | 1171 | */ |
1172 | - public function get_user_vat_number( $context = 'view' ) { |
|
1173 | - return $this->get_vat_number( $context ); |
|
1172 | + public function get_user_vat_number($context = 'view') { |
|
1173 | + return $this->get_vat_number($context); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | /** |
@@ -1180,8 +1180,8 @@ discard block |
||
1180 | 1180 | * @param string $context View or edit context. |
1181 | 1181 | * @return string |
1182 | 1182 | */ |
1183 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1184 | - return $this->get_vat_number( $context ); |
|
1183 | + public function get_customer_vat_number($context = 'view') { |
|
1184 | + return $this->get_vat_number($context); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | /** |
@@ -1191,8 +1191,8 @@ discard block |
||
1191 | 1191 | * @param string $context View or edit context. |
1192 | 1192 | * @return string |
1193 | 1193 | */ |
1194 | - public function get_vat_rate( $context = 'view' ) { |
|
1195 | - return $this->get_prop( 'vat_rate', $context ); |
|
1194 | + public function get_vat_rate($context = 'view') { |
|
1195 | + return $this->get_prop('vat_rate', $context); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | /** |
@@ -1202,8 +1202,8 @@ discard block |
||
1202 | 1202 | * @param string $context View or edit context. |
1203 | 1203 | * @return string |
1204 | 1204 | */ |
1205 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1206 | - return $this->get_vat_rate( $context ); |
|
1205 | + public function get_user_vat_rate($context = 'view') { |
|
1206 | + return $this->get_vat_rate($context); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | /** |
@@ -1213,8 +1213,8 @@ discard block |
||
1213 | 1213 | * @param string $context View or edit context. |
1214 | 1214 | * @return string |
1215 | 1215 | */ |
1216 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1217 | - return $this->get_vat_rate( $context ); |
|
1216 | + public function get_customer_vat_rate($context = 'view') { |
|
1217 | + return $this->get_vat_rate($context); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | /** |
@@ -1224,8 +1224,8 @@ discard block |
||
1224 | 1224 | * @param string $context View or edit context. |
1225 | 1225 | * @return string |
1226 | 1226 | */ |
1227 | - public function get_address( $context = 'view' ) { |
|
1228 | - return $this->get_prop( 'address', $context ); |
|
1227 | + public function get_address($context = 'view') { |
|
1228 | + return $this->get_prop('address', $context); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | /** |
@@ -1235,8 +1235,8 @@ discard block |
||
1235 | 1235 | * @param string $context View or edit context. |
1236 | 1236 | * @return string |
1237 | 1237 | */ |
1238 | - public function get_user_address( $context = 'view' ) { |
|
1239 | - return $this->get_address( $context ); |
|
1238 | + public function get_user_address($context = 'view') { |
|
1239 | + return $this->get_address($context); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | /** |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | * @param string $context View or edit context. |
1247 | 1247 | * @return string |
1248 | 1248 | */ |
1249 | - public function get_customer_address( $context = 'view' ) { |
|
1250 | - return $this->get_address( $context ); |
|
1249 | + public function get_customer_address($context = 'view') { |
|
1250 | + return $this->get_address($context); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | /** |
@@ -1257,8 +1257,8 @@ discard block |
||
1257 | 1257 | * @param string $context View or edit context. |
1258 | 1258 | * @return bool |
1259 | 1259 | */ |
1260 | - public function get_is_viewed( $context = 'view' ) { |
|
1261 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1260 | + public function get_is_viewed($context = 'view') { |
|
1261 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | /** |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | * @param string $context View or edit context. |
1269 | 1269 | * @return bool |
1270 | 1270 | */ |
1271 | - public function get_email_cc( $context = 'view' ) { |
|
1272 | - return $this->get_prop( 'email_cc', $context ); |
|
1271 | + public function get_email_cc($context = 'view') { |
|
1272 | + return $this->get_prop('email_cc', $context); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | /** |
@@ -1279,8 +1279,8 @@ discard block |
||
1279 | 1279 | * @param string $context View or edit context. |
1280 | 1280 | * @return bool |
1281 | 1281 | */ |
1282 | - public function get_template( $context = 'view' ) { |
|
1283 | - return $this->get_prop( 'template', $context ); |
|
1282 | + public function get_template($context = 'view') { |
|
1283 | + return $this->get_prop('template', $context); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | /** |
@@ -1290,8 +1290,8 @@ discard block |
||
1290 | 1290 | * @param string $context View or edit context. |
1291 | 1291 | * @return bool |
1292 | 1292 | */ |
1293 | - public function get_created_via( $context = 'view' ) { |
|
1294 | - return $this->get_prop( 'created_via', $context ); |
|
1293 | + public function get_created_via($context = 'view') { |
|
1294 | + return $this->get_prop('created_via', $context); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | /** |
@@ -1301,8 +1301,8 @@ discard block |
||
1301 | 1301 | * @param string $context View or edit context. |
1302 | 1302 | * @return bool |
1303 | 1303 | */ |
1304 | - public function get_address_confirmed( $context = 'view' ) { |
|
1305 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1304 | + public function get_address_confirmed($context = 'view') { |
|
1305 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | /** |
@@ -1312,8 +1312,8 @@ discard block |
||
1312 | 1312 | * @param string $context View or edit context. |
1313 | 1313 | * @return bool |
1314 | 1314 | */ |
1315 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1316 | - return $this->get_address_confirmed( $context ); |
|
1315 | + public function get_user_address_confirmed($context = 'view') { |
|
1316 | + return $this->get_address_confirmed($context); |
|
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | /** |
@@ -1323,8 +1323,8 @@ discard block |
||
1323 | 1323 | * @param string $context View or edit context. |
1324 | 1324 | * @return bool |
1325 | 1325 | */ |
1326 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1327 | - return $this->get_address_confirmed( $context ); |
|
1326 | + public function get_customer_address_confirmed($context = 'view') { |
|
1327 | + return $this->get_address_confirmed($context); |
|
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | /** |
@@ -1334,12 +1334,12 @@ discard block |
||
1334 | 1334 | * @param string $context View or edit context. |
1335 | 1335 | * @return float |
1336 | 1336 | */ |
1337 | - public function get_subtotal( $context = 'view' ) { |
|
1338 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1337 | + public function get_subtotal($context = 'view') { |
|
1338 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1339 | 1339 | |
1340 | 1340 | // Backwards compatibility. |
1341 | - if ( is_bool( $context ) && $context ) { |
|
1342 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1341 | + if (is_bool($context) && $context) { |
|
1342 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | return $subtotal; |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | * @param string $context View or edit context. |
1353 | 1353 | * @return float |
1354 | 1354 | */ |
1355 | - public function get_total_discount( $context = 'view' ) { |
|
1356 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1355 | + public function get_total_discount($context = 'view') { |
|
1356 | + return (float) $this->get_prop('total_discount', $context); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
@@ -1363,18 +1363,18 @@ discard block |
||
1363 | 1363 | * @param string $context View or edit context. |
1364 | 1364 | * @return float |
1365 | 1365 | */ |
1366 | - public function get_total_tax( $context = 'view' ) { |
|
1367 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1366 | + public function get_total_tax($context = 'view') { |
|
1367 | + return (float) $this->get_prop('total_tax', $context); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
1371 | 1371 | * @deprecated |
1372 | 1372 | */ |
1373 | - public function get_final_tax( $currency = false ) { |
|
1373 | + public function get_final_tax($currency = false) { |
|
1374 | 1374 | $tax = $this->get_total_tax(); |
1375 | 1375 | |
1376 | - if ( $currency ) { |
|
1377 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1376 | + if ($currency) { |
|
1377 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | return $tax; |
@@ -1387,8 +1387,8 @@ discard block |
||
1387 | 1387 | * @param string $context View or edit context. |
1388 | 1388 | * @return float |
1389 | 1389 | */ |
1390 | - public function get_total_fees( $context = 'view' ) { |
|
1391 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1390 | + public function get_total_fees($context = 'view') { |
|
1391 | + return (float) $this->get_prop('total_fees', $context); |
|
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | /** |
@@ -1398,8 +1398,8 @@ discard block |
||
1398 | 1398 | * @param string $context View or edit context. |
1399 | 1399 | * @return float |
1400 | 1400 | */ |
1401 | - public function get_fees_total( $context = 'view' ) { |
|
1402 | - return $this->get_total_fees( $context ); |
|
1401 | + public function get_fees_total($context = 'view') { |
|
1402 | + return $this->get_total_fees($context); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | /** |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | */ |
1411 | 1411 | public function get_total() { |
1412 | 1412 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1413 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1413 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | */ |
1433 | 1433 | public function get_initial_total() { |
1434 | 1434 | |
1435 | - if ( empty( $this->totals ) ) { |
|
1435 | + if (empty($this->totals)) { |
|
1436 | 1436 | $this->recalculate_total(); |
1437 | 1437 | } |
1438 | 1438 | |
@@ -1442,11 +1442,11 @@ discard block |
||
1442 | 1442 | $subtotal = $this->totals['subtotal']['initial']; |
1443 | 1443 | $total = $tax + $fee - $discount + $subtotal; |
1444 | 1444 | |
1445 | - if ( 0 > $total ) { |
|
1445 | + if (0 > $total) { |
|
1446 | 1446 | $total = 0; |
1447 | 1447 | } |
1448 | 1448 | |
1449 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1449 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | /** |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | */ |
1459 | 1459 | public function get_recurring_total() { |
1460 | 1460 | |
1461 | - if ( empty( $this->totals ) ) { |
|
1461 | + if (empty($this->totals)) { |
|
1462 | 1462 | $this->recalculate_total(); |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1468,11 +1468,11 @@ discard block |
||
1468 | 1468 | $subtotal = $this->totals['subtotal']['recurring']; |
1469 | 1469 | $total = $tax + $fee - $discount + $subtotal; |
1470 | 1470 | |
1471 | - if ( 0 > $total ) { |
|
1471 | + if (0 > $total) { |
|
1472 | 1472 | $total = 0; |
1473 | 1473 | } |
1474 | 1474 | |
1475 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1475 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | /** |
@@ -1483,10 +1483,10 @@ discard block |
||
1483 | 1483 | * @param string $currency Whether to include the currency. |
1484 | 1484 | * @return float |
1485 | 1485 | */ |
1486 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1486 | + public function get_recurring_details($field = '', $currency = false) { |
|
1487 | 1487 | |
1488 | 1488 | // Maybe recalculate totals. |
1489 | - if ( empty( $this->totals ) ) { |
|
1489 | + if (empty($this->totals)) { |
|
1490 | 1490 | $this->recalculate_total(); |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1506,8 +1506,8 @@ discard block |
||
1506 | 1506 | $currency |
1507 | 1507 | ); |
1508 | 1508 | |
1509 | - if ( isset( $data[$field] ) ) { |
|
1510 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1509 | + if (isset($data[$field])) { |
|
1510 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | return $data; |
@@ -1520,8 +1520,8 @@ discard block |
||
1520 | 1520 | * @param string $context View or edit context. |
1521 | 1521 | * @return array |
1522 | 1522 | */ |
1523 | - public function get_fees( $context = 'view' ) { |
|
1524 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1523 | + public function get_fees($context = 'view') { |
|
1524 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
@@ -1531,8 +1531,8 @@ discard block |
||
1531 | 1531 | * @param string $context View or edit context. |
1532 | 1532 | * @return array |
1533 | 1533 | */ |
1534 | - public function get_discounts( $context = 'view' ) { |
|
1535 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1534 | + public function get_discounts($context = 'view') { |
|
1535 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | /** |
@@ -1542,8 +1542,8 @@ discard block |
||
1542 | 1542 | * @param string $context View or edit context. |
1543 | 1543 | * @return array |
1544 | 1544 | */ |
1545 | - public function get_taxes( $context = 'view' ) { |
|
1546 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1545 | + public function get_taxes($context = 'view') { |
|
1546 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | /** |
@@ -1553,8 +1553,8 @@ discard block |
||
1553 | 1553 | * @param string $context View or edit context. |
1554 | 1554 | * @return GetPaid_Form_Item[] |
1555 | 1555 | */ |
1556 | - public function get_items( $context = 'view' ) { |
|
1557 | - return $this->get_prop( 'items', $context ); |
|
1556 | + public function get_items($context = 'view') { |
|
1557 | + return $this->get_prop('items', $context); |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | /** |
@@ -1564,8 +1564,8 @@ discard block |
||
1564 | 1564 | * @param string $context View or edit context. |
1565 | 1565 | * @return int |
1566 | 1566 | */ |
1567 | - public function get_payment_form( $context = 'view' ) { |
|
1568 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1567 | + public function get_payment_form($context = 'view') { |
|
1568 | + return intval($this->get_prop('payment_form', $context)); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | /** |
@@ -1575,8 +1575,8 @@ discard block |
||
1575 | 1575 | * @param string $context View or edit context. |
1576 | 1576 | * @return string |
1577 | 1577 | */ |
1578 | - public function get_submission_id( $context = 'view' ) { |
|
1579 | - return $this->get_prop( 'submission_id', $context ); |
|
1578 | + public function get_submission_id($context = 'view') { |
|
1579 | + return $this->get_prop('submission_id', $context); |
|
1580 | 1580 | } |
1581 | 1581 | |
1582 | 1582 | /** |
@@ -1586,8 +1586,8 @@ discard block |
||
1586 | 1586 | * @param string $context View or edit context. |
1587 | 1587 | * @return string |
1588 | 1588 | */ |
1589 | - public function get_discount_code( $context = 'view' ) { |
|
1590 | - return $this->get_prop( 'discount_code', $context ); |
|
1589 | + public function get_discount_code($context = 'view') { |
|
1590 | + return $this->get_prop('discount_code', $context); |
|
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | /** |
@@ -1597,8 +1597,8 @@ discard block |
||
1597 | 1597 | * @param string $context View or edit context. |
1598 | 1598 | * @return string |
1599 | 1599 | */ |
1600 | - public function get_gateway( $context = 'view' ) { |
|
1601 | - return $this->get_prop( 'gateway', $context ); |
|
1600 | + public function get_gateway($context = 'view') { |
|
1601 | + return $this->get_prop('gateway', $context); |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | /** |
@@ -1608,8 +1608,8 @@ discard block |
||
1608 | 1608 | * @return string |
1609 | 1609 | */ |
1610 | 1610 | public function get_gateway_title() { |
1611 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1612 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1611 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1612 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | /** |
@@ -1619,8 +1619,8 @@ discard block |
||
1619 | 1619 | * @param string $context View or edit context. |
1620 | 1620 | * @return string |
1621 | 1621 | */ |
1622 | - public function get_transaction_id( $context = 'view' ) { |
|
1623 | - return $this->get_prop( 'transaction_id', $context ); |
|
1622 | + public function get_transaction_id($context = 'view') { |
|
1623 | + return $this->get_prop('transaction_id', $context); |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | /** |
@@ -1630,9 +1630,9 @@ discard block |
||
1630 | 1630 | * @param string $context View or edit context. |
1631 | 1631 | * @return string |
1632 | 1632 | */ |
1633 | - public function get_currency( $context = 'view' ) { |
|
1634 | - $currency = $this->get_prop( 'currency', $context ); |
|
1635 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1633 | + public function get_currency($context = 'view') { |
|
1634 | + $currency = $this->get_prop('currency', $context); |
|
1635 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | /** |
@@ -1642,8 +1642,8 @@ discard block |
||
1642 | 1642 | * @param string $context View or edit context. |
1643 | 1643 | * @return bool |
1644 | 1644 | */ |
1645 | - public function get_disable_taxes( $context = 'view' ) { |
|
1646 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1645 | + public function get_disable_taxes($context = 'view') { |
|
1646 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1647 | 1647 | } |
1648 | 1648 | |
1649 | 1649 | /** |
@@ -1653,8 +1653,8 @@ discard block |
||
1653 | 1653 | * @param string $context View or edit context. |
1654 | 1654 | * @return int |
1655 | 1655 | */ |
1656 | - public function get_subscription_id( $context = 'view' ) { |
|
1657 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1656 | + public function get_subscription_id($context = 'view') { |
|
1657 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | /** |
@@ -1664,12 +1664,12 @@ discard block |
||
1664 | 1664 | * @param string $context View or edit context. |
1665 | 1665 | * @return int |
1666 | 1666 | */ |
1667 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1668 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1667 | + public function get_remote_subscription_id($context = 'view') { |
|
1668 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1669 | 1669 | |
1670 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1670 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1671 | 1671 | $parent = $this->get_parent(); |
1672 | - return $parent->get_subscription_id( $context ); |
|
1672 | + return $parent->get_subscription_id($context); |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | return $subscription_id; |
@@ -1682,20 +1682,20 @@ discard block |
||
1682 | 1682 | * @param string $context View or edit context. |
1683 | 1683 | * @return array |
1684 | 1684 | */ |
1685 | - public function get_payment_meta( $context = 'view' ) { |
|
1685 | + public function get_payment_meta($context = 'view') { |
|
1686 | 1686 | |
1687 | 1687 | return array( |
1688 | - 'price' => $this->get_total( $context ), |
|
1689 | - 'date' => $this->get_date_created( $context ), |
|
1690 | - 'user_email' => $this->get_email( $context ), |
|
1691 | - 'invoice_key' => $this->get_key( $context ), |
|
1692 | - 'currency' => $this->get_currency( $context ), |
|
1693 | - 'items' => $this->get_items( $context ), |
|
1694 | - 'user_info' => $this->get_user_info( $context ), |
|
1688 | + 'price' => $this->get_total($context), |
|
1689 | + 'date' => $this->get_date_created($context), |
|
1690 | + 'user_email' => $this->get_email($context), |
|
1691 | + 'invoice_key' => $this->get_key($context), |
|
1692 | + 'currency' => $this->get_currency($context), |
|
1693 | + 'items' => $this->get_items($context), |
|
1694 | + 'user_info' => $this->get_user_info($context), |
|
1695 | 1695 | 'cart_details' => $this->get_cart_details(), |
1696 | - 'status' => $this->get_status( $context ), |
|
1697 | - 'fees' => $this->get_fees( $context ), |
|
1698 | - 'taxes' => $this->get_taxes( $context ), |
|
1696 | + 'status' => $this->get_status($context), |
|
1697 | + 'fees' => $this->get_fees($context), |
|
1698 | + 'taxes' => $this->get_taxes($context), |
|
1699 | 1699 | ); |
1700 | 1700 | |
1701 | 1701 | } |
@@ -1710,9 +1710,9 @@ discard block |
||
1710 | 1710 | $items = $this->get_items(); |
1711 | 1711 | $cart_details = array(); |
1712 | 1712 | |
1713 | - foreach ( $items as $item_id => $item ) { |
|
1713 | + foreach ($items as $item_id => $item) { |
|
1714 | 1714 | $item->invoice_id = $this->get_id(); |
1715 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1715 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | return $cart_details; |
@@ -1723,11 +1723,11 @@ discard block |
||
1723 | 1723 | * |
1724 | 1724 | * @return null|GetPaid_Form_Item|int |
1725 | 1725 | */ |
1726 | - public function get_recurring( $object = false ) { |
|
1726 | + public function get_recurring($object = false) { |
|
1727 | 1727 | |
1728 | 1728 | // Are we returning an object? |
1729 | - if ( $object ) { |
|
1730 | - return $this->get_item( $this->recurring_item ); |
|
1729 | + if ($object) { |
|
1730 | + return $this->get_item($this->recurring_item); |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | return $this->recurring_item; |
@@ -1742,15 +1742,15 @@ discard block |
||
1742 | 1742 | public function get_subscription_name() { |
1743 | 1743 | |
1744 | 1744 | // Retrieve the recurring name |
1745 | - $item = $this->get_recurring( true ); |
|
1745 | + $item = $this->get_recurring(true); |
|
1746 | 1746 | |
1747 | 1747 | // Abort if it does not exist. |
1748 | - if ( empty( $item ) ) { |
|
1748 | + if (empty($item)) { |
|
1749 | 1749 | return ''; |
1750 | 1750 | } |
1751 | 1751 | |
1752 | 1752 | // Return the item name. |
1753 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1753 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | /** |
@@ -1760,9 +1760,9 @@ discard block |
||
1760 | 1760 | * @return string |
1761 | 1761 | */ |
1762 | 1762 | public function get_view_url() { |
1763 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1764 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1765 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1763 | + $invoice_url = get_permalink($this->get_id()); |
|
1764 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1765 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1766 | 1766 | } |
1767 | 1767 | |
1768 | 1768 | /** |
@@ -1771,25 +1771,25 @@ discard block |
||
1771 | 1771 | * @since 1.0.19 |
1772 | 1772 | * @return string |
1773 | 1773 | */ |
1774 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1774 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1775 | 1775 | |
1776 | 1776 | // Retrieve the checkout url. |
1777 | 1777 | $pay_url = wpinv_get_checkout_uri(); |
1778 | 1778 | |
1779 | 1779 | // Maybe force ssl. |
1780 | - if ( is_ssl() ) { |
|
1781 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1780 | + if (is_ssl()) { |
|
1781 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | // Add the invoice key. |
1785 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1785 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1786 | 1786 | |
1787 | 1787 | // (Maybe?) add a secret |
1788 | - if ( $secret ) { |
|
1789 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1788 | + if ($secret) { |
|
1789 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1790 | 1790 | } |
1791 | 1791 | |
1792 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1792 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | /** |
@@ -1804,14 +1804,14 @@ discard block |
||
1804 | 1804 | $receipt_url = wpinv_get_success_page_uri(); |
1805 | 1805 | |
1806 | 1806 | // Maybe force ssl. |
1807 | - if ( is_ssl() ) { |
|
1808 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1807 | + if (is_ssl()) { |
|
1808 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1809 | 1809 | } |
1810 | 1810 | |
1811 | 1811 | // Add the invoice key. |
1812 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1812 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1813 | 1813 | |
1814 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1814 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1815 | 1815 | } |
1816 | 1816 | |
1817 | 1817 | /** |
@@ -1824,8 +1824,8 @@ discard block |
||
1824 | 1824 | * @param string $context View or edit context. |
1825 | 1825 | * @return mixed Value of the given invoice property (if set). |
1826 | 1826 | */ |
1827 | - public function get( $key, $context = 'view' ) { |
|
1828 | - return $this->get_prop( $key, $context ); |
|
1827 | + public function get($key, $context = 'view') { |
|
1828 | + return $this->get_prop($key, $context); |
|
1829 | 1829 | } |
1830 | 1830 | |
1831 | 1831 | /* |
@@ -1848,11 +1848,11 @@ discard block |
||
1848 | 1848 | * @param mixed $value new value. |
1849 | 1849 | * @return mixed Value of the given invoice property (if set). |
1850 | 1850 | */ |
1851 | - public function set( $key, $value ) { |
|
1851 | + public function set($key, $value) { |
|
1852 | 1852 | |
1853 | 1853 | $setter = "set_$key"; |
1854 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1855 | - $this->{$setter}( $value ); |
|
1854 | + if (is_callable(array($this, $setter))) { |
|
1855 | + $this->{$setter}($value); |
|
1856 | 1856 | } |
1857 | 1857 | |
1858 | 1858 | } |
@@ -1866,47 +1866,47 @@ discard block |
||
1866 | 1866 | * @param bool $manual_update Is this a manual status change?. |
1867 | 1867 | * @return array details of change. |
1868 | 1868 | */ |
1869 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1869 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1870 | 1870 | $old_status = $this->get_status(); |
1871 | 1871 | |
1872 | 1872 | $statuses = $this->get_all_statuses(); |
1873 | 1873 | |
1874 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1875 | - unset( $statuses[ 'draft' ] ); |
|
1874 | + if (isset($statuses['draft'])) { |
|
1875 | + unset($statuses['draft']); |
|
1876 | 1876 | } |
1877 | 1877 | |
1878 | - $this->set_prop( 'status', $new_status ); |
|
1878 | + $this->set_prop('status', $new_status); |
|
1879 | 1879 | |
1880 | 1880 | // If setting the status, ensure it's set to a valid status. |
1881 | - if ( true === $this->object_read ) { |
|
1881 | + if (true === $this->object_read) { |
|
1882 | 1882 | |
1883 | 1883 | // Only allow valid new status. |
1884 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1884 | + if (!array_key_exists($new_status, $statuses)) { |
|
1885 | 1885 | $new_status = 'wpi-pending'; |
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1889 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1889 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1890 | 1890 | $old_status = 'wpi-pending'; |
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1894 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1894 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1895 | 1895 | $old_status = 'wpi-pending'; |
1896 | 1896 | } |
1897 | 1897 | |
1898 | 1898 | } |
1899 | 1899 | |
1900 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1900 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1901 | 1901 | $this->status_transition = array( |
1902 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1902 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1903 | 1903 | 'to' => $new_status, |
1904 | 1904 | 'note' => $note, |
1905 | 1905 | 'manual' => (bool) $manual_update, |
1906 | 1906 | ); |
1907 | 1907 | |
1908 | - if ( $manual_update ) { |
|
1909 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1908 | + if ($manual_update) { |
|
1909 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | $this->maybe_set_date_paid(); |
@@ -1929,8 +1929,8 @@ discard block |
||
1929 | 1929 | */ |
1930 | 1930 | public function maybe_set_date_paid() { |
1931 | 1931 | |
1932 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1933 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1932 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1933 | + $this->set_date_completed(current_time('mysql')); |
|
1934 | 1934 | } |
1935 | 1935 | } |
1936 | 1936 | |
@@ -1939,11 +1939,11 @@ discard block |
||
1939 | 1939 | * |
1940 | 1940 | * @since 1.0.19 |
1941 | 1941 | */ |
1942 | - public function set_parent_id( $value ) { |
|
1943 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1942 | + public function set_parent_id($value) { |
|
1943 | + if ($value && ($value === $this->get_id())) { |
|
1944 | 1944 | return; |
1945 | 1945 | } |
1946 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1946 | + $this->set_prop('parent_id', absint($value)); |
|
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | /** |
@@ -1951,8 +1951,8 @@ discard block |
||
1951 | 1951 | * |
1952 | 1952 | * @since 1.0.19 |
1953 | 1953 | */ |
1954 | - public function set_version( $value ) { |
|
1955 | - $this->set_prop( 'version', $value ); |
|
1954 | + public function set_version($value) { |
|
1955 | + $this->set_prop('version', $value); |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | /** |
@@ -1962,15 +1962,15 @@ discard block |
||
1962 | 1962 | * @param string $value Value to set. |
1963 | 1963 | * @return bool Whether or not the date was set. |
1964 | 1964 | */ |
1965 | - public function set_date_created( $value ) { |
|
1966 | - $date = strtotime( $value ); |
|
1965 | + public function set_date_created($value) { |
|
1966 | + $date = strtotime($value); |
|
1967 | 1967 | |
1968 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1969 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1968 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1969 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1970 | 1970 | return true; |
1971 | 1971 | } |
1972 | 1972 | |
1973 | - return $this->set_prop( 'date_created', '' ); |
|
1973 | + return $this->set_prop('date_created', ''); |
|
1974 | 1974 | |
1975 | 1975 | } |
1976 | 1976 | |
@@ -1981,15 +1981,15 @@ discard block |
||
1981 | 1981 | * @param string $value Value to set. |
1982 | 1982 | * @return bool Whether or not the date was set. |
1983 | 1983 | */ |
1984 | - public function set_due_date( $value ) { |
|
1985 | - $date = strtotime( $value ); |
|
1984 | + public function set_due_date($value) { |
|
1985 | + $date = strtotime($value); |
|
1986 | 1986 | |
1987 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1988 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1987 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1988 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1989 | 1989 | return true; |
1990 | 1990 | } |
1991 | 1991 | |
1992 | - $this->set_prop( 'due_date', '' ); |
|
1992 | + $this->set_prop('due_date', ''); |
|
1993 | 1993 | return false; |
1994 | 1994 | |
1995 | 1995 | } |
@@ -2000,8 +2000,8 @@ discard block |
||
2000 | 2000 | * @since 1.0.19 |
2001 | 2001 | * @param string $value New name. |
2002 | 2002 | */ |
2003 | - public function set_date_due( $value ) { |
|
2004 | - $this->set_due_date( $value ); |
|
2003 | + public function set_date_due($value) { |
|
2004 | + $this->set_due_date($value); |
|
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | /** |
@@ -2011,15 +2011,15 @@ discard block |
||
2011 | 2011 | * @param string $value Value to set. |
2012 | 2012 | * @return bool Whether or not the date was set. |
2013 | 2013 | */ |
2014 | - public function set_completed_date( $value ) { |
|
2015 | - $date = strtotime( $value ); |
|
2014 | + public function set_completed_date($value) { |
|
2015 | + $date = strtotime($value); |
|
2016 | 2016 | |
2017 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2018 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2017 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2018 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2019 | 2019 | return true; |
2020 | 2020 | } |
2021 | 2021 | |
2022 | - $this->set_prop( 'completed_date', '' ); |
|
2022 | + $this->set_prop('completed_date', ''); |
|
2023 | 2023 | return false; |
2024 | 2024 | |
2025 | 2025 | } |
@@ -2030,8 +2030,8 @@ discard block |
||
2030 | 2030 | * @since 1.0.19 |
2031 | 2031 | * @param string $value New name. |
2032 | 2032 | */ |
2033 | - public function set_date_completed( $value ) { |
|
2034 | - $this->set_completed_date( $value ); |
|
2033 | + public function set_date_completed($value) { |
|
2034 | + $this->set_completed_date($value); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | /** |
@@ -2041,15 +2041,15 @@ discard block |
||
2041 | 2041 | * @param string $value Value to set. |
2042 | 2042 | * @return bool Whether or not the date was set. |
2043 | 2043 | */ |
2044 | - public function set_date_modified( $value ) { |
|
2045 | - $date = strtotime( $value ); |
|
2044 | + public function set_date_modified($value) { |
|
2045 | + $date = strtotime($value); |
|
2046 | 2046 | |
2047 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2048 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2047 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2048 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2049 | 2049 | return true; |
2050 | 2050 | } |
2051 | 2051 | |
2052 | - $this->set_prop( 'date_modified', '' ); |
|
2052 | + $this->set_prop('date_modified', ''); |
|
2053 | 2053 | return false; |
2054 | 2054 | |
2055 | 2055 | } |
@@ -2060,9 +2060,9 @@ discard block |
||
2060 | 2060 | * @since 1.0.19 |
2061 | 2061 | * @param string $value New number. |
2062 | 2062 | */ |
2063 | - public function set_number( $value ) { |
|
2064 | - $number = sanitize_text_field( $value ); |
|
2065 | - $this->set_prop( 'number', $number ); |
|
2063 | + public function set_number($value) { |
|
2064 | + $number = sanitize_text_field($value); |
|
2065 | + $this->set_prop('number', $number); |
|
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | /** |
@@ -2071,9 +2071,9 @@ discard block |
||
2071 | 2071 | * @since 1.0.19 |
2072 | 2072 | * @param string $value Type. |
2073 | 2073 | */ |
2074 | - public function set_type( $value ) { |
|
2075 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2076 | - $this->set_prop( 'type', $type ); |
|
2074 | + public function set_type($value) { |
|
2075 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2076 | + $this->set_prop('type', $type); |
|
2077 | 2077 | } |
2078 | 2078 | |
2079 | 2079 | /** |
@@ -2082,10 +2082,10 @@ discard block |
||
2082 | 2082 | * @since 1.0.19 |
2083 | 2083 | * @param string $value Post type. |
2084 | 2084 | */ |
2085 | - public function set_post_type( $value ) { |
|
2086 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2087 | - $this->set_type( $value ); |
|
2088 | - $this->set_prop( 'post_type', $value ); |
|
2085 | + public function set_post_type($value) { |
|
2086 | + if (getpaid_is_invoice_post_type($value)) { |
|
2087 | + $this->set_type($value); |
|
2088 | + $this->set_prop('post_type', $value); |
|
2089 | 2089 | } |
2090 | 2090 | } |
2091 | 2091 | |
@@ -2095,9 +2095,9 @@ discard block |
||
2095 | 2095 | * @since 1.0.19 |
2096 | 2096 | * @param string $value New key. |
2097 | 2097 | */ |
2098 | - public function set_key( $value ) { |
|
2099 | - $key = sanitize_text_field( $value ); |
|
2100 | - $this->set_prop( 'key', $key ); |
|
2098 | + public function set_key($value) { |
|
2099 | + $key = sanitize_text_field($value); |
|
2100 | + $this->set_prop('key', $key); |
|
2101 | 2101 | } |
2102 | 2102 | |
2103 | 2103 | /** |
@@ -2106,9 +2106,9 @@ discard block |
||
2106 | 2106 | * @since 1.0.19 |
2107 | 2107 | * @param string $value mode. |
2108 | 2108 | */ |
2109 | - public function set_mode( $value ) { |
|
2110 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2111 | - $this->set_prop( 'value', $value ); |
|
2109 | + public function set_mode($value) { |
|
2110 | + if (!in_array($value, array('live', 'test'))) { |
|
2111 | + $this->set_prop('value', $value); |
|
2112 | 2112 | } |
2113 | 2113 | } |
2114 | 2114 | |
@@ -2118,8 +2118,8 @@ discard block |
||
2118 | 2118 | * @since 1.0.19 |
2119 | 2119 | * @param string $value path. |
2120 | 2120 | */ |
2121 | - public function set_path( $value ) { |
|
2122 | - $this->set_prop( 'path', $value ); |
|
2121 | + public function set_path($value) { |
|
2122 | + $this->set_prop('path', $value); |
|
2123 | 2123 | } |
2124 | 2124 | |
2125 | 2125 | /** |
@@ -2128,9 +2128,9 @@ discard block |
||
2128 | 2128 | * @since 1.0.19 |
2129 | 2129 | * @param string $value New name. |
2130 | 2130 | */ |
2131 | - public function set_name( $value ) { |
|
2132 | - $name = sanitize_text_field( $value ); |
|
2133 | - $this->set_prop( 'name', $name ); |
|
2131 | + public function set_name($value) { |
|
2132 | + $name = sanitize_text_field($value); |
|
2133 | + $this->set_prop('name', $name); |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | /** |
@@ -2139,8 +2139,8 @@ discard block |
||
2139 | 2139 | * @since 1.0.19 |
2140 | 2140 | * @param string $value New name. |
2141 | 2141 | */ |
2142 | - public function set_title( $value ) { |
|
2143 | - $this->set_name( $value ); |
|
2142 | + public function set_title($value) { |
|
2143 | + $this->set_name($value); |
|
2144 | 2144 | } |
2145 | 2145 | |
2146 | 2146 | /** |
@@ -2149,9 +2149,9 @@ discard block |
||
2149 | 2149 | * @since 1.0.19 |
2150 | 2150 | * @param string $value New description. |
2151 | 2151 | */ |
2152 | - public function set_description( $value ) { |
|
2153 | - $description = wp_kses_post( $value ); |
|
2154 | - return $this->set_prop( 'description', $description ); |
|
2152 | + public function set_description($value) { |
|
2153 | + $description = wp_kses_post($value); |
|
2154 | + return $this->set_prop('description', $description); |
|
2155 | 2155 | } |
2156 | 2156 | |
2157 | 2157 | /** |
@@ -2160,8 +2160,8 @@ discard block |
||
2160 | 2160 | * @since 1.0.19 |
2161 | 2161 | * @param string $value New description. |
2162 | 2162 | */ |
2163 | - public function set_excerpt( $value ) { |
|
2164 | - $this->set_description( $value ); |
|
2163 | + public function set_excerpt($value) { |
|
2164 | + $this->set_description($value); |
|
2165 | 2165 | } |
2166 | 2166 | |
2167 | 2167 | /** |
@@ -2170,8 +2170,8 @@ discard block |
||
2170 | 2170 | * @since 1.0.19 |
2171 | 2171 | * @param string $value New description. |
2172 | 2172 | */ |
2173 | - public function set_summary( $value ) { |
|
2174 | - $this->set_description( $value ); |
|
2173 | + public function set_summary($value) { |
|
2174 | + $this->set_description($value); |
|
2175 | 2175 | } |
2176 | 2176 | |
2177 | 2177 | /** |
@@ -2180,12 +2180,12 @@ discard block |
||
2180 | 2180 | * @since 1.0.19 |
2181 | 2181 | * @param int $value New author. |
2182 | 2182 | */ |
2183 | - public function set_author( $value ) { |
|
2184 | - $user = get_user_by( 'id', (int) $value ); |
|
2183 | + public function set_author($value) { |
|
2184 | + $user = get_user_by('id', (int) $value); |
|
2185 | 2185 | |
2186 | - if ( $user && $user->ID ) { |
|
2187 | - $this->set_prop( 'author', $user->ID ); |
|
2188 | - $this->set_prop( 'email', $user->user_email ); |
|
2186 | + if ($user && $user->ID) { |
|
2187 | + $this->set_prop('author', $user->ID); |
|
2188 | + $this->set_prop('email', $user->user_email); |
|
2189 | 2189 | } |
2190 | 2190 | |
2191 | 2191 | } |
@@ -2196,8 +2196,8 @@ discard block |
||
2196 | 2196 | * @since 1.0.19 |
2197 | 2197 | * @param int $value New user id. |
2198 | 2198 | */ |
2199 | - public function set_user_id( $value ) { |
|
2200 | - $this->set_author( $value ); |
|
2199 | + public function set_user_id($value) { |
|
2200 | + $this->set_author($value); |
|
2201 | 2201 | } |
2202 | 2202 | |
2203 | 2203 | /** |
@@ -2206,8 +2206,8 @@ discard block |
||
2206 | 2206 | * @since 1.0.19 |
2207 | 2207 | * @param int $value New user id. |
2208 | 2208 | */ |
2209 | - public function set_customer_id( $value ) { |
|
2210 | - $this->set_author( $value ); |
|
2209 | + public function set_customer_id($value) { |
|
2210 | + $this->set_author($value); |
|
2211 | 2211 | } |
2212 | 2212 | |
2213 | 2213 | /** |
@@ -2216,8 +2216,8 @@ discard block |
||
2216 | 2216 | * @since 1.0.19 |
2217 | 2217 | * @param string $value ip address. |
2218 | 2218 | */ |
2219 | - public function set_ip( $value ) { |
|
2220 | - $this->set_prop( 'ip', $value ); |
|
2219 | + public function set_ip($value) { |
|
2220 | + $this->set_prop('ip', $value); |
|
2221 | 2221 | } |
2222 | 2222 | |
2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
2226 | 2226 | * @since 1.0.19 |
2227 | 2227 | * @param string $value ip address. |
2228 | 2228 | */ |
2229 | - public function set_user_ip( $value ) { |
|
2230 | - $this->set_ip( $value ); |
|
2229 | + public function set_user_ip($value) { |
|
2230 | + $this->set_ip($value); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
2236 | 2236 | * @since 1.0.19 |
2237 | 2237 | * @param string $value first name. |
2238 | 2238 | */ |
2239 | - public function set_first_name( $value ) { |
|
2240 | - $this->set_prop( 'first_name', $value ); |
|
2239 | + public function set_first_name($value) { |
|
2240 | + $this->set_prop('first_name', $value); |
|
2241 | 2241 | } |
2242 | 2242 | |
2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
2246 | 2246 | * @since 1.0.19 |
2247 | 2247 | * @param string $value first name. |
2248 | 2248 | */ |
2249 | - public function set_user_first_name( $value ) { |
|
2250 | - $this->set_first_name( $value ); |
|
2249 | + public function set_user_first_name($value) { |
|
2250 | + $this->set_first_name($value); |
|
2251 | 2251 | } |
2252 | 2252 | |
2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
2256 | 2256 | * @since 1.0.19 |
2257 | 2257 | * @param string $value first name. |
2258 | 2258 | */ |
2259 | - public function set_customer_first_name( $value ) { |
|
2260 | - $this->set_first_name( $value ); |
|
2259 | + public function set_customer_first_name($value) { |
|
2260 | + $this->set_first_name($value); |
|
2261 | 2261 | } |
2262 | 2262 | |
2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
2266 | 2266 | * @since 1.0.19 |
2267 | 2267 | * @param string $value last name. |
2268 | 2268 | */ |
2269 | - public function set_last_name( $value ) { |
|
2270 | - $this->set_prop( 'last_name', $value ); |
|
2269 | + public function set_last_name($value) { |
|
2270 | + $this->set_prop('last_name', $value); |
|
2271 | 2271 | } |
2272 | 2272 | |
2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
2276 | 2276 | * @since 1.0.19 |
2277 | 2277 | * @param string $value last name. |
2278 | 2278 | */ |
2279 | - public function set_user_last_name( $value ) { |
|
2280 | - $this->set_last_name( $value ); |
|
2279 | + public function set_user_last_name($value) { |
|
2280 | + $this->set_last_name($value); |
|
2281 | 2281 | } |
2282 | 2282 | |
2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
2286 | 2286 | * @since 1.0.19 |
2287 | 2287 | * @param string $value last name. |
2288 | 2288 | */ |
2289 | - public function set_customer_last_name( $value ) { |
|
2290 | - $this->set_last_name( $value ); |
|
2289 | + public function set_customer_last_name($value) { |
|
2290 | + $this->set_last_name($value); |
|
2291 | 2291 | } |
2292 | 2292 | |
2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
2296 | 2296 | * @since 1.0.19 |
2297 | 2297 | * @param string $value phone. |
2298 | 2298 | */ |
2299 | - public function set_phone( $value ) { |
|
2300 | - $this->set_prop( 'phone', $value ); |
|
2299 | + public function set_phone($value) { |
|
2300 | + $this->set_prop('phone', $value); |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
2306 | 2306 | * @since 1.0.19 |
2307 | 2307 | * @param string $value phone. |
2308 | 2308 | */ |
2309 | - public function set_user_phone( $value ) { |
|
2310 | - $this->set_phone( $value ); |
|
2309 | + public function set_user_phone($value) { |
|
2310 | + $this->set_phone($value); |
|
2311 | 2311 | } |
2312 | 2312 | |
2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
2316 | 2316 | * @since 1.0.19 |
2317 | 2317 | * @param string $value phone. |
2318 | 2318 | */ |
2319 | - public function set_customer_phone( $value ) { |
|
2320 | - $this->set_phone( $value ); |
|
2319 | + public function set_customer_phone($value) { |
|
2320 | + $this->set_phone($value); |
|
2321 | 2321 | } |
2322 | 2322 | |
2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
2326 | 2326 | * @since 1.0.19 |
2327 | 2327 | * @param string $value phone. |
2328 | 2328 | */ |
2329 | - public function set_phone_number( $value ) { |
|
2330 | - $this->set_phone( $value ); |
|
2329 | + public function set_phone_number($value) { |
|
2330 | + $this->set_phone($value); |
|
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
2336 | 2336 | * @since 1.0.19 |
2337 | 2337 | * @param string $value email address. |
2338 | 2338 | */ |
2339 | - public function set_email( $value ) { |
|
2340 | - $this->set_prop( 'email', $value ); |
|
2339 | + public function set_email($value) { |
|
2340 | + $this->set_prop('email', $value); |
|
2341 | 2341 | } |
2342 | 2342 | |
2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
2346 | 2346 | * @since 1.0.19 |
2347 | 2347 | * @param string $value email address. |
2348 | 2348 | */ |
2349 | - public function set_user_email( $value ) { |
|
2350 | - $this->set_email( $value ); |
|
2349 | + public function set_user_email($value) { |
|
2350 | + $this->set_email($value); |
|
2351 | 2351 | } |
2352 | 2352 | |
2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
2356 | 2356 | * @since 1.0.19 |
2357 | 2357 | * @param string $value email address. |
2358 | 2358 | */ |
2359 | - public function set_email_address( $value ) { |
|
2360 | - $this->set_email( $value ); |
|
2359 | + public function set_email_address($value) { |
|
2360 | + $this->set_email($value); |
|
2361 | 2361 | } |
2362 | 2362 | |
2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
2366 | 2366 | * @since 1.0.19 |
2367 | 2367 | * @param string $value email address. |
2368 | 2368 | */ |
2369 | - public function set_customer_email( $value ) { |
|
2370 | - $this->set_email( $value ); |
|
2369 | + public function set_customer_email($value) { |
|
2370 | + $this->set_email($value); |
|
2371 | 2371 | } |
2372 | 2372 | |
2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
2376 | 2376 | * @since 1.0.19 |
2377 | 2377 | * @param string $value country. |
2378 | 2378 | */ |
2379 | - public function set_country( $value ) { |
|
2380 | - $this->set_prop( 'country', $value ); |
|
2379 | + public function set_country($value) { |
|
2380 | + $this->set_prop('country', $value); |
|
2381 | 2381 | } |
2382 | 2382 | |
2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
2386 | 2386 | * @since 1.0.19 |
2387 | 2387 | * @param string $value country. |
2388 | 2388 | */ |
2389 | - public function set_user_country( $value ) { |
|
2390 | - $this->set_country( $value ); |
|
2389 | + public function set_user_country($value) { |
|
2390 | + $this->set_country($value); |
|
2391 | 2391 | } |
2392 | 2392 | |
2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
2396 | 2396 | * @since 1.0.19 |
2397 | 2397 | * @param string $value country. |
2398 | 2398 | */ |
2399 | - public function set_customer_country( $value ) { |
|
2400 | - $this->set_country( $value ); |
|
2399 | + public function set_customer_country($value) { |
|
2400 | + $this->set_country($value); |
|
2401 | 2401 | } |
2402 | 2402 | |
2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
2406 | 2406 | * @since 1.0.19 |
2407 | 2407 | * @param string $value state. |
2408 | 2408 | */ |
2409 | - public function set_state( $value ) { |
|
2410 | - $this->set_prop( 'state', $value ); |
|
2409 | + public function set_state($value) { |
|
2410 | + $this->set_prop('state', $value); |
|
2411 | 2411 | } |
2412 | 2412 | |
2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
2416 | 2416 | * @since 1.0.19 |
2417 | 2417 | * @param string $value state. |
2418 | 2418 | */ |
2419 | - public function set_user_state( $value ) { |
|
2420 | - $this->set_state( $value ); |
|
2419 | + public function set_user_state($value) { |
|
2420 | + $this->set_state($value); |
|
2421 | 2421 | } |
2422 | 2422 | |
2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
2426 | 2426 | * @since 1.0.19 |
2427 | 2427 | * @param string $value state. |
2428 | 2428 | */ |
2429 | - public function set_customer_state( $value ) { |
|
2430 | - $this->set_state( $value ); |
|
2429 | + public function set_customer_state($value) { |
|
2430 | + $this->set_state($value); |
|
2431 | 2431 | } |
2432 | 2432 | |
2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
2436 | 2436 | * @since 1.0.19 |
2437 | 2437 | * @param string $value city. |
2438 | 2438 | */ |
2439 | - public function set_city( $value ) { |
|
2440 | - $this->set_prop( 'city', $value ); |
|
2439 | + public function set_city($value) { |
|
2440 | + $this->set_prop('city', $value); |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
2446 | 2446 | * @since 1.0.19 |
2447 | 2447 | * @param string $value city. |
2448 | 2448 | */ |
2449 | - public function set_user_city( $value ) { |
|
2450 | - $this->set_city( $value ); |
|
2449 | + public function set_user_city($value) { |
|
2450 | + $this->set_city($value); |
|
2451 | 2451 | } |
2452 | 2452 | |
2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
2456 | 2456 | * @since 1.0.19 |
2457 | 2457 | * @param string $value city. |
2458 | 2458 | */ |
2459 | - public function set_customer_city( $value ) { |
|
2460 | - $this->set_city( $value ); |
|
2459 | + public function set_customer_city($value) { |
|
2460 | + $this->set_city($value); |
|
2461 | 2461 | } |
2462 | 2462 | |
2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
2466 | 2466 | * @since 1.0.19 |
2467 | 2467 | * @param string $value zip. |
2468 | 2468 | */ |
2469 | - public function set_zip( $value ) { |
|
2470 | - $this->set_prop( 'zip', $value ); |
|
2469 | + public function set_zip($value) { |
|
2470 | + $this->set_prop('zip', $value); |
|
2471 | 2471 | } |
2472 | 2472 | |
2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
2476 | 2476 | * @since 1.0.19 |
2477 | 2477 | * @param string $value zip. |
2478 | 2478 | */ |
2479 | - public function set_user_zip( $value ) { |
|
2480 | - $this->set_zip( $value ); |
|
2479 | + public function set_user_zip($value) { |
|
2480 | + $this->set_zip($value); |
|
2481 | 2481 | } |
2482 | 2482 | |
2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
2486 | 2486 | * @since 1.0.19 |
2487 | 2487 | * @param string $value zip. |
2488 | 2488 | */ |
2489 | - public function set_customer_zip( $value ) { |
|
2490 | - $this->set_zip( $value ); |
|
2489 | + public function set_customer_zip($value) { |
|
2490 | + $this->set_zip($value); |
|
2491 | 2491 | } |
2492 | 2492 | |
2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
2496 | 2496 | * @since 1.0.19 |
2497 | 2497 | * @param string $value company. |
2498 | 2498 | */ |
2499 | - public function set_company( $value ) { |
|
2500 | - $this->set_prop( 'company', $value ); |
|
2499 | + public function set_company($value) { |
|
2500 | + $this->set_prop('company', $value); |
|
2501 | 2501 | } |
2502 | 2502 | |
2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
2506 | 2506 | * @since 1.0.19 |
2507 | 2507 | * @param string $value company. |
2508 | 2508 | */ |
2509 | - public function set_user_company( $value ) { |
|
2510 | - $this->set_company( $value ); |
|
2509 | + public function set_user_company($value) { |
|
2510 | + $this->set_company($value); |
|
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
2516 | 2516 | * @since 1.0.19 |
2517 | 2517 | * @param string $value company. |
2518 | 2518 | */ |
2519 | - public function set_customer_company( $value ) { |
|
2520 | - $this->set_company( $value ); |
|
2519 | + public function set_customer_company($value) { |
|
2520 | + $this->set_company($value); |
|
2521 | 2521 | } |
2522 | 2522 | |
2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
2526 | 2526 | * @since 1.0.19 |
2527 | 2527 | * @param string $value var number. |
2528 | 2528 | */ |
2529 | - public function set_vat_number( $value ) { |
|
2530 | - $this->set_prop( 'vat_number', $value ); |
|
2529 | + public function set_vat_number($value) { |
|
2530 | + $this->set_prop('vat_number', $value); |
|
2531 | 2531 | } |
2532 | 2532 | |
2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
2536 | 2536 | * @since 1.0.19 |
2537 | 2537 | * @param string $value var number. |
2538 | 2538 | */ |
2539 | - public function set_user_vat_number( $value ) { |
|
2540 | - $this->set_vat_number( $value ); |
|
2539 | + public function set_user_vat_number($value) { |
|
2540 | + $this->set_vat_number($value); |
|
2541 | 2541 | } |
2542 | 2542 | |
2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
2546 | 2546 | * @since 1.0.19 |
2547 | 2547 | * @param string $value var number. |
2548 | 2548 | */ |
2549 | - public function set_customer_vat_number( $value ) { |
|
2550 | - $this->set_vat_number( $value ); |
|
2549 | + public function set_customer_vat_number($value) { |
|
2550 | + $this->set_vat_number($value); |
|
2551 | 2551 | } |
2552 | 2552 | |
2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
2556 | 2556 | * @since 1.0.19 |
2557 | 2557 | * @param string $value var rate. |
2558 | 2558 | */ |
2559 | - public function set_vat_rate( $value ) { |
|
2560 | - $this->set_prop( 'vat_rate', $value ); |
|
2559 | + public function set_vat_rate($value) { |
|
2560 | + $this->set_prop('vat_rate', $value); |
|
2561 | 2561 | } |
2562 | 2562 | |
2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
2566 | 2566 | * @since 1.0.19 |
2567 | 2567 | * @param string $value var number. |
2568 | 2568 | */ |
2569 | - public function set_user_vat_rate( $value ) { |
|
2570 | - $this->set_vat_rate( $value ); |
|
2569 | + public function set_user_vat_rate($value) { |
|
2570 | + $this->set_vat_rate($value); |
|
2571 | 2571 | } |
2572 | 2572 | |
2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
2576 | 2576 | * @since 1.0.19 |
2577 | 2577 | * @param string $value var number. |
2578 | 2578 | */ |
2579 | - public function set_customer_vat_rate( $value ) { |
|
2580 | - $this->set_vat_rate( $value ); |
|
2579 | + public function set_customer_vat_rate($value) { |
|
2580 | + $this->set_vat_rate($value); |
|
2581 | 2581 | } |
2582 | 2582 | |
2583 | 2583 | /** |
@@ -2586,8 +2586,8 @@ discard block |
||
2586 | 2586 | * @since 1.0.19 |
2587 | 2587 | * @param string $value address. |
2588 | 2588 | */ |
2589 | - public function set_address( $value ) { |
|
2590 | - $this->set_prop( 'address', $value ); |
|
2589 | + public function set_address($value) { |
|
2590 | + $this->set_prop('address', $value); |
|
2591 | 2591 | } |
2592 | 2592 | |
2593 | 2593 | /** |
@@ -2596,8 +2596,8 @@ discard block |
||
2596 | 2596 | * @since 1.0.19 |
2597 | 2597 | * @param string $value address. |
2598 | 2598 | */ |
2599 | - public function set_user_address( $value ) { |
|
2600 | - $this->set_address( $value ); |
|
2599 | + public function set_user_address($value) { |
|
2600 | + $this->set_address($value); |
|
2601 | 2601 | } |
2602 | 2602 | |
2603 | 2603 | /** |
@@ -2606,8 +2606,8 @@ discard block |
||
2606 | 2606 | * @since 1.0.19 |
2607 | 2607 | * @param string $value address. |
2608 | 2608 | */ |
2609 | - public function set_customer_address( $value ) { |
|
2610 | - $this->set_address( $value ); |
|
2609 | + public function set_customer_address($value) { |
|
2610 | + $this->set_address($value); |
|
2611 | 2611 | } |
2612 | 2612 | |
2613 | 2613 | /** |
@@ -2616,8 +2616,8 @@ discard block |
||
2616 | 2616 | * @since 1.0.19 |
2617 | 2617 | * @param int|bool $value confirmed. |
2618 | 2618 | */ |
2619 | - public function set_is_viewed( $value ) { |
|
2620 | - $this->set_prop( 'is_viewed', $value ); |
|
2619 | + public function set_is_viewed($value) { |
|
2620 | + $this->set_prop('is_viewed', $value); |
|
2621 | 2621 | } |
2622 | 2622 | |
2623 | 2623 | /** |
@@ -2626,8 +2626,8 @@ discard block |
||
2626 | 2626 | * @since 1.0.19 |
2627 | 2627 | * @param string $value email recipients. |
2628 | 2628 | */ |
2629 | - public function set_email_cc( $value ) { |
|
2630 | - $this->set_prop( 'email_cc', $value ); |
|
2629 | + public function set_email_cc($value) { |
|
2630 | + $this->set_prop('email_cc', $value); |
|
2631 | 2631 | } |
2632 | 2632 | |
2633 | 2633 | /** |
@@ -2636,9 +2636,9 @@ discard block |
||
2636 | 2636 | * @since 1.0.19 |
2637 | 2637 | * @param string $value template. |
2638 | 2638 | */ |
2639 | - public function set_template( $value ) { |
|
2640 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2641 | - $this->set_prop( 'template', $value ); |
|
2639 | + public function set_template($value) { |
|
2640 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2641 | + $this->set_prop('template', $value); |
|
2642 | 2642 | } |
2643 | 2643 | } |
2644 | 2644 | |
@@ -2648,8 +2648,8 @@ discard block |
||
2648 | 2648 | * @since 1.0.19 |
2649 | 2649 | * @param string $value email recipients. |
2650 | 2650 | */ |
2651 | - public function created_via( $value ) { |
|
2652 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2651 | + public function created_via($value) { |
|
2652 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2653 | 2653 | } |
2654 | 2654 | |
2655 | 2655 | /** |
@@ -2658,8 +2658,8 @@ discard block |
||
2658 | 2658 | * @since 1.0.19 |
2659 | 2659 | * @param int|bool $value confirmed. |
2660 | 2660 | */ |
2661 | - public function set_address_confirmed( $value ) { |
|
2662 | - $this->set_prop( 'address_confirmed', $value ); |
|
2661 | + public function set_address_confirmed($value) { |
|
2662 | + $this->set_prop('address_confirmed', $value); |
|
2663 | 2663 | } |
2664 | 2664 | |
2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
2668 | 2668 | * @since 1.0.19 |
2669 | 2669 | * @param int|bool $value confirmed. |
2670 | 2670 | */ |
2671 | - public function set_user_address_confirmed( $value ) { |
|
2672 | - $this->set_address_confirmed( $value ); |
|
2671 | + public function set_user_address_confirmed($value) { |
|
2672 | + $this->set_address_confirmed($value); |
|
2673 | 2673 | } |
2674 | 2674 | |
2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
2678 | 2678 | * @since 1.0.19 |
2679 | 2679 | * @param int|bool $value confirmed. |
2680 | 2680 | */ |
2681 | - public function set_customer_address_confirmed( $value ) { |
|
2682 | - $this->set_address_confirmed( $value ); |
|
2681 | + public function set_customer_address_confirmed($value) { |
|
2682 | + $this->set_address_confirmed($value); |
|
2683 | 2683 | } |
2684 | 2684 | |
2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
2688 | 2688 | * @since 1.0.19 |
2689 | 2689 | * @param float $value sub total. |
2690 | 2690 | */ |
2691 | - public function set_subtotal( $value ) { |
|
2692 | - $this->set_prop( 'subtotal', $value ); |
|
2691 | + public function set_subtotal($value) { |
|
2692 | + $this->set_prop('subtotal', $value); |
|
2693 | 2693 | } |
2694 | 2694 | |
2695 | 2695 | /** |
@@ -2698,8 +2698,8 @@ discard block |
||
2698 | 2698 | * @since 1.0.19 |
2699 | 2699 | * @param float $value discount total. |
2700 | 2700 | */ |
2701 | - public function set_total_discount( $value ) { |
|
2702 | - $this->set_prop( 'total_discount', $value ); |
|
2701 | + public function set_total_discount($value) { |
|
2702 | + $this->set_prop('total_discount', $value); |
|
2703 | 2703 | } |
2704 | 2704 | |
2705 | 2705 | /** |
@@ -2708,8 +2708,8 @@ discard block |
||
2708 | 2708 | * @since 1.0.19 |
2709 | 2709 | * @param float $value discount total. |
2710 | 2710 | */ |
2711 | - public function set_discount( $value ) { |
|
2712 | - $this->set_total_discount( $value ); |
|
2711 | + public function set_discount($value) { |
|
2712 | + $this->set_total_discount($value); |
|
2713 | 2713 | } |
2714 | 2714 | |
2715 | 2715 | /** |
@@ -2718,8 +2718,8 @@ discard block |
||
2718 | 2718 | * @since 1.0.19 |
2719 | 2719 | * @param float $value tax total. |
2720 | 2720 | */ |
2721 | - public function set_total_tax( $value ) { |
|
2722 | - $this->set_prop( 'total_tax', $value ); |
|
2721 | + public function set_total_tax($value) { |
|
2722 | + $this->set_prop('total_tax', $value); |
|
2723 | 2723 | } |
2724 | 2724 | |
2725 | 2725 | /** |
@@ -2728,8 +2728,8 @@ discard block |
||
2728 | 2728 | * @since 1.0.19 |
2729 | 2729 | * @param float $value tax total. |
2730 | 2730 | */ |
2731 | - public function set_tax_total( $value ) { |
|
2732 | - $this->set_total_tax( $value ); |
|
2731 | + public function set_tax_total($value) { |
|
2732 | + $this->set_total_tax($value); |
|
2733 | 2733 | } |
2734 | 2734 | |
2735 | 2735 | /** |
@@ -2738,8 +2738,8 @@ discard block |
||
2738 | 2738 | * @since 1.0.19 |
2739 | 2739 | * @param float $value fees total. |
2740 | 2740 | */ |
2741 | - public function set_total_fees( $value ) { |
|
2742 | - $this->set_prop( 'total_fees', $value ); |
|
2741 | + public function set_total_fees($value) { |
|
2742 | + $this->set_prop('total_fees', $value); |
|
2743 | 2743 | } |
2744 | 2744 | |
2745 | 2745 | /** |
@@ -2748,8 +2748,8 @@ discard block |
||
2748 | 2748 | * @since 1.0.19 |
2749 | 2749 | * @param float $value fees total. |
2750 | 2750 | */ |
2751 | - public function set_fees_total( $value ) { |
|
2752 | - $this->set_total_fees( $value ); |
|
2751 | + public function set_fees_total($value) { |
|
2752 | + $this->set_total_fees($value); |
|
2753 | 2753 | } |
2754 | 2754 | |
2755 | 2755 | /** |
@@ -2758,13 +2758,13 @@ discard block |
||
2758 | 2758 | * @since 1.0.19 |
2759 | 2759 | * @param array $value fees. |
2760 | 2760 | */ |
2761 | - public function set_fees( $value ) { |
|
2761 | + public function set_fees($value) { |
|
2762 | 2762 | |
2763 | - if ( ! is_array( $value ) ) { |
|
2763 | + if (!is_array($value)) { |
|
2764 | 2764 | $value = array(); |
2765 | 2765 | } |
2766 | 2766 | |
2767 | - $this->set_prop( 'fees', $value ); |
|
2767 | + $this->set_prop('fees', $value); |
|
2768 | 2768 | |
2769 | 2769 | } |
2770 | 2770 | |
@@ -2774,13 +2774,13 @@ discard block |
||
2774 | 2774 | * @since 1.0.19 |
2775 | 2775 | * @param array $value taxes. |
2776 | 2776 | */ |
2777 | - public function set_taxes( $value ) { |
|
2777 | + public function set_taxes($value) { |
|
2778 | 2778 | |
2779 | - if ( ! is_array( $value ) ) { |
|
2779 | + if (!is_array($value)) { |
|
2780 | 2780 | $value = array(); |
2781 | 2781 | } |
2782 | 2782 | |
2783 | - $this->set_prop( 'taxes', $value ); |
|
2783 | + $this->set_prop('taxes', $value); |
|
2784 | 2784 | |
2785 | 2785 | } |
2786 | 2786 | |
@@ -2790,13 +2790,13 @@ discard block |
||
2790 | 2790 | * @since 1.0.19 |
2791 | 2791 | * @param array $value discounts. |
2792 | 2792 | */ |
2793 | - public function set_discounts( $value ) { |
|
2793 | + public function set_discounts($value) { |
|
2794 | 2794 | |
2795 | - if ( ! is_array( $value ) ) { |
|
2795 | + if (!is_array($value)) { |
|
2796 | 2796 | $value = array(); |
2797 | 2797 | } |
2798 | 2798 | |
2799 | - $this->set_prop( 'discounts', $value ); |
|
2799 | + $this->set_prop('discounts', $value); |
|
2800 | 2800 | } |
2801 | 2801 | |
2802 | 2802 | /** |
@@ -2805,18 +2805,18 @@ discard block |
||
2805 | 2805 | * @since 1.0.19 |
2806 | 2806 | * @param GetPaid_Form_Item[] $value items. |
2807 | 2807 | */ |
2808 | - public function set_items( $value ) { |
|
2808 | + public function set_items($value) { |
|
2809 | 2809 | |
2810 | 2810 | // Remove existing items. |
2811 | - $this->set_prop( 'items', array() ); |
|
2811 | + $this->set_prop('items', array()); |
|
2812 | 2812 | |
2813 | 2813 | // Ensure that we have an array. |
2814 | - if ( ! is_array( $value ) ) { |
|
2814 | + if (!is_array($value)) { |
|
2815 | 2815 | return; |
2816 | 2816 | } |
2817 | 2817 | |
2818 | - foreach ( $value as $item ) { |
|
2819 | - $this->add_item( $item ); |
|
2818 | + foreach ($value as $item) { |
|
2819 | + $this->add_item($item); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | } |
@@ -2827,8 +2827,8 @@ discard block |
||
2827 | 2827 | * @since 1.0.19 |
2828 | 2828 | * @param int $value payment form. |
2829 | 2829 | */ |
2830 | - public function set_payment_form( $value ) { |
|
2831 | - $this->set_prop( 'payment_form', $value ); |
|
2830 | + public function set_payment_form($value) { |
|
2831 | + $this->set_prop('payment_form', $value); |
|
2832 | 2832 | } |
2833 | 2833 | |
2834 | 2834 | /** |
@@ -2837,8 +2837,8 @@ discard block |
||
2837 | 2837 | * @since 1.0.19 |
2838 | 2838 | * @param string $value submission id. |
2839 | 2839 | */ |
2840 | - public function set_submission_id( $value ) { |
|
2841 | - $this->set_prop( 'submission_id', $value ); |
|
2840 | + public function set_submission_id($value) { |
|
2841 | + $this->set_prop('submission_id', $value); |
|
2842 | 2842 | } |
2843 | 2843 | |
2844 | 2844 | /** |
@@ -2847,8 +2847,8 @@ discard block |
||
2847 | 2847 | * @since 1.0.19 |
2848 | 2848 | * @param string $value discount code. |
2849 | 2849 | */ |
2850 | - public function set_discount_code( $value ) { |
|
2851 | - $this->set_prop( 'discount_code', $value ); |
|
2850 | + public function set_discount_code($value) { |
|
2851 | + $this->set_prop('discount_code', $value); |
|
2852 | 2852 | } |
2853 | 2853 | |
2854 | 2854 | /** |
@@ -2857,8 +2857,8 @@ discard block |
||
2857 | 2857 | * @since 1.0.19 |
2858 | 2858 | * @param string $value gateway. |
2859 | 2859 | */ |
2860 | - public function set_gateway( $value ) { |
|
2861 | - $this->set_prop( 'gateway', $value ); |
|
2860 | + public function set_gateway($value) { |
|
2861 | + $this->set_prop('gateway', $value); |
|
2862 | 2862 | } |
2863 | 2863 | |
2864 | 2864 | /** |
@@ -2867,9 +2867,9 @@ discard block |
||
2867 | 2867 | * @since 1.0.19 |
2868 | 2868 | * @param string $value transaction id. |
2869 | 2869 | */ |
2870 | - public function set_transaction_id( $value ) { |
|
2871 | - if ( ! empty( $value ) ) { |
|
2872 | - $this->set_prop( 'transaction_id', $value ); |
|
2870 | + public function set_transaction_id($value) { |
|
2871 | + if (!empty($value)) { |
|
2872 | + $this->set_prop('transaction_id', $value); |
|
2873 | 2873 | } |
2874 | 2874 | } |
2875 | 2875 | |
@@ -2879,8 +2879,8 @@ discard block |
||
2879 | 2879 | * @since 1.0.19 |
2880 | 2880 | * @param string $value currency id. |
2881 | 2881 | */ |
2882 | - public function set_currency( $value ) { |
|
2883 | - $this->set_prop( 'currency', $value ); |
|
2882 | + public function set_currency($value) { |
|
2883 | + $this->set_prop('currency', $value); |
|
2884 | 2884 | } |
2885 | 2885 | |
2886 | 2886 | /** |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | * @since 1.0.19 |
2890 | 2890 | * @param bool $value value. |
2891 | 2891 | */ |
2892 | - public function set_disable_taxes( $value ) { |
|
2893 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2892 | + public function set_disable_taxes($value) { |
|
2893 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2894 | 2894 | } |
2895 | 2895 | |
2896 | 2896 | /** |
@@ -2899,8 +2899,8 @@ discard block |
||
2899 | 2899 | * @since 1.0.19 |
2900 | 2900 | * @param string $value subscription id. |
2901 | 2901 | */ |
2902 | - public function set_subscription_id( $value ) { |
|
2903 | - $this->set_prop( 'subscription_id', $value ); |
|
2902 | + public function set_subscription_id($value) { |
|
2903 | + $this->set_prop('subscription_id', $value); |
|
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | /** |
@@ -2909,8 +2909,8 @@ discard block |
||
2909 | 2909 | * @since 1.0.19 |
2910 | 2910 | * @param string $value subscription id. |
2911 | 2911 | */ |
2912 | - public function set_remote_subscription_id( $value ) { |
|
2913 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2912 | + public function set_remote_subscription_id($value) { |
|
2913 | + $this->set_prop('remote_subscription_id', $value); |
|
2914 | 2914 | } |
2915 | 2915 | |
2916 | 2916 | /* |
@@ -2927,28 +2927,28 @@ discard block |
||
2927 | 2927 | */ |
2928 | 2928 | public function is_parent() { |
2929 | 2929 | $parent = $this->get_parent_id(); |
2930 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2930 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2931 | 2931 | } |
2932 | 2932 | |
2933 | 2933 | /** |
2934 | 2934 | * Checks if this is a renewal invoice. |
2935 | 2935 | */ |
2936 | 2936 | public function is_renewal() { |
2937 | - return ! $this->is_parent(); |
|
2937 | + return !$this->is_parent(); |
|
2938 | 2938 | } |
2939 | 2939 | |
2940 | 2940 | /** |
2941 | 2941 | * Checks if this is a recurring invoice. |
2942 | 2942 | */ |
2943 | 2943 | public function is_recurring() { |
2944 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2944 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2945 | 2945 | } |
2946 | 2946 | |
2947 | 2947 | /** |
2948 | 2948 | * Checks if this is a taxable invoice. |
2949 | 2949 | */ |
2950 | 2950 | public function is_taxable() { |
2951 | - return ! $this->get_disable_taxes(); |
|
2951 | + return !$this->get_disable_taxes(); |
|
2952 | 2952 | } |
2953 | 2953 | |
2954 | 2954 | /** |
@@ -2959,57 +2959,57 @@ discard block |
||
2959 | 2959 | |
2960 | 2960 | $requires_vat = false; |
2961 | 2961 | |
2962 | - if ( $this->country ) { |
|
2962 | + if ($this->country) { |
|
2963 | 2963 | $wpi_country = $this->country; |
2964 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2964 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2965 | 2965 | } |
2966 | 2966 | |
2967 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2967 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2968 | 2968 | } |
2969 | 2969 | |
2970 | 2970 | /** |
2971 | 2971 | * Checks to see if the invoice requires payment. |
2972 | 2972 | */ |
2973 | 2973 | public function is_free() { |
2974 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2974 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2975 | 2975 | |
2976 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2976 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2977 | 2977 | $is_free = false; |
2978 | 2978 | } |
2979 | 2979 | |
2980 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2980 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2981 | 2981 | } |
2982 | 2982 | |
2983 | 2983 | /** |
2984 | 2984 | * Checks if the invoice is paid. |
2985 | 2985 | */ |
2986 | 2986 | public function is_paid() { |
2987 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2988 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2987 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2988 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2989 | 2989 | } |
2990 | 2990 | |
2991 | 2991 | /** |
2992 | 2992 | * Checks if the invoice needs payment. |
2993 | 2993 | */ |
2994 | 2994 | public function needs_payment() { |
2995 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
2996 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
2995 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
2996 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
2997 | 2997 | } |
2998 | 2998 | |
2999 | 2999 | /** |
3000 | 3000 | * Checks if the invoice is refunded. |
3001 | 3001 | */ |
3002 | 3002 | public function is_refunded() { |
3003 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3004 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3003 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3004 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | /** |
3008 | 3008 | * Checks if the invoice is held. |
3009 | 3009 | */ |
3010 | 3010 | public function is_held() { |
3011 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3012 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3011 | + $is_held = $this->has_status('wpi-onhold'); |
|
3012 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3013 | 3013 | } |
3014 | 3014 | |
3015 | 3015 | /** |
@@ -3017,30 +3017,30 @@ discard block |
||
3017 | 3017 | */ |
3018 | 3018 | public function is_due() { |
3019 | 3019 | $due_date = $this->get_due_date(); |
3020 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3020 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3021 | 3021 | } |
3022 | 3022 | |
3023 | 3023 | /** |
3024 | 3024 | * Checks if the invoice is draft. |
3025 | 3025 | */ |
3026 | 3026 | public function is_draft() { |
3027 | - return $this->has_status( 'draft, auto-draft' ); |
|
3027 | + return $this->has_status('draft, auto-draft'); |
|
3028 | 3028 | } |
3029 | 3029 | |
3030 | 3030 | /** |
3031 | 3031 | * Checks if the invoice has a given status. |
3032 | 3032 | */ |
3033 | - public function has_status( $status ) { |
|
3034 | - $status = wpinv_parse_list( $status ); |
|
3035 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3033 | + public function has_status($status) { |
|
3034 | + $status = wpinv_parse_list($status); |
|
3035 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3036 | 3036 | } |
3037 | 3037 | |
3038 | 3038 | /** |
3039 | 3039 | * Checks if the invoice is of a given type. |
3040 | 3040 | */ |
3041 | - public function is_type( $type ) { |
|
3042 | - $type = wpinv_parse_list( $type ); |
|
3043 | - return in_array( $this->get_type(), $type ); |
|
3041 | + public function is_type($type) { |
|
3042 | + $type = wpinv_parse_list($type); |
|
3043 | + return in_array($this->get_type(), $type); |
|
3044 | 3044 | } |
3045 | 3045 | |
3046 | 3046 | /** |
@@ -3072,8 +3072,8 @@ discard block |
||
3072 | 3072 | * |
3073 | 3073 | */ |
3074 | 3074 | public function is_initial_free() { |
3075 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3076 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3075 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3076 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3077 | 3077 | } |
3078 | 3078 | |
3079 | 3079 | /** |
@@ -3083,11 +3083,11 @@ discard block |
||
3083 | 3083 | public function item_has_free_trial() { |
3084 | 3084 | |
3085 | 3085 | // Ensure we have a recurring item. |
3086 | - if ( ! $this->is_recurring() ) { |
|
3086 | + if (!$this->is_recurring()) { |
|
3087 | 3087 | return false; |
3088 | 3088 | } |
3089 | 3089 | |
3090 | - $item = $this->get_recurring( true ); |
|
3090 | + $item = $this->get_recurring(true); |
|
3091 | 3091 | return $item->has_free_trial(); |
3092 | 3092 | } |
3093 | 3093 | |
@@ -3095,7 +3095,7 @@ discard block |
||
3095 | 3095 | * Check if the free trial is a result of a discount. |
3096 | 3096 | */ |
3097 | 3097 | public function is_free_trial_from_discount() { |
3098 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3098 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3099 | 3099 | } |
3100 | 3100 | |
3101 | 3101 | /** |
@@ -3104,17 +3104,17 @@ discard block |
||
3104 | 3104 | public function discount_first_payment_only() { |
3105 | 3105 | |
3106 | 3106 | $discount_code = $this->get_discount_code(); |
3107 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
3107 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
3108 | 3108 | return true; |
3109 | 3109 | } |
3110 | 3110 | |
3111 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3111 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3112 | 3112 | |
3113 | - if ( ! $discount || ! $discount->exists() ) { |
|
3113 | + if (!$discount || !$discount->exists()) { |
|
3114 | 3114 | return true; |
3115 | 3115 | } |
3116 | 3116 | |
3117 | - return ! $discount->get_is_recurring(); |
|
3117 | + return !$discount->get_is_recurring(); |
|
3118 | 3118 | } |
3119 | 3119 | |
3120 | 3120 | /* |
@@ -3132,27 +3132,27 @@ discard block |
||
3132 | 3132 | * @param GetPaid_Form_Item|array $item |
3133 | 3133 | * @return WP_Error|Bool |
3134 | 3134 | */ |
3135 | - public function add_item( $item ) { |
|
3135 | + public function add_item($item) { |
|
3136 | 3136 | |
3137 | - if ( is_array( $item ) ) { |
|
3138 | - $item = $this->process_array_item( $item ); |
|
3137 | + if (is_array($item)) { |
|
3138 | + $item = $this->process_array_item($item); |
|
3139 | 3139 | } |
3140 | 3140 | |
3141 | - if ( is_numeric( $item ) ) { |
|
3142 | - $item = new GetPaid_Form_Item( $item ); |
|
3141 | + if (is_numeric($item)) { |
|
3142 | + $item = new GetPaid_Form_Item($item); |
|
3143 | 3143 | } |
3144 | 3144 | |
3145 | 3145 | // Make sure that it is available for purchase. |
3146 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3147 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3146 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3147 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3148 | 3148 | } |
3149 | 3149 | |
3150 | 3150 | // Do we have a recurring item? |
3151 | - if ( $item->is_recurring() ) { |
|
3151 | + if ($item->is_recurring()) { |
|
3152 | 3152 | |
3153 | 3153 | // An invoice can only contain one recurring item. |
3154 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3155 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3154 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3155 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3156 | 3156 | } |
3157 | 3157 | |
3158 | 3158 | $this->recurring_item = $item->get_id(); |
@@ -3163,9 +3163,9 @@ discard block |
||
3163 | 3163 | |
3164 | 3164 | // Retrieve all items. |
3165 | 3165 | $items = $this->get_items(); |
3166 | - $items[ (int) $item->get_id() ] = $item; |
|
3166 | + $items[(int) $item->get_id()] = $item; |
|
3167 | 3167 | |
3168 | - $this->set_prop( 'items', $items ); |
|
3168 | + $this->set_prop('items', $items); |
|
3169 | 3169 | return true; |
3170 | 3170 | } |
3171 | 3171 | |
@@ -3175,26 +3175,26 @@ discard block |
||
3175 | 3175 | * @since 1.0.19 |
3176 | 3176 | * @return GetPaid_Form_Item |
3177 | 3177 | */ |
3178 | - protected function process_array_item( $array ) { |
|
3178 | + protected function process_array_item($array) { |
|
3179 | 3179 | |
3180 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3181 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3180 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3181 | + $item = new GetPaid_Form_Item($item_id); |
|
3182 | 3182 | |
3183 | 3183 | // Set item data. |
3184 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3185 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3184 | + foreach (array('name', 'price', 'description') as $key) { |
|
3185 | + if (isset($array["item_$key"])) { |
|
3186 | 3186 | $method = "set_$key"; |
3187 | - $item->$method( $array[ "item_$key" ] ); |
|
3187 | + $item->$method($array["item_$key"]); |
|
3188 | 3188 | } |
3189 | 3189 | } |
3190 | 3190 | |
3191 | - if ( isset( $array['quantity'] ) ) { |
|
3192 | - $item->set_quantity( $array['quantity'] ); |
|
3191 | + if (isset($array['quantity'])) { |
|
3192 | + $item->set_quantity($array['quantity']); |
|
3193 | 3193 | } |
3194 | 3194 | |
3195 | 3195 | // Set item meta. |
3196 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3197 | - $item->set_item_meta( $array['meta'] ); |
|
3196 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3197 | + $item->set_item_meta($array['meta']); |
|
3198 | 3198 | } |
3199 | 3199 | |
3200 | 3200 | return $item; |
@@ -3206,10 +3206,10 @@ discard block |
||
3206 | 3206 | * |
3207 | 3207 | * @since 1.0.19 |
3208 | 3208 | */ |
3209 | - public function get_item( $item_id ) { |
|
3209 | + public function get_item($item_id) { |
|
3210 | 3210 | $items = $this->get_items(); |
3211 | 3211 | $item_id = (int) $item_id; |
3212 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3212 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3213 | 3213 | } |
3214 | 3214 | |
3215 | 3215 | /** |
@@ -3217,17 +3217,17 @@ discard block |
||
3217 | 3217 | * |
3218 | 3218 | * @since 1.0.19 |
3219 | 3219 | */ |
3220 | - public function remove_item( $item_id ) { |
|
3220 | + public function remove_item($item_id) { |
|
3221 | 3221 | $items = $this->get_items(); |
3222 | 3222 | $item_id = (int) $item_id; |
3223 | 3223 | |
3224 | - if ( $item_id == $this->recurring_item ) { |
|
3224 | + if ($item_id == $this->recurring_item) { |
|
3225 | 3225 | $this->recurring_item = null; |
3226 | 3226 | } |
3227 | 3227 | |
3228 | - if ( isset( $items[ $item_id ] ) ) { |
|
3229 | - unset( $items[ $item_id ] ); |
|
3230 | - $this->set_prop( 'items', $items ); |
|
3228 | + if (isset($items[$item_id])) { |
|
3229 | + unset($items[$item_id]); |
|
3230 | + $this->set_prop('items', $items); |
|
3231 | 3231 | } |
3232 | 3232 | } |
3233 | 3233 | |
@@ -3237,11 +3237,11 @@ discard block |
||
3237 | 3237 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3238 | 3238 | * @since 1.0.19 |
3239 | 3239 | */ |
3240 | - public function add_fee( $fee ) { |
|
3240 | + public function add_fee($fee) { |
|
3241 | 3241 | |
3242 | 3242 | $fees = $this->get_fees(); |
3243 | - $fees[ $fee['name'] ] = $fee; |
|
3244 | - $this->set_prop( 'fees', $fees ); |
|
3243 | + $fees[$fee['name']] = $fee; |
|
3244 | + $this->set_prop('fees', $fees); |
|
3245 | 3245 | |
3246 | 3246 | } |
3247 | 3247 | |
@@ -3250,9 +3250,9 @@ discard block |
||
3250 | 3250 | * |
3251 | 3251 | * @since 1.0.19 |
3252 | 3252 | */ |
3253 | - public function get_fee( $fee ) { |
|
3253 | + public function get_fee($fee) { |
|
3254 | 3254 | $fees = $this->get_fees(); |
3255 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3255 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3256 | 3256 | } |
3257 | 3257 | |
3258 | 3258 | /** |
@@ -3260,11 +3260,11 @@ discard block |
||
3260 | 3260 | * |
3261 | 3261 | * @since 1.0.19 |
3262 | 3262 | */ |
3263 | - public function remove_fee( $fee ) { |
|
3263 | + public function remove_fee($fee) { |
|
3264 | 3264 | $fees = $this->get_fees(); |
3265 | - if ( isset( $fees[ $fee ] ) ) { |
|
3266 | - unset( $fees[ $fee ] ); |
|
3267 | - $this->set_prop( 'fees', $fees ); |
|
3265 | + if (isset($fees[$fee])) { |
|
3266 | + unset($fees[$fee]); |
|
3267 | + $this->set_prop('fees', $fees); |
|
3268 | 3268 | } |
3269 | 3269 | } |
3270 | 3270 | |
@@ -3274,11 +3274,11 @@ discard block |
||
3274 | 3274 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3275 | 3275 | * @since 1.0.19 |
3276 | 3276 | */ |
3277 | - public function add_discount( $discount ) { |
|
3277 | + public function add_discount($discount) { |
|
3278 | 3278 | |
3279 | 3279 | $discounts = $this->get_discounts(); |
3280 | - $discounts[ $discount['name'] ] = $discount; |
|
3281 | - $this->set_prop( 'discounts', $discounts ); |
|
3280 | + $discounts[$discount['name']] = $discount; |
|
3281 | + $this->set_prop('discounts', $discounts); |
|
3282 | 3282 | |
3283 | 3283 | } |
3284 | 3284 | |
@@ -3288,15 +3288,15 @@ discard block |
||
3288 | 3288 | * @since 1.0.19 |
3289 | 3289 | * @return float |
3290 | 3290 | */ |
3291 | - public function get_discount( $discount = false ) { |
|
3291 | + public function get_discount($discount = false) { |
|
3292 | 3292 | |
3293 | 3293 | // Backwards compatibilty. |
3294 | - if ( empty( $discount ) ) { |
|
3294 | + if (empty($discount)) { |
|
3295 | 3295 | return $this->get_total_discount(); |
3296 | 3296 | } |
3297 | 3297 | |
3298 | 3298 | $discounts = $this->get_discounts(); |
3299 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3299 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3300 | 3300 | } |
3301 | 3301 | |
3302 | 3302 | /** |
@@ -3304,11 +3304,11 @@ discard block |
||
3304 | 3304 | * |
3305 | 3305 | * @since 1.0.19 |
3306 | 3306 | */ |
3307 | - public function remove_discount( $discount ) { |
|
3307 | + public function remove_discount($discount) { |
|
3308 | 3308 | $discounts = $this->get_discounts(); |
3309 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3310 | - unset( $discounts[ $discount ] ); |
|
3311 | - $this->set_prop( 'discounts', $discounts ); |
|
3309 | + if (isset($discounts[$discount])) { |
|
3310 | + unset($discounts[$discount]); |
|
3311 | + $this->set_prop('discounts', $discounts); |
|
3312 | 3312 | } |
3313 | 3313 | } |
3314 | 3314 | |
@@ -3317,12 +3317,12 @@ discard block |
||
3317 | 3317 | * |
3318 | 3318 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3319 | 3319 | */ |
3320 | - public function add_tax( $tax ) { |
|
3321 | - if ( $this->is_taxable() ) { |
|
3320 | + public function add_tax($tax) { |
|
3321 | + if ($this->is_taxable()) { |
|
3322 | 3322 | |
3323 | - $taxes = $this->get_taxes(); |
|
3324 | - $taxes[ $tax['name'] ] = $tax; |
|
3325 | - $this->set_prop( 'taxes', $tax ); |
|
3323 | + $taxes = $this->get_taxes(); |
|
3324 | + $taxes[$tax['name']] = $tax; |
|
3325 | + $this->set_prop('taxes', $tax); |
|
3326 | 3326 | |
3327 | 3327 | } |
3328 | 3328 | } |
@@ -3332,15 +3332,15 @@ discard block |
||
3332 | 3332 | * |
3333 | 3333 | * @since 1.0.19 |
3334 | 3334 | */ |
3335 | - public function get_tax( $tax = null ) { |
|
3335 | + public function get_tax($tax = null) { |
|
3336 | 3336 | |
3337 | 3337 | // Backwards compatility. |
3338 | - if ( empty( $tax ) ) { |
|
3338 | + if (empty($tax)) { |
|
3339 | 3339 | return $this->get_total_tax(); |
3340 | 3340 | } |
3341 | 3341 | |
3342 | 3342 | $taxes = $this->get_taxes(); |
3343 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3343 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3344 | 3344 | } |
3345 | 3345 | |
3346 | 3346 | /** |
@@ -3348,11 +3348,11 @@ discard block |
||
3348 | 3348 | * |
3349 | 3349 | * @since 1.0.19 |
3350 | 3350 | */ |
3351 | - public function remove_tax( $tax ) { |
|
3351 | + public function remove_tax($tax) { |
|
3352 | 3352 | $taxes = $this->get_taxes(); |
3353 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3354 | - unset( $taxes[ $tax ] ); |
|
3355 | - $this->set_prop( 'taxes', $taxes ); |
|
3353 | + if (isset($taxes[$tax])) { |
|
3354 | + unset($taxes[$tax]); |
|
3355 | + $this->set_prop('taxes', $taxes); |
|
3356 | 3356 | } |
3357 | 3357 | } |
3358 | 3358 | |
@@ -3363,17 +3363,17 @@ discard block |
||
3363 | 3363 | * @return float The recalculated subtotal |
3364 | 3364 | */ |
3365 | 3365 | public function recalculate_subtotal() { |
3366 | - $items = $this->get_items(); |
|
3366 | + $items = $this->get_items(); |
|
3367 | 3367 | $subtotal = 0; |
3368 | 3368 | $recurring = 0; |
3369 | 3369 | |
3370 | - foreach ( $items as $item ) { |
|
3370 | + foreach ($items as $item) { |
|
3371 | 3371 | $subtotal += $item->get_sub_total(); |
3372 | 3372 | $recurring += $item->get_recurring_sub_total(); |
3373 | 3373 | } |
3374 | 3374 | |
3375 | 3375 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3376 | - $this->set_subtotal( $current ); |
|
3376 | + $this->set_subtotal($current); |
|
3377 | 3377 | |
3378 | 3378 | $this->totals['subtotal'] = array( |
3379 | 3379 | 'initial' => $subtotal, |
@@ -3394,14 +3394,14 @@ discard block |
||
3394 | 3394 | $discount = 0; |
3395 | 3395 | $recurring = 0; |
3396 | 3396 | |
3397 | - foreach ( $discounts as $data ) { |
|
3398 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3399 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3397 | + foreach ($discounts as $data) { |
|
3398 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3399 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3400 | 3400 | } |
3401 | 3401 | |
3402 | 3402 | $current = $this->is_renewal() ? $recurring : $discount; |
3403 | 3403 | |
3404 | - $this->set_total_discount( $current ); |
|
3404 | + $this->set_total_discount($current); |
|
3405 | 3405 | |
3406 | 3406 | $this->totals['discount'] = array( |
3407 | 3407 | 'initial' => $discount, |
@@ -3419,17 +3419,17 @@ discard block |
||
3419 | 3419 | * @return float The recalculated tax |
3420 | 3420 | */ |
3421 | 3421 | public function recalculate_total_tax() { |
3422 | - $taxes = $this->get_taxes(); |
|
3422 | + $taxes = $this->get_taxes(); |
|
3423 | 3423 | $tax = 0; |
3424 | 3424 | $recurring = 0; |
3425 | 3425 | |
3426 | - foreach ( $taxes as $data ) { |
|
3427 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
3428 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
3426 | + foreach ($taxes as $data) { |
|
3427 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
3428 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
3429 | 3429 | } |
3430 | 3430 | |
3431 | 3431 | $current = $this->is_renewal() ? $recurring : $tax; |
3432 | - $this->set_total_tax( $current ); |
|
3432 | + $this->set_total_tax($current); |
|
3433 | 3433 | |
3434 | 3434 | $this->totals['tax'] = array( |
3435 | 3435 | 'initial' => $tax, |
@@ -3451,20 +3451,20 @@ discard block |
||
3451 | 3451 | $fee = 0; |
3452 | 3452 | $recurring = 0; |
3453 | 3453 | |
3454 | - foreach ( $fees as $data ) { |
|
3455 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3456 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3454 | + foreach ($fees as $data) { |
|
3455 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3456 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3457 | 3457 | } |
3458 | 3458 | |
3459 | 3459 | $current = $this->is_renewal() ? $recurring : $fee; |
3460 | - $this->set_total_fees( $current ); |
|
3460 | + $this->set_total_fees($current); |
|
3461 | 3461 | |
3462 | 3462 | $this->totals['fee'] = array( |
3463 | 3463 | 'initial' => $fee, |
3464 | 3464 | 'recurring' => $recurring, |
3465 | 3465 | ); |
3466 | 3466 | |
3467 | - $this->set_total_fees( $fee ); |
|
3467 | + $this->set_total_fees($fee); |
|
3468 | 3468 | return $current; |
3469 | 3469 | } |
3470 | 3470 | |
@@ -3485,9 +3485,9 @@ discard block |
||
3485 | 3485 | /** |
3486 | 3486 | * @deprecated |
3487 | 3487 | */ |
3488 | - public function recalculate_totals( $temp = false ) { |
|
3489 | - $this->update_items( $temp ); |
|
3490 | - $this->save( true ); |
|
3488 | + public function recalculate_totals($temp = false) { |
|
3489 | + $this->update_items($temp); |
|
3490 | + $this->save(true); |
|
3491 | 3491 | return $this; |
3492 | 3492 | } |
3493 | 3493 | |
@@ -3505,10 +3505,10 @@ discard block |
||
3505 | 3505 | * @return int|false The new note's ID on success, false on failure. |
3506 | 3506 | * |
3507 | 3507 | */ |
3508 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3508 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3509 | 3509 | |
3510 | 3510 | // Bail if no note specified or this invoice is not yet saved. |
3511 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3511 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3512 | 3512 | return false; |
3513 | 3513 | } |
3514 | 3514 | |
@@ -3516,23 +3516,23 @@ discard block |
||
3516 | 3516 | $author_email = '[email protected]'; |
3517 | 3517 | |
3518 | 3518 | // If this is an admin comment or it has been added by the user. |
3519 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3520 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3519 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3520 | + $user = get_user_by('id', get_current_user_id()); |
|
3521 | 3521 | $author = $user->display_name; |
3522 | 3522 | $author_email = $user->user_email; |
3523 | 3523 | } |
3524 | 3524 | |
3525 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3525 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3526 | 3526 | |
3527 | 3527 | } |
3528 | 3528 | |
3529 | 3529 | /** |
3530 | 3530 | * Generates a unique key for the invoice. |
3531 | 3531 | */ |
3532 | - public function generate_key( $string = '' ) { |
|
3533 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3532 | + public function generate_key($string = '') { |
|
3533 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3534 | 3534 | return strtolower( |
3535 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3535 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3536 | 3536 | ); |
3537 | 3537 | } |
3538 | 3538 | |
@@ -3542,11 +3542,11 @@ discard block |
||
3542 | 3542 | public function generate_number() { |
3543 | 3543 | $number = $this->get_id(); |
3544 | 3544 | |
3545 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3546 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3545 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3546 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3547 | 3547 | } |
3548 | 3548 | |
3549 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3549 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3550 | 3550 | |
3551 | 3551 | } |
3552 | 3552 | |
@@ -3559,55 +3559,55 @@ discard block |
||
3559 | 3559 | // Reset status transition variable. |
3560 | 3560 | $this->status_transition = false; |
3561 | 3561 | |
3562 | - if ( $status_transition ) { |
|
3562 | + if ($status_transition) { |
|
3563 | 3563 | try { |
3564 | 3564 | |
3565 | 3565 | // Fire a hook for the status change. |
3566 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3566 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3567 | 3567 | |
3568 | 3568 | // @deprecated this is deprecated and will be removed in the future. |
3569 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3569 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3570 | 3570 | |
3571 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3571 | + if (!empty($status_transition['from'])) { |
|
3572 | 3572 | |
3573 | 3573 | /* translators: 1: old invoice status 2: new invoice status */ |
3574 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3574 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
3575 | 3575 | |
3576 | 3576 | // Fire another hook. |
3577 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3578 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3577 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3578 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3579 | 3579 | |
3580 | 3580 | // @deprecated this is deprecated and will be removed in the future. |
3581 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3581 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3582 | 3582 | |
3583 | 3583 | // Note the transition occurred. |
3584 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3584 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3585 | 3585 | |
3586 | 3586 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3587 | 3587 | if ( |
3588 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3589 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3588 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3589 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3590 | 3590 | ) { |
3591 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3591 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3592 | 3592 | } |
3593 | 3593 | |
3594 | 3594 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3595 | 3595 | if ( |
3596 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3597 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3596 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3597 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3598 | 3598 | ) { |
3599 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3599 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3600 | 3600 | } |
3601 | 3601 | } else { |
3602 | 3602 | /* translators: %s: new invoice status */ |
3603 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3603 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
3604 | 3604 | |
3605 | 3605 | // Note the transition occurred. |
3606 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3606 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3607 | 3607 | |
3608 | 3608 | } |
3609 | - } catch ( Exception $e ) { |
|
3610 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3609 | + } catch (Exception $e) { |
|
3610 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3611 | 3611 | } |
3612 | 3612 | } |
3613 | 3613 | } |
@@ -3615,13 +3615,13 @@ discard block |
||
3615 | 3615 | /** |
3616 | 3616 | * Updates an invoice status. |
3617 | 3617 | */ |
3618 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3618 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3619 | 3619 | |
3620 | 3620 | // Fires before updating a status. |
3621 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3621 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3622 | 3622 | |
3623 | 3623 | // Update the status. |
3624 | - $this->set_status( $new_status, $note, $manual ); |
|
3624 | + $this->set_status($new_status, $note, $manual); |
|
3625 | 3625 | |
3626 | 3626 | // Save the order. |
3627 | 3627 | return $this->save(); |
@@ -3632,18 +3632,18 @@ discard block |
||
3632 | 3632 | * @deprecated |
3633 | 3633 | */ |
3634 | 3634 | public function refresh_item_ids() { |
3635 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3636 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3635 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3636 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3637 | 3637 | } |
3638 | 3638 | |
3639 | 3639 | /** |
3640 | 3640 | * @deprecated |
3641 | 3641 | */ |
3642 | - public function update_items( $temp = false ) { |
|
3642 | + public function update_items($temp = false) { |
|
3643 | 3643 | |
3644 | - $this->set_items( $this->get_items() ); |
|
3644 | + $this->set_items($this->get_items()); |
|
3645 | 3645 | |
3646 | - if ( ! $temp ) { |
|
3646 | + if (!$temp) { |
|
3647 | 3647 | $this->save(); |
3648 | 3648 | } |
3649 | 3649 | |
@@ -3657,11 +3657,11 @@ discard block |
||
3657 | 3657 | |
3658 | 3658 | $discount_code = $this->get_discount_code(); |
3659 | 3659 | |
3660 | - if ( empty( $discount_code ) ) { |
|
3660 | + if (empty($discount_code)) { |
|
3661 | 3661 | return false; |
3662 | 3662 | } |
3663 | 3663 | |
3664 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3664 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3665 | 3665 | |
3666 | 3666 | // Ensure it is active. |
3667 | 3667 | return $discount->exists(); |
@@ -3672,7 +3672,7 @@ discard block |
||
3672 | 3672 | * Refunds an invoice. |
3673 | 3673 | */ |
3674 | 3674 | public function refund() { |
3675 | - $this->set_status( 'wpi-refunded' ); |
|
3675 | + $this->set_status('wpi-refunded'); |
|
3676 | 3676 | $this->save(); |
3677 | 3677 | } |
3678 | 3678 | |
@@ -3681,56 +3681,56 @@ discard block |
||
3681 | 3681 | * |
3682 | 3682 | * @param string $transaction_id |
3683 | 3683 | */ |
3684 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3684 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3685 | 3685 | |
3686 | 3686 | // Set the transaction id. |
3687 | - if ( empty( $transaction_id ) ) { |
|
3687 | + if (empty($transaction_id)) { |
|
3688 | 3688 | $transaction_id = $this->generate_key('trans_'); |
3689 | 3689 | } |
3690 | 3690 | |
3691 | - if ( ! $this->get_transaction_id() ) { |
|
3692 | - $this->set_transaction_id( $transaction_id ); |
|
3691 | + if (!$this->get_transaction_id()) { |
|
3692 | + $this->set_transaction_id($transaction_id); |
|
3693 | 3693 | } |
3694 | 3694 | |
3695 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3695 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3696 | 3696 | return $this->save(); |
3697 | 3697 | } |
3698 | 3698 | |
3699 | 3699 | // Set the completed date. |
3700 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3700 | + $this->set_date_completed(current_time('mysql')); |
|
3701 | 3701 | |
3702 | 3702 | // Set the new status. |
3703 | - if ( $this->is_renewal() ) { |
|
3703 | + if ($this->is_renewal()) { |
|
3704 | 3704 | |
3705 | 3705 | $_note = sprintf( |
3706 | - __( 'Renewed via %s', 'invoicing' ), |
|
3707 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3706 | + __('Renewed via %s', 'invoicing'), |
|
3707 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3708 | 3708 | ); |
3709 | 3709 | |
3710 | - if ( 'none' == $this->get_gateway() ) { |
|
3710 | + if ('none' == $this->get_gateway()) { |
|
3711 | 3711 | $_note = $note; |
3712 | 3712 | } |
3713 | 3713 | |
3714 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3714 | + $this->set_status('wpi-renewal', $_note); |
|
3715 | 3715 | |
3716 | 3716 | } else { |
3717 | 3717 | |
3718 | 3718 | $_note = sprintf( |
3719 | - __( 'Paid via %s', 'invoicing' ), |
|
3720 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3719 | + __('Paid via %s', 'invoicing'), |
|
3720 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3721 | 3721 | ); |
3722 | 3722 | |
3723 | - if ( 'none' == $this->get_gateway() ) { |
|
3723 | + if ('none' == $this->get_gateway()) { |
|
3724 | 3724 | $_note = $note; |
3725 | 3725 | } |
3726 | 3726 | |
3727 | - $this->set_status( 'publish',$_note ); |
|
3727 | + $this->set_status('publish', $_note); |
|
3728 | 3728 | |
3729 | 3729 | } |
3730 | 3730 | |
3731 | 3731 | // Set checkout mode. |
3732 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3733 | - $this->set_mode( $mode ); |
|
3732 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3733 | + $this->set_mode($mode); |
|
3734 | 3734 | |
3735 | 3735 | // Save the invoice. |
3736 | 3736 | $this->save(); |
@@ -3756,9 +3756,9 @@ discard block |
||
3756 | 3756 | * Clears the subscription's cache. |
3757 | 3757 | */ |
3758 | 3758 | public function clear_cache() { |
3759 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3760 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3761 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3759 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3760 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3761 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3762 | 3762 | } |
3763 | 3763 | |
3764 | 3764 | } |
@@ -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 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -347,30 +347,30 @@ discard block |
||
347 | 347 | $invoice->recalculate_total(); |
348 | 348 | $invoice->save(); |
349 | 349 | |
350 | - if ( ! $invoice->get_id() ) { |
|
351 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
350 | + if (!$invoice->get_id()) { |
|
351 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | // Add private note. |
355 | - if ( ! empty( $data['private_note'] ) ) { |
|
356 | - $invoice->add_note( $data['private_note'] ); |
|
355 | + if (!empty($data['private_note'])) { |
|
356 | + $invoice->add_note($data['private_note']); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | // User notes. |
360 | - if ( !empty( $data['user_note'] ) ) { |
|
361 | - $invoice->add_note( $data['user_note'], true ); |
|
360 | + if (!empty($data['user_note'])) { |
|
361 | + $invoice->add_note($data['user_note'], true); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Created via. |
365 | - if ( isset( $data['created_via'] ) ) { |
|
366 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
365 | + if (isset($data['created_via'])) { |
|
366 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // Backwards compatiblity. |
370 | - if ( $invoice->is_quote() ) { |
|
370 | + if ($invoice->is_quote()) { |
|
371 | 371 | |
372 | - if ( isset( $data['valid_until'] ) ) { |
|
373 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
372 | + if (isset($data['valid_until'])) { |
|
373 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
374 | 374 | } |
375 | 375 | return $invoice; |
376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * @param $bool $deprecated |
386 | 386 | * @return WPInv_Invoice|null |
387 | 387 | */ |
388 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
388 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
389 | 389 | |
390 | 390 | // If we are retrieving the invoice from the cart... |
391 | - if ( $deprecated && empty( $invoice ) ) { |
|
391 | + if ($deprecated && empty($invoice)) { |
|
392 | 392 | $invoice = (int) getpaid_get_current_invoice_id(); |
393 | 393 | } |
394 | 394 | |
395 | 395 | // Retrieve the invoice. |
396 | - $invoice = new WPInv_Invoice( $invoice ); |
|
396 | + $invoice = new WPInv_Invoice($invoice); |
|
397 | 397 | |
398 | 398 | // Check if it exists. |
399 | - if ( $invoice->get_id() != 0 ) { |
|
399 | + if ($invoice->get_id() != 0) { |
|
400 | 400 | return $invoice; |
401 | 401 | } |
402 | 402 | |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | * @param array $args Args to search for. |
410 | 410 | * @return WPInv_Invoice[]|int[]|object |
411 | 411 | */ |
412 | -function wpinv_get_invoices( $args ) { |
|
412 | +function wpinv_get_invoices($args) { |
|
413 | 413 | |
414 | 414 | // Prepare args. |
415 | 415 | $args = wp_parse_args( |
416 | 416 | $args, |
417 | 417 | array( |
418 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
418 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
419 | 419 | 'type' => 'wpi_invoice', |
420 | - 'limit' => get_option( 'posts_per_page' ), |
|
420 | + 'limit' => get_option('posts_per_page'), |
|
421 | 421 | 'return' => 'objects', |
422 | 422 | ) |
423 | 423 | ); |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | 'post__in' => 'include', |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $map_legacy as $to => $from ) { |
|
439 | - if ( isset( $args[ $from ] ) ) { |
|
440 | - $args[ $to ] = $args[ $from ]; |
|
441 | - unset( $args[ $from ] ); |
|
438 | + foreach ($map_legacy as $to => $from) { |
|
439 | + if (isset($args[$from])) { |
|
440 | + $args[$to] = $args[$from]; |
|
441 | + unset($args[$from]); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Backwards compatibility. |
446 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
446 | + if (!empty($args['email']) && empty($args['user'])) { |
|
447 | 447 | $args['user'] = $args['email']; |
448 | - unset( $args['email'] ); |
|
448 | + unset($args['email']); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | // Handle cases where the user is set as an email. |
452 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
453 | - $user = get_user_by( 'email', $args['user'] ); |
|
452 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
453 | + $user = get_user_by('email', $args['user']); |
|
454 | 454 | |
455 | - if ( $user ) { |
|
455 | + if ($user) { |
|
456 | 456 | $args['author'] = $user->user_email; |
457 | 457 | } |
458 | 458 | |
@@ -463,31 +463,31 @@ discard block |
||
463 | 463 | |
464 | 464 | // Show all posts. |
465 | 465 | $paginate = true; |
466 | - if ( isset( $args['paginate'] ) ) { |
|
466 | + if (isset($args['paginate'])) { |
|
467 | 467 | |
468 | 468 | $paginate = $args['paginate']; |
469 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
470 | - unset( $args['paginate'] ); |
|
469 | + $args['no_found_rows'] = empty($args['paginate']); |
|
470 | + unset($args['paginate']); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Whether to return objects or fields. |
475 | 475 | $return = $args['return']; |
476 | - unset( $args['return'] ); |
|
476 | + unset($args['return']); |
|
477 | 477 | |
478 | 478 | // Get invoices. |
479 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
479 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
480 | 480 | |
481 | 481 | // Prepare the results. |
482 | - if ( 'objects' === $return ) { |
|
483 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
484 | - } elseif ( 'self' === $return ) { |
|
482 | + if ('objects' === $return) { |
|
483 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
484 | + } elseif ('self' === $return) { |
|
485 | 485 | return $invoices; |
486 | 486 | } else { |
487 | 487 | $results = $invoices->posts; |
488 | 488 | } |
489 | 489 | |
490 | - if ( $paginate ) { |
|
490 | + if ($paginate) { |
|
491 | 491 | return (object) array( |
492 | 492 | 'invoices' => $results, |
493 | 493 | 'total' => $invoices->found_posts, |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @param string $transaction_id The transaction id to check. |
506 | 506 | * @return int Invoice id on success or 0 on failure |
507 | 507 | */ |
508 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
509 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
508 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
509 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $invoice_number The invoice number to check. |
516 | 516 | * @return int Invoice id on success or 0 on failure |
517 | 517 | */ |
518 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
519 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
518 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
519 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | * @param string $invoice_key The invoice key to check. |
526 | 526 | * @return int Invoice id on success or 0 on failure |
527 | 527 | */ |
528 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
529 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
528 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
529 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | * @param string $type Optionally filter by type i.e customer|system |
537 | 537 | * @return array|null |
538 | 538 | */ |
539 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
539 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
540 | 540 | |
541 | 541 | // Prepare the invoice. |
542 | - $invoice = wpinv_get_invoice( $invoice ); |
|
543 | - if ( empty( $invoice ) ) { |
|
542 | + $invoice = wpinv_get_invoice($invoice); |
|
543 | + if (empty($invoice)) { |
|
544 | 544 | return NULL; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Fetch notes. |
548 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
548 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
549 | 549 | |
550 | 550 | // Filter the notes. |
551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -558,27 +558,27 @@ discard block |
||
558 | 558 | $columns = array( |
559 | 559 | |
560 | 560 | 'invoice-number' => array( |
561 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
561 | + 'title' => __('Invoice', 'invoicing'), |
|
562 | 562 | 'class' => 'text-left' |
563 | 563 | ), |
564 | 564 | |
565 | 565 | 'created-date' => array( |
566 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
566 | + 'title' => __('Created Date', 'invoicing'), |
|
567 | 567 | 'class' => 'text-left' |
568 | 568 | ), |
569 | 569 | |
570 | 570 | 'payment-date' => array( |
571 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
571 | + 'title' => __('Payment Date', 'invoicing'), |
|
572 | 572 | 'class' => 'text-left' |
573 | 573 | ), |
574 | 574 | |
575 | 575 | 'invoice-status' => array( |
576 | - 'title' => __( 'Status', 'invoicing' ), |
|
576 | + 'title' => __('Status', 'invoicing'), |
|
577 | 577 | 'class' => 'text-center' |
578 | 578 | ), |
579 | 579 | |
580 | 580 | 'invoice-total' => array( |
581 | - 'title' => __( 'Total', 'invoicing' ), |
|
581 | + 'title' => __('Total', 'invoicing'), |
|
582 | 582 | 'class' => 'text-right' |
583 | 583 | ), |
584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | |
590 | 590 | ); |
591 | 591 | |
592 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
592 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -599,54 +599,54 @@ discard block |
||
599 | 599 | |
600 | 600 | // Find the invoice. |
601 | 601 | $invoice_id = getpaid_get_current_invoice_id(); |
602 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
602 | + $invoice = new WPInv_Invoice($invoice_id); |
|
603 | 603 | |
604 | 604 | // Abort if non was found. |
605 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
605 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
606 | 606 | |
607 | 607 | return aui()->alert( |
608 | 608 | array( |
609 | 609 | 'type' => 'warning', |
610 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
610 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
611 | 611 | ) |
612 | 612 | ); |
613 | 613 | |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Can the user view this invoice? |
617 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
617 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
618 | 618 | |
619 | 619 | return aui()->alert( |
620 | 620 | array( |
621 | 621 | 'type' => 'warning', |
622 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
622 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
623 | 623 | ) |
624 | 624 | ); |
625 | 625 | |
626 | 626 | } |
627 | 627 | |
628 | 628 | // Load the template. |
629 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
629 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
630 | 630 | |
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
634 | 634 | * Displays the invoice history. |
635 | 635 | */ |
636 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
636 | +function getpaid_invoice_history($user_id = 0) { |
|
637 | 637 | |
638 | 638 | // Ensure that we have a user id. |
639 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
639 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
640 | 640 | $user_id = get_current_user_id(); |
641 | 641 | } |
642 | 642 | |
643 | 643 | // View user id. |
644 | - if ( empty( $user_id ) ) { |
|
644 | + if (empty($user_id)) { |
|
645 | 645 | |
646 | 646 | return aui()->alert( |
647 | 647 | array( |
648 | 648 | 'type' => 'warning', |
649 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
649 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
650 | 650 | ) |
651 | 651 | ); |
652 | 652 | |
@@ -656,55 +656,55 @@ discard block |
||
656 | 656 | $invoices = wpinv_get_invoices( |
657 | 657 | |
658 | 658 | array( |
659 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
659 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
660 | 660 | 'user' => $user_id, |
661 | 661 | 'paginate' => true, |
662 | 662 | ) |
663 | 663 | |
664 | 664 | ); |
665 | 665 | |
666 | - if ( empty( $invoices->total ) ) { |
|
666 | + if (empty($invoices->total)) { |
|
667 | 667 | |
668 | 668 | return aui()->alert( |
669 | 669 | array( |
670 | 670 | 'type' => 'info', |
671 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
671 | + 'content' => __('No invoices found.', 'invoicing'), |
|
672 | 672 | ) |
673 | 673 | ); |
674 | 674 | |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Load the template. |
678 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
678 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
679 | 679 | |
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
683 | 683 | * Formats an invoice number given an invoice type. |
684 | 684 | */ |
685 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
685 | +function wpinv_format_invoice_number($number, $type = '') { |
|
686 | 686 | |
687 | 687 | // Allow other plugins to overide this. |
688 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
689 | - if ( null !== $check ) { |
|
688 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
689 | + if (null !== $check) { |
|
690 | 690 | return $check; |
691 | 691 | } |
692 | 692 | |
693 | 693 | // Ensure that we have a numeric number. |
694 | - if ( ! is_numeric( $number ) ) { |
|
694 | + if (!is_numeric($number)) { |
|
695 | 695 | return $number; |
696 | 696 | } |
697 | 697 | |
698 | 698 | // Format the number. |
699 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
700 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
701 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
702 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
699 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
700 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
701 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
702 | + $formatted_number = zeroise(absint($number), $padd); |
|
703 | 703 | |
704 | 704 | // Add the prefix and post fix. |
705 | 705 | $formatted_number = $prefix . $formatted_number . $postfix; |
706 | 706 | |
707 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
707 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -713,58 +713,58 @@ discard block |
||
713 | 713 | * @param string $type. |
714 | 714 | * @return int|null|bool |
715 | 715 | */ |
716 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
716 | +function wpinv_get_next_invoice_number($type = '') { |
|
717 | 717 | |
718 | 718 | // Allow plugins to overide this. |
719 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
720 | - if ( null !== $check ) { |
|
719 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
720 | + if (null !== $check) { |
|
721 | 721 | return $check; |
722 | 722 | } |
723 | 723 | |
724 | 724 | // Ensure sequential invoice numbers is active. |
725 | - if ( ! wpinv_sequential_number_active() ) { |
|
725 | + if (!wpinv_sequential_number_active()) { |
|
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | 729 | // Retrieve the current number and the start number. |
730 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
731 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
730 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
731 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
732 | 732 | |
733 | 733 | // Ensure that we are starting at a positive integer. |
734 | - $start = max( $start, 1 ); |
|
734 | + $start = max($start, 1); |
|
735 | 735 | |
736 | 736 | // If this is the first invoice, use the start number. |
737 | - $number = max( $start, $number ); |
|
737 | + $number = max($start, $number); |
|
738 | 738 | |
739 | 739 | // Format the invoice number. |
740 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
740 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
741 | 741 | |
742 | 742 | // Ensure that this number is unique. |
743 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
743 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
744 | 744 | |
745 | 745 | // We found a match. Nice. |
746 | - if ( empty( $invoice_id ) ) { |
|
747 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
748 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
746 | + if (empty($invoice_id)) { |
|
747 | + update_option('wpinv_last_invoice_number', $number); |
|
748 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
749 | 749 | } |
750 | 750 | |
751 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
752 | - return wpinv_get_next_invoice_number( $type ); |
|
751 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
752 | + return wpinv_get_next_invoice_number($type); |
|
753 | 753 | |
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
757 | 757 | * The prefix used for invoice paths. |
758 | 758 | */ |
759 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
760 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
759 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
760 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
761 | 761 | } |
762 | 762 | |
763 | -function wpinv_generate_post_name( $post_ID ) { |
|
764 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
765 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
763 | +function wpinv_generate_post_name($post_ID) { |
|
764 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
765 | + $post_name = sanitize_title($prefix . $post_ID); |
|
766 | 766 | |
767 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
767 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
774 | 774 | */ |
775 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
776 | - $invoice = new WPInv_Invoice( $invoice ); |
|
775 | +function wpinv_is_invoice_viewed($invoice) { |
|
776 | + $invoice = new WPInv_Invoice($invoice); |
|
777 | 777 | return (bool) $invoice->get_is_viewed(); |
778 | 778 | } |
779 | 779 | |
@@ -782,17 +782,17 @@ discard block |
||
782 | 782 | * |
783 | 783 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
784 | 784 | */ |
785 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
786 | - $invoice = new WPInv_Invoice( $invoice ); |
|
785 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
786 | + $invoice = new WPInv_Invoice($invoice); |
|
787 | 787 | |
788 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
789 | - $invoice->set_is_viewed( true ); |
|
788 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
789 | + $invoice->set_is_viewed(true); |
|
790 | 790 | $invoice->save(); |
791 | 791 | } |
792 | 792 | |
793 | 793 | } |
794 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
795 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
794 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
795 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
796 | 796 | |
797 | 797 | /** |
798 | 798 | * Processes an invoice refund. |
@@ -801,27 +801,27 @@ discard block |
||
801 | 801 | * @param array $status_transition |
802 | 802 | * @todo: descrease customer/store earnings |
803 | 803 | */ |
804 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
804 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
805 | 805 | |
806 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
806 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
807 | 807 | return; |
808 | 808 | } |
809 | 809 | |
810 | 810 | $discount_code = $invoice->get_discount_code(); |
811 | - if ( ! empty( $discount_code ) ) { |
|
812 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
811 | + if (!empty($discount_code)) { |
|
812 | + $discount = wpinv_get_discount_obj($discount_code); |
|
813 | 813 | |
814 | - if ( $discount->exists() ) { |
|
814 | + if ($discount->exists()) { |
|
815 | 815 | $discount->increase_usage( -1 ); |
816 | 816 | } |
817 | 817 | |
818 | 818 | } |
819 | 819 | |
820 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
821 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
822 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
820 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
821 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
822 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
823 | 823 | } |
824 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
824 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
825 | 825 | |
826 | 826 | |
827 | 827 | /** |
@@ -829,48 +829,48 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param int $invoice_id |
831 | 831 | */ |
832 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
832 | +function getpaid_process_invoice_payment($invoice_id) { |
|
833 | 833 | |
834 | 834 | // Fetch the invoice. |
835 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
835 | + $invoice = new WPInv_Invoice($invoice_id); |
|
836 | 836 | |
837 | 837 | // We only want to do this once. |
838 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
838 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 | |
842 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
842 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
843 | 843 | |
844 | 844 | // Fires when processing a payment. |
845 | - do_action( 'getpaid_process_payment', $invoice ); |
|
845 | + do_action('getpaid_process_payment', $invoice); |
|
846 | 846 | |
847 | 847 | // Fire an action for each invoice item. |
848 | - foreach( $invoice->get_items() as $item ) { |
|
849 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
848 | + foreach ($invoice->get_items() as $item) { |
|
849 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // Increase discount usage. |
853 | 853 | $discount_code = $invoice->get_discount_code(); |
854 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
855 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
854 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
855 | + $discount = wpinv_get_discount_obj($discount_code); |
|
856 | 856 | |
857 | - if ( $discount->exists() ) { |
|
857 | + if ($discount->exists()) { |
|
858 | 858 | $discount->increase_usage(); |
859 | 859 | } |
860 | 860 | |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Record reverse vat. |
864 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
864 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
865 | 865 | |
866 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
867 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
866 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
867 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | } |
871 | 871 | |
872 | 872 | } |
873 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
873 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
874 | 874 | |
875 | 875 | /** |
876 | 876 | * Returns an array of invoice item columns |
@@ -878,13 +878,13 @@ discard block |
||
878 | 878 | * @param int|WPInv_Invoice $invoice |
879 | 879 | * @return array |
880 | 880 | */ |
881 | -function getpaid_invoice_item_columns( $invoice ) { |
|
881 | +function getpaid_invoice_item_columns($invoice) { |
|
882 | 882 | |
883 | 883 | // Prepare the invoice. |
884 | - $invoice = new WPInv_Invoice( $invoice ); |
|
884 | + $invoice = new WPInv_Invoice($invoice); |
|
885 | 885 | |
886 | 886 | // Abort if there is no invoice. |
887 | - if ( 0 == $invoice->get_id() ) { |
|
887 | + if (0 == $invoice->get_id()) { |
|
888 | 888 | return array(); |
889 | 889 | } |
890 | 890 | |
@@ -892,47 +892,47 @@ discard block |
||
892 | 892 | $columns = apply_filters( |
893 | 893 | 'getpaid_invoice_item_columns', |
894 | 894 | array( |
895 | - 'name' => __( 'Item', 'invoicing' ), |
|
896 | - 'price' => __( 'Price', 'invoicing' ), |
|
897 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
898 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
895 | + 'name' => __('Item', 'invoicing'), |
|
896 | + 'price' => __('Price', 'invoicing'), |
|
897 | + 'quantity' => __('Quantity', 'invoicing'), |
|
898 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
899 | 899 | ), |
900 | 900 | $invoice |
901 | 901 | ); |
902 | 902 | |
903 | 903 | // Quantities. |
904 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
904 | + if (isset($columns['quantity'])) { |
|
905 | 905 | |
906 | - if ( 'hours' == $invoice->get_template() ) { |
|
907 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
906 | + if ('hours' == $invoice->get_template()) { |
|
907 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
908 | 908 | } |
909 | 909 | |
910 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
911 | - unset( $columns[ 'quantity' ] ); |
|
910 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
911 | + unset($columns['quantity']); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | 916 | |
917 | 917 | // Price. |
918 | - if ( isset( $columns[ 'price' ] ) ) { |
|
918 | + if (isset($columns['price'])) { |
|
919 | 919 | |
920 | - if ( 'amount' == $invoice->get_template() ) { |
|
921 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
920 | + if ('amount' == $invoice->get_template()) { |
|
921 | + $columns['price'] = __('Amount', 'invoicing'); |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( 'hours' == $invoice->get_template() ) { |
|
925 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
924 | + if ('hours' == $invoice->get_template()) { |
|
925 | + $columns['price'] = __('Rate', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | } |
929 | 929 | |
930 | 930 | |
931 | 931 | // Sub total. |
932 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
932 | + if (isset($columns['subtotal'])) { |
|
933 | 933 | |
934 | - if ( 'amount' == $invoice->get_template() ) { |
|
935 | - unset( $columns[ 'subtotal' ] ); |
|
934 | + if ('amount' == $invoice->get_template()) { |
|
935 | + unset($columns['subtotal']); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | } |
@@ -946,30 +946,30 @@ discard block |
||
946 | 946 | * @param int|WPInv_Invoice $invoice |
947 | 947 | * @return array |
948 | 948 | */ |
949 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
949 | +function getpaid_invoice_totals_rows($invoice) { |
|
950 | 950 | |
951 | 951 | // Prepare the invoice. |
952 | - $invoice = new WPInv_Invoice( $invoice ); |
|
952 | + $invoice = new WPInv_Invoice($invoice); |
|
953 | 953 | |
954 | 954 | // Abort if there is no invoice. |
955 | - if ( 0 == $invoice->get_id() ) { |
|
955 | + if (0 == $invoice->get_id()) { |
|
956 | 956 | return array(); |
957 | 957 | } |
958 | 958 | |
959 | 959 | $totals = apply_filters( |
960 | 960 | 'getpaid_invoice_totals_rows', |
961 | 961 | array( |
962 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
963 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
964 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
965 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
966 | - 'total' => __( 'Total', 'invoicing' ), |
|
962 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
963 | + 'tax' => __('Tax', 'invoicing'), |
|
964 | + 'fee' => __('Fee', 'invoicing'), |
|
965 | + 'discount' => __('Discount', 'invoicing'), |
|
966 | + 'total' => __('Total', 'invoicing'), |
|
967 | 967 | ), |
968 | 968 | $invoice |
969 | 969 | ); |
970 | 970 | |
971 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
972 | - unset( $totals['tax'] ); |
|
971 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
972 | + unset($totals['tax']); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | return $totals; |
@@ -980,46 +980,46 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @param WPInv_Invoice $invoice |
982 | 982 | */ |
983 | -function getpaid_new_invoice( $invoice ) { |
|
983 | +function getpaid_new_invoice($invoice) { |
|
984 | 984 | |
985 | - if ( ! $invoice->get_status() ) { |
|
985 | + if (!$invoice->get_status()) { |
|
986 | 986 | return; |
987 | 987 | } |
988 | 988 | |
989 | 989 | // Add an invoice created note. |
990 | 990 | $invoice->add_note( |
991 | 991 | wp_sprintf( |
992 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
993 | - wpinv_status_nicename( $invoice->get_status() ) |
|
992 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
993 | + wpinv_status_nicename($invoice->get_status()) |
|
994 | 994 | ) |
995 | 995 | ); |
996 | 996 | |
997 | 997 | } |
998 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
998 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
999 | 999 | |
1000 | 1000 | /** |
1001 | 1001 | * This function updates invoice caches. |
1002 | 1002 | * |
1003 | 1003 | * @param WPInv_Invoice $invoice |
1004 | 1004 | */ |
1005 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1005 | +function getpaid_update_invoice_caches($invoice) { |
|
1006 | 1006 | |
1007 | 1007 | // Cache invoice number. |
1008 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1008 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1009 | 1009 | |
1010 | 1010 | // Cache invoice key. |
1011 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1011 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1012 | 1012 | |
1013 | 1013 | // (Maybe) cache transaction id. |
1014 | 1014 | $transaction_id = $invoice->get_transaction_id(); |
1015 | 1015 | |
1016 | - if ( ! empty( $transaction_id ) ) { |
|
1017 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1016 | + if (!empty($transaction_id)) { |
|
1017 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | } |
1021 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1022 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1021 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1022 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1023 | 1023 | |
1024 | 1024 | /** |
1025 | 1025 | * Duplicates an invoice. |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1030 | 1030 | * @return WPInv_Invoice The new invoice. |
1031 | 1031 | */ |
1032 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1032 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1033 | 1033 | |
1034 | 1034 | // Create the new invoice. |
1035 | 1035 | $invoice = new WPInv_Invoice(); |
@@ -1090,126 +1090,126 @@ discard block |
||
1090 | 1090 | * @param WPInv_Invoice $invoice |
1091 | 1091 | * @return array |
1092 | 1092 | */ |
1093 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1093 | +function getpaid_get_invoice_meta($invoice) { |
|
1094 | 1094 | |
1095 | 1095 | // Load the invoice meta. |
1096 | 1096 | $meta = array( |
1097 | 1097 | |
1098 | 1098 | 'number' => array( |
1099 | 1099 | 'label' => sprintf( |
1100 | - __( '%s Number', 'invoicing' ), |
|
1101 | - ucfirst( $invoice->get_type() ) |
|
1100 | + __('%s Number', 'invoicing'), |
|
1101 | + ucfirst($invoice->get_type()) |
|
1102 | 1102 | ), |
1103 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1103 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1104 | 1104 | ), |
1105 | 1105 | |
1106 | 1106 | 'status' => array( |
1107 | 1107 | 'label' => sprintf( |
1108 | - __( '%s Status', 'invoicing' ), |
|
1109 | - ucfirst( $invoice->get_type() ) |
|
1108 | + __('%s Status', 'invoicing'), |
|
1109 | + ucfirst($invoice->get_type()) |
|
1110 | 1110 | ), |
1111 | 1111 | 'value' => $invoice->get_status_label_html(), |
1112 | 1112 | ), |
1113 | 1113 | |
1114 | 1114 | 'date' => array( |
1115 | 1115 | 'label' => sprintf( |
1116 | - __( '%s Date', 'invoicing' ), |
|
1117 | - ucfirst( $invoice->get_type() ) |
|
1116 | + __('%s Date', 'invoicing'), |
|
1117 | + ucfirst($invoice->get_type()) |
|
1118 | 1118 | ), |
1119 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1119 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1120 | 1120 | ), |
1121 | 1121 | |
1122 | 1122 | 'date_paid' => array( |
1123 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1124 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1123 | + 'label' => __('Paid On', 'invoicing'), |
|
1124 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1125 | 1125 | ), |
1126 | 1126 | |
1127 | 1127 | 'gateway' => array( |
1128 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1129 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1128 | + 'label' => __('Payment Method', 'invoicing'), |
|
1129 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1130 | 1130 | ), |
1131 | 1131 | |
1132 | 1132 | 'transaction_id' => array( |
1133 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1134 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1133 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1134 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1135 | 1135 | ), |
1136 | 1136 | |
1137 | 1137 | 'due_date' => array( |
1138 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1139 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1138 | + 'label' => __('Due Date', 'invoicing'), |
|
1139 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1140 | 1140 | ), |
1141 | 1141 | |
1142 | 1142 | 'vat_number' => array( |
1143 | 1143 | 'label' => sprintf( |
1144 | - __( '%s Number', 'invoicing' ), |
|
1144 | + __('%s Number', 'invoicing'), |
|
1145 | 1145 | getpaid_tax()->get_vat_name() |
1146 | 1146 | ), |
1147 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1147 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1148 | 1148 | ), |
1149 | 1149 | |
1150 | 1150 | ); |
1151 | 1151 | |
1152 | 1152 | // If it is not paid, remove the date of payment. |
1153 | - if ( ! $invoice->is_paid() ) { |
|
1154 | - unset( $meta[ 'date_paid' ] ); |
|
1155 | - unset( $meta[ 'transaction_id' ] ); |
|
1153 | + if (!$invoice->is_paid()) { |
|
1154 | + unset($meta['date_paid']); |
|
1155 | + unset($meta['transaction_id']); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1159 | - unset( $meta[ 'gateway' ] ); |
|
1158 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1159 | + unset($meta['gateway']); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | // Only display the due date if due dates are enabled. |
1163 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1164 | - unset( $meta[ 'due_date' ] ); |
|
1163 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1164 | + unset($meta['due_date']); |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | // Only display the vat number if taxes are enabled. |
1168 | - if ( ! wpinv_use_taxes() ) { |
|
1169 | - unset( $meta[ 'vat_number' ] ); |
|
1168 | + if (!wpinv_use_taxes()) { |
|
1169 | + unset($meta['vat_number']); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | - if ( $invoice->is_recurring() ) { |
|
1172 | + if ($invoice->is_recurring()) { |
|
1173 | 1173 | |
1174 | 1174 | // Link to the parent invoice. |
1175 | - if ( $invoice->is_renewal() ) { |
|
1175 | + if ($invoice->is_renewal()) { |
|
1176 | 1176 | |
1177 | - $meta[ 'parent' ] = array( |
|
1177 | + $meta['parent'] = array( |
|
1178 | 1178 | |
1179 | 1179 | 'label' => sprintf( |
1180 | - __( 'Parent %s', 'invoicing' ), |
|
1181 | - ucfirst( $invoice->get_type() ) |
|
1180 | + __('Parent %s', 'invoicing'), |
|
1181 | + ucfirst($invoice->get_type()) |
|
1182 | 1182 | ), |
1183 | 1183 | |
1184 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1184 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1185 | 1185 | |
1186 | 1186 | ); |
1187 | 1187 | |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1190 | + $subscription = wpinv_get_subscription($invoice); |
|
1191 | 1191 | |
1192 | - if ( ! empty ( $subscription ) ) { |
|
1192 | + if (!empty ($subscription)) { |
|
1193 | 1193 | |
1194 | 1194 | // Display the renewal date. |
1195 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1195 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1196 | 1196 | |
1197 | - $meta[ 'renewal_date' ] = array( |
|
1197 | + $meta['renewal_date'] = array( |
|
1198 | 1198 | |
1199 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1200 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1199 | + 'label' => __('Renews On', 'invoicing'), |
|
1200 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1201 | 1201 | |
1202 | 1202 | ); |
1203 | 1203 | |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - if ( $invoice->is_parent() ) { |
|
1206 | + if ($invoice->is_parent()) { |
|
1207 | 1207 | |
1208 | 1208 | // Display the recurring amount. |
1209 | - $meta[ 'recurring_total' ] = array( |
|
1209 | + $meta['recurring_total'] = array( |
|
1210 | 1210 | |
1211 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1212 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
1211 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1212 | + 'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
1213 | 1213 | |
1214 | 1214 | ); |
1215 | 1215 | |
@@ -1219,15 +1219,15 @@ discard block |
||
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | // Add the invoice total to the meta. |
1222 | - $meta[ 'invoice_total' ] = array( |
|
1222 | + $meta['invoice_total'] = array( |
|
1223 | 1223 | |
1224 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1225 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
1224 | + 'label' => __('Total Amount', 'invoicing'), |
|
1225 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
1226 | 1226 | |
1227 | 1227 | ); |
1228 | 1228 | |
1229 | 1229 | // Provide a way for third party plugins to filter the meta. |
1230 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1230 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1231 | 1231 | |
1232 | 1232 | return $meta; |
1233 | 1233 |
@@ -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 | * This function is responsible for sending emails. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
35 | + public function send($to, $subject, $email, $attachments = array()) { |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Allow to filter data on per-email basis. |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | $data = apply_filters( |
41 | 41 | 'getpaid_email_data', |
42 | 42 | array( |
43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
45 | 45 | 'email' => $email, |
46 | 46 | 'headers' => $this->get_headers(), |
47 | 47 | 'attachments' => $attachments, |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | - $data = (array) wp_unslash( $data ); |
|
53 | + $data = (array) wp_unslash($data); |
|
54 | 54 | |
55 | 55 | // Cache it. |
56 | 56 | $this->wp_mail_data = $data; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | - foreach ( $this->wp_mail_data['to'] as $to ) { |
|
64 | - $result = $this->_send( $to, $data ); |
|
63 | + foreach ($this->wp_mail_data['to'] as $to) { |
|
64 | + $result = $this->_send($to, $data); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Remove our hooks. |
@@ -82,24 +82,24 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - protected function _send( $to, $data ) { |
|
85 | + protected function _send($to, $data) { |
|
86 | 86 | |
87 | 87 | // Prepare the sending function. |
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
88 | + $sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail'); |
|
89 | 89 | |
90 | 90 | // Send the actual email. |
91 | 91 | $result = call_user_func( |
92 | 92 | $sending_function, |
93 | 93 | $to, |
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
94 | + html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')), |
|
95 | 95 | $data['email'], |
96 | 96 | $data['headers'], |
97 | 97 | $data['attachments'] |
98 | 98 | ); |
99 | 99 | |
100 | - if ( ! $result ) { |
|
101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
100 | + if (!$result) { |
|
101 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']); |
|
102 | + wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $result; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $name = $this->get_from_name(); |
114 | 114 | $reply_to = $this->get_reply_to(); |
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
115 | + $headers = array("Reply-To:$name <$reply_to>"); |
|
116 | 116 | |
117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
117 | + return apply_filters('getpaid_email_headers', $headers, $this); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function before_sending() { |
127 | 127 | |
128 | - do_action( 'getpaid_before_send_email', $this ); |
|
129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
128 | + do_action('getpaid_before_send_email', $this); |
|
129 | + add_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
130 | + add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
131 | + add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
132 | + add_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function get_from_name() { |
140 | 140 | |
141 | - $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
|
141 | + $from_name = wpinv_get_option('email_from_name', get_bloginfo('name')); |
|
142 | 142 | |
143 | - if ( empty( $from_name ) ) { |
|
144 | - $from_name = get_bloginfo( 'name' ); |
|
143 | + if (empty($from_name)) { |
|
144 | + $from_name = get_bloginfo('name'); |
|
145 | 145 | } |
146 | 146 | |
147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
147 | + return wp_specialchars_decode($from_name, ENT_QUOTES); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function get_from_address() { |
154 | 154 | |
155 | - $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
|
155 | + $from_address = wpinv_get_option('email_from', $this->default_from_address()); |
|
156 | 156 | |
157 | - if ( ! is_email( $from_address ) ) { |
|
158 | - $from_address = $this->default_from_address(); |
|
157 | + if (!is_email($from_address)) { |
|
158 | + $from_address = $this->default_from_address(); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $from_address; |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | public function default_from_address() { |
175 | 175 | |
176 | 176 | // Get the site domain and get rid of www. |
177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | - $sitename = substr( $sitename, 4 ); |
|
177 | + $sitename = strtolower($_SERVER['SERVER_NAME']); |
|
178 | + if (substr($sitename, 0, 4) == 'www.') { |
|
179 | + $sitename = substr($sitename, 4); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $from_email = 'wordpress@' . $sitename; |
183 | 183 | |
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
184 | + return apply_filters('getpaid_default_from_address', $from_email); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | |
196 | 196 | $reply_to = wpinv_get_admin_email(); |
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
198 | + if (!is_email($reply_to)) { |
|
199 | + $reply_to = get_option('admin_email'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $reply_to; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | */ |
209 | 209 | public function get_content_type() { |
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
210 | + return apply_filters('getpaid_email_content_type', 'text/html', $this); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return array wp_mail_data. |
217 | 217 | */ |
218 | - public function ensure_email_content( $args ) { |
|
218 | + public function ensure_email_content($args) { |
|
219 | 219 | $args['message'] = $this->wp_mail_data['email']; |
220 | 220 | return $args; |
221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function after_sending() { |
228 | 228 | |
229 | - do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
|
230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 ); |
|
229 | + do_action('getpaid_after_send_email', $this->wp_mail_data); |
|
230 | + remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
231 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
232 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
233 | + remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000000); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = esc_attr( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = esc_attr($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ); |
|
244 | + return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,134 +249,134 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array |
251 | 251 | */ |
252 | -function wpinv_settings_sanitize( $input = array() ) { |
|
252 | +function wpinv_settings_sanitize($input = array()) { |
|
253 | 253 | |
254 | 254 | $wpinv_options = wpinv_get_options(); |
255 | 255 | |
256 | - if ( empty( wp_get_raw_referer() ) ) { |
|
256 | + if (empty(wp_get_raw_referer())) { |
|
257 | 257 | return $input; |
258 | 258 | } |
259 | 259 | |
260 | - wp_parse_str( wp_get_raw_referer(), $referrer ); |
|
260 | + wp_parse_str(wp_get_raw_referer(), $referrer); |
|
261 | 261 | |
262 | 262 | $settings = wpinv_get_registered_settings(); |
263 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
264 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
263 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
264 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
265 | 265 | |
266 | 266 | $input = $input ? $input : array(); |
267 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
268 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
267 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
268 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
269 | 269 | |
270 | 270 | // Loop through each setting being saved and pass it through a sanitization filter |
271 | - foreach ( $input as $key => $value ) { |
|
271 | + foreach ($input as $key => $value) { |
|
272 | 272 | |
273 | 273 | // Get the setting type (checkbox, select, etc) |
274 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
274 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
275 | 275 | |
276 | - if ( $type ) { |
|
276 | + if ($type) { |
|
277 | 277 | // Field type specific filter |
278 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
278 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // General filter |
282 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
282 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // Loop through the whitelist and unset any that are empty for the tab being saved |
286 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
287 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
286 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
287 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
288 | 288 | |
289 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
289 | + $found_settings = array_merge($main_settings, $section_settings); |
|
290 | 290 | |
291 | - if ( ! empty( $found_settings ) ) { |
|
292 | - foreach ( $found_settings as $key => $value ) { |
|
291 | + if (!empty($found_settings)) { |
|
292 | + foreach ($found_settings as $key => $value) { |
|
293 | 293 | |
294 | 294 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
295 | - if ( is_numeric( $key ) ) { |
|
295 | + if (is_numeric($key)) { |
|
296 | 296 | $key = $value['id']; |
297 | 297 | } |
298 | 298 | |
299 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
300 | - unset( $wpinv_options[ $key ] ); |
|
299 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
300 | + unset($wpinv_options[$key]); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | 305 | // Merge our new settings with the existing |
306 | - $output = array_merge( $wpinv_options, $input ); |
|
306 | + $output = array_merge($wpinv_options, $input); |
|
307 | 307 | |
308 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
308 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
309 | 309 | |
310 | 310 | return $output; |
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
313 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
314 | 314 | |
315 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
315 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
316 | 316 | return $input; |
317 | 317 | } |
318 | 318 | |
319 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
319 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
320 | 320 | // Shows an admin notice about upgrading previous order numbers |
321 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
321 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | return $input; |
325 | 325 | } |
326 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
326 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
327 | 327 | |
328 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
329 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
328 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
329 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
330 | 330 | return $input; |
331 | 331 | } |
332 | 332 | |
333 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
333 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
334 | 334 | |
335 | 335 | $tax_rates = array(); |
336 | 336 | |
337 | - if ( !empty( $new_rates ) ) { |
|
338 | - foreach ( $new_rates as $rate ) { |
|
339 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
337 | + if (!empty($new_rates)) { |
|
338 | + foreach ($new_rates as $rate) { |
|
339 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | |
343 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
343 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
344 | 344 | |
345 | 345 | $tax_rates[] = $rate; |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
349 | + update_option('wpinv_tax_rates', $tax_rates); |
|
350 | 350 | |
351 | 351 | return $input; |
352 | 352 | } |
353 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
353 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
354 | 354 | |
355 | -function wpinv_sanitize_text_field( $input ) { |
|
356 | - return trim( $input ); |
|
355 | +function wpinv_sanitize_text_field($input) { |
|
356 | + return trim($input); |
|
357 | 357 | } |
358 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
358 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
359 | 359 | |
360 | 360 | function wpinv_get_settings_tabs() { |
361 | 361 | $tabs = array(); |
362 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
363 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
364 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
365 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
366 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
367 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
368 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
369 | - |
|
370 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
362 | + $tabs['general'] = __('General', 'invoicing'); |
|
363 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
364 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
365 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
366 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
367 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
368 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
369 | + |
|
370 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
371 | 371 | } |
372 | 372 | |
373 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
373 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
374 | 374 | $tabs = false; |
375 | 375 | $sections = wpinv_get_registered_settings_sections(); |
376 | 376 | |
377 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
378 | - $tabs = $sections[ $tab ]; |
|
379 | - } else if ( $tab ) { |
|
377 | + if ($tab && !empty($sections[$tab])) { |
|
378 | + $tabs = $sections[$tab]; |
|
379 | + } else if ($tab) { |
|
380 | 380 | $tabs = false; |
381 | 381 | } |
382 | 382 | |
@@ -386,150 +386,150 @@ discard block |
||
386 | 386 | function wpinv_get_registered_settings_sections() { |
387 | 387 | static $sections = false; |
388 | 388 | |
389 | - if ( false !== $sections ) { |
|
389 | + if (false !== $sections) { |
|
390 | 390 | return $sections; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $sections = array( |
394 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
395 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
396 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
397 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
398 | - ) ), |
|
399 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
400 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
401 | - ) ), |
|
402 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
403 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
404 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
405 | - ) ), |
|
406 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
407 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
408 | - ) ), |
|
409 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
410 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
411 | - ) ), |
|
412 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
413 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
414 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
415 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
416 | - ) ), |
|
417 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
418 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
419 | - ) ), |
|
394 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
395 | + 'main' => __('General Settings', 'invoicing'), |
|
396 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
397 | + 'labels' => __('Label Texts', 'invoicing'), |
|
398 | + )), |
|
399 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
400 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
401 | + )), |
|
402 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
403 | + 'main' => __('Tax Settings', 'invoicing'), |
|
404 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
405 | + )), |
|
406 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
407 | + 'main' => __('Email Settings', 'invoicing'), |
|
408 | + )), |
|
409 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
410 | + 'main' => __('Privacy policy', 'invoicing'), |
|
411 | + )), |
|
412 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
413 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
414 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
415 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
416 | + )), |
|
417 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
418 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
419 | + )), |
|
420 | 420 | ); |
421 | 421 | |
422 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
422 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
423 | 423 | |
424 | 424 | return $sections; |
425 | 425 | } |
426 | 426 | |
427 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
427 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
428 | 428 | $pages_options = array(); |
429 | 429 | |
430 | - if( $default_label !== NULL && $default_label !== false ) { |
|
431 | - $pages_options = array( '' => $default_label ); // Blank option |
|
430 | + if ($default_label !== NULL && $default_label !== false) { |
|
431 | + $pages_options = array('' => $default_label); // Blank option |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $pages = get_pages(); |
435 | - if ( $pages ) { |
|
436 | - foreach ( $pages as $page ) { |
|
435 | + if ($pages) { |
|
436 | + foreach ($pages as $page) { |
|
437 | 437 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
438 | - $pages_options[ $page->ID ] = $title; |
|
438 | + $pages_options[$page->ID] = $title; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
442 | 442 | return $pages_options; |
443 | 443 | } |
444 | 444 | |
445 | -function wpinv_header_callback( $args ) { |
|
446 | - if ( !empty( $args['desc'] ) ) { |
|
445 | +function wpinv_header_callback($args) { |
|
446 | + if (!empty($args['desc'])) { |
|
447 | 447 | echo $args['desc']; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | -function wpinv_hidden_callback( $args ) { |
|
451 | +function wpinv_hidden_callback($args) { |
|
452 | 452 | global $wpinv_options; |
453 | 453 | |
454 | - if ( isset( $args['set_value'] ) ) { |
|
454 | + if (isset($args['set_value'])) { |
|
455 | 455 | $value = $args['set_value']; |
456 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
457 | - $value = $wpinv_options[ $args['id'] ]; |
|
456 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
457 | + $value = $wpinv_options[$args['id']]; |
|
458 | 458 | } else { |
459 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
459 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
460 | 460 | } |
461 | 461 | |
462 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
462 | + if (isset($args['faux']) && true === $args['faux']) { |
|
463 | 463 | $args['readonly'] = true; |
464 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
464 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
465 | 465 | $name = ''; |
466 | 466 | } else { |
467 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
467 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
468 | 468 | } |
469 | 469 | |
470 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
470 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
471 | 471 | |
472 | 472 | echo $html; |
473 | 473 | } |
474 | 474 | |
475 | -function wpinv_checkbox_callback( $args ) { |
|
475 | +function wpinv_checkbox_callback($args) { |
|
476 | 476 | global $wpinv_options; |
477 | 477 | |
478 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
478 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
479 | 479 | |
480 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
480 | + if (isset($args['faux']) && true === $args['faux']) { |
|
481 | 481 | $name = ''; |
482 | 482 | } else { |
483 | 483 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
484 | 484 | } |
485 | 485 | |
486 | - $std = isset( $args['std'] ) ? $args['std'] : 0; |
|
487 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
488 | - $checked = checked( empty( $value ), false, false ); |
|
486 | + $std = isset($args['std']) ? $args['std'] : 0; |
|
487 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
488 | + $checked = checked(empty($value), false, false); |
|
489 | 489 | |
490 | 490 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
491 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
491 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
492 | 492 | |
493 | 493 | echo $html; |
494 | 494 | } |
495 | 495 | |
496 | -function wpinv_multicheck_callback( $args ) { |
|
496 | +function wpinv_multicheck_callback($args) { |
|
497 | 497 | global $wpinv_options; |
498 | 498 | |
499 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
500 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
499 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
500 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
501 | 501 | |
502 | - if ( ! empty( $args['options'] ) ) { |
|
502 | + if (!empty($args['options'])) { |
|
503 | 503 | |
504 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
505 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
504 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
505 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
506 | 506 | |
507 | 507 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
508 | - foreach( $args['options'] as $key => $option ): |
|
509 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
510 | - if ( in_array( $sanitize_key, $value ) ) { |
|
508 | + foreach ($args['options'] as $key => $option): |
|
509 | + $sanitize_key = wpinv_sanitize_key($key); |
|
510 | + if (in_array($sanitize_key, $value)) { |
|
511 | 511 | $enabled = $sanitize_key; |
512 | 512 | } else { |
513 | 513 | $enabled = NULL; |
514 | 514 | } |
515 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
516 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
515 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
516 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
517 | 517 | endforeach; |
518 | 518 | echo '</div>'; |
519 | 519 | echo '<p class="description">' . $args['desc'] . '</p>'; |
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | -function wpinv_payment_icons_callback( $args ) { |
|
523 | +function wpinv_payment_icons_callback($args) { |
|
524 | 524 | global $wpinv_options; |
525 | 525 | |
526 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
526 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
527 | 527 | |
528 | - if ( ! empty( $args['options'] ) ) { |
|
529 | - foreach( $args['options'] as $key => $option ) { |
|
530 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
528 | + if (!empty($args['options'])) { |
|
529 | + foreach ($args['options'] as $key => $option) { |
|
530 | + $sanitize_key = wpinv_sanitize_key($key); |
|
531 | 531 | |
532 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
532 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
533 | 533 | $enabled = $option; |
534 | 534 | } else { |
535 | 535 | $enabled = NULL; |
@@ -537,197 +537,197 @@ discard block |
||
537 | 537 | |
538 | 538 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
539 | 539 | |
540 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
540 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
541 | 541 | |
542 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
543 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
542 | + if (wpinv_string_is_image_url($key)) { |
|
543 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
544 | 544 | } else { |
545 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
545 | + $card = strtolower(str_replace(' ', '', $option)); |
|
546 | 546 | |
547 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
548 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
547 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
548 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
549 | 549 | } else { |
550 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
550 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
551 | 551 | $content_dir = WP_CONTENT_DIR; |
552 | 552 | |
553 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
553 | + if (function_exists('wp_normalize_path')) { |
|
554 | 554 | // Replaces backslashes with forward slashes for Windows systems |
555 | - $image = wp_normalize_path( $image ); |
|
556 | - $content_dir = wp_normalize_path( $content_dir ); |
|
555 | + $image = wp_normalize_path($image); |
|
556 | + $content_dir = wp_normalize_path($content_dir); |
|
557 | 557 | } |
558 | 558 | |
559 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
559 | + $image = str_replace($content_dir, content_url(), $image); |
|
560 | 560 | } |
561 | 561 | |
562 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
562 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | 563 | } |
564 | 564 | echo $option . '</label>'; |
565 | 565 | } |
566 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
566 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | -function wpinv_radio_callback( $args ) { |
|
570 | +function wpinv_radio_callback($args) { |
|
571 | 571 | global $wpinv_options; |
572 | 572 | |
573 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
573 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
574 | 574 | |
575 | - foreach ( $args['options'] as $key => $option ) : |
|
576 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
575 | + foreach ($args['options'] as $key => $option) : |
|
576 | + $sanitize_key = wpinv_sanitize_key($key); |
|
577 | 577 | |
578 | 578 | $checked = false; |
579 | 579 | |
580 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
580 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
581 | 581 | $checked = true; |
582 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
582 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
583 | 583 | $checked = true; |
584 | 584 | |
585 | 585 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
586 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
586 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
587 | 587 | endforeach; |
588 | 588 | |
589 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
589 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
590 | 590 | } |
591 | 591 | |
592 | -function wpinv_gateways_callback( $args ) { |
|
592 | +function wpinv_gateways_callback($args) { |
|
593 | 593 | global $wpinv_options; |
594 | 594 | |
595 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
595 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
596 | 596 | |
597 | - foreach ( $args['options'] as $key => $option ) : |
|
598 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
597 | + foreach ($args['options'] as $key => $option) : |
|
598 | + $sanitize_key = wpinv_sanitize_key($key); |
|
599 | 599 | |
600 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
600 | + if (isset($wpinv_options['gateways'][$key])) |
|
601 | 601 | $enabled = '1'; |
602 | 602 | else |
603 | 603 | $enabled = null; |
604 | 604 | |
605 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
606 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
605 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
606 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
607 | 607 | endforeach; |
608 | 608 | } |
609 | 609 | |
610 | 610 | function wpinv_gateway_select_callback($args) { |
611 | 611 | global $wpinv_options; |
612 | 612 | |
613 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
614 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
613 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
614 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
615 | 615 | |
616 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
616 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
617 | 617 | |
618 | - foreach ( $args['options'] as $key => $option ) : |
|
619 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
620 | - $selected = selected( $key, $args['selected'], false ); |
|
618 | + foreach ($args['options'] as $key => $option) : |
|
619 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
620 | + $selected = selected($key, $args['selected'], false); |
|
621 | 621 | } else { |
622 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
622 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
623 | 623 | } |
624 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
624 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
625 | 625 | endforeach; |
626 | 626 | |
627 | 627 | echo '</select>'; |
628 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
628 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_text_callback( $args ) { |
|
631 | +function wpinv_text_callback($args) { |
|
632 | 632 | global $wpinv_options; |
633 | 633 | |
634 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
634 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
635 | 635 | |
636 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
637 | - $value = $wpinv_options[ $args['id'] ]; |
|
636 | + if (isset($wpinv_options[$args['id']])) { |
|
637 | + $value = $wpinv_options[$args['id']]; |
|
638 | 638 | } else { |
639 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
639 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
640 | 640 | } |
641 | 641 | |
642 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
642 | + if (isset($args['faux']) && true === $args['faux']) { |
|
643 | 643 | $args['readonly'] = true; |
644 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
644 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
645 | 645 | $name = ''; |
646 | 646 | } else { |
647 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
647 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
648 | 648 | } |
649 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
649 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
650 | 650 | |
651 | 651 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
652 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
653 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
654 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
652 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
653 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
654 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
655 | 655 | |
656 | 656 | echo $html; |
657 | 657 | } |
658 | 658 | |
659 | -function wpinv_number_callback( $args ) { |
|
659 | +function wpinv_number_callback($args) { |
|
660 | 660 | global $wpinv_options; |
661 | 661 | |
662 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
662 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
663 | 663 | |
664 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
665 | - $value = $wpinv_options[ $args['id'] ]; |
|
664 | + if (isset($wpinv_options[$args['id']])) { |
|
665 | + $value = $wpinv_options[$args['id']]; |
|
666 | 666 | } else { |
667 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
667 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
668 | 668 | } |
669 | 669 | |
670 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
670 | + if (isset($args['faux']) && true === $args['faux']) { |
|
671 | 671 | $args['readonly'] = true; |
672 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
672 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
673 | 673 | $name = ''; |
674 | 674 | } else { |
675 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
675 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
676 | 676 | } |
677 | 677 | |
678 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
679 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
680 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
681 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
678 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
679 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
680 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
681 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
682 | 682 | |
683 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
684 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
685 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
683 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
684 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
685 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
686 | 686 | |
687 | 687 | echo $html; |
688 | 688 | } |
689 | 689 | |
690 | -function wpinv_textarea_callback( $args ) { |
|
690 | +function wpinv_textarea_callback($args) { |
|
691 | 691 | global $wpinv_options; |
692 | 692 | |
693 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
693 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
694 | 694 | |
695 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
696 | - $value = $wpinv_options[ $args['id'] ]; |
|
695 | + if (isset($wpinv_options[$args['id']])) { |
|
696 | + $value = $wpinv_options[$args['id']]; |
|
697 | 697 | } else { |
698 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
698 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
699 | 699 | } |
700 | 700 | |
701 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
702 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
701 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
702 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
703 | 703 | |
704 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
705 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
704 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
705 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
706 | 706 | |
707 | 707 | echo $html; |
708 | 708 | } |
709 | 709 | |
710 | -function wpinv_password_callback( $args ) { |
|
710 | +function wpinv_password_callback($args) { |
|
711 | 711 | global $wpinv_options; |
712 | 712 | |
713 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
713 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
714 | 714 | |
715 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
716 | - $value = $wpinv_options[ $args['id'] ]; |
|
715 | + if (isset($wpinv_options[$args['id']])) { |
|
716 | + $value = $wpinv_options[$args['id']]; |
|
717 | 717 | } else { |
718 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
718 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
719 | 719 | } |
720 | 720 | |
721 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
722 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
723 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
721 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
722 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
723 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
724 | 724 | |
725 | 725 | echo $html; |
726 | 726 | } |
727 | 727 | |
728 | 728 | function wpinv_missing_callback($args) { |
729 | 729 | printf( |
730 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
730 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
731 | 731 | '<strong>' . $args['id'] . '</strong>' |
732 | 732 | ); |
733 | 733 | } |
@@ -735,134 +735,134 @@ discard block |
||
735 | 735 | function wpinv_select_callback($args) { |
736 | 736 | global $wpinv_options; |
737 | 737 | |
738 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
738 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
739 | 739 | |
740 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
741 | - $value = $wpinv_options[ $args['id'] ]; |
|
740 | + if (isset($wpinv_options[$args['id']])) { |
|
741 | + $value = $wpinv_options[$args['id']]; |
|
742 | 742 | } else { |
743 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
743 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
746 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
747 | 747 | $value = $args['selected']; |
748 | 748 | } |
749 | 749 | |
750 | - if ( isset( $args['placeholder'] ) ) { |
|
750 | + if (isset($args['placeholder'])) { |
|
751 | 751 | $placeholder = $args['placeholder']; |
752 | 752 | } else { |
753 | 753 | $placeholder = ''; |
754 | 754 | } |
755 | 755 | |
756 | - if( !empty( $args['onchange'] ) ) { |
|
757 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
756 | + if (!empty($args['onchange'])) { |
|
757 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
758 | 758 | } else { |
759 | 759 | $onchange = ''; |
760 | 760 | } |
761 | 761 | |
762 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
762 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
763 | 763 | |
764 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
764 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
765 | 765 | |
766 | - foreach ( $args['options'] as $option => $name ) { |
|
767 | - $selected = selected( $option, $value, false ); |
|
768 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
766 | + foreach ($args['options'] as $option => $name) { |
|
767 | + $selected = selected($option, $value, false); |
|
768 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $html .= '</select>'; |
772 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
772 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
773 | 773 | |
774 | 774 | echo $html; |
775 | 775 | } |
776 | 776 | |
777 | -function wpinv_color_select_callback( $args ) { |
|
777 | +function wpinv_color_select_callback($args) { |
|
778 | 778 | global $wpinv_options; |
779 | 779 | |
780 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
780 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
781 | 781 | |
782 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
783 | - $value = $wpinv_options[ $args['id'] ]; |
|
782 | + if (isset($wpinv_options[$args['id']])) { |
|
783 | + $value = $wpinv_options[$args['id']]; |
|
784 | 784 | } else { |
785 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
785 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
786 | 786 | } |
787 | 787 | |
788 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
788 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
789 | 789 | |
790 | - foreach ( $args['options'] as $option => $color ) { |
|
791 | - $selected = selected( $option, $value, false ); |
|
792 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
790 | + foreach ($args['options'] as $option => $color) { |
|
791 | + $selected = selected($option, $value, false); |
|
792 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | $html .= '</select>'; |
796 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
796 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
797 | 797 | |
798 | 798 | echo $html; |
799 | 799 | } |
800 | 800 | |
801 | -function wpinv_rich_editor_callback( $args ) { |
|
801 | +function wpinv_rich_editor_callback($args) { |
|
802 | 802 | global $wpinv_options, $wp_version; |
803 | 803 | |
804 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
804 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
805 | 805 | |
806 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
807 | - $value = $wpinv_options[ $args['id'] ]; |
|
806 | + if (isset($wpinv_options[$args['id']])) { |
|
807 | + $value = $wpinv_options[$args['id']]; |
|
808 | 808 | |
809 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
810 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
809 | + if (empty($args['allow_blank']) && empty($value)) { |
|
810 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
811 | 811 | } |
812 | 812 | } else { |
813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
813 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
814 | 814 | } |
815 | 815 | |
816 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
816 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
817 | 817 | |
818 | 818 | $html = '<div class="getpaid-settings-editor-input">'; |
819 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
819 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
820 | 820 | ob_start(); |
821 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
821 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
822 | 822 | $html .= ob_get_clean(); |
823 | 823 | } else { |
824 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
824 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
825 | 825 | } |
826 | 826 | |
827 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
827 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
828 | 828 | |
829 | 829 | echo $html; |
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_upload_callback( $args ) { |
|
832 | +function wpinv_upload_callback($args) { |
|
833 | 833 | global $wpinv_options; |
834 | 834 | |
835 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
835 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
836 | 836 | |
837 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
837 | + if (isset($wpinv_options[$args['id']])) { |
|
838 | 838 | $value = $wpinv_options[$args['id']]; |
839 | 839 | } else { |
840 | 840 | $value = isset($args['std']) ? $args['std'] : ''; |
841 | 841 | } |
842 | 842 | |
843 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
844 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
845 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
846 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
843 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
844 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
845 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
846 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
847 | 847 | |
848 | 848 | echo $html; |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_color_callback( $args ) { |
|
851 | +function wpinv_color_callback($args) { |
|
852 | 852 | global $wpinv_options; |
853 | 853 | |
854 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
854 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
855 | 855 | |
856 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
857 | - $value = $wpinv_options[ $args['id'] ]; |
|
856 | + if (isset($wpinv_options[$args['id']])) { |
|
857 | + $value = $wpinv_options[$args['id']]; |
|
858 | 858 | } else { |
859 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
859 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
860 | 860 | } |
861 | 861 | |
862 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
863 | 863 | |
864 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
865 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
865 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
866 | 866 | |
867 | 867 | echo $html; |
868 | 868 | } |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | function wpinv_country_states_callback($args) { |
871 | 871 | global $wpinv_options; |
872 | 872 | |
873 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
873 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
874 | 874 | |
875 | - if ( isset( $args['placeholder'] ) ) { |
|
875 | + if (isset($args['placeholder'])) { |
|
876 | 876 | $placeholder = $args['placeholder']; |
877 | 877 | } else { |
878 | 878 | $placeholder = ''; |
@@ -880,16 +880,16 @@ discard block |
||
880 | 880 | |
881 | 881 | $states = wpinv_get_country_states(); |
882 | 882 | |
883 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
884 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
883 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
884 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
885 | 885 | |
886 | - foreach ( $states as $option => $name ) { |
|
887 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
888 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
886 | + foreach ($states as $option => $name) { |
|
887 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
888 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | $html .= '</select>'; |
892 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
893 | 893 | |
894 | 894 | echo $html; |
895 | 895 | } |
@@ -904,96 +904,96 @@ discard block |
||
904 | 904 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
905 | 905 | <thead> |
906 | 906 | <tr> |
907 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
908 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
909 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
910 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
911 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
912 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
907 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
908 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
909 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
910 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
911 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
912 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
913 | 913 | </tr> |
914 | 914 | </thead> |
915 | 915 | <tbody> |
916 | - <?php if( !empty( $rates ) ) : ?> |
|
917 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
916 | + <?php if (!empty($rates)) : ?> |
|
917 | + <?php foreach ($rates as $key => $rate) : ?> |
|
918 | 918 | <?php |
919 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
919 | + $sanitized_key = wpinv_sanitize_key($key); |
|
920 | 920 | ?> |
921 | 921 | <tr> |
922 | 922 | <td class="wpinv_tax_country"> |
923 | 923 | <?php |
924 | - echo wpinv_html_select( array( |
|
925 | - 'options' => wpinv_get_country_list( true ), |
|
924 | + echo wpinv_html_select(array( |
|
925 | + 'options' => wpinv_get_country_list(true), |
|
926 | 926 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
927 | 927 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
928 | 928 | 'selected' => $rate['country'], |
929 | 929 | 'show_option_all' => false, |
930 | 930 | 'show_option_none' => false, |
931 | 931 | 'class' => 'wpinv-tax-country wpi_select2', |
932 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
933 | - ) ); |
|
932 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
933 | + )); |
|
934 | 934 | ?> |
935 | 935 | </td> |
936 | 936 | <td class="wpinv_tax_state"> |
937 | 937 | <?php |
938 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
939 | - if( !empty( $states ) ) { |
|
940 | - echo wpinv_html_select( array( |
|
941 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
938 | + $states = wpinv_get_country_states($rate['country']); |
|
939 | + if (!empty($states)) { |
|
940 | + echo wpinv_html_select(array( |
|
941 | + 'options' => array_merge(array('' => ''), $states), |
|
942 | 942 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
943 | 943 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
944 | 944 | 'selected' => $rate['state'], |
945 | 945 | 'show_option_all' => false, |
946 | 946 | 'show_option_none' => false, |
947 | 947 | 'class' => 'wpi_select2', |
948 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
949 | - ) ); |
|
948 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
949 | + )); |
|
950 | 950 | } else { |
951 | - echo wpinv_html_text( array( |
|
951 | + echo wpinv_html_text(array( |
|
952 | 952 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
953 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
953 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
954 | 954 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
955 | - ) ); |
|
955 | + )); |
|
956 | 956 | } |
957 | 957 | ?> |
958 | 958 | </td> |
959 | 959 | <td class="wpinv_tax_global"> |
960 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
961 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
960 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
961 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
962 | 962 | </td> |
963 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
964 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
965 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
963 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
964 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
965 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
966 | 966 | </tr> |
967 | 967 | <?php endforeach; ?> |
968 | 968 | <?php else : ?> |
969 | 969 | <tr> |
970 | 970 | <td class="wpinv_tax_country"> |
971 | 971 | <?php |
972 | - echo wpinv_html_select( array( |
|
973 | - 'options' => wpinv_get_country_list( true ), |
|
972 | + echo wpinv_html_select(array( |
|
973 | + 'options' => wpinv_get_country_list(true), |
|
974 | 974 | 'name' => 'tax_rates[0][country]', |
975 | 975 | 'show_option_all' => false, |
976 | 976 | 'show_option_none' => false, |
977 | 977 | 'class' => 'wpinv-tax-country wpi_select2', |
978 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
979 | - ) ); ?> |
|
978 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
979 | + )); ?> |
|
980 | 980 | </td> |
981 | 981 | <td class="wpinv_tax_state"> |
982 | - <?php echo wpinv_html_text( array( |
|
982 | + <?php echo wpinv_html_text(array( |
|
983 | 983 | 'name' => 'tax_rates[0][state]' |
984 | - ) ); ?> |
|
984 | + )); ?> |
|
985 | 985 | </td> |
986 | 986 | <td class="wpinv_tax_global"> |
987 | 987 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
988 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
988 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
989 | 989 | </td> |
990 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
990 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
991 | 991 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
992 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
992 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
993 | 993 | </tr> |
994 | 994 | <?php endif; ?> |
995 | 995 | </tbody> |
996 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
996 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
997 | 997 | </table> |
998 | 998 | <?php |
999 | 999 | echo ob_get_clean(); |
@@ -1004,76 +1004,76 @@ discard block |
||
1004 | 1004 | ob_start(); ?> |
1005 | 1005 | </td><tr> |
1006 | 1006 | <td colspan="2" class="wpinv_tools_tdbox"> |
1007 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1008 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1007 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
1008 | + <?php do_action('wpinv_tools_before'); ?> |
|
1009 | 1009 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1010 | 1010 | <thead> |
1011 | 1011 | <tr> |
1012 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
1013 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
1014 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
1012 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
1013 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
1014 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
1015 | 1015 | </tr> |
1016 | 1016 | </thead> |
1017 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1017 | + <?php do_action('wpinv_tools_row'); ?> |
|
1018 | 1018 | <tbody> |
1019 | 1019 | </tbody> |
1020 | 1020 | </table> |
1021 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1021 | + <?php do_action('wpinv_tools_after'); ?> |
|
1022 | 1022 | <?php |
1023 | 1023 | echo ob_get_clean(); |
1024 | 1024 | } |
1025 | 1025 | |
1026 | -function wpinv_descriptive_text_callback( $args ) { |
|
1027 | - echo wp_kses_post( $args['desc'] ); |
|
1026 | +function wpinv_descriptive_text_callback($args) { |
|
1027 | + echo wp_kses_post($args['desc']); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | -function wpinv_hook_callback( $args ) { |
|
1031 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1030 | +function wpinv_hook_callback($args) { |
|
1031 | + do_action('wpinv_' . $args['id'], $args); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | function wpinv_set_settings_cap() { |
1035 | 1035 | return wpinv_get_capability(); |
1036 | 1036 | } |
1037 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1037 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1038 | 1038 | |
1039 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1040 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
1041 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
1039 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1040 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
1041 | + $value = wpinv_sanitize_amount($value, 4); |
|
1042 | 1042 | $value = $value >= 100 ? 99 : $value; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | return $value; |
1046 | 1046 | } |
1047 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1047 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1048 | 1048 | |
1049 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1050 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1051 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1049 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1050 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1051 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1052 | 1052 | |
1053 | - if ( $old != $new ) { |
|
1054 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1053 | + if ($old != $new) { |
|
1054 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1058 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1059 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1060 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1061 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1062 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1063 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1064 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1065 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1066 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1067 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1068 | - |
|
1069 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1057 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1058 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1059 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1060 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1061 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1062 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1063 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1064 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1065 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1066 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1067 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1068 | + |
|
1069 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1070 | 1070 | ?> |
1071 | 1071 | <div class="wpinv-email-wc-row "> |
1072 | 1072 | <div class="wpinv-email-wc-td"> |
1073 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1073 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1074 | 1074 | <p class="wpinv-email-wc-description"> |
1075 | 1075 | <?php |
1076 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1076 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1077 | 1077 | <strong>{site_title} :</strong> Site Title<br> |
1078 | 1078 | <strong>{name} :</strong> Customer\'s full name<br> |
1079 | 1079 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1088 | 1088 | <strong>{date} :</strong> Today\'s date.<br> |
1089 | 1089 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1090 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1090 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1091 | 1091 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1092 | 1092 | ?> |
1093 | 1093 | </p> |