@@ -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 |
@@ -7,79 +7,79 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
12 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
13 | 13 | |
14 | 14 | $currency = $form->get_currency(); |
15 | 15 | |
16 | 16 | ?> |
17 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
17 | +<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
18 | 18 | <div class="form-row"> |
19 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
20 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
19 | + <?php foreach ($columns as $key => $label) : ?> |
|
20 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo $item->get_id(); ?>"> |
|
21 | 21 | <?php |
22 | 22 | |
23 | 23 | // Item name. |
24 | - if ( 'name' == $key ) { |
|
25 | - echo sanitize_text_field( $item->get_name() ); |
|
24 | + if ('name' == $key) { |
|
25 | + echo sanitize_text_field($item->get_name()); |
|
26 | 26 | $description = $item->get_description(); |
27 | 27 | |
28 | - if ( ! empty( $description ) ) { |
|
29 | - $description = wp_kses_post( $description ); |
|
28 | + if (!empty($description)) { |
|
29 | + $description = wp_kses_post($description); |
|
30 | 30 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
31 | 31 | } |
32 | 32 | |
33 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
33 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
34 | 34 | |
35 | - if ( $description ) { |
|
35 | + if ($description) { |
|
36 | 36 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | // Item price. |
41 | - if ( 'price' == $key ) { |
|
41 | + if ('price' == $key) { |
|
42 | 42 | |
43 | 43 | // Set the currency position. |
44 | 44 | $position = wpinv_currency_position(); |
45 | 45 | |
46 | - if ( $position == 'left_space' ) { |
|
46 | + if ($position == 'left_space') { |
|
47 | 47 | $position = 'left'; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $position == 'right_space' ) { |
|
50 | + if ($position == 'right_space') { |
|
51 | 51 | $position = 'right'; |
52 | 52 | } |
53 | 53 | |
54 | - if ( $item->user_can_set_their_price() ) { |
|
54 | + if ($item->user_can_set_their_price()) { |
|
55 | 55 | ?> |
56 | 56 | <div class="input-group input-group-sm"> |
57 | - <?php if( 'left' == $position ) : ?> |
|
57 | + <?php if ('left' == $position) : ?> |
|
58 | 58 | <div class="input-group-prepend"> |
59 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
59 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
60 | 60 | </div> |
61 | 61 | <?php endif; ?> |
62 | - <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( $item->get_price() ); ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input"> |
|
62 | + <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr($item->get_price()); ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input"> |
|
63 | 63 | |
64 | - <?php if( 'left' != $position ) : ?> |
|
64 | + <?php if ('left' != $position) : ?> |
|
65 | 65 | <div class="input-group-append"> |
66 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
66 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
67 | 67 | </div> |
68 | 68 | <?php endif; ?> |
69 | 69 | </div> |
70 | 70 | <?php |
71 | 71 | } else { |
72 | - echo wpinv_price( wpinv_format_amount( $item->get_price() ), $currency ); |
|
72 | + echo wpinv_price(wpinv_format_amount($item->get_price()), $currency); |
|
73 | 73 | ?> |
74 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
74 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
75 | 75 | <?php |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Item quantity. |
80 | - if ( 'quantity' == $key ) { |
|
80 | + if ('quantity' == $key) { |
|
81 | 81 | |
82 | - if ( $item->allows_quantities() ) { |
|
82 | + if ($item->allows_quantities()) { |
|
83 | 83 | ?> |
84 | 84 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='number' class='getpaid-item-quantity-input pr-1' value='<?php echo (int) $item->get_qantity(); ?>' min='1' required> |
85 | 85 | <?php |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Item sub total. |
96 | - if ( 'subtotal' == $key ) { |
|
97 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $currency ); |
|
96 | + if ('subtotal' == $key) { |
|
97 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $currency); |
|
98 | 98 | } |
99 | 99 | |
100 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
100 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php endforeach; ?> |
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | <?php |
107 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
107 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
@@ -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 | * @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. |
@@ -802,27 +802,27 @@ discard block |
||
802 | 802 | * @param array $status_transition |
803 | 803 | * @todo: descrease customer/store earnings |
804 | 804 | */ |
805 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
805 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
806 | 806 | |
807 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
807 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
808 | 808 | return; |
809 | 809 | } |
810 | 810 | |
811 | 811 | $discount_code = $invoice->get_discount_code(); |
812 | - if ( ! empty( $discount_code ) ) { |
|
813 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
812 | + if (!empty($discount_code)) { |
|
813 | + $discount = wpinv_get_discount_obj($discount_code); |
|
814 | 814 | |
815 | - if ( $discount->exists() ) { |
|
815 | + if ($discount->exists()) { |
|
816 | 816 | $discount->increase_usage( -1 ); |
817 | 817 | } |
818 | 818 | |
819 | 819 | } |
820 | 820 | |
821 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
822 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
823 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
821 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
822 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
823 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
824 | 824 | } |
825 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
825 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | /** |
@@ -830,48 +830,48 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @param int $invoice_id |
832 | 832 | */ |
833 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
833 | +function getpaid_process_invoice_payment($invoice_id) { |
|
834 | 834 | |
835 | 835 | // Fetch the invoice. |
836 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
836 | + $invoice = new WPInv_Invoice($invoice_id); |
|
837 | 837 | |
838 | 838 | // We only want to do this once. |
839 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
839 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
840 | 840 | return; |
841 | 841 | } |
842 | 842 | |
843 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
843 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
844 | 844 | |
845 | 845 | // Fires when processing a payment. |
846 | - do_action( 'getpaid_process_payment', $invoice ); |
|
846 | + do_action('getpaid_process_payment', $invoice); |
|
847 | 847 | |
848 | 848 | // Fire an action for each invoice item. |
849 | - foreach( $invoice->get_items() as $item ) { |
|
850 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
849 | + foreach ($invoice->get_items() as $item) { |
|
850 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | // Increase discount usage. |
854 | 854 | $discount_code = $invoice->get_discount_code(); |
855 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
856 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
855 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
856 | + $discount = wpinv_get_discount_obj($discount_code); |
|
857 | 857 | |
858 | - if ( $discount->exists() ) { |
|
858 | + if ($discount->exists()) { |
|
859 | 859 | $discount->increase_usage(); |
860 | 860 | } |
861 | 861 | |
862 | 862 | } |
863 | 863 | |
864 | 864 | // Record reverse vat. |
865 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
865 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
866 | 866 | |
867 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
868 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
867 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
868 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | } |
872 | 872 | |
873 | 873 | } |
874 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
874 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Returns an array of invoice item columns |
@@ -879,13 +879,13 @@ discard block |
||
879 | 879 | * @param int|WPInv_Invoice $invoice |
880 | 880 | * @return array |
881 | 881 | */ |
882 | -function getpaid_invoice_item_columns( $invoice ) { |
|
882 | +function getpaid_invoice_item_columns($invoice) { |
|
883 | 883 | |
884 | 884 | // Prepare the invoice. |
885 | - $invoice = new WPInv_Invoice( $invoice ); |
|
885 | + $invoice = new WPInv_Invoice($invoice); |
|
886 | 886 | |
887 | 887 | // Abort if there is no invoice. |
888 | - if ( 0 == $invoice->get_id() ) { |
|
888 | + if (0 == $invoice->get_id()) { |
|
889 | 889 | return array(); |
890 | 890 | } |
891 | 891 | |
@@ -893,47 +893,47 @@ discard block |
||
893 | 893 | $columns = apply_filters( |
894 | 894 | 'getpaid_invoice_item_columns', |
895 | 895 | array( |
896 | - 'name' => __( 'Item', 'invoicing' ), |
|
897 | - 'price' => __( 'Price', 'invoicing' ), |
|
898 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
899 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
896 | + 'name' => __('Item', 'invoicing'), |
|
897 | + 'price' => __('Price', 'invoicing'), |
|
898 | + 'quantity' => __('Quantity', 'invoicing'), |
|
899 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
900 | 900 | ), |
901 | 901 | $invoice |
902 | 902 | ); |
903 | 903 | |
904 | 904 | // Quantities. |
905 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
905 | + if (isset($columns['quantity'])) { |
|
906 | 906 | |
907 | - if ( 'hours' == $invoice->get_template() ) { |
|
908 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
907 | + if ('hours' == $invoice->get_template()) { |
|
908 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
909 | 909 | } |
910 | 910 | |
911 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
912 | - unset( $columns[ 'quantity' ] ); |
|
911 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
912 | + unset($columns['quantity']); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | } |
916 | 916 | |
917 | 917 | |
918 | 918 | // Price. |
919 | - if ( isset( $columns[ 'price' ] ) ) { |
|
919 | + if (isset($columns['price'])) { |
|
920 | 920 | |
921 | - if ( 'amount' == $invoice->get_template() ) { |
|
922 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
921 | + if ('amount' == $invoice->get_template()) { |
|
922 | + $columns['price'] = __('Amount', 'invoicing'); |
|
923 | 923 | } |
924 | 924 | |
925 | - if ( 'hours' == $invoice->get_template() ) { |
|
926 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
925 | + if ('hours' == $invoice->get_template()) { |
|
926 | + $columns['price'] = __('Rate', 'invoicing'); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | } |
930 | 930 | |
931 | 931 | |
932 | 932 | // Sub total. |
933 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
933 | + if (isset($columns['subtotal'])) { |
|
934 | 934 | |
935 | - if ( 'amount' == $invoice->get_template() ) { |
|
936 | - unset( $columns[ 'subtotal' ] ); |
|
935 | + if ('amount' == $invoice->get_template()) { |
|
936 | + unset($columns['subtotal']); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | } |
@@ -947,30 +947,30 @@ discard block |
||
947 | 947 | * @param int|WPInv_Invoice $invoice |
948 | 948 | * @return array |
949 | 949 | */ |
950 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
950 | +function getpaid_invoice_totals_rows($invoice) { |
|
951 | 951 | |
952 | 952 | // Prepare the invoice. |
953 | - $invoice = new WPInv_Invoice( $invoice ); |
|
953 | + $invoice = new WPInv_Invoice($invoice); |
|
954 | 954 | |
955 | 955 | // Abort if there is no invoice. |
956 | - if ( 0 == $invoice->get_id() ) { |
|
956 | + if (0 == $invoice->get_id()) { |
|
957 | 957 | return array(); |
958 | 958 | } |
959 | 959 | |
960 | 960 | $totals = apply_filters( |
961 | 961 | 'getpaid_invoice_totals_rows', |
962 | 962 | array( |
963 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
964 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
965 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
966 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
967 | - 'total' => __( 'Total', 'invoicing' ), |
|
963 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
964 | + 'tax' => __('Tax', 'invoicing'), |
|
965 | + 'fee' => __('Fee', 'invoicing'), |
|
966 | + 'discount' => __('Discount', 'invoicing'), |
|
967 | + 'total' => __('Total', 'invoicing'), |
|
968 | 968 | ), |
969 | 969 | $invoice |
970 | 970 | ); |
971 | 971 | |
972 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
973 | - unset( $totals['tax'] ); |
|
972 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
973 | + unset($totals['tax']); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | return $totals; |
@@ -981,46 +981,46 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @param WPInv_Invoice $invoice |
983 | 983 | */ |
984 | -function getpaid_new_invoice( $invoice ) { |
|
984 | +function getpaid_new_invoice($invoice) { |
|
985 | 985 | |
986 | - if ( ! $invoice->get_status() ) { |
|
986 | + if (!$invoice->get_status()) { |
|
987 | 987 | return; |
988 | 988 | } |
989 | 989 | |
990 | 990 | // Add an invoice created note. |
991 | 991 | $invoice->add_note( |
992 | 992 | wp_sprintf( |
993 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
994 | - wpinv_status_nicename( $invoice->get_status() ) |
|
993 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
994 | + wpinv_status_nicename($invoice->get_status()) |
|
995 | 995 | ) |
996 | 996 | ); |
997 | 997 | |
998 | 998 | } |
999 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
999 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1000 | 1000 | |
1001 | 1001 | /** |
1002 | 1002 | * This function updates invoice caches. |
1003 | 1003 | * |
1004 | 1004 | * @param WPInv_Invoice $invoice |
1005 | 1005 | */ |
1006 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1006 | +function getpaid_update_invoice_caches($invoice) { |
|
1007 | 1007 | |
1008 | 1008 | // Cache invoice number. |
1009 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1009 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1010 | 1010 | |
1011 | 1011 | // Cache invoice key. |
1012 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1012 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1013 | 1013 | |
1014 | 1014 | // (Maybe) cache transaction id. |
1015 | 1015 | $transaction_id = $invoice->get_transaction_id(); |
1016 | 1016 | |
1017 | - if ( ! empty( $transaction_id ) ) { |
|
1018 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1017 | + if (!empty($transaction_id)) { |
|
1018 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | } |
1022 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1023 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1022 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1023 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1024 | 1024 | |
1025 | 1025 | /** |
1026 | 1026 | * Duplicates an invoice. |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1031 | 1031 | * @return WPInv_Invoice The new invoice. |
1032 | 1032 | */ |
1033 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1033 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1034 | 1034 | |
1035 | 1035 | // Create the new invoice. |
1036 | 1036 | $invoice = new WPInv_Invoice(); |
@@ -1091,126 +1091,126 @@ discard block |
||
1091 | 1091 | * @param WPInv_Invoice $invoice |
1092 | 1092 | * @return array |
1093 | 1093 | */ |
1094 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1094 | +function getpaid_get_invoice_meta($invoice) { |
|
1095 | 1095 | |
1096 | 1096 | // Load the invoice meta. |
1097 | 1097 | $meta = array( |
1098 | 1098 | |
1099 | 1099 | 'number' => array( |
1100 | 1100 | 'label' => sprintf( |
1101 | - __( '%s Number', 'invoicing' ), |
|
1102 | - ucfirst( $invoice->get_type() ) |
|
1101 | + __('%s Number', 'invoicing'), |
|
1102 | + ucfirst($invoice->get_type()) |
|
1103 | 1103 | ), |
1104 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1104 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1105 | 1105 | ), |
1106 | 1106 | |
1107 | 1107 | 'status' => array( |
1108 | 1108 | 'label' => sprintf( |
1109 | - __( '%s Status', 'invoicing' ), |
|
1110 | - ucfirst( $invoice->get_type() ) |
|
1109 | + __('%s Status', 'invoicing'), |
|
1110 | + ucfirst($invoice->get_type()) |
|
1111 | 1111 | ), |
1112 | 1112 | 'value' => $invoice->get_status_label_html(), |
1113 | 1113 | ), |
1114 | 1114 | |
1115 | 1115 | 'date' => array( |
1116 | 1116 | 'label' => sprintf( |
1117 | - __( '%s Date', 'invoicing' ), |
|
1118 | - ucfirst( $invoice->get_type() ) |
|
1117 | + __('%s Date', 'invoicing'), |
|
1118 | + ucfirst($invoice->get_type()) |
|
1119 | 1119 | ), |
1120 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1120 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1121 | 1121 | ), |
1122 | 1122 | |
1123 | 1123 | 'date_paid' => array( |
1124 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1125 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1124 | + 'label' => __('Paid On', 'invoicing'), |
|
1125 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1126 | 1126 | ), |
1127 | 1127 | |
1128 | 1128 | 'gateway' => array( |
1129 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1130 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1129 | + 'label' => __('Payment Method', 'invoicing'), |
|
1130 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1131 | 1131 | ), |
1132 | 1132 | |
1133 | 1133 | 'transaction_id' => array( |
1134 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1135 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1134 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1135 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1136 | 1136 | ), |
1137 | 1137 | |
1138 | 1138 | 'due_date' => array( |
1139 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1140 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1139 | + 'label' => __('Due Date', 'invoicing'), |
|
1140 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1141 | 1141 | ), |
1142 | 1142 | |
1143 | 1143 | 'vat_number' => array( |
1144 | 1144 | 'label' => sprintf( |
1145 | - __( '%s Number', 'invoicing' ), |
|
1145 | + __('%s Number', 'invoicing'), |
|
1146 | 1146 | getpaid_tax()->get_vat_name() |
1147 | 1147 | ), |
1148 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1148 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1149 | 1149 | ), |
1150 | 1150 | |
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | // If it is not paid, remove the date of payment. |
1154 | - if ( ! $invoice->is_paid() ) { |
|
1155 | - unset( $meta[ 'date_paid' ] ); |
|
1156 | - unset( $meta[ 'transaction_id' ] ); |
|
1154 | + if (!$invoice->is_paid()) { |
|
1155 | + unset($meta['date_paid']); |
|
1156 | + unset($meta['transaction_id']); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1160 | - unset( $meta[ 'gateway' ] ); |
|
1159 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1160 | + unset($meta['gateway']); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | // Only display the due date if due dates are enabled. |
1164 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1165 | - unset( $meta[ 'due_date' ] ); |
|
1164 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1165 | + unset($meta['due_date']); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | // Only display the vat number if taxes are enabled. |
1169 | - if ( ! wpinv_use_taxes() ) { |
|
1170 | - unset( $meta[ 'vat_number' ] ); |
|
1169 | + if (!wpinv_use_taxes()) { |
|
1170 | + unset($meta['vat_number']); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | - if ( $invoice->is_recurring() ) { |
|
1173 | + if ($invoice->is_recurring()) { |
|
1174 | 1174 | |
1175 | 1175 | // Link to the parent invoice. |
1176 | - if ( $invoice->is_renewal() ) { |
|
1176 | + if ($invoice->is_renewal()) { |
|
1177 | 1177 | |
1178 | - $meta[ 'parent' ] = array( |
|
1178 | + $meta['parent'] = array( |
|
1179 | 1179 | |
1180 | 1180 | 'label' => sprintf( |
1181 | - __( 'Parent %s', 'invoicing' ), |
|
1182 | - ucfirst( $invoice->get_type() ) |
|
1181 | + __('Parent %s', 'invoicing'), |
|
1182 | + ucfirst($invoice->get_type()) |
|
1183 | 1183 | ), |
1184 | 1184 | |
1185 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1185 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1186 | 1186 | |
1187 | 1187 | ); |
1188 | 1188 | |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1191 | + $subscription = wpinv_get_subscription($invoice); |
|
1192 | 1192 | |
1193 | - if ( ! empty ( $subscription ) ) { |
|
1193 | + if (!empty ($subscription)) { |
|
1194 | 1194 | |
1195 | 1195 | // Display the renewal date. |
1196 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1196 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1197 | 1197 | |
1198 | - $meta[ 'renewal_date' ] = array( |
|
1198 | + $meta['renewal_date'] = array( |
|
1199 | 1199 | |
1200 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1201 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1200 | + 'label' => __('Renews On', 'invoicing'), |
|
1201 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1202 | 1202 | |
1203 | 1203 | ); |
1204 | 1204 | |
1205 | 1205 | } |
1206 | 1206 | |
1207 | - if ( $invoice->is_parent() ) { |
|
1207 | + if ($invoice->is_parent()) { |
|
1208 | 1208 | |
1209 | 1209 | // Display the recurring amount. |
1210 | - $meta[ 'recurring_total' ] = array( |
|
1210 | + $meta['recurring_total'] = array( |
|
1211 | 1211 | |
1212 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1213 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
1212 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1213 | + 'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
1214 | 1214 | |
1215 | 1215 | ); |
1216 | 1216 | |
@@ -1220,15 +1220,15 @@ discard block |
||
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | // Add the invoice total to the meta. |
1223 | - $meta[ 'invoice_total' ] = array( |
|
1223 | + $meta['invoice_total'] = array( |
|
1224 | 1224 | |
1225 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1226 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
1225 | + 'label' => __('Total Amount', 'invoicing'), |
|
1226 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
1227 | 1227 | |
1228 | 1228 | ); |
1229 | 1229 | |
1230 | 1230 | // Provide a way for third party plugins to filter the meta. |
1231 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1231 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1232 | 1232 | |
1233 | 1233 | return $meta; |
1234 | 1234 |
@@ -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 |